Rustfmt is extremely slow in large files when using nvim-lsp
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
- 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
- Lenguaje dominante
- Vim Script
- Estrellas
- 4.2k
- Forks
- 323
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rust.vim
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 76/100
-
It's Dead, Jim!Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
-
Remove hard coded edition fallbackPosiblemente ocupada @alerque la tomó hace 230 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 35/100
-
README.md syntastic to aleAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 55/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
Todos los issues de rust-lang/rust.vim
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
cqframework/vscode-cql#198 ·
-
bug documentation good first issue help wanted testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Show evidence time and supersede warnings in the memory inspectorPosiblemente ocupada @Sinchanak-212 la tomó hoy. Abiertoarea: ux good first issue priority: medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
rohit746/pdf-view.nvim#109 ·
Los mantenedores suelen responder en 1 día