From a3e47e6788b568cf04d5103ad8a918ed902df9ce Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 2 Dec 2018 16:03:36 +0100 Subject: tv: rename vim-tv to vim-syntax-nix-nested --- tv/2configs/vim.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv/2configs/vim.nix') diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index a5641f09..c6364c22 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -129,7 +129,7 @@ let { command! -n=0 -bar ShowSyntax :call ShowSyntax() ''; }))) - ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-tv" { + ((rtp: rtp // { inherit rtp; }) (pkgs.write "vim-syntax-nix-nested" { "/syntax/haskell.vim".text = /* vim */ '' syn region String start=+\[[[:alnum:]]*|+ end=+|]+ -- cgit v1.2.3 From e847d935ade4b36aecf8588faffb3dd61e3ebdfe Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 2 Dec 2018 15:48:01 +0100 Subject: tv vim-syntax-nix-nested: simplify regexes --- tv/2configs/vim.nix | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'tv/2configs/vim.nix') diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index c6364c22..00928081 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -239,26 +239,56 @@ let { " This is required because containedin isn't transitive. syn cluster nix_has_dollar_curly \ add=@nix_${lang}_syntax - '') { + '') (let + + 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]\+\)''; + + in { c = {}; cabal = {}; diff = {}; haskell = {}; - jq.extraStart = concatStringsSep ''\|'' [ - ''writeJq.*'' + jq.extraStart = alts [ + (writer "Jq") ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' ]; lua = {}; - sed.extraStart = ''writeSed[^ \t\r\n]*[ \t\r\n]*"[^"]*"''; - sh.extraStart = concatStringsSep ''\|'' [ - ''write\(A\|Ba\|Da\)sh[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)'' - ''[a-z]*Phase[ \t\r\n]*='' + sed.extraStart = writer "Sed"; + sh.extraStart = let + phases = [ + "unpack" + "patch" + "configure" + "build" + "check" + "install" + "fixup" + "installCheck" + "dist" + ]; + shells = [ + "ash" + "bash" + "dash" + ]; + in alts [ + (def "shellHook") + (def "${alts phases}Phase") + (def "${alts ["pre" "post"]}${alts (map capitalize phases)}") + (writer (alts (map capitalize shells))) ]; yaml = {}; vim.extraStart = ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"''; xdefaults = {}; - })} + }))} " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. syn clear shVarAssign -- cgit v1.2.3 From c544596952c7ed42479616cea6904b061085e2f0 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 2 Dec 2018 16:07:53 +0100 Subject: tv vim-syntax-nix-nested: add js, and py --- tv/2configs/vim.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tv/2configs/vim.nix') diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix index 00928081..3794628c 100644 --- a/tv/2configs/vim.nix +++ b/tv/2configs/vim.nix @@ -259,7 +259,9 @@ let { (writer "Jq") ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' ]; + javascript.extraStart = ''/\* js \*/''; lua = {}; + python.extraStart = ''/\* py \*/''; sed.extraStart = writer "Sed"; sh.extraStart = let phases = [ -- cgit v1.2.3