Skip to content

Commit d9baadd

Browse files
riobardqstrahl
authored andcommitted
Allow customizing individual concealing characters
1 parent 6b057a9 commit d9baadd

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,26 @@ Enables JavaScript code folding.
5555

5656
Default Value: 1
5757

58-
#### g:javascript_conceal
59-
60-
Enables concealing characters. For example, `function` is replaced with `ƒ`
61-
62-
Default Value: 0
6358

6459
#### javascript_ignore_javaScriptdoc
6560

6661
Disables JSDoc syntax highlighting
6762

6863
Default Value: 0
6964

65+
#### Concealing Characters
66+
67+
You can customize concealing characters by defining one or more of the following
68+
variables:
69+
70+
let g:javascript_conceal_function = "ƒ"
71+
let g:javascript_conceal_null = "ø"
72+
let g:javascript_conceal_this = "@"
73+
let g:javascript_conceal_return = "⇚"
74+
let g:javascript_conceal_undefined = "¿"
75+
let g:javascript_conceal_NaN = "ℕ"
76+
let g:javascript_conceal_prototype = "¶"
77+
7078
## Contributing
7179

7280
This project uses the [git

syntax/javascript.vim

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,12 @@ syntax match jsFloat /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-
100100
syntax match jsObjectKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\)\@=/ contains=jsFunctionKey contained
101101
syntax match jsFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\s*function\s*\)\@=/ contained
102102

103-
if g:javascript_conceal == 1
104-
syntax keyword jsNull null conceal cchar=ø
105-
syntax keyword jsThis this conceal cchar=@
106-
syntax keyword jsReturn return conceal cchar=
107-
syntax keyword jsUndefined undefined conceal cchar=¿
108-
syntax keyword jsNan NaN conceal cchar=
109-
syntax keyword jsPrototype prototype conceal cchar=
110-
else
111-
syntax keyword jsNull null
112-
syntax keyword jsThis this
113-
syntax keyword jsReturn return
114-
syntax keyword jsUndefined undefined
115-
syntax keyword jsNan NaN
116-
syntax keyword jsPrototype prototype
117-
endif
103+
exe 'syntax keyword jsNull null '.(exists('g:javascript_conceal_null') ? 'conceal cchar='.g:javascript_conceal_null : '')
104+
exe 'syntax keyword jsReturn return '.(exists('g:javascript_conceal_return') ? 'conceal cchar='.g:javascript_conceal_return : '')
105+
exe 'syntax keyword jsUndefined undefined '.(exists('g:javascript_conceal_undefined') ? 'conceal cchar='.g:javascript_conceal_undefined : '')
106+
exe 'syntax keyword jsNan NaN '.(exists('g:javascript_conceal_NaN') ? 'conceal cchar='.g:javascript_conceal_NaN : '')
107+
exe 'syntax keyword jsPrototype prototype '.(exists('g:javascript_conceal_prototype') ? 'conceal cchar='.g:javascript_conceal_prototype : '')
108+
exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal_this') ? 'conceal cchar='.g:javascript_conceal_this : '')
118109

119110
"" Statement Keywords
120111
syntax keyword jsStatement break continue with
@@ -203,11 +194,7 @@ if main_syntax == "javascript"
203194
syntax sync match jsHighlight grouphere jsBlock /{/
204195
endif
205196

206-
if g:javascript_conceal == 1
207-
syntax match jsFunction /\<function\>/ nextgroup=jsFuncName,jsFuncArgs skipwhite conceal cchar=ƒ
208-
else
209-
syntax match jsFunction /\<function\>/ nextgroup=jsFuncName,jsFuncArgs skipwhite
210-
endif
197+
exe 'syntax match jsFunction /\<function\>/ nextgroup=jsFuncName,jsFuncArgs skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '')
211198

212199
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite
213200
syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas,jsFuncArgRest nextgroup=jsFuncBlock keepend skipwhite skipempty

0 commit comments

Comments
 (0)