Repository navigation
Expand file tree
/
Copy pathinit.vim
More file actions
299 lines (239 loc) · 7.48 KB
/
Copy pathinit.vim
File metadata and controls
299 lines (239 loc) · 7.48 KB
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
" specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')
" nerd tree
Plug 'scrooloose/nerdtree'
Plug 'paulondc/vim-nerdtree-open-externally'
Plug 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeChDirMode=2
let g:NERDTreeShowLineNumbers=0
let g:NERDTreeShowHidden=1
let g:NERDTreeQuitOnOpen=1
let g:NERDTreeIgnore=[
\ 'build',
\ 'target',
\ '.coverage',
\ '__pycache__',
\ '\.pyc$',
\ '\.git$',
\ '.lock',
\ ]
" status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline#extensions#tabline#tab_nr_type=1
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#left_sep=' '
let g:airline#extensions#tabline#left_alt_sep='|'
let g:airline#extensions#tabline#formatter='default'
let g:airline#extensions#tabline#tabs_label=''
let g:airline#extensions#tabline#show_splits=0
let g:airline#extensions#tabline#buffers_label=''
let g:airline#extensions#tabline#show_buffers=0
let g:airline#extensions#tabline#show_close_button=0
let g:airline#extensions#tabline#fnamemod=':t'
let g:airline#extensions#tabline#enabled=1
let g:airline_powerline_fonts=1
" display markers as a separated column beside of the line number
Plug 'kshenoy/vim-signature'
" color schemes (loaded later)
Plug 'rafi/awesome-vim-colorschemes'
" search and replace highlight
Plug 'osyo-manga/vim-over'
" nice defaults settings for vim
Plug 'tpope/vim-sensible'
" auto tab based on the current file
Plug 'tpope/vim-sleuth'
" full path fuzzy file, buffer finder
Plug 'ctrlpvim/ctrlp.vim'
let g:ctrlp_custom_ignore={
\ 'dir': '\v(\.git|node_modules|__pycache__|build|target|htmlcov|dist)$',
\ 'file': '\v\.(swp|ico|git|pyc|lock)$',
\ }
let g:ctrlp_prompt_mappings={
\ 'AcceptSelection("e")': ['<2-LeftMouse>'],
\ 'AcceptSelection("t")': ['<cr>'],
\ }
" syntax highlight for Hjson
Plug 'hjson/vim-hjson'
" ejs syntax highlight
Plug 'nikvdp/ejs-syntax'
" css color highlight
Plug 'ap/vim-css-color'
" pgsql syntax highlight
Plug 'lifepillar/pgsql.vim'
let g:sql_type_default='pgsql'
" surround extension for vim
Plug 'tpope/vim-surround'
" search and replace across multiple files
Plug 'brooth/far.vim'
let g:far#auto_preview=0
" move block selection
Plug 'matze/vim-move'
let g:move_key_modifier='C'
vmap <C-down> <Plug>MoveBlockDown
vmap <C-up> <Plug>MoveBlockUp
" comment/uncomment selected lines by hitting: ctrl + /
Plug 'tpope/vim-commentary'
" in neovim on linux pressing <C-/> is registered as <C-_>
nmap <C-_> <Plug>Commentary
vmap <C-_> <Plug>Commentary
" auto complete support
let g:coc_global_extensions=[
\ 'coc-json',
\ 'coc-yaml',
\ 'coc-tsserver',
\ 'coc-sh',
\ 'coc-pairs',
\ 'coc-rust-analyzer',
\ 'coc-pyright',
\ 'coc-clangd',
\ 'coc-cmake',
\ ]
Plug 'neoclide/coc.nvim', {
\ 'branch': 'release',
\ 'do': { -> coc#util#install() }
\ }
" multiple cursors support
Plug 'terryma/vim-multiple-cursors'
" get rid of trailing whitespace
Plug 'ntpeters/vim-better-whitespace'
let g:better_whitespace_guicolor='#263247'
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
" nice way to interact with json in vim
Plug 'elzr/vim-json'
" show git diff as column
Plug 'airblade/vim-gitgutter'
" initializing plugin system
call plug#end()
" if you have vim >=8.0 or Neovim >= 0.1.5
if (has("termguicolors"))
set termguicolors
endif
" for neovim 0.1.3 and 0.1.4
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
" enabling theme
syntax enable
colorscheme onedark " deus
" disable folding
set nofoldenable
" improving scrolling speed in large files
set lazyredraw
set regexpengine=1
" show line numbers
set number
" keeping 5 lines below the current line
set scrolloff=5
" clipboard
set clipboard+=unnamedplus
" the width of a TAB is set to 4. Still it is a \t. It is just that Vim will
" interpret it to be having a width of 4
set tabstop=4
" indents will have a width of 4
set shiftwidth=4
" sets the number of columns for a TAB
set softtabstop=4
" expand tabs to spaces
set expandtab
" white space chars
set listchars=tab:>·,trail:~,extends:>,precedes:<,space:.
" enable spell checking (z= to show suggestions)
set spell
" spell checking languages
set spelllang=en
" f1 toggle nerdtree
nmap <F1> :NERDTreeToggle<CR>
" disabling help in insert mode
imap <F1> <Nop>
" traditional tabs
vmap <Tab> >gv
vmap <S-Tab> <gv
" disabling ex mode (entering Ex mode. Type visual to go to Normal mode)...
nnoremap Q <Nop>
" using ESC to leave the insert mode when inside of term
tnoremap <Esc> <C-\><C-n>
" clear hightlight
nnoremap <esc><esc> :noh<return>
" jump to a buffer where it is (in another window, another tab) instead of
" replacing the current buffer
set switchbuf=useopen,usetab
" removing the autocomplete preview displayed on top
set completeopt-=preview
" disabling plugins during multiple cursors
function Multiple_cursors_before()
set foldmethod=manual
if exists(':NeoCompleteLock')==2
exe 'NeoCompleteLock'
endif
endfunction
function Multiple_cursors_after()
set foldmethod=syntax
if exists(':NeoCompleteUnlock')==2
exe 'NeoCompleteUnlock'
endif
endfunction
" hide line numbers and start in insert mode in terminal
function! TermModeDefauts()
set norelativenumber
set nonumber
startinsert
endfunc
autocmd TermOpen * :call TermModeDefauts()
" split window to a terminal
function! SplitWindowToTerm()
belowright split
resize -8
term
endfunc
nnoremap <C-T> :call SplitWindowToTerm()<CR>
" background colors for active vs inactive windows
hi ActiveWindow guibg=#282c34
hi InactiveWindow guibg=#22262e
" change highlight group of active/inactive windows
augroup WindowManagement
autocmd!
autocmd WinNew * call HandleHighlight()
autocmd WinLeave * call HandleHighlight()
autocmd WinEnter * call HandleHighlight()
augroup END
function! HandleHighlight()
setlocal winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow
endfunc
" opening nerd tree automatically when launching vim from a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in")
\ | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
autocmd BufWinEnter * NERDTreeMirror
autocmd bufenter * if (winnr("$") == 1 && tabpagenr() > 1 && exists("b:NERDTree")
\ && b:NERDTree.isTabTree()) | q | endif
" navigate in the definitions in coc
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" scroll documentation in coc autocomplete
nnoremap <nowait><expr> <C-f> coc#float#has_scroll()
\ ? coc#float#scroll(1) : "\<C-f>"
nnoremap <nowait><expr> <C-b> coc#float#has_scroll()
\ ? coc#float#scroll(0) : "\<C-b>"
inoremap <nowait><expr> <C-f> coc#float#has_scroll()
\ ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <nowait><expr> <C-b> coc#float#has_scroll()
\ ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
" use <tab> for trigger completion and navigate to the next complete item in coc
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1]=~'\s'
endfunction
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"
" symbol renaming in coc
nmap <silent>rn <Plug>(coc-rename)
" disabling the pairs for < in coc
autocmd FileType * let b:coc_pairs_disabled = ['<']
" automatically detecting and converting CRLF to LF
function WatchForCRLF()
if &fileformat ==# 'dos' && confirm('',"CRLF (dos) line ending detected. Do you want to switch to LF (unix)? (&Yes\n&No)",1)==1
set fileformat=unix
endif
endfunction
au BufReadPost,BufNewFile * call WatchForCRLF()