tv vim-syntax-nix-nested: simplify regexes

This commit is contained in:
tv 2018-12-02 15:48:01 +01:00
parent a3e47e6788
commit e847d935ad

View file

@ -239,26 +239,56 @@ let {
" 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
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 = {}; c = {};
cabal = {}; cabal = {};
diff = {}; diff = {};
haskell = {}; haskell = {};
jq.extraStart = concatStringsSep ''\|'' [ jq.extraStart = alts [
''writeJq.*'' (writer "Jq")
''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"'' ''write[^ \t\r\n]*[ \t\r\n]*"[^"]*\.jq"''
]; ];
lua = {}; lua = {};
sed.extraStart = ''writeSed[^ \t\r\n]*[ \t\r\n]*"[^"]*"''; sed.extraStart = writer "Sed";
sh.extraStart = concatStringsSep ''\|'' [ sh.extraStart = let
''write\(A\|Ba\|Da\)sh[^ \t\r\n]*[ \t\r\n]*\("[^"]*"\|[a-z]\+\)'' phases = [
''[a-z]*Phase[ \t\r\n]*='' "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 = {}; yaml = {};
vim.extraStart = vim.extraStart =
''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"''; ''write[^ \t\r\n]*[ \t\r\n]*"\(\([^"]*\.\)\?vimrc\|[^"]*\.vim\)"'';
xdefaults = {}; xdefaults = {};
})} }))}
" Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY. " Clear syntax that interferes with nixINSIDE_DOLLAR_CURLY.
syn clear shVarAssign syn clear shVarAssign