my personal defined snipps doesn't work

Asked by hackrole

I don't know why it happend. I have come throngh the doc file and everything seems ok.
it work fine first with the system snippets. But the system snippets seem ugly. So I redefine some snippets. But find it doesnot work. I try to change the snippets file's position,but it still doesnot work. After all tries, I open a python file, enter the insert mode, press <f7> I can only see the system snippets but not my own. I have search the bugs list find not help. I do not think this is bug. So I am here to ask for some help.
 this is what my conf
1) this is my conf:
" 使用python2.7
let g:UltiSnipsUsePythonVersion = 2
" how window is opened
let g:UltiSnipsEditSplit = "horizontal"
" 定义私有Snips目录
let g:UltiSnipsSnippetsDir = "~/.vim/snippets/ultisnips"
" 定义按键
let g:UltiSnipsExpandTrigger = "<C-e>"
let g:UltiSnipsListSnippets = "<f7>"
let g:UltiSnipsJumpForwardTrigger = "<C-k>"
let g:UltiSnipsJumpBackwardTrigger = "<C-j>"

and this is my personal snippet dirs:
daipeng@daipeng:~/.vim$ ll -R snippets/
snippets/:
total 12
drwxrwxr-x 3 daipeng vboxusers 4096 Jul 17 17:43 ./
drwxrwxr-x 15 daipeng vboxusers 4096 Jul 15 17:56 ../
drwxr-xr-x 3 daipeng vboxusers 4096 Jul 17 17:23 ultisnips/

snippets/ultisnips:
total 20
drwxr-xr-x 3 daipeng vboxusers 4096 Jul 17 17:23 ./
drwxrwxr-x 3 daipeng vboxusers 4096 Jul 17 17:43 ../
-rw-r--r-- 1 daipeng vboxusers 41 Jul 17 16:59 all.snippets
drwxr-xr-x 2 daipeng vboxusers 4096 Jul 17 17:21 python/
-rw-r--r-- 1 daipeng vboxusers 775 Jul 17 17:23 python.snippets

snippets/ultisnips/python:
total 12
drwxr-xr-x 2 daipeng vboxusers 4096 Jul 17 17:21 ./
drwxr-xr-x 3 daipeng vboxusers 4096 Jul 17 17:23 ../
-rw-r--r-- 1 daipeng vboxusers 775 Jul 17 17:21 python.snippets

then this is my own snippets file:
daipeng@daipeng:~/.vim/snippets/ultisnips$ cat python.snippets
# hd
snippet hd "header for python scripts" !b
#!/user/bin/env python
# encoding: utf-8
${0}
endsnippet

# def
snippet def "def func with docstrings" !
def ${1:func}(${2:arg}):
 """ ${3:docstrings for ${1}} """
 ${0:pass}
endsnippet

snippet defs "def func(self,) with doc" !
def ${1:func}(self, ${2:argv}):
 """ ${3:docstrings for ${1}}"""
 ${0:pass}
endsnippet

snippet defc "def func(cls,) with doc" !
def ${1:func}(cls, ${2:argv}):
 """ ${3:docstrings for ${1}}"""
 ${0:pass}
endsnippet

# class
snippet class "class with docstrings" !b
class ${1:MyC}(${2:object}):
 """
 ${3:docstring for ${1}}
 """

 ${0:pass}
endsnippet

# sqlalchemy

# others
snippet init "def __init__()"
def __init__(self${1:, argv}):
 ${0:pass}
endsnippet

hope you help. thanks at first

Question information

Language:
English Edit question
Status:
Solved
For:
UltiSnips Edit question
Assignee:
No assignee Edit question
Solved by:
hackrole
Solved:
Last query:
Last reply:
Revision history for this message
SirVer (sirver) said :
#1

I think the problem is that "~/.vim/snippets/ultisnips" is not on your runtimepath. g:UltiSnipsSnippetsDir is only used for the :UltiSnipsEdit command, but ultisnips still goes through your rtp to find the snippets. See https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt#L310 to how to configure this.

to make sure that nothing else is broken, move your personal snippets into ~/.vim/UltiSnips and test if they work there.

Revision history for this message
hackrole (daipeng123456) said :
#2

yes, this solve my problem. the question seems to be the runtime path.

I really cannot understand why the Ultisnip search all directories in the runtime with particular name, install of set a global list to save the some particular directories. It seems more clean and simple, did not?

and, really thank you for your time and answer.

Revision history for this message
SirVer (sirver) said :
#3

> I really cannot understand why the Ultisnip search all directories in the runtime with particular name, install of set a global list to save the some particular directories. It seems more clean and simple, did not?

well, there are plugins which ship with ultisnips snippets, so searching all the paths makes sense. The original way to define where snippets are searched for were dead simple (like you suggest here), but over time we needed to expand the way it works to satisfy all needs - and there are still people requesting more flexible search patterns. You can never please all :).