summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-06-09 05:44:26 +0200
committertv <tv@krebsco.de>2016-06-10 16:04:55 +0200
commitf99c796c8722ff3d081a7d74f1efed00bef1349d (patch)
tree092b7143ddeef6b4909798368fed668c5b8ec395
parente0b3773a64caccbe4a9c3ee673fd17eae3ef8788 (diff)
tv nix.vim: generate NixSubLangs
-rw-r--r--tv/2configs/vim.nix52
1 files changed, 32 insertions, 20 deletions
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index ee2cbdb..e224df9 100644
--- a/tv/2configs/vim.nix
+++ b/tv/2configs/vim.nix
@@ -179,31 +179,43 @@ let
hi link NixEnter NixCode
hi link NixExit NixData
-
- syn include @HaskellSyntax syntax/haskell.vim
- syn region HaskellBlock
- \ matchgroup=NixExit
- \ start="/\* haskell \*/ '''"
- \ skip="''''"
- \ end="'''"
- \ contains=@HaskellSyntax
- unlet b:current_syntax
-
- syn include @VimSyntax syntax/vim.vim
- syn region VimBlock
- \ matchgroup=NixExit
- \ start="\(/\* vim \*/\|write[-0-9A-Za-z'_]* *\"\(\([^\"]*\.\)\?vimrc\|[^\"]*\.vim\)\"\) *'''"
- \ skip="''''"
- \ end="'''"
- \ contains=@VimSyntax
- unlet b:current_syntax
+ hi link NixQuote NixData
+ hi link NixQuote2 NixQuote
+ hi link NixQuote3 NixQuote
+
+ syn cluster NixSubLangs contains=NONE
+
+ ${concatStringsSep "\n" (mapAttrsToList (name: { start ? null }: let
+ in /* vim */ ''
+ syn include @${name}Syntax syntax/${name}.vim
+ syn region ${name}Block
+ \ matchgroup=NixExit
+ \ start="\(/\* ${name} \*/${optionalString (start != null) ''\|${start}''}\) '''"
+ \ skip="'''\('\|[$]\|\\[nrt]\)"
+ \ end="'''"
+ \ contains=@${name}Syntax
+ syn cluster NixSubLangs add=${name}Block,@${name}Syntax
+ unlet b:current_syntax
+ '') {
+ haskell = {};
+ vim.start = ''write[^ ]* *\"\(\([^\"]*\.\)\?vimrc\|[^\"]*\.vim\)\"'';
+ })}
syn region NixBlock
\ matchgroup=NixEnter
\ start="[$]{"
\ end="}"
- \ contains=ALL
- \ containedin=HaskellBlock,@HaskellSyntax,VimBlock,@VimSyntax
+ \ contains=TOP
+ \ containedin=@NixSubLangs
+
+ syn region NixBlockHack
+ \ start="{"
+ \ end="}"
+ \ contains=TOP
+
+ syn match NixQuote "'''[$]"he=e-1 contained containedin=@NixSubLangs
+ syn match NixQuote2 "''''"he=s+1 contained containedin=@NixSubLangs
+ syn match NixQuote3 "'''\\[nrt]" contained containedin=@NixSubLangs
let b:current_syntax = "nix"
'';