-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
executable file
·268 lines (219 loc) · 8.55 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
"akhil's .vimrc
syntax enable " Turn on syntax highlighting.
runtime macros/matchit.vim
filetype plugin indent on
let mapleader="\<space>" " Maps space-bar as the leader key.
let g:python3_host_prog = "/opt/homebrew/bin/python3"
set nrformats= "This will cause Vim to treat all numerals as decimal, regardless of whether they are padded with zeros(would be treated octal otherwise).
set shiftwidth=4 softtabstop=4 expandtab
set showcmd " Display incomplete commands.
set noshowmode " Show mode unnecessary because it is visble in airline.
set backspace=indent,eol,start " Intuitive backspacing.
set wildmenu " Complete files like a z-shell.
set wildmode=full
set history=1000
set ignorecase " Case-insensitive searching.
set infercase " Smart Keyword autocompletion.
set smartcase " But case-sensitive if expression contains a capital letter.
set number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set nobackup " Don't make a backup before overwriting
set nowritebackup " And again.
set cursorline
set hidden
set encoding=utf-8
set signcolumn=yes
set clipboard=unnamed
set guifont=monaco:h12
" open all folds by default.
autocmd BufRead * normal zR
" Install vim-plug if it's not already installed. Use PlugInstall to install all the below plugins post that. (only works for *inx/cygwin).
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.github.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugins installations using vim-plug.
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
" Editing
Plug 'mbbill/undotree'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-obsession'
Plug 'jiangmiao/auto-pairs'
" Aesthetics
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Search & Navigation
Plug 'mhinz/vim-grepper'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'easymotion/vim-easymotion'
" Programming
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-dispatch'
Plug 'editorconfig/editorconfig-vim'
" LSP and Autocompletion.
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'SirVer/ultisnips' " Snippets engine.
Plug 'honza/vim-snippets' " Snippets are separated from the engine. Add this if you want them:
Plug 'thomasfaingnaert/vim-lsp-snippets'
Plug 'thomasfaingnaert/vim-lsp-ultisnips'
" File format specific
Plug 'chrisbra/csv.vim'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
call plug#end()
" =============================
" ****PLUGIN CONFIGURATIONS.****
" =============================
"Mapping for undotree.
nnoremap <F5> :UndotreeToggle<CR>
" Use gruvbox for colorscheme.
colorscheme gruvbox
set background=dark
"Mapping for tagbar (as specified by it's author)
nmap <leader>m :TagbarToggle<CR>
" ========================================
" Grepper mappings.
" ========================================
let g:grepper = {}
let g:grepper.tools = [ 'ag', 'grep', 'git']
" Fires search tools.
nnoremap <leader>ga :Grepper -tool ag<cr>
nnoremap <leader>gg :Grepper -tool grep<cr>
" Search for the current word
nnoremap <leader>g* :Grepper -cword -noprompt<CR>
" Search for the current selection
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" =================================
"Configurations from Practical Vim.
" =================================
"Ex Commands mapping from practical vim.
"Mapping for :edit %:h<Tab> //Practical vim Tip #41.
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
"Normal Mode key mappings from practical vim.
nnoremap <f3> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --exclude=.git .<CR>
noremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
"Tab mappings.
map <leader>tt :tabnew<cr>
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
"Settings for visual selection search
xnoremap * :<C-u>call <SID>VSetSearch()<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch()<CR>?<C-R>=@/<CR><CR>
function! s:VSetSearch()
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, '/\'), '\n', '\\n', 'g')
let @s = temp
endfunction
"Settings for visual selection search ==ENDS
"Vim-Script to use :Qargs to populate argument-list with quickfix-list.
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" ============================
"Configurations from Modern Vim.
" ============================
"Keybinding for FZF plugin
set rtp+=/opt/homebrew/opt/fzf
nnoremap <C-p> :<C-u>FZF<CR>
let g:fzf_nvim_statusline = 0 " disable statusline overwriting
nnoremap <silent> <leader>ff :Files<CR>
nnoremap <silent> <leader>fb :Buffers<CR>
nnoremap <silent> <leader>fw :Windows<CR>
nnoremap <silent> <leader>fl :BLines<CR>
nnoremap <silent> <leader>fO :BTags<CR>
nnoremap <silent> <leader>ft :Tags<CR>
nnoremap <silent> <leader>f: :History:<CR>
nnoremap <silent> <leader>f/ :History/<CR>
nnoremap <silent> <leader>fc :Commands<CR>
imap <C-x><C-f> <plug>(fzf-complete-file-ag)
imap <C-x><C-l> <plug>(fzf-complete-line)
" vim-commentary comment configuration for cmake.
autocmd FileType cmake setlocal commentstring=#\ %s
" Key bindings for switching windows.
" Normal mode
nnoremap <leader>h <C-w>h
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
tnoremap <Esc> <C-\><C-n>
tnoremap <C-]> <C-\><C-n>
"<c-v><Esc> for sending Esc key to the program running in Terminal mode.
tnoremap <C-v><Esc> <Esc>
"terminal-cursor is marked in red when changing to normal mode.
highlight! TermCursorNC guibg=red guifg=white ctermbg=1 ctermfg=15
" terminal-mode
tnoremap <leader><leader>h <c-\><c-n><c-w>h
tnoremap <leader><leader>j <c-\><c-n><c-w>j
tnoremap <leader><leader>k <c-\><c-n><c-w>k
tnoremap <leader><leader>l <c-\><c-n><c-w>l
nnoremap <leader>xd :LspDefinition<cr>
nnoremap <leader>xp :LspPeekDefinition<cr>
nnoremap <leader>xx :LspDeclaration<cr>
nnoremap <leader>xc :LspPeekDeclaration<cr>
nnoremap <leader>xr :LspRename<cr>
nnoremap <leader>xw :LspReferences<cr>
nnoremap <leader>xh :LspHover<cr>
nnoremap <leader>xa :LspCodeAction<cr>
nnoremap <leader>xs :LspDocumentSymbol<cr>
nnoremap <leader>xf :LspDocumentFormat<cr>
nnoremap <leader>xp :LspWorkspaceSymbol<cr>
nnoremap <leader>x] :LspNextError <cr>
nnoremap <leader>x[ :LspPreviousError <cr>
" air-line
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
" set foldmethod=expr
" \ foldexpr=lsp#ui#vim#folding#foldexpr()
" \ foldtext=lsp#ui#vim#folding#foldtext()
" ultisnips settings
let g:UltiSnipsExpandTrigger="<tab>" " use <Tab> to trigger autocompletion
let g:UltiSnipsJumpForwardTrigger="<c-n>"
let g:UltiSnipsJumpBackwardTrigger="<c-p>"
" Obsession key mappings
nnoremap <leader>o :Obsess<cr>
nnoremap <leader>s :Obsess!<cr>
" UltiSnips Trigger configuration.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" copied from https://github.com/thomasfaingnaert/vim-lsp-ultisnips
if executable('clangd')
augroup vim_lsp_cpp
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ })
autocmd FileType c,cpp,objc,objcpp,cc setlocal omnifunc=lsp#complete
augroup end
endif