Rustfmt is extremely slow in large files when using nvim-lsp
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
- 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
- 主要言語
- Vim Script
- スター
- 4.2k
- フォーク
- 323
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust.vim のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
-
It's Dead, Jim!オープン
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
-
Remove hard coded edition fallback対応中かも @alerque が 230 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
rust-lang/rust.vim の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
bug documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
cqframework/vscode-cql#198 ·
-
bug documentation good first issue help wanted testing
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
Show evidence time and supersede warnings in the memory inspector対応中かも @Sinchanak-212 が今日担当しました。 オープンarea: ux good first issue priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
rohit746/pdf-view.nvim#109 ·
メンテナーはふだん 1 日以内に返信