From e6849b2a9412bd4d33bcc43d89d3245f8845ab58 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Wed, 13 Nov 2019 11:12:47 -0700 Subject: [PATCH 1/3] Syntax highlight snippets files --- syntax/minisnip.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/syntax/minisnip.vim b/syntax/minisnip.vim index cf872b7..b381f2c 100644 --- a/syntax/minisnip.vim +++ b/syntax/minisnip.vim @@ -23,6 +23,18 @@ 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 filetype = get(matchlist(expand("%:t:r"), '_\([^_]\+\)_.\+$'), 1, '') + if !empty(filetype) + silent! exe "runtime! syntax/" . filetype . ".vim" + unlet! b:current_syntax + endif +endif + " Get the minisnip defined delimiters exe "syntax match minisnipKeyword /" . g:minisnip_startdelim . "/" exe "syntax match minisnipKeyword /" . g:minisnip_enddelim . "/" From 7de3afe9386998b6f2e455070a3b553d15867985 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Wed, 13 Nov 2019 11:16:50 -0700 Subject: [PATCH 2/3] Add help doc for g:minisnip_nested_syntax --- doc/minisnip.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/minisnip.txt b/doc/minisnip.txt index 2694de1..d1435aa 100644 --- a/doc/minisnip.txt +++ b/doc/minisnip.txt @@ -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: '' @@ -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: From 71fbfbdb38f893b64f5e9a71cd814b5cd22541b5 Mon Sep 17 00:00:00 2001 From: Greg Anders Date: Wed, 13 Nov 2019 11:58:56 -0700 Subject: [PATCH 3/3] Handle multiple filetypes for embedded syntax --- syntax/minisnip.vim | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/syntax/minisnip.vim b/syntax/minisnip.vim index b381f2c..b937d77 100644 --- a/syntax/minisnip.vim +++ b/syntax/minisnip.vim @@ -28,11 +28,14 @@ if !exists("g:minisnip_nested_syntax") endif if g:minisnip_nested_syntax - let filetype = get(matchlist(expand("%:t:r"), '_\([^_]\+\)_.\+$'), 1, '') - if !empty(filetype) - silent! exe "runtime! syntax/" . filetype . ".vim" - unlet! b:current_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