rust-lang / rust.vim

Vim configuration for Rust.
Apache License 2.0
3.91k stars 298 forks source link

Syntax Errors Get 'Stuck' #317

Open naftulikay opened 5 years ago

naftulikay commented 5 years ago
Additional NeoVim Info ``` NVIM v0.3.1 Build type: Release LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-M0l_b5/neovim-0.3.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-M0l_b5/neovim-0.3.1/build/config -I/build/neovim-M0l_b5/neovim-0.3.1/src -I/usr/include -I/build/neovim-M0l_b5/neovim-0.3.1/build/src/nvim/auto -I/build/neovim-M0l_b5/neovim-0.3.1/build/include Compiled by team+vim@tracker.debian.org Features: +acl +iconv +jemalloc +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim" Run :checkhealth for more info ```

Steps to reproduce:

Expected vs. actual behavior:

Expected
Actual

Screenshot from 2019-04-16 11 34 31

cargo build and cargo test pass without any issues. I have tried :SyntasticReset and :LanguageClientStop and :LanguageClientStart. The only way I have found to reliably fix things is to completely exit and restart NeoVim.

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 = 1
let g:loaded_syntastic_rust_filetype = v:null
let g:loaded_syntastic_rust_rustc_checker = 1
let g:rust_bang_comment_leader = v:null
let g:rust_cargo_avoid_whole_workspace = v:null
let g:rust_clip_command = 'xclip -i -selection clipboard'
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_because_of_config = v:null
let g:rustfmt_autosave_if_config_present = v:null
let g:rustfmt_command = '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 = ''
rustfmt 1.0.3-stable (d6829d6 2019-02-14)
rustc 1.34.0 (91856ed52 2019-04-10)
cargo 1.34.0 (6789d8a0a 2019-04-01)

NVIM v0.3.1
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-M0l_b5/neovim-0.3.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D
_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra
 -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bound
s -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-M0l_b5/neovim-0.3.1/build/config -I/build
/neovim-M0l_b5/neovim-0.3.1/src -I/usr/include -I/build/neovim-M0l_b5/neovim-0.3.1/build/src/nvim/auto -I/build/neovim-M0l_b5/neovim-0.3.1/build/include
Compiled by team+vim@tracker.debian.org

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
----
Info from Syntastic:
Syntastic version: 3.9.0-36 (Vim 800, Neovim, Linux)
Info for filetype: rust
Global mode: active
Filetype rust is active
The current file will be checked automatically
Available checkers: cargo rustc
Currently enabled checker: cargo
da-x commented 5 years ago

Thanks for reporting!

Do you have a specific crate on which I can attempt to reproduce the problem? I tried with a minimal plug.vim configuration containing only Syntastic and LanguageClient, both with signs enabled. But I was not able to reproduce the problem.

naftulikay commented 5 years ago

I've seen it doing this way too many times to count. I've found that :bd (completly closing a buffer) can fix things.

My exact Vim setup can be found here.

Simply adding a dependency into Cargo.toml can permabreak a buffer until :bd closes it entirely. Add serde or some other dependency, then edit your code to use serde and it will get into a state where it is convinced that everything is broken. Deleting lines and trying again doesn't seem to fix it.

I also just saw it with a Cargo workspace, I have an additional crate in the workspace named envoy; I added serde to its dependencies and it became broken when editing things in the crate. When trying to use the envoy crate from my main crate, it also broke that buffer: auto-complete saw that the struct was there, but error reporting told me that the struct wasn't found.

da-x commented 5 years ago

Thanks - I'll try.

In the meanwhile, can you try with an another editor using RLS to rule out a problem in RLS/LanguageClient?

naftulikay commented 5 years ago

It's hard to know exactly what's up but I just installed Atom and ide-rust which uses RLS under the hood. Completion on std:: works as expected. I added envy as a dependency in envoy/Cargo.toml and then attempted to use envy; in that crate and I get no autocompletion and it's reported as an error.

It may be RLS.

Is there a way for me to debug RLS or see what's working/what's not?

naftulikay commented 5 years ago

Actually scratch that, I'm unable to reproduce in Atom.

da-x commented 5 years ago

Sounds like RLS. Just a guess, but maybe Atom already reproduced a workaround, which I believe would be to restart RLS when Cargo.toml editing is detected.

naftulikay commented 5 years ago

Is there a way to restart RLS from NeoVim using rust.vim? I see quite a few RLS processes running for different projects presumably, and I even have one defunct one, somehow it must have gotten unparented and zombified.