Can I change the "snippet_dirs" to a seperate Dropbox folder?
Closed this issue · 4 comments
Feature request
I use snippets on a hourly basis, and more often than not, I will make changes to the snippets. However, currently, all snippets seems to be canned within the Vim-snipmate
plugin. Thus, it makes it very hard to me to keep the snippets up-to-date when I switch workstations (e.g., from a Windows desktop machine to a laptop).
It would nice to give users an option to source a specific folder outside the installation package of the plugin.
Failed attempts
- Tried to change the following setting, in vain:
let g:SnipMate['snippet_dirs']
\ = funcref#Function('return split(&runtimepath,",")')
- Tried to add the following to my
_vimrc
(on a Windows machine):
set rtp+=c:\Users\llinfeng\Dropbox\snippet\
- Have also tried the solution in issue #12, as follows. Yet, nothing happens after I pressing the
<tab>
key for completion.
let g:snipMate = {}
let g:snipMate['snippet_dirs'] = funcref#Function('return ["~/.vim/snippets"]')
Ideal solution
Please advise the specific settings I can use to have all my snippets stored in one Dropbox folder, for example, under ~Dropbox\Tool_Private\Vim_Settings\Snippets\
" setting pending
The way to do this is to add a directory to 'rtp'
. Note that with this approach, SnipMate will look in the given directory for a directory named snippets
, and it'll look in that directory for snippets. Using the directory in your post, you could either put your snippets in c:\Users\llinfeng\Dropbox\snippet\snippets
or rename your directory to snippets
. Then you would do either set rtp+=c:\Users\llinfeng\Dropbox\snippet
or set rtp+=c:\Users\llinfeng\Dropbox
, respectively.
@ajzafar Thanks a lot!
note
The directory name, snippets
, is case-sensitive. All *.snippets
shall go under this folder/directory.
The settings that worked:
The latest solution is here honza@581a4d1#commitcomment-48874436
@vrkansagara How is what you wrote different from what @ajzafar provided as the solution to my original post? I suppose there are now two ways to source snippets elsewhere, as below
; This is the old recommended setting form 2017, which worked fine over 4+ years for me.
; Note, the `filetype.snippets` files should be nested under the full path specified below.
set rtp+="/full/path/to/folder/of/snippets/"
; This is another way to specify the same thing. A single period in Vim concatinates two strings.
; This was referred to as "the lastest solution".
let &runtimepath.=','.'/full/path/to/folder/of/snippets/'
Since these two entries in .vimrc
should be identical in practice, I am listing them here together.