-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim(linux)
369 lines (287 loc) · 11.8 KB
/
init.vim(linux)
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
let mapleader = "\<Space>"
set nocompatible
filetype off
"let g:python_host_prog='C:\Python38'
" ============= Plugins ==================== }}}
" Specify a directory for plugins
call plug#begin('~/.local/share/nvim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'joshdick/onedark.vim'
Plug 'Raimondi/delimitMate'
Plug 'Shougo/deoplete.nvim'
Plug 'dyng/ctrlsf.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'sheerun/vim-polyglot'
Plug 'nfvs/vim-perforce'
Plug 'mhinz/vim-startify'
Plug 'terryma/vim-multiple-cursors'
Plug 'vim-airline/vim-airline'
Plug 'yuttie/comfortable-motion.vim'
Plug 'w0rp/ale' "linting
Plug 'kien/rainbow_parentheses.vim'
Plug 'haya14busa/vim-keeppad'
Plug 'racer-rust/vim-racer'
Plug 'rust-lang/rust.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
call plug#end()
"}}}
" ============= Terminal Config ================ {{{
" Window split settings
highlight TermCursor ctermfg=red guifg=red
set splitbelow
set splitright
" Terminal settings
tnoremap <Leader><ESC> <C-\><C-n>
" Window navigation function
" Make ctrl-h/j/k/l move between windows and auto-insert in terminals
func! s:mapMoveToWindowInDirection(direction)
func! s:maybeInsertMode(direction)
stopinsert
execute "wincmd" a:direction
if &buftype == 'terminal'
startinsert!
endif
endfunc
execute "tnoremap" "<silent>" "<C-" . a:direction . ">"
\ "<C-\\><C-n>"
\ ":call <SID>maybeInsertMode(\"" . a:direction . "\")<CR>"
execute "nnoremap" "<silent>" "<C-" . a:direction . ">"
\ ":call <SID>maybeInsertMode(\"" . a:direction . "\")<CR>"
endfunc
for dir in ["h", "j", "l", "k"]
call s:mapMoveToWindowInDirection(dir)
endfor
" ============= General Config ================ {{{
:au BufEnter * if &buftype == 'terminal' | :startinsert | endif
:cd ~
set relativenumber "Show numbers relative to current line
set history=500 "Store lots of :cmdline history
set showcmd "Show incomplete cmds down the bottom
set noshowmode "Hide showmode because of the powerline plugin
set gdefault "Set global flag for search and replace
set gcr=a:blinkon500-blinkwait500-blinkoff500 "Set cursor blinking rate
set cursorline "Highlight current line
set smartcase "Smart case search if there is uppercase
set ignorecase "case insensitive search
set mouse=a "Enable mouse usage
set showmatch "Highlight matching bracket
set nostartofline "Jump to first non-blank character
set timeoutlen=1000 ttimeoutlen=0 "Reduce Command timeout for faster escape and O
set fileencoding=utf-8 "Set utf-8 encoding on write
set wrap "Enable word wrap
set linebreak "Wrap lines at convenient points
set listchars=tab:\ \ ,trail:· "Set trails for tabs and spaces
set list "Enable listchars
set lazyredraw "Do not redraw on registers and macros
set background=dark "Set background to dark
set hidden "Hide buffers in background
set conceallevel=2 concealcursor=i "neosnippets conceal marker
set splitright "Set up new vertical splits positions
set splitbelow "Set up new horizontal splits positions
set path+=** "Allow recursive search
set inccommand=split "Show substitute changes immidiately in separate split
set fillchars+=vert:\│ "Make vertical split separator full line
set pumheight=30 "Maximum number of entries in autocomplete popup
set mouse=a
"" Disable the blinking cursor.
set gcr=a:blinkon0
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
" vim-airline
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1
augroup VCenterCursor
au!
au BufEnter,WinEnter,WinNew,VimResized *,*.*
\ let &scrolloff=winheight(win_getid())/2
augroup END
" map reload of VIMRC
nmap <F5> :so $MYVIMRC<CR>
" map save
nmap <leader>s :w!<CR>
" map system clipboard to leader yank and paste
nmap <leader>y "+y
vmap <leader>y "+y
nmap <leader>p "+p
vmap <leader>p "+p
" leader shortcuts for NERDTree
map <leader>t :NERDTree<CR>
" leader shortcut for opening explorer
map <F3> :!start explorer /select,%:p<CR>
nnoremap j gj
nnoremap k gk
syntax on "turn on syntax highlighting
silent! colorscheme onedark
" rust
" Vim racer
au FileType rust nmap gd <Plug>(rust-def)
au FileType rust nmap gs <Plug>(rust-def-split)
au FileType rust nmap gx <Plug>(rust-def-vertical)
au FileType rust nmap <leader>gD <Plug>(rust-doc)
"" Git
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Gcommit<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>
" }}}
" ================ Indentation ====================== {{{
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set smartindent
set nofoldenable
" }}}
" ================ Rainbow_parentheses ====================== {{{
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\ ]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" }}}
" ================ Turn Off Swap Files ============== {{{
set noswapfile
set nobackup
set nowb
"}}}
" ================ Powerline ============== {{{
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#ale#enabled = 1
"}}}
" ================ Persistent Undo ================== {{{
" Keep undo history across sessions, by storing in file.
silent !mkdir ~/.local/share/nvim/backups > /dev/null 2>&1
set undodir=~/.local/share/nvim/backups
set undofile
"}}}
" ================ Auto commands ====================== {{{
augroup vimrc
autocmd!
augroup END
autocmd vimrc InsertEnter * :set nocul "Remove cursorline highlight
autocmd vimrc FocusGained,BufEnter * checktime "Refresh file when vim gets focus
"}}}
" ================ Search setup ================ {{{
nmap <leader>ff <Plug>CtrlSFPrompt
vmap <leader>ff <Plug>CtrlSFVwordPath
vmap <leader>fF <Plug>CtrlSFVwordExec
nmap <leader>fn <Plug>CtrlSFCwordPath
nmap <leader>fp <Plug>CtrlSFPwordPath
nnoremap <leader>fo :CtrlSFOpen<CR>
nnoremap <leader>ft :CtrlSFToggle<CR>
inoremap <leader>ft <Esc>:CtrlSFToggle<CR>
let g:ctrlsf_ackprg = "/usr/bin/ack"
"}}}
" ================ windows controls ================ {{{
"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>
nmap <leader>k <C-w>k
nmap <leader>j <C-w>j
nmap <leader>h <C-w>h
nmap <leader>l <C-w>l
"}}}
let g:multi_cursor_start_key='<leader>d'
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" ================ ctrl P ================ {{{
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
endif
"}}}
" ================ Colorscheme setup ================ {{{
autocmd vimrc FileType php setlocal sw=4 sts=4 ts=4 "Set indentation to 4 for php
let g:bold_highlight_groups = ['Function', 'Statement', 'Todo', 'CursorLineNr', 'MatchParen', 'StatusLine']
for group in g:bold_highlight_groups
call onedark#extend_highlight(group, { 'gui': 'bold' })
endfor
"}}}
"*****************************************************************************
"" Convenience variables
"*****************************************************************************
" vim-airline
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
if !exists('g:airline_powerline_fonts')
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '»'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '«'
let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
let g:airline#extensions#readonly#symbol = '⊘'
let g:airline#extensions#linecolumn#prefix = '¶'
let g:airline#extensions#paste#symbol = 'ρ'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
else
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
endif