Fix typo in syntax highlighting for vim.
[vvhitespace] / syntax_highlighting / README.md
CommitLineData
6464ec02
AT
1VVhitespace Syntax Highlighting
2===============================
3
4![VVS Syntax Highlighting Example](vvs_syntax_highlighting.gif)
5
6I find it useful to highlight each IMP a different color as well as highlight
7code comments and label definitions. The above image is typical of my
8VVhitespace editing environment.
9
10If you would like something similar, the configuration examples below can be
11used with `vim` or `neatvi`. Other editors that use regex matching can reuse
12the regular expressions from these examples to achieve similar results.
13
14This syntax highlighting definition works only with the way I write VVhitespace
15code in this repository. Comments in particular can take many forms other
16than specified here.
17
18If you take the time to put together a configuration for other editors, or
19improve the regex definitions, let me know.
20
21
22VIM Highlighting
23----------------
24
25If they don't already exist, create the folders `~/.vim/syntax` and
26`~/.vim/ftdetect`.
27
28 % mkdir -p ~/.vim/syntax
29 % mkdir -p ~/.vim/ftdetect
30
31Create a file named `~/.vim/ftdetect/vvhitespace.vim` to detect the filetype
32based on the file extension. It should contain a single line:
33
34 au BufRead,BufNewFile *.pvvs set filetype=vvhitespace
35
36Create a file named `~/.vim/syntax/vvhitespace.vim` containing the following:
37
38 if exists("b:current_syntax")
39 finish
40 endif
41
4dfd7c1f 42 let b:current_syntax = "vvhitespace"
6464ec02
AT
43
44 " Stack IMP
45 syn match stackIMP '^[sS][sS]'
46 syn match stackIMP '^[sS][nN][sStTnN]'
47
48 " Arithmetic IMP
49 syn match arithIMP '^[tT][sS][sStT][sStTnN]'
50
51 " Heap IMP
52 syn match heapIMP '^[tT][tT][sStT]'
53
54 " Control Flow IMP
55 syn match controlIMP '^[nN][nNsStT][nNsStT]'
56
57 " IO IMP
58 syn match ioIMP '^[tT][nN][sStT][sStT]'
59
60 " Label Definition
61 syn match labelDef 'V[sStT]\+N'
62
63 " Comments
64 syn match commentBlock '|.*$'
65 syn match commentBlock '@.*$'
66
67 " Define colors using existing Highlight Groups.
68 " To see a list of other Highlight Groups, type `:highlight` in vim.
69 hi def link stackIMP Type
70 hi def link arithIMP ModeMsg
71 hi def link heapIMP Special
72 hi def link controlIMP Constant
73 hi def link ioIMP Keyword
74 hi def link labelDef Function
75 hi def link commentBlock NonText
76
77That's it! You should now see syntax highlighting when opening files with names
78ending in `*.pvvs`.
79
80If you don't any see syntax highlighting, check your `.vimrc` and other config
81locations for conflicting options. Try manually enabling syntax highlighting
82with the `syntax on` configuration directive.
83
84
85NeatVI Highlighting
86-------------------
87
88Open the file `conf.h` for editing.
89
90Add the following line to the `filetypes` array, matching all `*.pvvs` files.
91
92 {"pvvs", "\\.pvvs$"}, /* VVhitespace */
93
94Add the following block to the `highlights` array.
95
96 {"pvvs", {2}, "^[sS][sS]"}, /* IMP: Stack Manipulation */
97 {"pvvs", {2}, "^[sS][nN][sStTnN]"}, /* IMP: Stack Manipulation */
98 {"pvvs", {8}, "^[tT][sS][sStT][sStTnN]"}, /* IMP: Arithmetic */
99 {"pvvs", {5}, "^[tT][tT][sStT]"}, /* IMP: Heap Access */
100 {"pvvs", {1}, "^[nN][nNsStT][nNsStT]"}, /* IMP: Control Flow */
101 {"pvvs", {4}, "^[tT][nN][sStT][sStT]"}, /* IMP: Input/Output */
102 {"pvvs", {6 | SYN_BD}, "V[sStT]+N "}, /* Label Definitions */
103 {"pvvs", {3 | SYN_IT}, "\\|.*$"}, /* Comments */
104 {"pvvs", {3 | SYN_IT}, "\\@.*$"}, /* Comments */
105
106Recompile NeatVI and syntax highlighting should work on all files with names
107ending in `*.pvvs`.