How to set up syntastic for vim? - 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.

Related

vim Error detected while processing function <SNR>66_MRU_Select_File_Cmd

I use vim8. When I use vim, whether I open or save a file, there will be errors. To save a file, I must use: w!, Open the file must be q to close the error.
Error detected while processing function <SNR>66_MRU_Select_File_Cmd[21]..<SNR>66_MRU_Window_Edit_File[67]..BufRead Autocommands for "*"..function <SNR>25_Detect[17]..<SNR>25_BufInit[1]..<SNR>25_autoload[2]..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]..function <SNR>87_add_methods[2]..<SNR>87_function:
I tried to reinstall vim, but it didn't work
sudo apt remove vim
sudo apt install vim
Also try to modify the .vimrc file and copy the .vimrc file of vim that is normally used on other servers, but it doesn't work
I also tried to add the content shown in the answer here to the top of the file, but it still failed https://github.com/powerline/powerline/issues/1925
if has('python3')
silent! python3 1
endif
and i tried the solution here, but it still failed Error detected while processing function vundle#installer#new
set shell=/bin/bash
Then I tried the solution here, but it still didn't work https://github.com/vim/vim/issues/3117
mv ~/.vimrc ~/.vimrc_back
mv ~/.vim ~/.vim_back
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
cp ~/.vim/bundle/Vundle.vim/test/minirc.vim ~/.vimrc
What should I do so that vim can be used normally and no error will be reported
When a script is sourced by Vim it is given a number, which can be used to make sense of a stack trace like yours (edited for legibility):
Error detected while processing function <SNR>66_MRU_Select_File_Cmd[21]
..<SNR>66_MRU_Window_Edit_File[67]
..BufRead Autocommands for "*"
..function <SNR>25_Detect[17]
..<SNR>25_BufInit[1]
..<SNR>25_autoload[2]
..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]
..function <SNR>87_add_methods[2]
..<SNR>87_function:
Before reinstalling Vim, a more constructive approach would be to figure out whether the problem occurs in Vim's own runtime files or in yours. You can use :help :scriptnames to put a filename to those numbers, so to speak.
Without even seeing the output of that command, it doesn't take much effort to find out that at least some of your problems come from your runtime files:
" one plugin
<SNR>66_MRU_Select_File_Cmd[21]
<SNR>66_MRU_Window_Edit_File[67]
" another plugin
..script /root/.vim/bundle/vim-rails/autoload/rails.vim[169]
..function <SNR>87_add_methods[2]
..<SNR>87_function:
Which means that you should look for the actual cause, not throw the towel and reinstall Vim or try random answers to random unrelated questions.
One good starting point would be line 21 of function MRU_Select_File_Cmd() in script number 66, which should be a call to MRU_Window_Edit_File() in your outdated version. The stack trace then points to line 67 of that function, and so on.
Hypotheses:
badly installed plugins,
incompatible Vim version,
incompatible plugins,
options incompatible with your plugins,
etc.
Good luck.

Is BundleInstall (for Vundle) required every time Vim is started?

