-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
301 lines (252 loc) · 7.5 KB
/
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
colorscheme xoria256
filetype on
set mouse=
set expandtab
set shiftwidth=4
set tabstop=4
set autochdir
set ruler
set nowrap
nmap 's :source ~/.config/nvim/init.vim<cr>
nmap 'v :e! ~/.config/nvim/init.vim<cr>
nnoremap ,t :Nuake<CR>
inoremap ,t <C-\><C-n>:Nuake<CR>
tnoremap ,t <C-\><C-n>:Nuake<CR>
inoremap ,q <C-\><C-n>:NuakeLast<CR>
tnoremap ,q <C-\><C-n>:NuakeLast<CR>
nnoremap ,q :NuakeLast<CR>
let g:nuake_position = 'left'
set noeol "No automatically add a newline to modified files
noremap H H
nmap ,h :GitGutterLineHighlightsToggle<cr>
" Map Leader to <space><space>
" Then map the global clipboard to easier to use keys
let mapleader=" "
noremap <Leader>y "*y
noremap <Leader>p "*P
if has('nvim')
let $GIT_EDITOR = 'nvr -cc split --remote-wait'
endif
autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete
function! SetVar()
set filetype=make
endfunction
au BufReadPost * if getline(2) =~ "- Makefile -" | call SetVar() | endif
"autocmd FileType fzf silent! tunmap <Esc>
" Next/Previous Buffer
map <Tab> :tabnext<cr>
map <S-Tab> :tabprev<cr>
map ,e :FZ<cr>
map ,g :GFiles?<cr>
map ,d :setl bufhidden=delete<Bar>bnext <cr>
map ,<space> zz
nmap `e :Buffers<cr>
map ,b :Buffers<cr>
" Remove the need to use ctrl-f and ctrl-u for page up page down navigation
map ,f <C-f>
map ,u <C-u>
map ,o <C-o>
map ,O <C-o>
" Remove the need to use ctrl-v for columular selection
map ,v <C-v>
" Split window command + Navigation
nmap `1 1<C-W><C-W>
nmap `2 2<C-W><C-W>
nmap `3 3<C-W><C-W>
nmap `4 4<C-W><C-W>
nmap `r <C-W><C-V>:terminal<cr>
nmap `t :tabnew<cr>
nmap `v <C-W><C-V>
nmap `s <C-W>s
nmap `c <C-W>c
nmap `h <C-W>h
nmap `j <C-W>j
nmap `k <C-W>k
nmap `l <C-W>l
nmap `bd :bp\|bd#<cr>
nmap `r :wincmd v<cr>:terminal<cr>
nmap `v :wincmd v<cr>
nmap `c :wincmd c<cr>
nmap `h :wincmd h<cr>
nmap `j :wincmd j<cr>
nmap `k :wincmd k<cr>
nmap `l :wincmd l<cr>
" Disable C-w as its confusing
nmap <C-w> <C-\>
" Offload some of this to the right hand
" Split window command + Navigation
nmap +1 1<C-W><C-W>
nmap +2 2<C-W><C-W>
nmap +3 3<C-W><C-W>
nmap +4 4<C-W><C-W>
nmap +r <C-W><C-V>:terminal<cr>
nmap +v <C-W><C-V>
nmap +s <C-W>s
nmap +c <C-W>c
nmap +h <C-W>h
nmap +j <C-W>j
nmap +k <C-W>k
nmap +l <C-W>l
nmap +bd :bp\|bd#<cr>
nmap <Left> <C-W>h
nmap <Down> <C-W>j
nmap <Up> <C-W>k
nmap <Right> <C-W>l
nmap ') ysiw)
nmap `) ysiw)
"Disable EX mode
map Q <Nop>
" Show/Hide line numbers
nmap ,n :call ToggleNumbers()<cr>
" Enable spell check
nmap 'S :setlocal spell spelllang=en_us<cr>
nmap <Leader>s :setlocal spell spelllang=en_us<cr>
" Use 'z=' to show suggestions
" Enable spell check for Git Commits
au FileType markdown,gitcommit setlocal spell spelllang=en_us
" Toggle NERD Tree
nmap tt :NERDTreeToggle<cr>
" Terminal mappings
tnoremap <C-w> <C-\><C-n>
tnoremap <Esc> <C-\><C-n>
tnoremap <C-v><Esc> <Esc>
" Sneak options
let g:sneak#label = 1
" Now that we have sneak we can override () in visual mode
vmap ) S)
" ***** Plugins ****************************************************************
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'airblade/vim-gitgutter'
Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
"Plug 'ap/vim-buftabline'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-eunuch' "File commands like Rename"
Plug 'tpope/vim-surround' "Surround a word with parens
Plug 'Lenovsky/nuake'
Plug 'justinmk/vim-sneak'
Plug 'will133/vim-dirdiff'
Plug 'kana/vim-textobj-user' " Helper script for vim-textobj-user https://www.vim.org/scripts/script.php?script_id=2100
Plug 'kana/vim-textobj-line' " Help surround words with out newline https://www.vim.org/scripts/script.php?script_id=3886
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'Shougo/deoplete.nvim'
" Initialize plugin system
call plug#end()
" ***** /Plugins ***************************************************************
" Plugin Options """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Faster update time for git-gutter?
set updatetime=25
let g:buftabline_separators = 1
let g:buftabline_indicators = 1
let g:buftabline_numbers = 1
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ ['mode', 'paste' ], [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
" DirDiff Plugin Options """""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:DirDiffExcludes = ".git,vendor"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Next/Previous diff section
map <C-j> ]czz
map <C-k> [czz
map <down> ]czz
map <up> [czz
" Ignore/Don't Ignore white spaces in diffs"""""""""""""""""""""""""""""""""""""
command! WS call s:WSOn()
function! s:WSOn()
set diffopt-=iwhite
endfunction
command! NWS call s:WSOff()
function! s:WSOff()
set diffopt+=iwhite
endfunction
"function! DiffTo
" let g:gitgutter_diff_base = ''
"endfunction
" Diff current buffers
command! SetDiff call SetDiffEnviron()
function! SetDiffEnviron()
set diff
set scrollbind
set scrollopt=ver,jump,hor
set nowrap
set fdm=diff
endfunction
set encoding=utf-8
set list listchars=tab:→\ ,trail:·
"autocmd FileType go,make :set listchars=tab:\ \ ,trail:-,extends:>,precedes:<,nbsp:+
"autocmd FileType go,make :set noexpandtab
if &diff
colorscheme xoria256
set diffopt=filler,context:1000000 " filler is default and inserts empty lines for sync
" set diffopt+=iwhite " Ignore white space
else
set diffopt=filler,vertical,context:1000000 " filler is default and inserts empty lines for sync
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Examples
"let g:gitgutter_diff_base = '<commit SHA>'
command! FZ call RunFZFromRoot()
function! RunFZFromRoot()
let CWD=getcwd()
let ROOT=system("git rev-parse --show-toplevel")
execute 'cd' ROOT
execute 'FZF'
endfunction
" FZF does not close ,e dialog via escape in nvim
autocmd! FileType fzf tnoremap <buffer> <esc> <c-c>
nnoremap ,m :call TestMaximizeToggle()<CR>
function! TestMaximizeToggle()
if exists("g:maximize_session")
unlet g:maximize_session
echom "Closing down maximized session"
tabclose
else
let g:maximize_session = tempname()
echom "Maximizing session"
tabedit %
endif
endfunction
" Deprecated
function! MaximizeToggle()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
function! ToggleNumbers()
if &number == 0
set number
else
set nonumber
endif
endfunction
" Helper mappings: Go to opening brace of function
" https://vim.fandom.com/wiki/Jumping_to_the_start_and_end_of_a_code_block
map [[ :silent! eval search('{', 'b')<CR>w99[{
map ][ :silent! eval search('}')<CR>b99]}
map ]] j0[[%:silent! eval search('{')<CR>
map [] k$][%:silent! eval search('}', 'b')<CR>