Skip to content

Commit cb80947

Browse files
committed
Reintroduce zinit, closes #772
1 parent 87a26c5 commit cb80947

File tree

3 files changed

+133
-1
lines changed

3 files changed

+133
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A collection of language packs for Vim.
77
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
88
99
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
10-
- It **installs and updates 120+ times faster** than the <!--Package Count-->597<!--/Package Count--> packages it consists of.
10+
- It **installs and updates 120+ times faster** than the <!--Package Count-->598<!--/Package Count--> packages it consists of.
1111
- It is also more secure (scripts loaded for every filetype are generated by vim-polyglot)
1212
- Best syntax and indentation support (no other features). Hand-selected language packs.
1313
- Automatically detects indentation (includes performance-optimized version of [vim-sleuth](https://github.com/tpope/vim-sleuth), can be disabled)
@@ -207,6 +207,7 @@ On top of all language packs from [vim repository](https://github.com/vim/vim/tr
207207
- [yard](https://github.com/noprompt/vim-yardoc)
208208
- [zephir](https://github.com/xwsoul/vim-zephir) (Zephir syntax highlighting for zep files)
209209
- [zig](https://github.com/ziglang/zig.vim) (Zig syntax highlighting for zir, zig and zir files)
210+
- [zinit](https://github.com/zdharma-continuum/zinit-vim-syntax/tree/main)
210211
<!--/Language Packs-->
211212

212213
## Updating

after/syntax/zsh.vim

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
if polyglot#init#is_disabled(expand('<sfile>:p'), 'zinit', 'after/syntax/zsh.vim')
2+
finish
3+
endif
4+
5+
" Copyright (c) 2019 Sebastian Gniazdowski
6+
"
7+
" Syntax highlighting for Zinit commands in any file of type `zsh'.
8+
" It adds definitions for the Zinit syntax to the ones from the
9+
" existing zsh.vim definitions-file.
10+
11+
" Main Zinit command.
12+
" Should be the only TOP rule for the whole syntax.
13+
syntax match ZinitCommand /\<zinit\>\s/me=e-1
14+
\ skipwhite
15+
\ nextgroup=ZinitSubCommands,ZinitPluginSubCommands,ZinitSnippetSubCommands
16+
\ contains=ZinitSubCommands,ZinitPluginSubCommands,ZinitSnippetSubCommands
17+
18+
" TODO: add options for e.g. light
19+
syntax match ZinitSubCommands /\s\<\%(ice\|compinit\|env-whitelist\|cdreplay\|cdclear\|update\)\>\s/ms=s+1,me=e-1
20+
\ contained
21+
22+
syntax match ZinitPluginSubCommands /\s\<\%(light\|load\)\>\s/ms=s+1,me=e-1
23+
\ skipwhite nextgroup=ZinitPlugin1,ZinitPlugin2,ZinitPlugin3
24+
\ contains=ZinitPlugin1,ZinitPlugin2,ZinitPlugin3
25+
26+
syntax match ZinitSnippetSubCommands /\s\<\%(snippet\)\>\s/ms=s+1,me=e-1
27+
\ skipwhite
28+
\ nextgroup=ZinitSnippetShorthands1,ZinitSnippetShorthands2
29+
\ contains=ZinitSnippetShorthands1,ZinitSnippetShorthands2
30+
31+
" "user/plugin"
32+
syntax match ZinitPlugin1 /\s["]\%([!-_]*\%(\/[!-_]\+\)\+\|[!-_]\+\)["]/ms=s+1,hs=s+2,he=e-1
33+
\ contained
34+
\ nextgroup=ZinitTrailingWhiteSpace
35+
\ contains=ZinitTrailingWhiteSpace
36+
37+
" 'user/plugin'
38+
syntax match ZinitPlugin2 /\s[']\%([!-_]*\%(\/[!-_]\+\)\+\|[!-_]\+\)[']/ms=s+1,hs=s+2,he=e-1
39+
\ contained
40+
\ nextgroup=ZinitTrailingWhiteSpace
41+
\ contains=ZinitTrailingWhiteSpace
42+
43+
" user/plugin
44+
syntax match ZinitPlugin3 /\s\%([!-_]*\%(\/[!-_]\+\)\+\|[!-_]\+\)/ms=s+1,me=e+2
45+
\ contained
46+
\ nextgroup=ZinitTrailingWhiteSpace
47+
\ contains=ZinitTrailingWhiteSpace
48+
49+
" OMZ:: or PZT::
50+
" TODO: 'OMZ:: or 'PZT::
51+
syntax match ZinitSnippetShorthands1 /\s\<\%(\%(OMZ\|PZT\)\>::\|\)/hs=s+1,he=e-2
52+
\ contained
53+
\ skipwhite
54+
\ nextgroup=ZinitSnippetUrl1,ZinitSnippetUrl2
55+
\ contains=ZinitSnippetUrl1,ZinitSnippetUrl2
56+
57+
" "OMZ:: or "PZT::
58+
syntax match ZinitSnippetShorthands2 /\s["]\%(\%(OMZ\|PZT\)\>::\|\)/hs=s+2,he=e-2
59+
\ contained
60+
\ skipwhite
61+
\ nextgroup=ZinitSnippetUrl3,ZinitSnippetUrl4
62+
\ contains=ZinitSnippetUrl3,ZinitSnippetUrl4
63+
64+
syntax match ZinitSnippetUrl3 /\<\%(http:\/\/\|https:\/\/\|ftp:\/\/\|\$HOME\|\/\)[!-_]\+\%(\/[!-_]\+\)*\/\?["]/he=e-1
65+
\ contained
66+
\ nextgroup=ZinitTrailingWhiteSpace
67+
\ contains=ZinitTrailingWhiteSpace
68+
69+
" TODO: Fix ZinitTrailingWhiteSpace not matching
70+
syntax match ZinitSnippetUrl4 /\%(\%(OMZ\|PZT\)::\)[!-_]\+\%(\/[!-_]\+\)*\/\?["]/hs=s+5,he=e-1
71+
\ contained
72+
\ nextgroup=ZinitTrailingWhiteSpace
73+
\ contains=ZinitTrailingWhiteSpace
74+
75+
" http://… or https://… or ftp://… or $HOME/… or /…
76+
" TODO: Fix $HOME/… and /… not matching
77+
syntax match ZinitSnippetUrl1 /\<\%(http:\/\/\|https:\/\/\|ftp:\/\/\|\$HOME\|\/\)[!-_]\+\%(\/[!-_]\+\)*\/\?/
78+
\ contained
79+
\ nextgroup=ZinitTrailingWhiteSpace
80+
\ contains=ZinitTrailingWhiteSpace
81+
82+
" TODO: Fix ZinitTrailingWhiteSpace not matching
83+
syntax match ZinitSnippetUrl2 /\<\%(\%(OMZ\|PZT\)::\)[!-_]\+\%(\/[!-_]\+\)*\/\?/hs=s+5
84+
\ contained
85+
\ nextgroup=ZinitTrailingWhiteSpace
86+
\ contains=ZinitTrailingWhiteSpace
87+
88+
syntax match ZinitTrailingWhiteSpace /[[:space:]]\+$/ contained
89+
90+
" TODO: differentiate the no-value ices
91+
" TODO: use contained
92+
syntax match ZinitIceSubCommand /\sice\s/ms=s+1,me=e-1 nextgroup=ZinitIceModifiers
93+
syntax match ZinitIceModifiers /\s\<\%(svn\|proto\|from\|teleid\|bindmap\|cloneopts\|id-as\|depth\|if\|wait\|load\)\>/ms=s+1
94+
syntax match ZinitIceModifiers /\s\<\%(unload\|blockf\|on-update-of\|subscribe\|pick\|bpick\|src\|as\|ver\|silent\)\>/ms=s+1
95+
syntax match ZinitIceModifiers /\s\<\%(lucid\|notify\|mv\|cp\|atinit\|atclone\|atload\|atpull\|nocd\|run-atpull\|has\)\>/ms=s+1
96+
syntax match ZinitIceModifiers /\s\<\%(cloneonly\|make\|service\|trackbinds\|multisrc\|compile\|nocompile\)\>/ms=s+1
97+
syntax match ZinitIceModifiers /\s\<\%(nocompletions\|reset-prompt\|wrap-track\|reset\|aliases\|sh\|bash\|ksh\|csh\)\>/ms=s+1
98+
syntax match ZinitIceModifiers /\s\<\%(\\!sh\|!sh\|\\!bash\|!bash\|\\!ksh\|!ksh\|\\!csh\|!csh\)\>/ms=s+1
99+
syntax match ZinitIceModifiers /\s\<\%(blockf\|silent\|lucid\|trackbinds\|cloneonly\|nocd\|run-atpull\)\>/ms=s+1
100+
syntax match ZinitIceModifiers /\s\<\%(\|sh\|\!sh\|bash\|\!bash\|ksh\|\!ksh\|csh\|\!csh\)\>/ms=s+1
101+
syntax match ZinitIceModifiers /\s\<\%(nocompletions\|svn\|aliases\|trigger-load\)\>/ms=s+1
102+
syntax match ZinitIceModifiers /\s\<\%(light-mode\|is-snippet\|countdown\|ps-on-unload\|ps-on-update\)\>/ms=s+1
103+
104+
" Include also ices added by the existing annexes
105+
syntax match ZinitIceModifiers /\s\<\%(test\|zman\|submod\|dl\|patch\|fbin\|sbin\|fsrc\|ferc\|fmod\|gem\|node\|rustup\|cargo\)\>/ms=s+1
106+
107+
" Additional Zsh and Zinit functions
108+
syntax match ZshAndZinitFunctions /\<\%(compdef\|compinit\|zpcdreplay\|zpcdclear\|zpcompinit\|zpcompdef\)\>/
109+
110+
" Link
111+
highlight def link ZshAndZinitFunctions Keyword
112+
highlight def link ZinitCommand Statement
113+
highlight def link ZinitSubCommands Title
114+
highlight def link ZinitPluginSubCommands Title
115+
highlight def link ZinitSnippetSubCommands Title
116+
highlight def link ZinitIceModifiers Type
117+
highlight def link ZinitSnippetShorthands1 Keyword
118+
highlight def link ZinitSnippetShorthands2 Keyword
119+
highlight def link ZinitPlugin1 Macro
120+
highlight def link ZinitPlugin2 Macro
121+
highlight def link ZinitPlugin3 Macro
122+
highlight def link ZinitSnippetUrl1 Macro
123+
highlight def link ZinitSnippetUrl2 Macro
124+
highlight def link ZinitSnippetUrl3 Macro
125+
highlight def link ZinitSnippetUrl4 Macro
126+
highlight def link ZinitTrailingWhiteSpace Error

packages.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5541,3 +5541,8 @@ filetypes:
55415541
patterns:
55425542
- pattern: '*.org'
55435543
description: GNU Emacs' Org mode
5544+
---
5545+
name: zinit
5546+
remote: zdharma-continuum/zinit-vim-syntax@main
5547+
# just adds to zsh filetype
5548+
filetypes: []

0 commit comments

Comments
 (0)