简体   繁体   中英

VIm snipmate <TAB> auto completion not working

This is the first time 'm trying snipmate with VIm 7.3 in ubuntu 12.04 .

My .vimrc configuration is :

" kill vi compatibility
set nocompatible               " be iMproved

" -------------------------------------
" ---------snipmate--------------------
" -------------------------------------
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "honza/vim-snippets"

Bundle "garbas/vim-snipmate"
" -------------------------------------
 filetype plugin on

I believe thats all I want followed by :BundleInstall .

The tree structure of my .vim/bundle is

prayag@prayag:~$ tree -d .vim/bundle/
.vim/bundle/
|-- vim-colors-solarized
|   |-- autoload
|   |-- bitmaps
|   |-- colors
|   `-- doc
|-- vim-snipmate
|   |-- after
|   |   `-- plugin
|   |-- autoload
|   |-- doc
|   |-- ftplugin
|   |-- plugin
|   `-- syntax
|-- vim-snippets
|   |-- UltiSnips
|   |-- autoload
|   `-- snippets
|       |-- coffee
|       `-- javascript
`-- vundle
    |-- after
    |   |-- ftplugin
    |   `-- plugin
    |-- autoload
    |   `-- vundle
    |-- doc
    |-- ftplugin
    |-- plugin
    |-- syntax
    `-- test
        `-- files

139 directories

BUT, when I try some java code to test main snippet,

$ vi App.java
main

After pressing <TAB> gives me following result/error

main<Plug>snipMateNextOrTrigger

:verbose imap <Plug>snipMateNextOrTrigger gives me

No mapping found

with finish section commented in plugin/snipMate.vim , :verbose imap <Plug>snipMateNextOrTrigger gives me following information,

i  <Plug>snipMateNextOrTrigger * <C-R>=snipMate#TriggerSnippet()<CR>
        Last set from ~/.vim/bundle/vim-snipmate/plugin/snipMate.vim

and On pressing <TAB>

Error detected while processing /home/prayag/.vim/bundle/vundle/autoload/snipMate.vim:                                                                              
line   15:
E122: Function <SNR>84_RemoveSnippet already exists, add ! to replace it

Same result/error I get with following configuration in .vimrc ,

:imap <C-J> <Plug>snipMateNextOrTrigger
:smap <C-J> <Plug>snipMateNextOrTrigger

Same configuration worked fine for another ubuntu 13.04 machine.

I must be doing something wrong but couldn't figure it out.

References

Vim: snipMate plug-in does not trigger snippet completion

First of all, I suggest that you remove :set nocompatible from your vimrc file. Vim automatically resets the 'cp' option if it finds a personal vimrc file (not a system vimrc file) on startup, and if you ever :source ~/.vimrc then it can have confusing results.

A complete answer to your question would be a very large troubleshooting flowchart. That would be a good thing to have, but I am not going to work that hard. Here is a summary of the conversation we had in the comments to diagnose this problem.

I have snipMate installed, but when I enter "main<Tab>" in Insert mode, I get "main<Plug>snipMateNextOrTrigger" .

What do :verbose imap <Tab> and :verbose set cpo? tell you? Check :version for the "<size> version", where <size> is one of Tiny, Small, Big, Huge (I may be missing some). (The problem may be how <Tab> is mapped, or you may be in compatible mode, or your version of vim may not support maps or may not support the <Tab> notation in maps.)

":verbose imap <Tab>" shows that " <Tab>" is mapped to "<Plug>snipMateNextOrTrigger" in "~/.vim/bundle/vim-snipmate/after/plugin/snipMate.vim" , and the other stuff looks right.

How about :verbose imap <Plug>snipMateNextOrTrigger ? (The problem seems to be that <Tab> is mapped to something; that something is supposed to be remapped, but it is not.)

":verbose imap <Plug>snipMateNextOrTrigger" gives me "No mapping found".

That is the problem. The file plugin/snipMate.vim contains the line inoremap <silent> <Plug>snipMateNextOrTrigger <CR>=snipMate#TriggerSnippet()<CR> . Either you do not have that file, it is missing that line, or it is not being :source d when vim starts up. Or maybe the variable loaded_snips is defined somewhere else. Look at the file, check :scriptnames right after starting vim, and search for "loaded_snips" in your other startup files. I guess there are other possibilities, too, like :imapclear , but that seems unlikely.

The file is there, and has the right line. (At first I looked at "after/plugin/snipMate.vim" instead of "plugin/snipMate.vim".) I checked ":scriptnames" and it is listed. I did not check for other files defining "loaded_snips", but I commented out

if exists('loaded_snips') || &cp || version < 700
    finish
endif

and got an error from "snipMate.vim" in another directory. I removed that file, re-installed snipMate, and now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM