forked from jaywcjlove/vim-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.vim
178 lines (125 loc) · 4.45 KB
/
config.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
"
" WebVim Configuration : Plugins configuration
"
" author: Bertrand Chevrier <[email protected]>
" source: https://github.com/krampstudio/dotvim
" year : 2015
"
" TODO split by plugin ?
" [> NERDTree <]
" on vim enter opens nerd tree
function! OpenNerdTree()
let s:exclude = ['COMMIT_EDITMSG', 'MERGE_MSG']
if index(s:exclude, expand('%:t')) < 0
NERDTreeFind
exec "normal! \<c-w>\<c-w>"
endif
endfunction
autocmd VimEnter * call OpenNerdTree()
" nerdtree autoclose if it is the last opened buffer
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" nerdtree window resize
let g:NERDTreeWinSize = 35
" show hidden files
let g:NERDTreeShowHidden=1
" single click to open nodes
" let g:NERDTreeMouseMode=3
" ignored files
let g:NERDTreeIgnore=['\.swp$', '\~$']
nnoremap <c-n> :NERDTreeToggle<cr>
" [> NERDCommenter <]
noremap <c-_> :call NERDComment(0, "Toggle")<cr>
" [> Airline <]
" status line always opened
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
" powerline font
let g:airline_powerline_fonts=1
" [> EditorConfig <]
" to avoid issues with fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" [> Syntastic <]
"" Syntax checkers
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1
let g:syntastic_php_checkers=['php', 'phpcs', 'phpmd']
let g:syntastic_html_checkers=['tidy']
let g:syntastic_vim_checkers=['vimlint']
let g:syntastic_json_checkers=['jsonlint']
let g:syntastic_yaml_checkers=['js-yaml']
let g:syntastic_scss_checkers=['scss-lint']
let g:syntastic_css_checkers=['csslint']
let g:syntastic_handlebars_checkers=['handlebars']
let g:syntastic_tpl_checkers=['handlebars']
" get available js linters
function! GetJslinters()
let l:linters = [ ['eslint', '.eslintrc'], ['jshint', '.jshintrc'] ]
let l:available = []
for l:linter in l:linters
if executable(l:linter[0])
call add(l:available, l:linter)
endif
endfor
return l:available
endfunction
" check if the path to see if a linter config is present
function! Jslinter(path, linters)
let l:dir = fnamemodify(a:path, ':p:h')
if(l:dir == '/')
return ''
endif
for l:linter in a:linters
if filereadable(l:dir . '/' . l:linter[1])
return l:linter[0]
endif
endfor
return Jslinter(fnamemodify(l:dir, ':h'), a:linters)
endfunction
" set the jslinter into Syntastic
function! SyntasticSetJsLinter()
let l:availableLinters = GetJslinters()
" look for linter config in the current folder
let l:jslinter = Jslinter(expand('%:p'), l:availableLinters)
if l:jslinter == ''
" otherwise look into the home dir
let l:jslinter = Jslinter($HOME, l:availableLinters)
endif
" configure the linter
if l:jslinter != ''
let g:syntastic_javascript_checkers=[l:jslinter]
endif
endfunction
call SyntasticSetJsLinter()
" [> EasyAlign <]
" select paragraph and start easyalign on the left
" nnoremap <leader>a vip<Plug>(EasyAlign)<cr>
" Start interactive align to the right
" vmap <leader>a <Plug>(EasyAlign)<cr><right>
let g:easy_align_ignore_groups = ['Comment']
" 对齐插件
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" [> multiple cursor <]
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-m>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<esc>'
" [> JsBeautify <]
" format selection
autocmd FileType javascript vnoremap <buffer> <c-f> :call RangeJsBeautify()<cr>
autocmd FileType json vnoremap <buffer> <c-f> :call RangeJsonBeautify()<cr>
autocmd FileType html vnoremap <buffer> <c-f> :call RangeHtmlBeautify()<cr>
autocmd FileType css vnoremap <buffer> <c-f> :call RangeCSSBeautify()<cr>
" format the whole file
autocmd FileType javascript nnoremap <buffer> <c-f> :call JsBeautify()<cr>
autocmd FileType json nnoremap <buffer> <c-f> :call JsonBeautify()<cr>
autocmd FileType html nnoremap <buffer> <c-f> :call HtmlBeautify()<cr>
autocmd FileType css nnoremap <buffer> <c-f> :call CSSBeautify()<cr>
" [> YankStack <]
nmap <leader>p <Plug>yankstack_substitute_older_paste
nmap <leader>P <Plug>yankstack_substitute_newer_paste
" [> Javascript libraries syntax <]
let g:used_javascript_libs = 'jquery,underscore,requirejs,chai,handlebars'