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

Syntax highlight snippets files #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions doc/minisnip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Minisnip adds the `minisnip` |filetype| for syntax highlighting to all files
matching `*/minisnip/*`. If you store your snippets in another directory then
you'll have to create your own |autocmd| to do this.

Further, if |g:minisnip_nested_syntax| is |TRUE| (the default), filetype aware
snippets files will be syntax highlighted according to their filetype.

-------------------------------------------------------------------------------
*'g:minisnip_trigger'*
Default: '<Tab>'
Expand Down Expand Up @@ -148,5 +151,11 @@ these placeholders will be targeted last. >
# END FUNCTION {{+~\~1+}}
<

-------------------------------------------------------------------------------
*'g:minisnip_nested_syntax'*
Default: 1

For filetype specific snippets files, include the syntax highlighting for that
filetype when editing the snippets file.

vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
15 changes: 15 additions & 0 deletions syntax/minisnip.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ if exists("b:current_syntax")
finish
endif

if !exists("g:minisnip_nested_syntax")
let g:minisnip_nested_syntax = 1
endif

if g:minisnip_nested_syntax
let s:filetype = get(matchlist(expand("%:t:r"), '_\([^_]\+\)_.\+$'), 1, '')
if !empty(s:filetype)
for s:ft in split(s:filetype, '\.')
silent! exe "runtime! syntax/" . s:ft . ".vim"
unlet! b:current_syntax
endfor
endif
unlet s:filetype s:ft
endif

" Get the minisnip defined delimiters
exe "syntax match minisnipKeyword /" . g:minisnip_startdelim . "/"
exe "syntax match minisnipKeyword /" . g:minisnip_enddelim . "/"
Expand Down