Skip to content
This repository was archived by the owner on Mar 5, 2020. It is now read-only.

Support multiple directories in g:minisnip_dir #5

Merged
merged 2 commits into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/doc/tags
24 changes: 13 additions & 11 deletions autoload/minisnip.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ function! minisnip#ShouldTrigger()
let l:cword = matchstr(getline('.'), '\v\f+%' . col('.') . 'c')

" look for a snippet by that name
let l:snippetfile = g:minisnip_dir . '/' . l:cword
let l:ft_snippetfile = g:minisnip_dir . '/_' . &filetype . '_' . l:cword
if filereadable(l:ft_snippetfile)
" filetype snippets override general snippets
let l:snippetfile = l:ft_snippetfile
endif
for l:dir in split(g:minisnip_dir, ':')
let l:snippetfile = l:dir . '/' . l:cword
let l:ft_snippetfile = l:dir . '/_' . &filetype . '_' . l:cword
if filereadable(l:ft_snippetfile)
" filetype snippets override general snippets
let l:snippetfile = l:ft_snippetfile
endif

" make sure the snippet exists
if filereadable(l:snippetfile)
let s:snippetfile = l:snippetfile
return 1
endif
" make sure the snippet exists
if filereadable(l:snippetfile)
let s:snippetfile = l:snippetfile
return 1
endif
endfor

return search(g:minisnip_delimpat, 'e')
endfunction
Expand Down
17 changes: 9 additions & 8 deletions doc/minisnip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ CONFIGURATION *minisnip-configuration*

-------------------------------------------------------------------------------
*'g:minisnip_dir'*
Default: $HOME . '/.vim/minisnip'
Default: '~/.vim/minisnip'

This allows you to specify where minisnip looks for snippet files. Add this
line to your `.vimrc`: >
let g:minisnip_dir = '/path/to/directory'
A colon-separated list of directories to look for snippet files, similar to
$PATH. The first match will be used. For example to share system-wide
snippets: >
let g:minisnip_dir = '/usr/share/minisnip:~/.vim/minisnip'
<

-------------------------------------------------------------------------------
Expand All @@ -66,7 +67,7 @@ example: >
*'g:minisnip_enddelim'*
Defaults: '{{+', '+}}'

The start and end delimeters of the placeholder string to use. For example,
The start and end delimiters of the placeholder string to use. For example,
with the default values, a sample snippet could look like this: >
<!DOCTYPE html>
<html lang='en'>
Expand All @@ -83,7 +84,7 @@ with the default values, a sample snippet could look like this: >
*'g:minisnip_evalmarker'*
Default: '~'

Marks a template as meant to be executed as vimscript. With the default value,
Marks a template as meant to be executed as VimScript. With the default value,
this looks something like: >
It has been {{+~localtime()+}} seconds since the Unix epoch
<
Expand Down Expand Up @@ -113,7 +114,7 @@ MISCELLANEOUS *minisnip-miscellaneous*

Syntax highlighting for minisnips:

If you would like to have the minisnip delimeters hightlighted for better
If you would like to have the minisnip delimiters highlighted for better
visibility in your minisnip files, add the following to your `.vimrc`: >
autocmd BufRead,BufNewFile /path/to/minisnips/* set filetype=minisnip
autocmd BufRead,BufNewFile */minisnip/_* setlocal filetype=minisnip
<