-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
313 lines (252 loc) · 8.46 KB
/
.vimrc
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
set nocompatible " be iMproved
filetype off " required!
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.vim/plugged')
" Install plugins with :PlugInstall
" General
Plug 'tpope/vim-sensible'
Plug 'scrooloose/nerdtree'
"Plug 'Raimondi/delimitMate'
Plug 'jiangmiao/auto-pairs'
Plug 'altercation/vim-colors-solarized'
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdcommenter'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'godlygeek/tabular'
Plug 'Lokaltog/vim-easymotion'
Plug 'tpope/vim-surround'
"Plug 'scrooloose/syntastic'
Plug 'w0rp/ale'
Plug 'mileszs/ack.vim'
" Dependency plugs
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
" Auto complete and snippets
"Plug 'Shougo/neocomplete'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
Plug 'Shougo/neosnippet'
Plug 'Shougo/neosnippet-snippets'
Plug 'garbas/vim-snipmate'
Plug 'jonotron/snippets'
Plug 'ervandew/supertab'
" HTML
Plug 'docunext/closetag.vim'
Plug 'rstacruz/sparkup'
Plug 'gregsexton/MatchTag'
"Plug 'mattn/emmet-vim'
" Javascript
"Plug 'groenewege/vim-less'
"Plug 'nono/vim-handlebars'
"Plug 'pangloss/vim-javascript'
Plug 'othree/yajs.vim'
Plug 'othree/es.next.syntax.vim'
"Plug 'jelera/vim-javascript-syntax'
Plug 'mxw/vim-jsx'
Plug 'gavocanov/vim-js-indent'
Plug 'prettier/vim-prettier'
" JSON
Plug 'elzr/vim-json'
" jison
Plug 'wizicer/vim-jison'
" Markdown
Plug 'plasticboy/vim-markdown'
" Git
Plug 'airblade/vim-gitgutter'
call plug#end()
" NERDTree config
let g:NERDTreeDirArrows = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" Don't fold markdown
let g:vim_markdown_folding_disabled=1
" Don't conceal markdown
let g:vim_markdown_conceal = 0
set background=dark
let g:solarized_termtrans=1
let g:solarized_termcolors=256
let g:solarized_contrast="high"
let g:solarized_visibility="high"
colorscheme solarized
filetype on
filetype plugin on
filetype indent on
syntax on
" Autoreload .vimrc if we change it in vim
autocmd! bufwritepost $MYVIMRC source $MYVIMRC
" Set my leader key
let mapleader = ','
" Escape out of insert mode when jj is pressed
imap jj <Esc>
" Enable mouse support in terminal mode
set mouse=a
" Window key mappings
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-h> <C-w>h
map <C-l> <C-w>l
map <C-q> <C-w>q
" :W<CR> should be an alias to :w<CR>
command! W w
" easily create new tabs
nmap <leader>t :tabnew<CR>
" Set cwd when to dir as file when opened in buffer
autocmd BufEnter * cd %:p:h
" Add tabularize support
vmap <leader>a= :Tabularize /=<CR>
nmap <leader>a= :Tabularize /=<CR>
vmap <leader>a: :Tabularize /:\zs<CR>
nmap <leader>a: :Tabularize /:\zs<CR>
vmap <leader>a, :Tabularize /,\zs<CR>
nmap <leader>a, :Tabularize /,\zs<CR>
" Remap supertab keys
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
" Various config options
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set hlsearch
set incsearch
" set autoindent
" set smartindent
set showmatch
set splitbelow
set splitright
set ignorecase
set smartcase
" Hide the toolbar in guivim
set go-=T
" set .swp files to appear here instead
set backupdir=~/.vim/backup
set directory=~/.vim/backup
" enable less.css highlighting
au BufRead,BufNewFile *.less set filetype=less
" set handlebars for .hbs
au BufRead,BufNewFile *.hbs set ft=handlebars
" enable CloseTag plugin for html/xml like files
autocmd FileType html,xml,handlebars let b:closetag_html_style=1
autocmd FileType html,xhtml,xml,handlebars source ~/.vim/bundle/closetag.vim/plugin/closetag.vim
" enable JSX syntax highlighting in .js files
let g:jsx_ext_required = 0
" enable Sparkup plugin for html/xml like files
au FileType html,xhtml,xml,handlebars source ~/.vim/bundle/sparkup/vim/ftplugin/html/sparkup.vim
" enable Sparkup for jsx
autocmd FileType javascript.jsx runtime! ftplugin/html/sparkup.vim
" Prettier config
let g:prettier#autoformat = 0
"let g:prettier#quickfix_enabled = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql PrettierAsync
" ctrlp should always use the directory started from as root
let g:ctrlp_working_path_mode = 'ra'
" Set ignores for ctrlp
let g:ctrlp_custom_ignore = {
\'dir': '\.git$\|\.hg$\|\.svn$\|cache\|vendor\|logs\|build\|node_modules\|components\',
\'file': '\.swp$\|\.exe$\|\.so$\|\.dll$\|\.swo$\|\.lock$\|\.gitignore$\|\.project$'
\}
" set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/vendor/*,*/cache/*,*/logs/*
" don't error on angular propertys
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
" auto set cursorline
autocmd WinLeave * set nocursorline
autocmd WinEnter * set cursorline
set cursorline
" nop the arrow keys
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" set relative line numbers
" set relativenumber
" set absolute line numbers
" set number
" easily turn off highlighting
nnoremap <leader><space> :noh<cr>
" highlight 80char colum
set colorcolumn=80
" #### neocomplete settings
" Disable AutoComplPop.
"let g:acp_enableAtStartup = 0
"" Use neocomplete.
"let g:neocomplete#enable_at_startup = 1
"" Use smartcase.
"let g:neocomplete#enable_smart_case = 1
"" Set minimum syntax keyword length.
"let g:neocomplete#sources#syntax#min_keyword_length = 3
"" Define dictionary.
"let g:neocomplete#sources#dictionary#dictionaries = {
"\ 'default' : '',
"\ 'vimshell' : $HOME.'/.vimshell_hist',
"\ 'scheme' : $HOME.'/.gosh_completions'
"\ }
"" Define keyword.
"if !exists('g:neocomplete#keyword_patterns')
"let g:neocomplete#keyword_patterns = {}
"endif
"let g:neocomplete#keyword_patterns['default'] = '\h\w*'
"" Plugin key-mappings.
"inoremap <expr><C-g> neocomplete#undo_completion()
"inoremap <expr><C-l> neocomplete#complete_common_string()
"" Recommended key-mappings.
"" <CR>: close popup and save indent.
"inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
"function! s:my_cr_function()
"return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
"" For no inserting <CR> key.
""return pumvisible() ? "\<C-y>" : "\<CR>"
"endfunction
"" <TAB>: completion.
"inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
"" <C-h>, <BS>: close popup and delete backword char.
"inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
"" Check if popup is visible otherwise use delmitmate bs
"inoremap <expr><BS> pumvisible() ? neocomplete#smart_close_popup()."\<C-h>" : delimitMate#BS()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
"if !exists('g:neocomplete#sources#omni#input_patterns')
"let g:neocomplete#sources#omni#input_patterns = {}
"endif
""let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
""let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
""let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
"" For perlomni.vim setting.
"" https://github.com/c9s/perlomni.vim
"let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
" ### end neocomplete config
" neosnippet key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" reload snippets when edited
autocmd BufWritePost *.snip,*.snippets
\ call neosnippet#variables#set_snippets({})