-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
220 lines (173 loc) · 6.22 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
source ~/.vim/bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
" toggle filetype off and on: needed for certain plugins
filetype off
filetype indent plugin on
set nocompatible " vanilla vi: not even once
" tab settings: expand to 4 spaces
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoindent " start line at same indentation as previous line
set backspace=indent,eol,start " allow backspacing over these
set showmode " show if in INSERT mode
set showcmd " show command being typed
set ruler " show line and column of cursor
set scrolloff=3 " 3 lines above or below cursor
set laststatus=2 " always show status bar at bottom
set wildmode=list:longest,full " do bash-style tab-completion
set wildmenu " pop-up menu when multiple matches for tab-completion
set wildignore+=.git,.hg,.svn " version control files
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.o,*.so,*.a " object files
set wildignore+=*.swp,*.swo " vim swap files
set nohls " don't highlight search results
set ignorecase " search is case-insensitive
set smartcase " ...unless the search contains uppercase letters
set showmatch " brief jump to matching bracket
set incsearch " start searching before hitting Enter
set nomodeline " I never use these, and it sometimes breaks git commits
set splitbelow " make :split create the new window below
set splitright " make :vsplit create the new window on right
" fix Windows bug with :2R in new windows
set t_u7=
" resize splits when window is resized
au VimResized * exe "normal! \<c-w>="
" go up/down by a screen line instead of by text line
nnoremap j gj
nnoremap k gk
" use brighter colors, but only in terminal
if has('gui_running')
set background=light
else
set background=dark
endif
set mouse=a " mouse support in all modes
if has('mouse_sgr')
set ttymouse=sgr
else
set ttymouse=xterm2
end
" .ll files should use llvm syntax highlighting
au BufNewFile,BufRead *.ll set filetype=llvm
" .td files should use tablegen syntax highlighting
au BufNewFile,BufRead *.td set filetype=tablegen
" .xe_asm files should use asm syntax highliting
au BufNewFile,BufRead *.xe_asm set filetype=asm
" swarm2c files should use C syntax highlighting
au BufNewFile,BufRead *.swc set filetype=c
au BufNewFile,BufRead *.swh set filetype=c
" Persisent undo
set undodir=~/.vim/tmp/undo//
set undofile
set backupdir=~/.vim/tmp/backup//
set backup
set directory=~/.vim/tmp/swap//
" better-looking completion menus
highlight PMenu ctermbg=grey
highlight PMenuSel cterm=reverse
" mapping to remove trailing whitespace in current file
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Turn on folding for XML files
let g:xml_syntax_folding=1
au FileType xml setlocal foldmethod=syntax
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" Ye shall be judged
iabbrev ldis ಠ_ಠ
" Quick jump to beginning or end of line
noremap H ^
noremap L g_
" Easy buffer navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <leader>v <C-w>v
" Reduce pinky strain
nnoremap ; :
" Easily create blank lines
nnoremap <Enter> o<ESC>
nnoremap <S-Enter> O<ESC>
augroup ft_statuslinecolor
au!
au InsertEnter * hi StatusLine ctermfg=196 guifg=#FF3145
au InsertLeave * hi StatusLine ctermfg=130 guifg=#CD5907
augroup END
" Linediff mappings
vnoremap <leader>l :Linediff<cr>
nnoremap <leader>L :LinediffReset<cr>
" Show name of current C function
fun! ShowFuncName()
let lnum = line(".")
let col = col(".")
echohl ModeMsg
echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
echohl None
call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun
map <leader>f :call ShowFuncName() <CR>
" Don't exit visual mode after shifting
vnoremap < <gv
vnoremap > >gv
" Return to normal mode on FocusLost
au FocusLost * call feedkeys("\<C-\>\<C-n>")
" Options for powerline
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_linecolumn_prefix = '␊ '
let g:airline_linecolumn_prefix = ' '
let g:airline_linecolumn_prefix = '¶ '
let g:airline_branch_prefix = '⎇ '
let g:airline_paste_symbol = 'ρ'
let g:airline_paste_symbol = 'Þ'
let g:airline_paste_symbol = '∥'
let g:airline_whitespace_symbol = 'Ξ'
" Disable bell, since vim ignores /etc/inputrc
set visualbell
set t_vb=
let g:coc_global_extensions = [ 'coc-python' ]
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" 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> <NUL> 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>"
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <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')
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)