tv vim nix: add comment

This commit is contained in:
tv 2019-08-13 00:15:26 +02:00
parent 8527caef16
commit 9cf4d9e26f

View File

@ -63,16 +63,27 @@ with import <stockholm/lib>;
syn cluster nix_ind_strings contains=NixIND_STRING syn cluster nix_ind_strings contains=NixIND_STRING
syn cluster nix_strings contains=NixSTRING syn cluster nix_strings contains=NixSTRING
${concatStringsSep "\n" (mapAttrsToList (name: { ${concatStringsSep "\n" (let
alts = xs: ''\(${concatStringsSep ''\|'' xs}\)'';
capitalize = s: let
xs = stringToCharacters s;
in
toUpper (head xs) + concatStrings (tail xs);
comment = k: ''/\* ${k} \*/'';
def = k: ''${k}[ \t\r\n]*='';
writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)'';
writerExt = k: writerName ''[^"]*\.${k}'';
writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"'';
in mapAttrsToList (name: {
extraStart ? null, extraStart ? null,
lang ? name lang ? name
}: }:
let let
startAlts = filter isString [ startAlts = filter isString [
''/\* ${name} \*/'' (comment name)
extraStart extraStart
]; ];
sigil = ''\(${concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*''; sigil = ''${alts startAlts}[ \t\r\n]*'';
in /* vim */ '' in /* vim */ ''
syn include @nix_${lang}_syntax syntax/${lang}.vim syn include @nix_${lang}_syntax syntax/${lang}.vim
if exists("b:current_syntax") if exists("b:current_syntax")
@ -111,22 +122,7 @@ with import <stockholm/lib>;
" This is required because containedin isn't transitive. " This is required because containedin isn't transitive.
syn cluster nix_has_dollar_curly syn cluster nix_has_dollar_curly
\ add=@nix_${lang}_syntax \ add=@nix_${lang}_syntax
'') (let '') {
# TODO move this higher
capitalize = s: let
xs = stringToCharacters s;
in
toUpper (head xs) + concatStrings (tail xs);
alts = xs: ''\(${concatStringsSep ''\|'' xs}\)'';
def = k: ''${k}[ \t\r\n]*='';
writer = k: ''write${k}[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)'';
writerExt = k: writerName ''[^"]*\.${k}'';
writerName = k: ''write[^ \t\r\n]*[ \t\r\n]*"${k}"'';
in {
c = {}; c = {};
cabal = {}; cabal = {};
diff = {}; diff = {};
@ -136,10 +132,10 @@ with import <stockholm/lib>;
(writer "Jq") (writer "Jq")
(writerExt "jq") (writerExt "jq")
]; ];
javascript.extraStart = ''/\* js \*/''; javascript.extraStart = comment "jq";
lua = {}; lua = {};
#nginx = {}; #nginx = {};
python.extraStart = ''/\* py \*/''; python.extraStart = comment "py";
sed.extraStart = writer "Sed"; sed.extraStart = writer "Sed";
sh.extraStart = let sh.extraStart = let
phases = [ phases = [
@ -172,7 +168,7 @@ with import <stockholm/lib>;
]; ];
xdefaults = {}; xdefaults = {};
xmodmap = {}; xmodmap = {};
}))} })}
" Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY.
syn clear shVarAssign syn clear shVarAssign