I'm using Vim on Cygwin and I've recently decided to attempt to install some plugins. I installed Vundle and managed to get the vim-airline plugin working, but for some reason I cannot get Syntastic to work.
My vimrc:
set nocompatible
filetype off
set rtp+=c:/cygwin64/home/USERNAME/.vim/bundle/Vundle.vim
call vundle#begin('c:/cygwin64/home/USERNAME/.vim/bundle/')
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'vim-syntastic/syntastic'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
call vundle#end()
filetype plugin indent on
I believe syntastic downloaded properly as it updates when I run :PluginInstall and :PluginUpdate from within Vim.
When I open a .py file with the .vimrc above, I receive the following error:
syntastic: error: checker python/python returned abnormal status 2
From sniffing around I learned that from within Vim, the following can be helpful in diagnosing syntastic problems.
:let g:syntastic_debug=3
:w
:mes
One of the portions of the :mes returns
syntastic: 73.033500: checker output: ['C:\Python36\python.exe: can''t open file ''/home/USERNAME/.vim/
bundle/syntastic/syntax_checkers/python/compile.py'': [Errno 2] No such file or directory', '']
After a little more digging I found that my shellslash variable may not be set, which is causing Windows filepaths to be interpreted as UNIX filepaths (or vice versa). Other people found this portion of the :mes return helpful:
syntastic: 72.928500: &shell = '/bin/bash', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellqu
ote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape
= ''
I added a line to my .vimrc, set shellslash, yet after I saved it and reopened vim, nothing changed (I tried adding it in several different places, like before the set rtp, after syntastic plugin call, and at the very end). I got the same error, and when I ran through the prompts for :mes again, there was no shellslash variable listed. The output looked exactly like above. I also tried :set shellslash from within Vim, and while no errors were thrown, the problem remained.
The last thing I could think of was that Vim was loading a different .vimrc file, so I ran :scriptnames but it returned in the top row the location of the .vimrc I've been editing.
So how do I set shellslash? I believe that might allow Syntastic to work properly in Vim on Cygwin.
Related
Hello fellow Stack Overflow vim users,
I have recently found myself spending a considerable amount of time in my school's Computer Science lab writing code. I've configured vim on countless linux systems and have never encountered this error:
E499: Empty file name for '%' or '#', only works with ":p:h"
This error happens anytime I use % in a command in vim. I've never seen this before, but I will give as much info as I can. Here is my .vimrc:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"Plugin 'scrooloose/nerdtree'
"Plugin 'bling/vim-airline'
"Plugin 'altercation/vim-colors-solarized'
call vundle#end()
filetype plugin indent on
I've commented out those last few plugins to see if they had any correlation with the error, but that didn't seem to help. I used Git to install vim as usual:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
All I did after that was run :PluginInstall to install the plugins, and then tried to use :source %, resulting in the error.
This has really stumped me, and I hope to solve it, as I'd like to use my customized vim setup for this CS class, but I can deal with stock ViM or even Vi, or if it comes to it... nano.
EDIT: Using Ubuntu 15.04
This seems to be related to empty %. You can do two things: pass the filename when invoking vim: vim myscript.vim and then calling :source %, or passing the filename to :source (:source myscript.vim).
EDIT
If you issue :help registers, there is listed that % is a read-only register containing the current filename. So, if you are editing a buffer that doesn't have a filename (not saved), this register is empty and so you get error message.
Today I encountered very strange behaviour in vim. When I open a python file some things are automatically setup p.ex. expandtab. If I open a second python file with :sp then expandtab is not set, while filetype=python seems to be correct.
I removed .vim and stripped down my .vimrc to:
filetype plugin indent on
With the help of verbose set filetype? I could figure out:
first buffer: Last set from /usr/share/vim/vim74/filetype.vim
split buffer: Last set from /usr/share/vim/vim74/scripts.vim
Why is this different and how could I fix it?
(I'm using vim version: 2:7.4.052-1ubuntu3)
I'm running OS X 10.9. I downloaded the Python 3.3.3 .dmg file and installed it. I download the vim code (not macvim) via google code (mercurial) and built it with the following commands:
./configure --enable-python3interp --with-python3-config-dir=/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3
make VIMRUNTIMEDIR=/usr/local/share/vim/vim74
sudo make install
Everything seems to work normally. I mention all this to try to cover my basis in case I've caused my own issue.
What I'm trying to figure out is why when I check the file type with "if &ft == 'python'" it only returns true if I run "filetype detect" 1st. I am not running "filetype on" or any other filetype command. I know Vim correctly recognizes my .py files without the "filetype detect" because I can run ":echo &ft" and it returns "python".
Is this normal behavior or did I screw something up in the compile? What makes me think this might not be normal is that every example I can find from example .vimrc files I don't see anyone else running "filetype detect".
Thanks.
Edit: I've tried this with "filetype on" before the if statement, without the "filetype detect", but this doesn't seem to work either.
From :help filetype-detect:
...
When filetype detection was off, it will be enabled first, like the "on"
argument was used.
So either of these sequences should have the effect of setting 'filetype' to "python":
:filetype on
:e foo.py
:e foo.py
:filetype detect
My preference is to add :filetype on to my vimrc file, either directly or with something like
:runtime vimrc_example.vim
Beyond the initial conditional detection of the filetype issue, I also ran into the condition failing when opening a new tab or split. Whatever is within the condition is applied to new buffers regardless of file type when I check with the following:
filetype detect
if &ft == 'python'
....
endif
The following however is checked correctly with each new buffer load:
au BufRead *.py [arguments]
as in
au BufRead *.py let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
I hope this helps others.
I'm using MacVim (kind of gvim for OSX) and try to get the slimv plugin running.
Sadly it's not working out of the box. In fact, it does not start up at all.
My setup:
MacVim (32bit cause of this) (vim 7.3)
:scriptnames does not list ftplugin/slimv.vim while plugin/paredit.vim is listed
:set ft? shows filetype=lisp for .lisp files
:messages shows no errors
:filetype filetype detection:ON plugin:ON indent:ON
:echo g:paredit_loaded 1
:echo g:slimv_loaded E121: Undefined variable: g:slimv_loaded \ E15: Invalid expression: g:slimv_loaded
compiled with +python (2.7)
SBCL and slime are installed - works flawless with emacs.
I tried it with and without let g:slimv_swank_cmd = ... in .vimrc and changed the line recommended on the plugin page from
let g:slimv_swank_cmd = '!osascript -e "tell application \"Terminal\" to do script \"sbcl --load ~/.vim/slime/start-swank.lisp\""'
to
let g:slimv_swank_cmd = '!sh -c "sbcl --load /Applications/MacVim.app/Contents/Resources/vim/runtime/slime/start-swank.lisp" &'
since the osascript was not working and I don't know how to fix it. But a similar call to xterm is sufficient for Linux so my sh call should be fine.
Well, I got no idea what to try next. :/
The problem got solved by installing slimv to ~/.vim instead of the vim ebedded in MacVim. Maybe some kind of bug? However, Common Lisp + vim - I just love it.
Because moving the slimv plugin to ~/.vim fixed it, I suspect the problem is that MacVim's default /Applications/MacVim.app/Contents/Resources/vim/runtime/ftplugin/lisp.vim is being sourced before the ftplugin/lisp/slimv-lisp.vim file provided with slimv.
Both of those files (lisp.vim and slimv-lisp.vim) start with code like this:
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
finish
endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
and so whichever file gets sourced first will prevent the other file from running since vim does finish (exits the script) if it detects that another *lisp*.vim script was run previously and therefore set the b:did_ftplugin buffer-local variable.
You can tell this is happening by running MacVim from the command line with the arguments:
-V20macvim-log.txt hello.lisp
Then quit the MacVim session that starts up, and look at the macvim-log.txt file it created.
Search for b:did_ftplugin and you'll see it referenced each time lisp.vim or slimv-lisp.vim runs, and you can see that lisp.vim runs first, which prevents slimv-lisp.vim from working.
Moving your slimv install from the /Applications/MacVim.app/ dir to your ~/.vim dir will change the order so that slimv-lisp.vim is sourced before lisp.vim, and then slimv will work.
If slimv.vim is not listed in :scriptnames and g:slimv_loaded is undefined then you don't have the plugin loaded at all. I guess you don't have filetype plugins enabled. Paredit is a general plugin but slimv.vim is a filetype plugin and filetype/indent plugins must explicitly be enabled. Try to add these lines to your .vimrc:
filetype plugin on
filetype indent on
The problem got solved by installing slimv to ~/.vim instead of the vim ebedded in MacVim. Maybe some kind of bug?
However, Common Lisp + vim - I just love it.
In my .vimrc I have the following snippet:
if has('autocmd')
filetype plugin indent on
syntax on
but when I start vim it shows the following error:
Can't open file /usr/share/vim/syntax/syntax.vim
error seems to have occurred on syntax on line in .vimrc.
I do not have syntax.vim in path /usr/share/vim/syntax though I have others like clojure.vim cpp.vim java.vim etc...
I searched but can't seem to find the default syntax.vim if it comes with default version of vim.
I've been stuck with this for a while and would like some help.
I use Arch and build vim from the AUR using the vim-git PKGBUILD. For me, it was the case of using vim-git, but vim-runtime from the official repos, not vim-runtime-git from the AUR.
Switching to vim-runtime-git solved this issue for me and provided the syntax file (and colours, and...).
It should be there so there may be other files missing. I would suggest you re-install!.
For a QDF here is what the
syntax.vim file should look like this:-
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram#vim.org>
" Last Change: 2001 Sep 04
" This file is used for ":syntax on".
" It installs the autocommands and starts highlighting for all buffers.
if !has("syntax")
finish
endif
" If Syntax highlighting appears to be on already, turn it off first, so that
" any leftovers are cleared.
if exists("syntax_on") || exists("syntax_manual")
so <sfile>:p:h/nosyntax.vim
endif
" Load the Syntax autocommands and set the default methods for highlighting.
runtime syntax/synload.vim
" Load the FileType autocommands if not done yet.
if exists("did_load_filetypes")
let s:did_ft = 1
else
filetype on
let s:did_ft = 0
endif
" Set up the connection between FileType and Syntax autocommands.
" This makes the syntax automatically set when the file type is detected.
augroup syntaxset
au! FileType * exe "set syntax=" . expand("<amatch>")
augroup END
" Execute the syntax autocommands for the each buffer.
" If the filetype wasn't detected yet, do that now.
" Always do the syntaxset autocommands, for buffers where the 'filetype'
" already was set manually (e.g., help buffers).
doautoall syntaxset FileType
if !s:did_ft
doautoall filetypedetect BufRead
endif
I had this problem as well after upgrading to 7.3 (I'm using cygwin). Check whether running "vi" instead of "vim" has the same problem. I found that vim was actually the old 7.2 executable, but the syntax files were in the location expected by 7.3; vi was the correct 7.3 executable.
I have been using compiled vim from source without explicitly installing it on my system (due to missing sudo privileges).
I was able to solve the issue by adding the following line to my .bashrc:
export VIMRUNTIME=<path to cloned vim repo>/runtime
Thus: Pointing this env variable to the runtime director in the git tree, makes vim find the needed file(s).