summaryrefslogtreecommitdiffstats
path: root/tv
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-06-09 03:19:12 +0200
committertv <tv@krebsco.de>2016-06-09 04:31:05 +0200
commit6750832ac8b861bc83729cb9c61b81a35869257f (patch)
tree940d540476d05ae2b00c264743bc5481520430f0 /tv
parent40204421d2285c9c56fcb258f37b7d414c2daad1 (diff)
tv nix.vim: highlight embedded {Haskell,Vim}
Diffstat (limited to 'tv')
-rw-r--r--tv/2configs/vim.nix72
1 files changed, 52 insertions, 20 deletions
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index 21fb6cd..82d06f6 100644
--- a/tv/2configs/vim.nix
+++ b/tv/2configs/vim.nix
@@ -132,27 +132,59 @@ let
setf nix
set isk=@,48-57,_,192-255,-,'
+ syn match NixCode /./
+
" Ref <nix/src/libexpr/lexer.l>
- syn match INT /\<[0-9]\+\>/
- syn match PATH /[a-zA-Z0-9\.\_\-\+]*\(\/[a-zA-Z0-9\.\_\-\+]\+\)\+/
- syn match HPATH /\~\(\/[a-zA-Z0-9\.\_\-\+]\+\)\+/
- syn match SPATH /<[a-zA-Z0-9\.\_\-\+]\+\(\/[a-zA-Z0-9\.\_\-\+]\+\)*>/
- syn match URI /[a-zA-Z][a-zA-Z0-9\+\-\.]*:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']\+/
- hi link INT Constant
- hi link PATH Constant
- hi link HPATH Constant
- hi link SPATH Constant
- hi link URI Constant
-
- syn match String /"\([^\\"]\|\\.\)*"/
- syn match Comment /\(^\|\s\)#.*/
-
- " Haskell comments
- syn region Comment start=/\(^\|\s\){-#/ end=/#-}/
- syn match Comment /\(^\|\s\)--.*/
-
- " Vim comments
- syn match Comment /\(^\|\s\)"[^"]*$/
+ syn match NixINT /\<[0-9]\+\>/
+ syn match NixPATH /[a-zA-Z0-9\.\_\-\+]*\(\/[a-zA-Z0-9\.\_\-\+]\+\)\+/
+ syn match NixHPATH /\~\(\/[a-zA-Z0-9\.\_\-\+]\+\)\+/
+ syn match NixSPATH /<[a-zA-Z0-9\.\_\-\+]\+\(\/[a-zA-Z0-9\.\_\-\+]\+\)*>/
+ syn match NixURI /[a-zA-Z][a-zA-Z0-9\+\-\.]*:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\']\+/
+
+ syn match NixString /"\([^\\"]\|\\.\)*"/
+ syn match NixCommentMatch /\(^\|\s\)#.*/
+ syn region NixCommentRegion start="/\*" end="\*/"
+
+ hi NixCode ctermfg=034
+ hi NixData ctermfg=040
+
+ hi link NixComment Comment
+ hi link NixCommentMatch NixComment
+ hi link NixCommentRegion NixComment
+ hi link NixINT NixData
+ hi link NixPATH NixData
+ hi link NixHPATH NixData
+ hi link NixSPATH NixData
+ hi link NixURI NixData
+ hi link NixString NixData
+
+ 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
+
+ syn region NixBlock
+ \ matchgroup=NixEnter
+ \ start="[$]{"
+ \ end="}"
+ \ contains=ALL
+ \ containedin=HaskellBlock,@HaskellSyntax,VimBlock,@VimSyntax
let b:current_syntax = "nix"
'';