-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneovim.init.vim
322 lines (270 loc) · 9.72 KB
/
neovim.init.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
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
""" Overall Configuration =======================
set tabstop=2 " Configs tab indent width to 2 spaces
set shiftwidth=2 " ..
set expandtab " ..
set number
set relativenumber
set mouse=a " Enable mouse interaction for all modes
"set scrolloff=10
set termguicolors
set inccommand=split " Highlight regex and show replace alteration before confirm
set clipboard=unnamed " Share one clipboard for everything
set completeopt=longest,menuone,noselect,preview
set background=dark "
set t_Co=256 "
set updatetime=100 " Configure file updatetime to 100 ms
set autoread " Automatically update file if changed outside of Vim
set autowrite " Automaically save file when swap between opened files
""" Key Bindings ================================
"" My keybindings
let mapleader=","
nnoremap <leader>q :q<cr> " Close file
nnoremap <leader>w :w<cr> " Write file (save)
nnoremap <Leader>x :x<CR> " Write and close file
nnoremap <Leader>n :next<CR> " Next file on Buffer
nnoremap <leader>p :prev<CR> " Previous file on Buffer
nnoremap <c-h> :noh<cr> " Clean highlights
inoremap <c-a> <c-o>0 " Go to begin of line ( insert mode )
inoremap <c-e> <c-o>$ " Go to end of line ( insert mode )
inoremap <c-z> <c-o>u " Undo ( insert mode )
nnoremap <cr><cr> m`o<esc>`` " Insert newline below, but keeps on cursor on place
nnoremap Q :qall<CR> " Close all files
" Toggle terminal on/off (neovim)
nnoremap <A-t> :call TermToggle(12)<CR>
inoremap <A-t> <Esc>:call TermToggle(12)<CR>
tnoremap <A-t> <C-\><C-n>:call TermToggle(12)<CR>
" Terminal go back to normal mode
tnoremap <Esc> <C-\><C-n>
tnoremap :q! <C-\><C-n>:q!<CR>
"" reMapping things
map n nzz " Center line during search navigation
map N Nzz " ..
nnoremap <up> g<up> " Navigate up/down through multine line
nnoremap <down> g<down> " ..
"" Plugins Bindings
map <leader>vp :VimuxPromptCommand<cr>
map <leader>vl :VimuxRunLastCommand<cr>
map <Leader>wr :w \| VimuxRunLastCommand<CR>
" Toggle eRegex plugin
nnoremap <leader>/ :call eregex#toggle()<CR>
" FZF keybindings
nnoremap <c-b> :Buffers<cr> " Navigate through buffer files
nnoremap <c-p> :Files<cr> " Search for file through folder
nnoremap <c-f> :Rg<space> " Search for string inside files through folder
" <CR> confirm and close selection menu ( eg. autocompletion menu )
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" more key mappings at end of file
""" Auto Commands ===============================
" Create highlight over current line
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au VimEnter,WinEnter,BufWinEnter * hi cursorline gui=bold guifg=none guibg=#404747
au WinLeave * setlocal nocursorline
augroup END
augroup PMenu
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * hi Pmenu guibg=#404040 guifg=white
augroup END
" Move file when cursor reach 1/3 from window borders
augroup VCenterCursor
au!
au BufEnter,WinEnter,WinNew,VimResized *,*.*
\ let &scrolloff=winheight(win_getid())/3
augroup END
""" Plugin Management ===========================
call plug#begin()
"" Plugins Installation ---------------
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'xuyuanp/nerdtree-git-plugin'
Plug 'tyok/nerdtree-ack'
Plug 'ivalkeen/nerdtree-execute'
Plug 'pseewald/nerdtree-tagbar-combined'
Plug 'terryma/vim-multiple-cursors'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim',
Plug 'sheerun/vim-polyglot'
Plug 'jiangmiao/auto-pairs'
Plug 'godlygeek/tabular'
Plug 'Yggdroot/indentLine'
Plug 'severin-lemaignan/vim-minimap'
Plug 'wellle/tmux-complete.vim'
Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
Plug 'w0rp/ale'
Plug 'tpope/vim-surround'
Plug 'roxma/vim-paste-easy'
Plug 'benmills/vimux'
Plug 'tmux-plugins/vim-tmux'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'ryanoasis/vim-devicons'
Plug 'majutsushi/tagbar'
Plug 'mileszs/ack.vim'
Plug 'othree/eregex.vim'
Plug 'mhinz/vim-signify'
Plug 'vim-scripts/matchit.zip'
Plug 'wellle/targets.vim'
Plug 'tpope/vim-commentary'
"Plug 'ervandew/supertab'
Plug 'kana/vim-arpeggio'
Plug 'lambdalisue/vim-manpager'
Plug 'vifm/vifm.vim'
Plug 'liuchengxu/vim-clap'
Plug 'ncm2/float-preview'
Plug 'chrisbra/Colorizer'
Plug 'APZelos/blamer.nvim'
Plug 'tpope/vim-fugitive'
Plug 'sodapopcan/vim-twiggy'
Plug 'rbong/vim-flog'
"" Themes -----------------------------
Plug 'felixhummel/setcolors.vim'
Plug 'flazz/vim-colorschemes'
Plug 'bling/vim-airline'
Plug 'jacoborus/tender.vim'
Plug 'sonph/onehalf', { 'rtp': '/vim' }
Plug 'flrnprz/candid.vim'
Plug 'lifepillar/vim-solarized8'
Plug 'connorholyday/vim-snazzy'
Plug 'kaicataldo/material.vim'
call plug#end()
""" Themes Configuration ========================
colorscheme candid
let g:airline_theme='onehalfdark'
""" Plugins Configuration =======================
"" Ack.vim ----------------------------
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
"" Airline ----------------------------
" Turn on Powerline fonts
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
"" ALE --------------------------------
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚠'
"" Arpeggio Mappings ------------------
call arpeggio#map('n','',0,'sv',':vsplit<CR>')
call arpeggio#map('n','',0,'sh',':split<CR>')
call arpeggio#map('i','',0,'jo','<C-o>o')
call arpeggio#map('i','',0,'ko','<C-o>O')
"" Blamer -----------------------------
let g:blamer_enabled = 1
let g:blamer_delay = 500
let g:blamer_prefix = ' ❱ '
"" Coc --------------------------------
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Or use `complete_info` if your vim support it, like:
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
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)
" Use K to show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
"" eRegex -----------------------------
let g:eregex_default_enable = 0
"" FZF --------------------------------
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
endif
"" indentLine -------------------------
let g:indentLine_char = '▏'
"" NerdTREE ---------------------------
" Mappings
map <leader>' :NERDTreeToggle<CR>
" NERDTree Git
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"" SuperTAB ---------------------------
let g:SuperTabDefaultCompletionType = "<c-n>"
"" Vim Tmux Navigation ----------------
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <C-Left> :TmuxNavigateLeft<cr>
nnoremap <silent> <C-Down> :TmuxNavigateDown<cr>
nnoremap <silent> <C-Up> :TmuxNavigateUp<cr>
nnoremap <silent> <C-Right> :TmuxNavigateRight<cr>
nnoremap <silent> <C-\> :TmuxNavigatePrevious<cr>
filetype plugin on
filetype indent on
""" Functions ===================================
"" My functions -----------------------
" Terminal Function
let g:term_buf = 0
let g:term_win = 0
function! TermToggle(height)
if win_gotoid(g:term_win)
hide
else
botright new
exec "resize " . a:height
try
exec "buffer " . g:term_buf
catch
call termopen($SHELL, {"detach": 0})
let g:term_buf = bufnr("")
set nonumber
set norelativenumber
set signcolumn=no
endtry
startinsert!
let g:term_win = win_getid()
endif
endfunction