Skip to content

Commit 95572d0

Browse files
committed
✨ change colorful config to manual setting
1 parent 76235b7 commit 95572d0

2 files changed

Lines changed: 51 additions & 25 deletions

File tree

README.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,41 @@ your `~/.vimrc`:
5858
Plug 'othree/es.next.syntax.vim'
5959
```
6060
61+
execute command in vim:
62+
63+
:so ~/.vimrc
64+
:PlugInstall
65+
66+
Configuration
67+
---
68+
69+
|name|default|detail|
70+
|---|---|---|
71+
|`g:vim_jsx_pretty_enable_jsx_highlight`|1|jsx highlight flag|
72+
|`g:vim_jsx_pretty_colorful_config`|0|colorful config flag|
73+
74+
75+
- Disable jsx highlight (but highlight group is set to jsx syntax. so this plugin expect to add highlight settings in case of disabled.)
76+
77+
```vim
78+
let g:vim_jsx_pretty_enable_jsx_highlight = 1 " default 1
79+
```
80+
6181
- Colorful style (**vim-javascript only**)
6282
6383
```vim
64-
augroup VimJsxPretty
65-
autocmd!
66-
autocmd VimEnter *.js,*.jsx highlight jsNoise ctermfg=197 cterm=bold guifg=#F92672 gui=bold
67-
autocmd VimEnter *.js,*.jsx highlight jsArrowFunction ctermfg=197 cterm=bold guifg=#F92672 gui=bold
68-
autocmd VimEnter *.js,*.jsx highlight jsObjectBraces ctermfg=197 cterm=bold guifg=#F92672 gui=bold
69-
autocmd VimEnter *.js,*.jsx highlight jsFuncBraces ctermfg=118 guifg=#A6E22E
70-
autocmd VimEnter *.js,*.jsx highlight jsFuncCall ctermfg=228 guifg=#A6A5AE
71-
autocmd VimEnter *.js,*.jsx highlight jsBrackets cterm=bold gui=bold
72-
augroup END
84+
let g:vim_jsx_pretty_colorful_config = 1 " default 0
7385
```
7486
75-
execute command in vim:
87+
### Highlight group list
7688
77-
:so ~/.vimrc
78-
:PlugInstall
89+
|name|place|
90+
|---|---|
91+
|jsxTag| `<tag id="sample">`<br />`~~~~~~~~~~~~~~~~~`|
92+
|jsxTagName| `<tag id="sample">`<br />`_~~~_____________`|
93+
|jsxEqual| `<tag id="sample">`<br />`_______~_________`|
94+
|jsxString| `<tag id="sample">`<br />`________~~~~~~~~_`|
95+
|jsxCloseTag| `</tag> | <tag />`<br />`~~~~~~ | _____~~` |
7996
8097
LICENSE
8198
---

after/syntax/javascript.vim

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,28 @@ syntax region jsxEscapeJs
118118
syntax cluster jsExpression add=jsxRegion
119119
syntax cluster javascriptNoReserved add=jsxRegion
120120

121-
highlight def link jsxTag Function
122-
highlight def link jsxTagName Function
123-
highlight def link jsxString String
124-
highlight def link jsxNameSpace Function
125-
highlight def link jsxComment Error
126-
highlight def link jsxAttrib Type
127-
highlight def link jsxEscapeJs jsxEscapeJs
128-
highlight def link jsxCloseTag Identifier
129-
highlight def link jsxCloseString Identifier
130-
131-
highlight def link jsObjectKey Label
132-
highlight def link jsArrowFuncArgs Type
133-
highlight def link jsFuncArgs Type
121+
let s:vim_jsx_pretty_enable_jsx_highlight = get(g:, 'vim_jsx_pretty_enable_jsx_highlight', 1)
122+
123+
if s:vim_jsx_pretty_enable_jsx_highlight == 1
124+
highlight def link jsxTag Function
125+
highlight def link jsxTagName Function
126+
highlight def link jsxString String
127+
highlight def link jsxNameSpace Function
128+
highlight def link jsxComment Error
129+
highlight def link jsxAttrib Type
130+
highlight def link jsxEscapeJs jsxEscapeJs
131+
highlight def link jsxCloseTag Identifier
132+
highlight def link jsxCloseString Identifier
133+
endif
134+
135+
let s:vim_jsx_pretty_colorful_config = get(g:, 'vim_jsx_pretty_colorful_config', 0)
136+
137+
if s:vim_jsx_pretty_colorful_config == 1
138+
highlight def link jsObjectKey Label
139+
highlight def link jsArrowFuncArgs Type
140+
highlight def link jsFuncArgs Type
141+
endif
142+
134143

135144
let b:current_syntax = 'javascript.jsx'
136145

0 commit comments

Comments
 (0)