-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
436 lines (369 loc) · 12.1 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
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
" vim:fdm=marker
" Use ' ' as the leader key
let mapleader="\<Space>"
" Write the changes
call plug#begin('~/.vim/plugged')
if !has('nvim')
Plug 'tpope/vim-surround' " Manipulate parenthesis :help surround
endif
Plug 'tpope/vim-commentary' " Comment out lines :help commentary
"" Plug 'tmsvg/pear-tree' " Vim auto-pair plugin.
Plug 'wlangstroth/vim-racket'
Plug 'imsnif/kdl.vim'
Plug 'ojroques/vim-oscyank'
vmap <leader>t <Plug>OSCYankVisual
" Plug 'dstein64/vim-startuptime'
" On-demand loading
" The undo history visualizer for VIM {{{
" Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' } " Show Undo tree. :help undotree-intro
" nnoremap <F5> :UndotreeToggle<CR>
" }}}
" LSP alternative for preservim {{{
Plug 'liuchengxu/vista.vim'
nnoremap <F8> :Vista!!<CR>
let g:vista#finders = ['fzf']
let g:vista_echo_cursor_strategy = 'floating_win'
let g:vista_fzf_preview = ['right:30%']
let g:vista_sidebar_width = 40
" }}}
set tags=$TAGSFILE
" set tags=$VIM_TAG_FILE2
" nnoremap <leader>st :call SwitchTagsFile()<CR>
" function! SwitchTagsFile()
" if &tags == $VIM_ALT_TAG_FILE
" set tags=$VIM_TAG_FILE
" else
" set tags=$VIM_ALT_TAG_FILE
" endif
" echo &tags
" endfunction
" Plugin to provide additional text objects: E.g. change inside brackets and
" parenthesis
Plug 'wellle/targets.vim'
" Show function context {{{
Plug 'wellle/context.vim', { 'on': 'ContextToggle' } " Show context.
nnoremap <F4> :ContextToggle<CR>
" }}}
if !has('nvim')
" Airline status bar {{{
Plug 'vim-airline/vim-airline' " Status line :help airline
Plug 'vim-airline/vim-airline-themes'
" let g:airline_section_a=''
" let g:airline_section_b='%-0.90{getcwd()}'
let g:airline_section_b=''
let g:airline_section_c='%t'
" let g:airline_section_x=''
let g:airline_section_y=''
let g:airline_section_error=''
let g:airline_section_warning=''
let g:airline_powerline_fonts=1
" remove separators for empty sections
let g:airline_skip_empty_sections=1
" Disable tagbar integration, enable vista integration
" let g:airline#extensions#tagbar#flags = 'f'
" let g:airline#extensions#tagbar#enabled = 1
let g:airline#extensions#vista#enabled = 1
" let g:airline#extensions#tabline#show_splits = 1 " enable/disable displaying open splits per tab (only when tabs are opened). >
let g:airline#extensions#tabline#show_buffers = 1 " enable/disable displaying buffers with a single tab
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
let g:airline#extensions#tabline#buffer_idx_mode = 1 " show buffer numbers
let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers
let g:airline#extensions#tabline#fnamemod = ':t' " Show just the filename
let g:airline#extensions#wordcount#enabled = 0
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
" AirLine colorscheme
" let g:airline_theme="ayu_dark"
" let g:airline_theme="base16"
" let g:airline_theme="base16_bright"
let g:airline_theme="base16_chalk"
" let g:airline_theme="molokai"
" let g:airline_theme="papercolor"
" let g:airline_theme="light"
" let g:airline_theme="onedark"
"
" }}}
Plug 'morhetz/gruvbox'
" Dim inactive windows {{{
Plug 'blueyed/vim-diminactive'
" }}}
" Plug 'markonm/traces.vim'
" " Snippet insertion engine and collection {{{
" Plug 'SirVer/ultisnips'
" Plug 'honza/vim-snippets'
" let g:UltiSnipsExpandTrigger="<C-j>"
" let g:UltiSnipsJumpForwardTrigger="<c-b"
" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" " }}}
" Smooth scrolling plugin in vimscript
if has('patch4746')
Plug 'psliwka/vim-smoothie'
endif
" easy way to search and navigate the current file {{{
" f,F,t,T smarter find/till char commands
Plug 'rhysd/clever-f.vim'
" }}}
" Easy navigation around the burrent buffer.
Plug 'easymotion/vim-easymotion'
" incsearch {{{
Plug 'haya14busa/incsearch.vim'
Plug 'haya14busa/incsearch-fuzzy.vim'
" map z/ <Plug>(incsearch-fuzzy-/)
" map z? <Plug>(incsearch-fuzzy-?)
" map zg/ <Plug>(incsearch-fuzzy-stay)
map z/ <Plug>(incsearch-fuzzyspell-/)
map z? <Plug>(incsearch-fuzzyspell-?)
map zg/ <Plug>(incsearch-fuzzyspell-stay)
Plug 'haya14busa/incsearch-easymotion.vim'
Plug 'machakann/vim-highlightedyank'
if !exists('##TextYankPost')
nmap y <Plug>(highlightedyank)
xmap y <Plug>(highlightedyank)
omap y <Plug>(highlightedyank)
endif
let g:highlightedyank_highlight_duration = 200
let g:highlightedyank_highlight_in_visual = 0
" }}}
endif
" Fuzzy file finder {{{
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
nnoremap <silent> <leader><C-p> :Files<CR>
nnoremap <silent> <leader><C-l> :Buffers<CR>
" let g:fzf_layout = { 'down': "~60%" }
" let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" --column: Show column number
" --line-number: Show line number
" --no-heading: Do not show file headings in results
" --fixed-strings: Search term as a literal string
" --ignore-case: Case insensitive search
" --no-ignore: Do not respect .gitignore, etc...
" --hidden: Search hidden files and folders
" --follow: Follow symlinks
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder)
" --color: Search color options
command! -bang -nargs=* AFind call fzf#vim#grep('rg $VIM_RG_ARGS '.shellescape(<q-args>), 1, <bang>0)
command! -bang -nargs=* Rg call fzf#vim#grep( 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1, fzf#vim#with_preview(), <bang>0)
let $FZF_DEFAULT_OPTS = $FZF_DEFAULT_OPTS . ' --no-reverse'
let g:fzf_history_dir = '~/.local/share/fzf-history'
let g:fzf_buffers_jump = 1
imap <c-x><c-w> <plug>(fzf-complete-word)
imap <c-x><c-p> <plug>(fzf-complete-path)
imap <c-x><c-l> <plug>(fzf-complete-line)
" inoremap <expr> <c-x><c-p> fzf#vim#complete#path('fd')
" inoremap <expr> <c-x><c-f> fzf#vim#complete#path('rg --files')
" inoremap <expr> <c-x><c-w> fzf#vim#complete#word({'window': { 'width': 0.5, 'height': 0.8, 'xoffset': 1 }})
" Enter date
" }}}
" Rainbow plugin {{{
Plug 'junegunn/rainbow_parentheses.vim'
let g:rainbow#max_level = 16
let g:rainbow#blacklist = [175]
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]
highlight MatchParen cterm=bold
" }}}
" Align plugin {{{
Plug 'junegunn/vim-easy-align'
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" }}}
Plug 'vim-scripts/DoxygenToolkit.vim'
let g:DoxygenToolkit_authorName = $USER
Plug 'preservim/nerdcommenter'
" Directory diff in vim
Plug 'will133/vim-dirdiff'
" Perforce integration
Plug 'nfvs/vim-perforce'
" Plug 'wfxr/minimap.vim'
" directory browser {{{
" Disable netrw (file explorer) plugins
let g:loaded_netrw = 1
let g:loaded_netrwPlugin = 1
if !has('nvim')
Plug 'preservim/nerdtree'
nnoremap <F7> :NERDTreeToggle<CR>
endif
" }}}
if !has('nvim')
Plug 'ryanoasis/vim-devicons'
" Plug 'mhinz/vim-startify'
" Plug 'edkolev/tmuxline.vim'
endif
call plug#end()
filetype indent plugin on
if !has('nvim')
set mouse=a
set ttymouse=sgr
endif
set autoindent
set ttyfast
set hidden
set nomodeline
set nocompatible
set foldmethod=syntax
set path+=**
set wildmenu
runtime macros/matchit.vim
set dictionary+=/usr/share/dict/words
" Allow backspacing over autoindent, line breaks and start of insert
set backspace=indent,eol,start
" Use spaces instead of tab
set expandtab
" Specify tab size
set tabstop=2
" Indent size
set shiftwidth=2
noremap <C-s> :update<CR>
vnoremap <C-s> <C-C>:update<CR>
inoremap <C-s> <C-O>:update<CR>
" Exit if file not modified
nnoremap <leader>qq :q<CR>
" Close current window
nnoremap <leader>wd :close<CR>
" Force exit irrespective of changes
nnoremap <leader>Q :q!<CR>
" Close current buffer
nnoremap <leader>x :x<CR>
" disable Ex mode
noremap Q <Nop>
" moving around with jkl; {{{
" moving around the current buffer
nnoremap ; <Right>
nnoremap l <Up>
nnoremap k <Down>
nnoremap j <Left>
" move between windows
nmap <silent> <C-w>j :wincmd h<CR>
nmap <silent> <C-w>k :wincmd j<CR>
nmap <silent> <C-w>l :wincmd k<CR>
nmap <silent> <C-w>; :wincmd l<CR>
" move windows
nmap <silent> <C-w>J :wincmd H<CR>
nmap <silent> <C-w>K :wincmd J<CR>
nmap <silent> <C-w>L :wincmd K<CR>
nmap <silent> <C-w>: :wincmd L<CR>
" visual mode
xnoremap ; <Right>
xnoremap l <Up>
xnoremap k <Down>
xnoremap j <Left>
" operator pending
onoremap ; <Right>
onoremap l <Up>
onoremap k <Down>
onoremap j <Left>
" capitalized
nnoremap K k
xnoremap K k
onoremap K k
" }}}
" Display line numbers by default {{{
set number relativenumber
nnoremap <leader>nu :set nonumber! relativenumber!<CR>
nnoremap <leader>si :call ToggleSignColumn()<CR>
function! ToggleSignColumn()
if &signcolumn == 'no'
set signcolumn=yes
else
set signcolumn=no
endif
endfunction
augroup numbertoggle
autocmd!
" autocmd BufEnter,FocusGained,InsertLeave * set relativenumber number
" autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
autocmd BufEnter,FocusGained * set relativenumber number
autocmd BufLeave,FocusLost * set norelativenumber
augroup END
" }}}
let &scrolloff = 18
nnoremap <leader>so :let &scrolloff = 18 - &scrolloff<CR>
set smoothscroll
" do not wrap around long lines
set nowrap
" Toggle wrap around long lines
nmap <leader><C-h> <ESC>:set wrap!<CR>
" visually select the entire buffer
nnoremap <leader>av ggvG$
" yank all lines of the file and return to current position
nnoremap <leader>ay maggvG$y'a
" yank into/paste from clipboard register
set clipboard=unnamed,unnamedplus
nnoremap <leader>y "+y
nnoremap <leader>p "+p
" disable help via F1 key
nmap <F1> <>
" Map enter in normal mode to :
nnoremap <expr> <CR> &buftype ==# 'nofile' ? "\<CR>" : ':'
" ignore = in filename completion
set isfname-==
" search settings {{{
" search highlighting
set hlsearch
nmap <leader>sh <ESC>:set hlsearch!<CR>
" live search while typing, cursor returns to original position on no match or pressing ESC
set incsearch
" }}}
" ignore case while searching {{{
set ignorecase
" Toggle ignorecase while searching
nmap <leader>ic <ESC>:set ignorecase!<CR>
" }}}
" left/right to step through buffers
nnoremap L :bnext<CR>
nnoremap H :bprevious<CR>
" Move to next tag
nmap <leader>t <ESC>:tn<CR>
" Move to previous tag
nmap <leader>p <ESC>:tp<CR>
if has("autocmd")
autocmd BufNewFile,BufRead Make*,*.mk,*.make set filetype=make
autocmd BufNewFile,BufRead buildmap.config set filetype=confini
autocmd BufNewFile,BufRead buildip.config,ip*.config set filetype=yaml
autocmd BufNewFile,BufRead *.zsh set filetype=bash
autocmd BufNewFile,BufRead *.C set filetype=cpp
autocmd BufNewFile,BufRead *.vs,*.sv,*.v,*.vh set filetype=verilog
autocmd BufNewFile,BufRead *.tn set filetype=tcl
autocmd BufReadPost *.lisp,*.scm,*.rkt,*.tktl set filetype=lisp
autocmd BufReadPost *.gdbinit.urmish set filetype=gdb
autocmd filetype racket set lisp autoindent
autocmd filetype racket,lisp,scheme,commonlisp setlocal equalprg=scmindent
" Activation based on file type
autocmd FileType c,cpp setlocal formatprg=clang-format\ -style=file:$HOME/.clang-format
autocmd FileType rust setlocal formatprg=rustfmt\ --emit=stdout
if !has("nvim")
autocmd FileType c,cpp,lua,lisp,clojure,scheme,rust,python RainbowParentheses
endif
endif
" Use gs to toggle whitespace ignore in vimdiff
if &diff
syntax off
map <leader>ds :call IwhiteToggle()<CR>
function! IwhiteToggle()
if &diffopt =~ 'iwhite'
set diffopt-=iwhite
else
set diffopt+=iwhite
endif
endfunction
endif
" Highlight cursor row and column background in current window
augroup Cursor
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn
au WinLeave * setlocal nocursorline nocursorcolumn
augroup END
nnoremap <leader>edate i <C-r>=strftime('%F')<CR><ESC>
set termguicolors
" Colorscheme settings {{{
set background=dark
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_contrast_light='hard'
if !has('nvim')
colorscheme gruvbox
" highlight CursorLine ctermbg=236 guibg=#444444 cterm=none gui=none
" highlight CursorColumn ctermbg=236 guibg=#444444
" highlight CursorLineNr cterm=none gui=none
endif
" }}}