Vim ALE processing an older version of the file I'm editing - vim

I'm using VIM 8.1 with ALE, specifically the rust linter (basically just cargo). The problem is that the errors and warnings reported by ALE are from an older version of the current file. Editing and saving the file has no effect, nor does re-starting vim. I've tried :ALEReset and then :ALELint, but it just shows the same lints. Other tools (like cargo) use the files just fine, and there doesn't appear to be anything wrong with the file itself.
This is the output of :ALEInfo:
ALEInfo
Current Filetype: rust
Available Linters: ['cargo', 'rls', 'rustc']
Enabled Linters: ['cargo', 'rustc']
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'rustfmt' - Fix Rust files with Rustfmt.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_rust_cargo_avoid_whole_workspace = 1
let g:ale_rust_cargo_check_all_targets = 0
let g:ale_rust_cargo_check_examples = 0
let g:ale_rust_cargo_check_tests = 1
let g:ale_rust_cargo_clippy_options = ''
let g:ale_rust_cargo_default_feature_behavior = 'default'
let g:ale_rust_cargo_include_features = ''
let g:ale_rust_cargo_use_check = 1
let g:ale_rust_cargo_use_clippy = 0
let g:ale_rust_ignore_error_codes = []
let g:ale_rust_ignore_secondary_spans = 0
let g:ale_rust_rustc_options = '-Z no-codegen'
ALE is my only installed plugin.
How can I fix this and use my linter plugin again?

