From 9cf4d9e26f07e31cb04888c00779900c91718f1b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:15:26 +0200 Subject: tv vim nix: add `comment` --- tv/5pkgs/vim/nix.nix | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'tv/5pkgs/vim/nix.nix') diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 747ab0bc0..1998f9d72 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -63,16 +63,27 @@ with import ; syn cluster nix_ind_strings contains=NixIND_STRING 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, lang ? name }: let startAlts = filter isString [ - ''/\* ${name} \*/'' + (comment name) extraStart ]; - sigil = ''\(${concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*''; + sigil = ''${alts startAlts}[ \t\r\n]*''; in /* vim */ '' syn include @nix_${lang}_syntax syntax/${lang}.vim if exists("b:current_syntax") @@ -111,22 +122,7 @@ with import ; " This is required because containedin isn't transitive. syn cluster nix_has_dollar_curly \ 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 = {}; cabal = {}; diff = {}; @@ -136,10 +132,10 @@ with import ; (writer "Jq") (writerExt "jq") ]; - javascript.extraStart = ''/\* js \*/''; + javascript.extraStart = comment "jq"; lua = {}; #nginx = {}; - python.extraStart = ''/\* py \*/''; + python.extraStart = comment "py"; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ @@ -172,7 +168,7 @@ with import ; ]; xdefaults = {}; xmodmap = {}; - }))} + })} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. syn clear shVarAssign -- cgit v1.2.3 From af518678bf730ee540dc3d3fe922e1f8f4fa1059 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:16:54 +0200 Subject: tv vim nix: recognize python by extension --- tv/5pkgs/vim/nix.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tv/5pkgs/vim/nix.nix') diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 1998f9d72..61323ab35 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -135,7 +135,10 @@ with import ; javascript.extraStart = comment "jq"; lua = {}; #nginx = {}; - python.extraStart = comment "py"; + python.extraStart = alts [ + (comment "py") + (writerExt "py") + ]; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ -- cgit v1.2.3 From bc7c360b80409cff1bea0fe2c187c43b0eec8269 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 13 Aug 2019 00:22:59 +0200 Subject: tv vim nix writerName: recognize toFile --- tv/5pkgs/vim/nix.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tv/5pkgs/vim/nix.nix') diff --git a/tv/5pkgs/vim/nix.nix b/tv/5pkgs/vim/nix.nix index 61323ab35..4f3f83aaa 100644 --- a/tv/5pkgs/vim/nix.nix +++ b/tv/5pkgs/vim/nix.nix @@ -73,7 +73,8 @@ with import ; 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}"''; + writerName = k: + ''${alts [''toFile'' ''write[^ \t\r\n]*'']}*[ \t\r\n]*"${k}"''; in mapAttrsToList (name: { extraStart ? null, lang ? name -- cgit v1.2.3