MacVim: slimv does not start - vim

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.

Related

Why ~/.vimrc is not working for vim on ubuntu server

I installed ubuntu server on vmware player. I want to use vim, so I put .vimrc file under my home directory.
But when I open vim, vim is not using the configuration from the file ~/.vimrc.
If I do it the same way on a ubuntu desktop virtual machine, everything works fine.
What did I do wrong in the server environment? What else should I do?
In order to tell if your .vimrc is running at all, put
echom ".vimrc message 1"
On the first line of ~/.vimrc
Then launch vim and type
:messages
in regular mode. If you see ".vimrc message 1", you know that the .vimrc is at least being read ... it may be stopping before it does anything useful, but at least vim is picking it up.
I would also try which vim to see which program is being called when you type vim.
You can capture a full log of a Vim session with vim -V20vimlog. After quitting Vim, examine the vimlog log file. It will show where Vim searched.
Does Vim correctly detect your home directory? :echo $HOME will tell you.
Also, read :help .vimrc for details on the resolution and locations of .vimrc.

Why won't vim recognise a plugin command in the vimrc, but it will recognise it when running?

I've installed the vim-gitgutter plugin with pathogen.
I can type :GitGutterLineHighlightsEnable from inside vim and line highlights are turned on, great.
But I want line highlights to be automatically enabled at startup, so I added the command to my ~/.vimrc. However when I start vim, I get "E492: Not an editor command: GitGutterLineHighlightsEnable". Once vim has started up, I can run the command.
My vimrc looks like this:
execute pathogen#infect()
colorscheme railscasts
.. snip tabs and colors etc ..
GitGutterLineHighlightsEnable
hi GitGutterAddLine guibg=#222F22
hi GitGutterChangeLine guibg=#222239
hi GitGutterDeleteLine guibg=#2F2222
Figured it out.
.vimrc is executed before plugins are loaded. From this related question, I changed the commands to:
autocmd VimEnter * GitGutterLineHighlightsEnable
This executes the command after vim has started up.
Use
let g:gitgutter_highlight_lines = 1
instead of
GitGutterLineHighlightsEnable
As you determined yourself, plugins are processed after the .vimrc.
What you can do if you don't like using a VimEnter autocmd, is put a file in your ~/.vim/after/plugin directory for any commands that should run after plugins are loaded.

vimrc: checking &ft doesn't work unless "filetype detect" ran 1st

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.

ctags not working as expected with Vim plus general setup problems (C programming)

I have installed cvim and NodeTree plugins and generated an exuberant ctags file for my build tree.
This is what my ~/.vim/.vimrc file looks like:
:noremap :TlistToggle
:let Tlist_Show_One_File = 1
:let Tlist_Exit_OnlyWindow = 1
:let Tlist_Use_Right_Window = 1
set tags=./tags;/
set number
set tabstop=4
set incsearch
When I start editing a file, I notice that Ctrl ] does not work and I have to resort to typing ta: funcname - which gets tiring after a while. Interestingly enough, Ctrl T pops me off the tag stack as expected - I don't understand whats going on - how do I fix this?
Incidentally, vim (appears to) completely ignores the contents of my .vimrc file and I always have to type the same commands in the editor, so as to get the settings I want - very annoying.
Last but not the least, I used to be able to type :make in the editor window, drop to the console and then have the build results displayed in a little window which I can then go to and select a line (with an error or warning say), and then have the editor automagically take me to the offending line - unfortunately, I don't remember the plugin (or commands) I used to allow me to build from within vim.
So, how do I:
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
Fix my .vimrc file so that contents are actually applied to my vim session.
Find the appropriate plugin to install to allow builds (using make) from within vim
You're asking about a weird mix of problems.
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
The tags functionality is working; I suspect that you have a mapping blocking Ctrl-]. Try
:verbose nmap <C-]>
and
:nunmap <C-]>
Fix my .vimrc file so that contents are actually applied to my vim session.
:echo $MYVIMRC
will tell you the location of the .vimrc that Vim uses. Also, check the output of :scriptnames which scripts get loaded, and read :help vimrc to understand the logic Vim applies.
Find the appropriate plugin to install to allow builds (using make) from within vim
That's built into Vim. With the appropriate 'makeprg' set (it defaults to make), you can run :make. Vim parses the output (through the 'errorformat' option), and you can open the quickfix list via :copen.
Your vimrc is:
~/.vim/.vimrc
If you run Vim 7.4, it should be:
~/.vim/vimrc
or
~/.vimrc
If you run Vim 7.3 or older, it should be:
~/.vimrc
And... what Ingo said.

How to turn-off a plugin in Vim temporarily?

I have multiple plugins in Vim and some of them modify the default behavior of Vim. For example I use Vimacs plugin, which makes Vim behave like emacs in the insert mode alone. Sometime I want to turn off the Vimacs plugin without moving the vimacs.vim out of the plugins directory. Is there a way to do it?
You can do this if you use a plugin manager like Vundle or Pathogen, which will keep the plugin in its own directory underneath the ~/.vim/bundle/ directory.
In that case, just find out the runtimepath of the vimacs plugin with the following command:
set runtimepath?
Let's say it's ~/.vim/bundle/vimacs.
Then, put this command in your .vimrc:
set runtimepath-=~/.vim/bundle/vimacs
To load vimacs, just comment that line out and relaunch Vim (or source your .vimrc).
See which variable vimacs check on start. On the begin of the script file find something Like if exists('g:vimacs_is_loaded").... Then set this variable in your .vimrc or while start vim with vim --cmd "let g:vimacs_is_loaded = 1".
In case you are using pathogen, this post gives a better answer, in my opinion. Since I have frequent need to disable snippets when using latex, also added this in my ~/.config/ranger/rc.conf:
map bs shell vim --cmd "let g:pathogen_blacklist = [ 'ultisnips', 'vim-snipmate' ]" %f
This way, whenever I want to open a file with snippets disabled, it is easy.

Resources