It turned out that this was not a VIM or ALE issue, it was a cargo issue. ALE used cargo check to check code without doing codegen (it's faster and leaves less artifacts), and while cargo build did not return any errors or warning, cargo check for some reason returned warning from an older version of the project (not just the file). This was fixed with cargo clean, and then running cargo build and cargo check again. Because I ran cargo clean, I no longer have a project that causes this behavior, so I can't really delve deeper to find out what was wrong with the project.

Related

My clang-complete doesn't run well in my Vim

I installed clang-complete by using Vundle,and downloaded llvm using sudo apt install llvm-4.0, downloaded clang by using sudo apt install libclang-4.0.Here is my .vimrc:
let g:clang_complete_auto=1 " automatically complete after -> . ::
let g:clang_hl_errors=1 " highlight the warnings and error the same way clang does it
let g:clang_complete_copen=0 " open quickfix window on error
let g:clang_periodic_quickfix=0 " periodically update the quickfix window
let g:clang_snippets=0
let g:clang_close_preview=1
let g:clang_use_library=1
let g:clang_library_path='/usr/lib/llvm-4.0/lib'
let g:clang_user_options='-stdlib=libc++ -std=c++11 -I /usr/include/c++/8/'
set completeopt=menu,longest
However, it doesn't run well in this way. When I type std::, the menu only shows some useless items such as size_t but except cout etc.
Follow the Troubleshooting section in the README of your plugin. It says that the first step is to check completefunc and omnifunc when in your C++ buffer, and then to check the output of :messages. I think that knowing what those settings are at runtime of your Vim would show us what's going on.
If completefunc isn't set, then there's something going on with one of your settings; the plugin is trying to do what it does, but one of your settings are improperly formatted (or something like that.) The output of :messages should be able to show you which setting this is, as well.

Syntastic not checking python code

I have both syntastic and python-mode installed.. However, I want to syntax check using syntastic.. To do this, I have disabled pymode check with, let g:pymode_lint = 0
Also, when python file if opened, syntastic says that checker is present, but does not detect errors..
Currently active checker = python

Vim Syntastic plugin not working for coffeescript 1.6.0+

I have the following syntastic settings inside my .vimrc:
"------------SYNTASTIC-----------
let g:syntastic_enable_signs=1
let g:syntastic_mode_map={ 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': ['html', 'java'] }
let g:syntastic_coffee_checkers = ['coffeelint', 'coffee']
let g:syntastic_coffee_coffeelint_args = "--file [absolute path to]/coffeelint.json"
let g:syntastic_enable_signs=1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
when I have coffeescript installed to 1.6.0+ (i.e. npm install -g coffee-script#1.6.3) syntastic doesn't seem able to detect any compilation errors, even though both coffee file.coffee and coffeelint file.coffee displays the error fine.
I ran :SyntasticCheck then :messages and no debug error surfaced.
I've also made sure that npm is part of the PATH: PATH="/usr/local/share/npm/bin:$PATH"
On the other hand, when coffeescript is installed at coffee-script#1.5.0 the errors DO in fact surface (everything works!), except that it doesn't pick up the coffeelint_args. This behavior might be expect from https://github.com/scrooloose/syntastic/wiki/CoffeeScript%3A---coffee
Do I need to know something special to get syntastic working w/ coffeescript 1.6.0+ on Mac?
Here's the issue on github: https://github.com/scrooloose/syntastic/issues/694
The fix was to do a git fetch && git rebase or git pull from the syntastic git directory (assuming you're using pathogen)

How to set up syntastic for vim?

So I git cloned the repository to ~/.vim/bundle and had pathogen installed. I can be sure pathogen works fine since my other plugins in bundle are all working fine. After googling for a while, it seems that syntastic should work out of box for c code. I also checked that I have all the executables specified in syntastic/syntax_checkers/c/.
Here is a part of my .vimrc file:
" syntastic
let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1
When I open a *.c file and do :SyntasticCheck, nothing happens. There is no errors complaining command not found, so syntastic is loaded. However, even if the *.c file that's currently opened contains errors syntax error, syntastic is not showing anything.
It is the first time I use syntastic so I don't really know the correct way to invoke it.
I also tried :SyntasticCheck [c] and I get the following error message:
Error detected while processing function <SNR>_22_UpdateErrors..<SNR>22_CacheErrors:
line 16:
E121: Undefined variable: checkers
E15: Invalid expression: checkers
Can someone tell me what I did wrong and how to invoke syntastic?
Thanks!
Try adding this to your vimrc:
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
(This is lifted straight from my vimrc, which has some other Syntastic settings if you'd like.)
I don't really understand the reason, but when I re-installed the YouCompleteMe plugin for vim with ./install.sh --clang-completer. Syntastic works like charm.
Installing clang and/or ctags packages fixed this for me
I did two things and then Syntastic started to behave as expected with JS files and ESlint. Can't tell which one did the trick:
1- In the project's directory ran eslint --init.
2- Started vim opening the file without the -S flag.
Before it failed silently, no errors and no diagnostics. This is how ESlint behaves when there is no configuration file.

How Do I get a syntax check to work in/with vim?

This question has been asked, in one form or another, a dozen times here, and it blows my mind how not a single one actually addresses how to configure syntastic or jslint such that it actually does what it is supposed to do (its README file is completely useless)
see here
Can anyone provide some step by step instructions, or a link to such instructions. I tried to install jslint and spidermonkey, and I got nowhere.
I managed to get the syntax check to work (thanks to romainl). A few things I learned along the way that may help anyone with a similar problem
To build Javascript Lint look for the README file nested in jsl-x.x.x/src/README.html
The build instructions are gmake -f Makefile.ref but gmake is the same thing as make so issue the command sudo ln -s /usr/bin/make /usr/bin/gmake
jsl will now be found in jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl. To make it generally accessible do something like: ln -s /whatever/jsl-0.3.0/src/Linux_All_DBG.OBJ /home/ForestGump/bin/jsl. More information here
To check that jsl actually works find a test file ( here) then issue the command jsl -process test.js. It should list all the errors.
To customize your command line, add this to your vimrc file set statusline=%{SyntasticStatuslineFlag()}
What did you do? What works and what doesn't? Do you get error messages?
Here is what I did:
Downloaded the jsl sources from the JavaScript Lint site.
Built jsl and moved it somewhere in my $PATH.
Checked if it worked by running it against a random .js file
Downloaded and installed Syntastic as a Pathogen bundle.
Typed :helptags /path/to/syntastic/doc because for some reason Pathogen's automatic help tags generation doesn't work for me.
Read Syntastic's documentation: :help syntastic.
Steps 1 to 5 didn't take more than 3 or 4 minutes, maybe less.
Step 6 is obligatory, whatever new tool you try. RTFM.
I didn't have to configure anything beside these 3 lines in my .vimrc (and I believe the third is redundant):
let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1
and customizing my statusline a bit with:
%{SyntasticStatuslineFlag()}
EDIT
Here is my statusline:
set statusline=%<\ %n:%f\ %m%r%y%{SyntasticStatuslineFlag()}%=line:\ %l\ of\ %L,\ col:\ %c%V,\ win:\ %{WindowNumber()}\
Don't copy it verbatim or you'll get some errors due to the function call at the end. There is a paragraph about that in syntastic's help.
END EDIT
After all that, 10 or 12 minutes if you count reading the documentation, I have a very helpful location list and signs poping up each time I save a .js file with syntax errors.
Setup vundle according to its README.
Put this into your .vimrc:
Bundle 'scrooloose/syntastic'
Then enter this command in vim:
:BundleInstall
That's it.
EDIT: Vundle has changed its syntax since I originally wrote this. Nowadays, you use
Plugin 'scrooloose/syntastic'
and then enter
:PluginInstall

Resources