-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
323 lines (263 loc) · 8 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
314
315
316
317
318
319
320
321
322
323
set nocompatible
" Backups {{{
if v:version >= 703
set undofile
set undodir=./.tmp,/tmp
else
let g:gundo_disable = 1
endif
set backupdir=./.tmp,.,/tmp
set directory=./.tmp,/tmp
set history=500
set undolevels=500
" }}}
" appearance options
set t_Co=256
set background=dark
autocmd vimenter * ++nested colorscheme solarized8
" Security
set modelines=0
" Tabs/spaces
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" Special filetype conf
au FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Basic options
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
set number
set pastetoggle=<F2>
" Leader
let mapleader = ","
" Searching
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
" Disable highlight
map <leader><space> :noh<cr>:call clearmatches()<cr>
runtime macros/matchit.vim
nmap <tab> %
vmap <tab> %
" Soft/hard wrapping
set wrap
set textwidth=79
set formatoptions=qrn1
" Use the same symbols as TextMate for tabstops and EOLs
set list
set listchars=tab:▸\
" Color scheme (terminal)
syntax on
" Use the damn hjkl keys, never use the arrow keys ! Never ever !
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" And make them fucking work, too.
nnoremap j gj
nnoremap k gk
" Fuck you, help key.
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Remapping esc key
"inoremap jk <esc>
" Save when losing focus
au FocusLost * :wa
" Easier linewise reselection
map <leader>v V`]
" Splits / Open file in the same directory as current file
map <leader>ew :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>es :sp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>ev :vsp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>et :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Easy splits navigation
map <C-h> <C-w>h
map <C-l> <C-w>l
" From tab to vsplit
nnoremap <c-w>V mAZZ<c-w>v`A
" Insert <Tab> or complete identifier
" if the cursor is after a keyword character
function! MyTabOrComplete()
let col = col('.')-1
if !col || getline('.')[col-1] !~ '\k'
return "\<tab>"
else
return "\<C-N>"
endif
endfunction
inoremap <Tab> <C-R>=MyTabOrComplete()<CR>
" text titles and doc helpers
nnoremap <leader>é yypVr=
nnoremap <leader>" yypVr-
nnoremap <leader>' yypVr~
" Surround shortcut
nmap <leader>& ysiw
" Thanks to vim-unimpaired
" Bubble single lines
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-k> [egv
vmap <C-j> ]egv
" yank and leave the cursor at the end of a visual selection
:vnoremap gy y`>
" sudo save
cmap w!! w !sudo tee % >/dev/null
" Here are some abbreviations
iabbrev cl console.log
let g:airline_powerline_fonts = 1
" strip all trailing whitespace in the current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Use Node.js for JavaScript interpretation
let $JS_CMD='node'
" Highlight Word, initial version from:
" https://gist.github.com/emilyst/9243544#file-vimrc-L142
"
" This mini-plugin provides a few mappings for highlighting words temporarily.
"
" Sometimes you're looking at a hairy piece of code and would like a certain
" word or two to stand out temporarily. You can search for it, but that only
" gives you one color of highlighting. Now you can use <leader>N where N is
" a number from 1-6 to highlight the current word in a specific color.
"
" <leader>0 unsets all highlighting
function! HiInterestingWord(n)
hi def HiInterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
hi def HiInterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
hi def HiInterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
hi def HiInterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
hi def HiInterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
hi def HiInterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
" HiInterestingWord(0) clears all the matches, including the general
" search highlighting.
if a:n == 0
let i = 1
while i <= 6
let mid = 86750 + i
silent! call matchdelete(mid)
let i += 1
endwhile
set hlsearch!
return
endif
" Save our location.
normal! mz
" Yank the current word into the z register.
normal! "zyiw
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
let mid = 86750 + a:n
" Clear existing matches, but don't worry if they don't exist.
silent! call matchdelete(mid)
" Construct a literal pattern that has to match at boundaries.
let pat = '\V\<' . escape(@z, '\') . '\>'
" Actually match the words.
call matchadd('HiInterestingWord' . a:n, pat, 1, mid)
" Move back to our original location.
normal! `z
endfunction
" Default Highlights
nmap <silent> <leader>0 :call HiInterestingWord(0)<cr>
nmap <silent> <leader>1 :call HiInterestingWord(1)<cr>
nmap <silent> <leader>2 :call HiInterestingWord(2)<cr>
nmap <silent> <leader>3 :call HiInterestingWord(3)<cr>
nmap <silent> <leader>4 :call HiInterestingWord(4)<cr>
nmap <silent> <leader>5 :call HiInterestingWord(5)<cr>
nmap <silent> <leader>6 :call HiInterestingWord(6)<cr>
au BufNewFile,BufRead *.mako set filetype=html
" Fix the git-gutter column color
hi clear SignColumn
" move close bracket to third line and put cursor at second line
autocmd FileType javascript inoremap {<CR> {<CR>}<Esc><S-o>
autocmd FileType less inoremap {<CR> {<CR>}<Esc><S-o>
" Set some default values for indentation
au FileType md setlocal ts=2 sts=2 sw=2 expandtab
au FileType html setlocal ts=2 sts=2 sw=2 expandtab
au FileType js setlocal ts=2 sts=2 sw=2 expandtab
au FileType mako setlocal ts=2 sts=2 sw=2 expandtab
" Change default vim update time
" Useful for gitgutter
set updatetime=250
" Disable auto folding in markdown
let g:vim_markdown_folding_disabled = 1
" Disable auto folding in vue
let g:vim_vue_plugin_use_foldexpr=0
let g:ale_fixers = {}
let g:ale_fixers['javascript'] = ['prettier']
let g:ale_fixers['vue'] = ['prettier']
" automatically fix files on save
let g:ale_fix_on_save = 1
nmap <silent> <leader>j <Plug>(ale_previous_wrap)
nmap <silent> <leader>k <Plug>(ale_next_wrap)
" install vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
" CoC Conquer of Completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'yaegassy/coc-volar', {'do': 'yarn install --frozen-lockfile'}
Plug 'yaegassy/coc-volar-tools', {'do': 'yarn install --frozen-lockfile'}
" fzf
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
map <C-p> :FZF <Enter>
" NERDTree
Plug 'preservim/nerdtree'
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
Plug 'airblade/vim-gitgutter'
Plug 'davidhalter/jedi-vim'
Plug 'easymotion/vim-easymotion'
Plug 'editorconfig/editorconfig-vim'
Plug 'glench/vim-jinja2-syntax'
Plug 'groenewege/vim-less'
Plug 'haya14busa/incsearch.vim'
Plug 'leafgarland/typescript-vim'
Plug 'mattn/emmet-vim'
Plug 'nvie/vim-flake8'
Plug 'pangloss/vim-javascript'
Plug 'plasticboy/vim-markdown'
Plug 'preservim/nerdcommenter'
Plug 'prettier/vim-prettier'
Plug 'psf/black'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'yaegassy/coc-ruff', {'do': 'yarn install --frozen-lockfile'}
" Initialize plugin system
call plug#end()
" Backup copy, avoid issues with webpack watching mechanism
set backupcopy=yes
" Spelling for commit messages
autocmd FileType gitcommit setlocal spelllang=en spell