summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2020-05-31 20:57:37 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2020-05-31 20:57:37 +0200
commitc73ea49ecb3a8e0cde152ce6c8155bbd73c4378d (patch)
tree7e58196a25bbd0170bca8c57cbb4be9a2ed27d40
parentb2be47befcba7c2e4ae1261e4baf0fc2e7db07d8 (diff)
downloadvim-polyglot-c73ea49ecb3a8e0cde152ce6c8155bbd73c4378d.tar.gz
vim-polyglot-c73ea49ecb3a8e0cde152ce6c8155bbd73c4378d.zip
Improve bash and zsh highlighting
-rw-r--r--README.md3
-rwxr-xr-xbuild1
-rw-r--r--syntax/sh.vim60
-rw-r--r--syntax/zsh.vim60
4 files changed, 123 insertions, 1 deletions
diff --git a/README.md b/README.md
index a35cb742..970ac966 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
-- It **installs and updates 120+ times faster** than the <!--Package Count-->150<!--/Package Count--> packages it consists of.
+- It **installs and updates 120+ times faster** than the <!--Package Count-->151<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -160,6 +160,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [sbt](https://github.com/derekwyatt/vim-sbt) (syntax)
- [scala](https://github.com/derekwyatt/vim-scala) (syntax, indent, compiler, ftplugin, ctags)
- [scss](https://github.com/cakebaker/scss-syntax.vim) (syntax, indent, ftplugin)
+- [sh](https://github.com/arzg/vim-sh) (syntax)
- [slim](https://github.com/slim-template/vim-slim) (syntax, indent, ftplugin)
- [slime](https://github.com/slime-lang/vim-slime-syntax) (syntax, indent)
- [smt2](https://github.com/bohlender/vim-smt2) (syntax, autoload, ftplugin)
diff --git a/build b/build
index 436885b2..05d26080 100755
--- a/build
+++ b/build
@@ -252,6 +252,7 @@ PACKS="
sbt:derekwyatt/vim-sbt
scala:derekwyatt/vim-scala
scss:cakebaker/scss-syntax.vim
+ sh:arzg/vim-sh
slim:slim-template/vim-slim
slime:slime-lang/vim-slime-syntax
smt2:bohlender/vim-smt2
diff --git a/syntax/sh.vim b/syntax/sh.vim
new file mode 100644
index 00000000..96a70e2f
--- /dev/null
+++ b/syntax/sh.vim
@@ -0,0 +1,60 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sh') == -1
+
+" Shebang
+syn match shShebang "^#!.*$" containedin=shComment
+
+" Operators
+syn match shOperator '||'
+syn match shOperator '&&'
+
+" Match semicolons as Delimiter rather than Operator
+syn match shSemicolon ';' containedin=shOperator,zshOperator
+
+" Highlight braces, brackets and parens as Delimiters in zsh
+syn match zshDelim '\v(\(|\))' containedin=zshParentheses
+syn match zshDelim '\v(\{|\})' containedin=zshBraces
+syn match zshDelim '\v(\[|\])' containedin=zshParentheses
+
+" Match command flags in zsh
+syn match zshFlag "\v<-\w+" containedin=zshBrackets,zshParentheses
+
+" Special files as Constants
+syn match Constant "\v/dev/\w+"
+ \ containedin=shFunctionOne,shIf,shCmdParenRegion,shCommandSub
+
+" Common commands
+let commands = [ 'arch', 'awk', 'b2sum', 'base32', 'base64', 'basename', 'basenc', 'bash', 'brew', 'cat', 'chcon', 'chgrp', 'chown', 'chroot', 'cksum', 'comm', 'cp', 'csplit', 'curl', 'cut', 'date', 'dd', 'defaults', 'df', 'dir', 'dircolors', 'dirname', 'ed', 'env', 'expand', 'factor', 'fmt', 'fold', 'git', 'grep', 'groups', 'head', 'hexdump', 'hostid', 'hostname', 'hugo', 'id', 'install', 'join', 'killall', 'link', 'ln', 'logname', 'md5sum', 'mkdir', 'mkfifo', 'mknod', 'mktemp', 'nice', 'nl', 'nohup', 'npm', 'nproc', 'numfmt', 'od', 'open', 'paste', 'pathchk', 'pr', 'printenv', 'printf', 'ptx', 'readlink', 'realpath', 'rg', 'runcon', 'scutil', 'sed', 'seq', 'sha1sum', 'sha2', 'shred', 'shuf', 'split', 'stat', 'stdbuf', 'stty', 'sudo', 'sum', 'sync', 'tac', 'tee', 'terminfo', 'timeout', 'tmux', 'top', 'touch', 'tput', 'tr', 'truncate', 'tsort', 'tty', 'uname', 'unexpand', 'uniq', 'unlink', 'uptime', 'users', 'vdir', 'vim', 'wc', 'who', 'whoami', 'yabai', 'yes' ]
+
+for i in commands
+ execute 'syn match shStatement "\v(\w|-)@<!'
+ \ . i
+ \ . '(\w|-)@!" containedin=shFunctionOne,shIf,shCmdParenRegion,shCommandSub,zshBrackets'
+endfor
+
+" Fix default highlighting groups
+hi def link bashSpecialVariables Identifier
+hi def link shCmdSubRegion Delimiter
+hi def link shDerefSimple Identifier
+hi def link shFor Identifier
+hi def link shFunctionKey Statement
+hi def link shQuote StringDelimiter
+hi def link shRange Delimiter
+hi def link shSnglCase Delimiter
+hi def link shStatement Statement
+hi def link shTestOpr Operator
+hi def link shVarAssign Operator
+hi def link zshDeref Identifier
+hi def link zshFunction Function
+hi def link zshOperator Operator
+hi def link zshStringDelimiter StringDelimiter
+hi def link zshSubst Identifier
+hi def link zshSubstDelim Delimiter
+hi def link zshVariableDef Identifier
+
+" Link custom groups
+hi def link shSemicolon Delimiter
+hi def link shShebang PreProc
+hi def link zshDelim Delimiter
+hi def link zshFlag Special
+
+endif
diff --git a/syntax/zsh.vim b/syntax/zsh.vim
new file mode 100644
index 00000000..96a70e2f
--- /dev/null
+++ b/syntax/zsh.vim
@@ -0,0 +1,60 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sh') == -1
+
+" Shebang
+syn match shShebang "^#!.*$" containedin=shComment
+
+" Operators
+syn match shOperator '||'
+syn match shOperator '&&'
+
+" Match semicolons as Delimiter rather than Operator
+syn match shSemicolon ';' containedin=shOperator,zshOperator
+
+" Highlight braces, brackets and parens as Delimiters in zsh
+syn match zshDelim '\v(\(|\))' containedin=zshParentheses
+syn match zshDelim '\v(\{|\})' containedin=zshBraces
+syn match zshDelim '\v(\[|\])' containedin=zshParentheses
+
+" Match command flags in zsh
+syn match zshFlag "\v<-\w+" containedin=zshBrackets,zshParentheses
+
+" Special files as Constants
+syn match Constant "\v/dev/\w+"
+ \ containedin=shFunctionOne,shIf,shCmdParenRegion,shCommandSub
+
+" Common commands
+let commands = [ 'arch', 'awk', 'b2sum', 'base32', 'base64', 'basename', 'basenc', 'bash', 'brew', 'cat', 'chcon', 'chgrp', 'chown', 'chroot', 'cksum', 'comm', 'cp', 'csplit', 'curl', 'cut', 'date', 'dd', 'defaults', 'df', 'dir', 'dircolors', 'dirname', 'ed', 'env', 'expand', 'factor', 'fmt', 'fold', 'git', 'grep', 'groups', 'head', 'hexdump', 'hostid', 'hostname', 'hugo', 'id', 'install', 'join', 'killall', 'link', 'ln', 'logname', 'md5sum', 'mkdir', 'mkfifo', 'mknod', 'mktemp', 'nice', 'nl', 'nohup', 'npm', 'nproc', 'numfmt', 'od', 'open', 'paste', 'pathchk', 'pr', 'printenv', 'printf', 'ptx', 'readlink', 'realpath', 'rg', 'runcon', 'scutil', 'sed', 'seq', 'sha1sum', 'sha2', 'shred', 'shuf', 'split', 'stat', 'stdbuf', 'stty', 'sudo', 'sum', 'sync', 'tac', 'tee', 'terminfo', 'timeout', 'tmux', 'top', 'touch', 'tput', 'tr', 'truncate', 'tsort', 'tty', 'uname', 'unexpand', 'uniq', 'unlink', 'uptime', 'users', 'vdir', 'vim', 'wc', 'who', 'whoami', 'yabai', 'yes' ]
+
+for i in commands
+ execute 'syn match shStatement "\v(\w|-)@<!'
+ \ . i
+ \ . '(\w|-)@!" containedin=shFunctionOne,shIf,shCmdParenRegion,shCommandSub,zshBrackets'
+endfor
+
+" Fix default highlighting groups
+hi def link bashSpecialVariables Identifier
+hi def link shCmdSubRegion Delimiter
+hi def link shDerefSimple Identifier
+hi def link shFor Identifier
+hi def link shFunctionKey Statement
+hi def link shQuote StringDelimiter
+hi def link shRange Delimiter
+hi def link shSnglCase Delimiter
+hi def link shStatement Statement
+hi def link shTestOpr Operator
+hi def link shVarAssign Operator
+hi def link zshDeref Identifier
+hi def link zshFunction Function
+hi def link zshOperator Operator
+hi def link zshStringDelimiter StringDelimiter
+hi def link zshSubst Identifier
+hi def link zshSubstDelim Delimiter
+hi def link zshVariableDef Identifier
+
+" Link custom groups
+hi def link shSemicolon Delimiter
+hi def link shShebang PreProc
+hi def link zshDelim Delimiter
+hi def link zshFlag Special
+
+endif