Rustfmt is extremely slow in large files when using nvim-lsp
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start by reproducing the delay with the listed Neovim, rust-analyzer, and rustfmt setup, comparing :RustFmt with the language server enabled and disabled. The issue names no relevant source files or tests, so trace the formatting entry point and its interaction with nvim-lsp. Done means formatting a large Rust file completes without freezing the editor; the report has had no comment for 835 days.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
- rust.vim version: 87c745d (latest
master) installed through vim-plug - OS: macOS 10.15.7
- Terminal: alacritty 0.7.2 (5ac8060)
Steps to reproduce:
-
Install
nvimfrom the tip ofmaster(must be an 0.5 version) -
Install
rustup -
Run
rustup toolchain install nightly-2021-03-01 -
Run
rustup component add rustfmt --toolchain nightly-2021-03-01 -
Install
rust-analyzer(I'm on rust-analyzer 2021-02-15, installed via Nix unstable) -
Put the following minimal config in
~/.config/nvim/init.vim:set shell=/bin/bash " Install vim-plug if it isn't already if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim au VimEnter * PlugInstall --sync | source $MYVIMRC endif call plug#begin('~/.local/share/nvim/plugged') Plug 'neovim/nvim-lspconfig' Plug 'rust-lang/rust.vim' call plug#end() lua <<EOF require'lspconfig'.rust_analyzer.setup({}) EOF let g:rustfmt_command = 'rustup run nightly-2021-03-01 rustfmt' let g:rustfmt_autosave = 1 -
Make sure
~/.local/share/nvim/site/autoloadand~/.local/share/nvim/pluggedare empty or do not exist -
Open
nvimonce to allow the plugins to install, then close it -
Create a crate that contains a very long Rust file (in my case, the file is over 3000 lines long - the problem appears with shorter files but is less noticeable), and open that long file
-
Verify the language server is running by (e.g.) putting the cursor over a documented type name and running
:lua vim.lsp.buf.hover()(documentation info should appear) -
Insert some extra blank lines in the file, so that rustfmt will remove them when run
-
Run
:w
Expected vs. actual behavior:
- Expected: the file saves quickly, with no noticeable delay, and the contents of the file are automatically formatted using rustfmt
- Actual: The file is formatted correctly, but takes more than 10 seconds to save, during which time the editor is completely frozen
Please note a few things:
- The issue also appears when running
:RustFmtmanually - Saving the file becomes almost instantaneous if auto-formatting is disabled (but
:RustFmtstill hangs just as much) - Saving the file and formatting it also becomes almost instantaneous (with auto-formatting enabled) if the language server is disabled (remove the Lua section in the config above), so it appears to be the interaction between the two things that's the problem.
cargo +nightly-2021-03-01 fmtonly takes about a second, at most, to run from outsidenvim- There has been some mention before of shells such as
fish(which is my login shell) causing delays, and I do see additional delays if I removeset shell=/bin/bashfrom that config, but please note that that line meansfishshouldn't be involved here. Changing my login shell tobashorzshdoes not fix the problem.
I'm happy to do any debugging or profiling you'd like me to, but you'll have to let me know what to run in order to do that, because my knowledge of vim really isn't extensive enough for me to know how to do that myself. Thanks!
Paste debugging info from the Rust Vim plugin via one of the following
commands: :RustInfo, :RustInfoToClipboard, or :RustInfoToFile <filename>.
rust.vim Global Variables:
let g:ftplugin_rust_source_path = v:null
let g:loaded_syntastic_rust_cargo_checker = v:null
let g:loaded_syntastic_rust_filetype = v:null
let g:loaded_syntastic_rust_rustc_checker = v:null
let g:rust_bang_comment_leader = v:null
let g:rust_cargo_avoid_whole_workspace = v:null
let g:rust_clip_command = v:null
let g:rust_conceal = v:null
let g:rust_conceal_mod_path = v:null
let g:rust_conceal_pub = v:null
let g:rust_fold = v:null
let g:rust_last_args = v:null
let b:rust_last_args = []
let g:rust_last_rustc_args = v:null
let b:rust_last_rustc_args = []
let g:rust_original_delimitMate_excluded_regions = v:null
let g:rust_playpen_url = v:null
let g:rust_prev_delimitMate_quotes = v:null
let g:rust_recent_nearest_cargo_tol = v:null
let g:rust_recent_root_cargo_toml = v:null
let g:rust_recommended_style = v:null
let g:rust_set_conceallevel = v:null
let g:rust_set_conceallevel=1 = v:null
let g:rust_set_foldmethod = v:null
let g:rust_set_foldmethod=1 = v:null
let g:rust_shortener_url = v:null
let g:rustc_makeprg_no_percent = v:null
let g:rustc_path = v:null
let g:rustfmt_autosave = 1
let g:rustfmt_autosave_if_config_present = v:null
let g:rustfmt_command = 'rustup run nightly-2021-03-01 rustfmt'
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
let g:rustfmt_options = ''
let g:syntastic_extra_filetypes = ['rust']
let g:syntastic_rust_cargo_fname = v:null
rustfmt 1.4.36-nightly (7de6968e 2021-02-07)
rustc 1.51.0-nightly (1d0d76f8d 2021-01-24)
cargo 1.51.0-nightly (783bc43c6 2021-01-20)
NVIM v0.5.0-dev+c1fbc2ddf
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210301-91403-1qxibkt/build/config -I/tmp/neovim-20210301-91403-1qxibkt/src -I/usr/local/include -I/usr/local/opt/luv/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210301-91403-1qxibkt/build/src/nvim/auto -I/tmp/neovim-20210301-91403-1qxibkt/build/include
Compiled by [email protected]
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-c1fbc2d_1/share/nvim"
Run :checkhealth for more info
- Vorherrschende Sprache
- Vim Script
- Sterne
- 4.2k
- Forks
- 323
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rust-lang/rust.vim
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
It's Dead, Jim!Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
Remove hard coded edition fallbackEvtl. vergeben @alerque hat das vor 231 Tagen übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 35/100
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 55/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
Alle Issues in rust-lang/rust.vim
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
WenyuChiou/agent-board#1283 ·
Maintainer antworten meist innerhalb von 1 Tag
-
theme:submission
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
jamesmontemagno/ohmyposh-configurator#125 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
RadiusNetworks/radius-spec#122 ·
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
enhancement triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
ShaftHQ/SHAFT_ENGINE#7902 ·
Maintainer antworten meist innerhalb von 1 Tag