I'm using Vim/Cream on Win7 with the Vim binaries provided with Cream (v7.3.107), and have installed Vundle, and the plugins work fine after I run :BundleInstall. But after exiting and restarting, the plugins don't work until I run BundleInstall again. Is this normal? I thought BundleInstall was a one-time command (excepting when used for updates). Here's an excerpt of what I have in my vimrc (actually cream-user.vim, which is what Cream prefers):
set nocompatible
filetype off
set runtimepath+=$HOME/vimfiles/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" Your bundles go here:
"
" ORIGINAL REPOS ON GITHUB
Bundle '907th/vim-auto-save'
.
However, when I run :AutoSaveToggle (a vim-auto-save command), I get the following error:
E492: Not an editor command: AutoSaveToggle
.
The cream-user.vim file is being invoked (it's listed in scriptnames):
83: C:\Users\<MyUserName>\.cream\cream-user.vim
[...]
85: C:\Users\<MyUserName>\.vim\bundle\vundle\autoload\vundle.vim
86: C:\Users\<MyUserName>\.vim\bundle\vundle\autoload\vundle\config.vim
.
...and Vundle itself is installed, as its commands work, notably :BundleList, which lists vim-auto-save among the installed bundles:
" My Bundles
Bundle 'gmarik/vundle'
Bundle '907th/vim-auto-save'
After I re-run BundleInstall, the plugins start working, and I do notice scriptnames now includes the extra files:
125: C:\Users\<MyUserName>\.vim\bundle\vundle\autoload\vundle\installer.vim
126: C:\Users\<MyUserName>\.vim\bundle\vundle\autoload\vundle\scripts.vim
127: C:\Users\<MyUserName>\.vim\bundle\vim-auto-save\plugin\AutoSave.vim
Putting :BundleInstall in the .vimrc doesn't look like the right move either, as it opens a buffer (can be worked around, but still...). I'm a brand new to Vim so I'm not sure what's wrong, probably something simple on my end, like my not being clear on how to appropriately invoke vundle. Any ideas on how to fix this?
First: You're right, :BundleInstall is not required on every launch. I guess the behavior you're seeing has to do with the Cream customizations; it probably messes with 'runtimepath' itself, and therefore interferes with Vundle.
If you just chose Cream for an easy install of Vim (though your 7.3.107 is quite dated already), there's also a "Vim-only" installer. Also, a Vim 7.4 installer is available from http://www.vim.org/download.php.
In case you do want Cream (wouldn't recommend that; especially if you're into programming / customizing Vim with plugins), I'd open an issue with the Vundle project, asking for help / support of Cream.
I had a similar problem with MacVim. The problem for me was that I didn't follow the instructions closely enough. I just assumed that I could just put the Vundle lines in my .gvimrc. This was WRONG! The solution, as per the instructions, was to place the lines in the .vimrc file. The order of operations matters, and it's possible this matters for Cream.
I found a solution to this problem in this bug report: https://github.com/gmarik/Vundle.vim/issues/430
At the end of your cream-user.vim file, add:
call vundle#config#require(g:bundles)
This causes the plugins to be loaded without showing the Vundle\Installer buffer at startup.

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

Cannot edit HAML files in carlhuda - janus VIM distro

I switched from my own VIM setup to janus recently. I really like the organization.
When I tried to edit and save HAML files, I got following error.
Error detected while processing function <SNR>44_UpdateErrors..<SNR>44_RefreshSigns..<SNR>44_SignErrors:
line 12:
E474: Invalid argument
How can I fix this issue?
probably, it will fix with fixing following line in your vimrc.
let g:syntastic_enable_signs=1
to
let g:syntastic_enable_signs=0
It was an error with syntastic plugin. I created an issue at GitHub.
scrooloose has fixed this issue.
You can find the patch here
Simply run
rake
inside your ~/.vim directory. It'll update the syntastic plugin.

Pathogen does not load plugins

Pathogen does not work for me. I am following Adam Lowe's hints posted here (and few more) without any success...
My vimrc:
filetype off
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
syntax on
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
set number
colorscheme darkblue
Contents of .vim - ls .vim/*:
.vim/autoload:
pathogen.vim
.vim/bundle:
nerdcommenter/ vim-haml/ vim-surround/
vim-endwise/ vim-rails/ vim-vividchalk/
All plugins in bundle were installed by cloning them from GitHub into bundle directory.
I have tried with pathogen 1.1 and 1.2 and even the latest from GitHub without any result. Vividchalk, Vim-rails and nerdcommenter are not working. I have very little experience with other plugs so I am not sure about them, but I suppose they are not working too.
I am using ArchLinux, vim 7.2.385-1 (not the latest because the latest requires me to install ruby1.9, but it is still 7.2). It has been installed via pacman - ArchLinux package manager. No vim plugins were installed the other way than using pathogen (I have even reinstalled vim package with cleaning /usr/share/vim).
What am I doing wrong?
EDIT:
/etc/vimrc http://hpaste.org/fastcgi/hpaste.fcgi/view?id=29685#a29685
/usr/share/vim/vimfiles/archlinux.vim http://hpaste.org/fastcgi/hpaste.fcgi/view?id=29686#a29686
This seems to be common problem caused by the "system" vimrc in some distributions setting filetype on before you set up pathogen. So turning it off and back on again forces plugins to load correctly:
call pathogen#runtime_append_all_bundles()
filetype off
syntax on
filetype plugin indent on
More info here.
I was having a similar problem. Pathogen was loading some of my plugins while not all of them.
After some fiddling and wondering I discovered (I don't know if it's mentioned in the documentation) that in each bundle/'plugin_name' folder, there should be another folder called plugin that contains the *.vim file.
Then, when vim starts will look, not in bundle, but in those folders within bundle that contain a folder called plugin... and will create other folders (in each plugin folder).
So, if the plugin is just a .vim file make a folder for it...
instead of:
~/.vim/bundle/vimexplorer/vimExplorer.vim
you need:
~/.vim/bundle/vimexplorer/plugin/vimExplorer.vim
And everything works like a charm.
I've had problems loading particular plugins: specifically, plugins with a plugin subdirectory. For example, on a fresh MacVim install, a plugin in ~/.vim/bundle/surround/plugin/surround.vim wasn't being loaded, even though ~/.vim/bundle/surround appeared in the output of :scriptnames.
The problem was that I was loading Pathogen in .gvimrc, not .vimrc. For whatever reason, stuff in .vim/bundle/*/plugin subdirectories won't load if you do that, so do it in .vimrc!
I've opened an issue on github—I don't know if it can be made to work even if it loads from .gvimrc, but there should at least be some sort of warning in the documentation for idiots like me.
If your .vim is based on a git repo and submodules, DO REMEMBER to run git submodule init and git submodule update after cloning the repo. i.e.
git submodule init
git submodule update
I had the same error and tried all of the above, but it didn't work. Until I initialized and updated the git submodules.
Hope this helps for anyone who has a similar error.
Maybe Arch's default vimrc (possibly /etc/vim/vimrc) doesn't play well with Pathogen. Try starting Vim without loading config files:
vim -u NONE
and then load your vimrc from within vim:
:so ~/.vimrc
Do the plugins work then?
Fixed by (mattn & tpope) after raising issue via github
set nocp
call pathogen#infect()
syntax on
filetype plugin indent on
call pathogen#infect()
see https://github.com/tpope/vim-pathogen/issues/50#issuecomment-3137909
My environment is Vim 7.3.35 and Ubuntu 11.04.
I spent some time trying to resolve it. I clone the project https://github.com:r00k/dotfiles and follow the instructions to install.
When started vi a got the so commented
E117: Unknown function: pathogen#runtime_append_all_bundles
and the solution:
filetype off
call pathogen#runtime_append_all_bundles()
filetype on
did not work.
I found the .vim symlink in my home directory where no properly set. The install script made a .vim DIRECTORY with a symlink vim inside of it pointing to my .dotfiles/vim. The solution was to delete the .vim directory and make a symlink .vim pointing .dotfiles/vim.
A kept the filetype off/on in my .vimrc also.
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
Try to check your runtime path using command:
:set runtimepath?
First entry should be something like ~/.vim.
My problem with not loading plugins/pathogen was that i placed my vim environment in ~/.dotfiles/vim where my vimrc and rest of the stuff (plugins etc.) lives.
After creating symlink to ~/.dotfiles/vim/vimrc in ~/.vimrc i forgot to make second symlink ~/.vim -> ~/.dotfiles/vim/ which caused vim to be confused cause he was looking for stuff in ~/.vim (default). After i made proper symlink everything poped in right place.
I hope it will help someone who forgot about second symlink like I did ;-)
Instead of call pathogen#runtime_append_all_bundles(), I used call pathogen#infect('~/.vim/bundle') and it worked for me.
I was having the same problem with Ubuntu. The log was:
linha 4: executando "/usr/share/vim/vim73/ftoff.vim"
Erro detectado ao processar /usr/share/vim/vim73/ftoff.vim:
linha 11:
E216: Grupo ou evento inexistente: filetypedetect *
fim da execução de /usr/share/vim/vim73/ftoff.vim
The solution was to add "\n"s at the end from file /usr/share/vim/vim73/ftoff.vim to execute it properly.
set nocp
call pathogen#infect()
syntax on
filetype plugin indent on
call pathogen#infect()
The above helped me fix the issue, can't leave a comment on other peoples however thank you for posting the code above.
I have it in mine as:
silent! call pathogen#runtime_append_all_bundles()
After spending waaaay too long trying to solve this problem with nerd-commenter/pathogen, I broke down and just used Debian's OS provided nerd-commenter plugin:
vim-addons install nerd-commenter
If you're on Debian and need to get back to work, try it out. You probably need "vim-addon-manager" and "vim-scripts" packages installed from apt if you don't have it already.
In my case I cloned to a folder ~/dotfiles but vun looks for a folder ~/.vim, as a result he carried no plugins or color schemes to solve the problem I did this:
ln -s ~/.dotfiles ~/.vim
I had the same problem. I tried every possible combination.
Finally I found that if I use mksession to save my Vim workspace and have it load on Vim startup, it made pathogen not load new plugins I put into the bundle folder.
After installing a new plugin I now always delete my session file and start Vim fresh and every plugin loads fine.
filetype off
set nocompatible
set laststatus=2
execute pathogen#infect()
syntax on
filetype plugin indent on
For the sake of completion I'll add my solution for this problem.
I just renamed my ~/.gvimrc file to ~/.vimrc, and all my problems were solved. I literally copied my .vim and my .gvimrc from linux and did this change and everything works as expected.
I was facing the same issue, finally after lot of google and tweaking the vimrc file, found the solution. Hope the following code snippet would resolve the issue.
set nocp
source /home/ameet/.vim/autoload/pathogen.vim "location of my pathogen.vim
call pathogen#infect()
call pathogen#helptags()
i had the same problem , solved by copying this file into ~/.vim/autoload:
https://github.com/sontek/dotfiles/blob/master/_vim/autoload/pathogen.vim

Resources