-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
231 lines (191 loc) · 5.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
221
222
223
224
225
226
227
228
229
230
231
"""
""" General
"""
" Window name
let &titlestring = @%
set title
" Syntax highlighting
syntax on
" Visual mode color
highlight Visual cterm=reverse ctermbg=NONE
" Line numbers
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" Identation
filetype plugin indent on
set tabstop=8
set softtabstop=2
set shiftwidth=2
set expandtab
" Highlight searches
set hlsearch
hi Search cterm=bold ctermfg=black ctermbg=yellow
set ignorecase smartcase
" Status line
hi Statusline ctermbg=Gray ctermfg=234
hi StatusLineNC ctermbg=Gray ctermfg=234
" Popup
hi Pmenu ctermfg=Gray ctermbg=Black guibg=Black
hi PmenuSel ctermfg=Black ctermbg=Gray guibg=Gray
hi PmenuSbar ctermfg=Black ctermbg=Gray guibg=Gray
function! InsertTabWrapper(direction)
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "backward" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper("forward")<CR>
inoremap <S-Tab> <c-r>=InsertTabWrapper("backward")<CR>
" Invisible characters
set list
set listchars=tab:ᐅ\
" Wild menu
set wildmenu
" Shared clipboard
set clipboard=unnamedplus
"""
""" Navigation and workflow
"""
" Switchbuf preferences
set switchbuf=useopen,split,usetab
" Pane navigation
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Tab bar
hi TabLineFill ctermfg=Black ctermbg=White
hi TabLine ctermfg=Blue ctermbg=Black
hi TabLineSel ctermfg=Red ctermbg=Black
" Buffers
set hidden
nmap <leader>bl :ls<CR>
nmap <leader>j :bnext<CR>
nmap <leader>k :bprevious<CR>
nmap <leader>bn :enew<cr>
nmap <leader>bc :bp <BAR> bd #<CR>
" Splits
hi VertSplit ctermfg=Black ctermbg=White
set fillchars+=vert:\
" Location list
noremap <leader>lo :lopen<CR>
noremap <leader>lc :lclose<CR>
" Quickfix list
noremap <leader>co :copen<CR>
noremap <leader>cc :cclose<CR>
" Preview windows
noremap <leader>pc :pclose<CR>
" Navigating with guides
inoremap ;;<Space> <Esc>/<++><Enter>"_c4l
vnoremap ;;<Space> <Esc>/<++><Enter>"_c4l
map ;;<Space> <Esc>/<++><Enter>"_c4l
inoremap ;gui <++>
"""
""" Utilities
"""
" Reload Vim config file
nnoremap <Leader>sv :so ~/.vimrc<CR>
" Highlight trailing whitespaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
"autocmd BufWinLeave * call clearmatches()
" Cursor line
hi CursorLine cterm=NONE ctermbg=233
nnoremap <Leader>c :set cursorline!<CR>
" Copy and paste on X clipboard
map <leader>xcc :w !xsel -i -b<CR>
map <leader>xcp :w !xsel -i -p<CR>
map <leader>xcs :w !xsel -i -s<CR>
map <leader>xpp :r!xsel -p<CR>
map <leader>xps :r!xsel -s<CR>
map <leader>xpb :r!xsel -b<CR>
" Spell-check:
hi clear SpellBad
hi SpellBad cterm=underline ctermfg=1
hi clear SpellRare
hi SpellRare cterm=underline
hi clear SpellCap
hi SpellCap cterm=underline
hi clear SpellLocal
hi SpellLocal cterm=underline
let g:myLang = 0
let g:myLangList = ['nospell', 'en_us', 'pt_pt']
function! MySpellLang()
if g:myLang == 0 | setlocal nospell | endif
if g:myLang == 1 | let &l:spelllang = g:myLangList[g:myLang] | setlocal spell | endif
if g:myLang == 2 | let &l:spelllang = g:myLangList[g:myLang] | setlocal spell | endif
echomsg 'Spellcheck language:' g:myLangList[g:myLang]
let g:myLang = g:myLang + 1
if g:myLang >= len(g:myLangList) | let g:myLang = 0 | endif
endfunction
map <F7> :<C-U>call MySpellLang()<CR>
" Find (grep)
nnoremap <Leader>fg :exec ":Grep ".input("grep: ")<CR>
nnoremap <Leader>fr :exec ":Rg ".input("ripgrep: ")<CR>
" Omnicomplete
inoremap <Tab> <C-n>
"""
""" Plugin specific
"""
" Filetype
set nocompatible
filetype plugin on
let g:vimwiki_ext2syntax = {
\ '.Rmd': 'markdown',
\ '.rmd': 'markdown',
\ '.md': 'markdown',
\ '.markdown': 'markdown',
\ '.mdown': 'markdown'
\}
" NERDTree
map <C-n> :NERDTreeToggle<CR>
" Tagbar
nmap <F8> :TagbarToggle<CR>
" auto-pairs
let g:AutoPairsShortcutToggle = '<Leader>p'
" ALE
nnoremap <Leader>gt :ALEGoToDefinition<CR>
nnoremap <Leader>gr :ALEFindReferences<CR>
nnoremap <Leader>gd :ALEHover<CR>
nnoremap <Leader>gs :ALESymbolSearch<CR>
nnoremap <Leader>gR :ALERename<CR>
let g:ale_completion_enabled = 1
let g:ale_completion_autoimport = 1
let g:ale_set_balloons = 1
let g:ale_sign_error = 'E'
let g:ale_sign_warning = 'W'
let g:ale_echo_msg_format = '[%severity%] %s (%code%) [%linter%]'
let g:ale_cpp_ccls_init_options = {
\ 'cache': {
\ 'directory': expand("$HOME/.cache/ccls")
\ }
\}
" vim-android
let g:android_sdk_path = expand("$ANDROID_HOME")
let g:gradle_loclist_show = 0
let g:gradle_show_signs = 0
augroup GradleGroup
autocmd!
au BufWrite build.gradle* call gradle#sync()
augroup END
" indentLine
let g:indentLine_char = '▏'
let g:indentLine_color_term = 234
let g:indentLine_concealcursor = 'inc'
let g:indentLine_conceallevel = 1
set list lcs=tab:\▏\
highlight SpecialKey ctermfg=234
" CamelCaseMotion
let g:camelcasemotion_key = '<leader>'