summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-06-10 16:07:47 +0200
committertv <tv@krebsco.de>2016-06-10 16:09:44 +0200
commitd51179bf6b6ac4cbd6f6b06408735bc5ee49bbf8 (patch)
tree509542d9e856b5b118d9a7a40192d0f85af6eb58 /tv
parentfed55eed93033a2eae440b45b5bf54f120d0ac8b (diff)
tv nix.vim: support ${lang}Block in NixString
Diffstat (limited to 'tv')
-rw-r--r--tv/2configs/vim.nix39
1 files changed, 29 insertions, 10 deletions
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index f6a5cc9c1..4fa3fdda5 100644
--- a/tv/2configs/vim.nix
+++ b/tv/2configs/vim.nix
@@ -256,25 +256,44 @@ let
syn cluster NixSubLangs contains=NONE
- ${concatStringsSep "\n" (mapAttrsToList (name: { start ? null }: let
+ ${concatStringsSep "\n" (mapAttrsToList (lang: { extraStart ? null }: let
+ startAlts = filter isString [
+ ''/\* ${lang} \*/''
+ extraStart
+ ];
+ sigil = ''\(${concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*'';
in /* vim */ ''
- syn include @${name}Syntax syntax/${name}.vim
- syn region ${name}Block
+ syn include @${lang}Syntax syntax/${lang}.vim
+ unlet b:current_syntax
+
+ syn region ${lang}Block_NixSTRING
+ \ matchgroup=NixExit
+ \ extend
+ \ start='${replaceStrings ["'"] ["\\'"] sigil}"'
+ \ skip='\\"'
+ \ end='"'
+ \ contains=@${lang}Syntax
+
+ syn region ${lang}Block_NixIND_STRING
\ matchgroup=NixExit
- \ start="\(/\* ${name} \*/${optionalString (start != null) ''\|${start}''}\) '''"
+ \ extend
+ \ start="${replaceStrings ["\""] ["\\\""] sigil}'''"
\ skip="'''\('\|[$]\|\\[nrt]\)"
\ end="'''"
- \ contains=@${name}Syntax
- syn cluster NixSubLangs add=${name}Block,@${name}Syntax
- unlet b:current_syntax
+ \ contains=@${lang}Syntax
+
+ syn cluster NixSubLangs
+ \ add=@${lang}Syntax,${lang}Block_NixSTRING,${lang}Block_NixIND_STRING
- hi link ${name}Block Statement
+ hi link ${lang}Block_NixSTRING Statement
+ hi link ${lang}Block_NixIND_STRING Statement
'') {
c = {};
cabal = {};
haskell = {};
- sh.start = ''write\(Ba\|Da\)sh[^ ]* *\"[^\"]*\"'';
- vim.start = ''write[^ ]* *\"\(\([^\"]*\.\)\?vimrc\|[^\"]*\.vim\)\"'';
+ sh.extraStart = ''write\(Ba\|Da\)sh[^ \t\r\n]*[ \t\r\n]*"[^"]*"'';
+ vim.extraStart =
+ ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"'';
})}
" Clear syntax that interferes with NixBlock.