summaryrefslogtreecommitdiffstats
path: root/tv/2configs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-12-02 15:48:01 +0100
committertv <tv@krebsco.de>2018-12-02 16:05:41 +0100
commite847d935ade4b36aecf8588faffb3dd61e3ebdfe (patch)
treec646a74bd33779df2b8101ac3cab7b46b1c93a87 /tv/2configs
parenta3e47e6788b568cf04d5103ad8a918ed902df9ce (diff)
tv vim-syntax-nix-nested: simplify regexes
Diffstat (limited to 'tv/2configs')
-rw-r--r--tv/2configs/vim.nix46
1 files changed, 38 insertions, 8 deletions
diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index c6364c223..009280815 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