-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
292 lines (245 loc) · 7.86 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
set clipboard^=unnamed,unnamedplus
set relativenumber
" Install vim-plug if not found
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin('~/.vim/plugged')
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" Make sure you use single quotes
Plug 'junegunn/vim-plug'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
" Plug 'L9'
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
Plug 'ascenator/L9', {'name': 'newL9'}
"[1]themes
""" Theme / Pretty stuff
"""
Plug 'overcache/NeoSolarized'
Plug 'gruvbox-community/gruvbox'
Plug 'mikker/vim-togglebg'
" Awesome looking meta at bottom
" Fugitive will help with git related stuff, and show branch on statusline
Plug 'vim-airline/vim-airline' |
\ Plug 'vim-airline/vim-airline-themes' |
\ Plug 'bling/vim-bufferline'
Plug 'tpope/vim-fugitive'
Plug 'jreybert/vimagit'
Plug 'duggiefresh/vim-easydir'
"[2] IDE
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
Plug 'kshenoy/vim-signature'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdcommenter'
Plug 'jackguo380/vim-lsp-cxx-highlight'
"[3]
"FocusGained and FocusLost autocommand events are not working in terminal vim.
"This plugin restores them when using vim inside Tmux.
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'christoomey/vim-tmux-navigator'
Plug 'christoomey/vim-tmux-runner'
Plug 'tmux-plugins/vim-tmux'
"Plug 'edkolev/tmuxline.vim'
"[markdown]
"helps aligning MD tables
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'habamax/vim-asciidoctor'
"[css]display colors in files
Plug 'ap/vim-css-color'
"[rust]
Plug 'rust-lang/rust.vim'
Plug 'dense-analysis/ale'
"[fuzzy file search]
"another plugin to jump to files slower but no dependencies
Plug 'ctrlpvim/ctrlp.vim'
Plug 'dyng/ctrlsf.vim'
"TODO: check fzf
"Plug 'junegunn/fzf'
if has('nvim')
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
endif
"[session management]
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
" Initialize plugin system
call plug#end()
set pastetoggle=<F2>
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nmap <C-F>f <Plug>CtrlSFPrompt
nmap <C-F>n <Plug>CtrlSFCwordPath
nmap <C-F>p <Plug>CtrlSFPwordPath
let g:ctrlsf_compact_position = 'bottom_inside'
let g:ctrlsf_populate_qflist = 1
let g:ctrlsf_default_view_mode = 'compact'
"exclude .git and .gitignore from file search in ctrlp
let g:ctrlp_user_command = [
\'.git',
\'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_show_hidden = 1
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-git',
\ 'coc-explorer',
\ 'coc-clangd',
\ 'coc-clang-format-style-options',
\ 'coc-rust-analyzer']
let g:coc_user_config = {}
let g:coc_user_config['explorer.icon.enableNerdfont']='true'
nmap <leader>e <Cmd>CocCommand explorer<CR>
if has('nvim')
if has('termguicolors')
set termguicolors
endif
endif
syntax enable
" initialize the colorscheme for the first run
if system("gsettings get org.gnome.desktop.interface color-scheme") =~ 'dark'
set background=dark
else
set background=light
endif
let $GRUVBOX_DIR=expand("~/.vim/plugged/gruvbox")
if isdirectory($GRUVBOX_DIR)
colorscheme gruvbox
" Hack to avoid first calling togglebg#map on <F5>
let g:no_plugin_maps=1
call togglebg#map("<F6>")
unlet g:no_plugin_maps
endif
" ChangeBackground changes the background mode based on macOS's `Appearance`
" setting. We also refresh the statusline colors to reflect the new mode.
function! ChangeBackground()
execute "ToggleBG"
colorscheme gruvbox
try
execute "AirlineRefresh"
catch
endtry
execute "redraw"
endfunction
"call ChangeBackground()
" change the color scheme if we receive a SigUSR1
" autocmd Signal SIGUSR1 ToggleBG
if has('nvim')
autocmd Signal SIGUSR1 call ChangeBackground()
else
autocmd SigUSR1 * call ChangeBackground() | redraw
endif
"autocmd SigUSR1 * call ChangeBackground()
let g:airline#extensions#tabline#enabled = 1
" vim-gitgutter used to do this by default:
highlight! link SignColumn LineNr
let g:gitgutter_override_sign_column_highlight = 0
set colorcolumn=80
nnoremap <Leader>H :call<SID>LongLineHLToggle()<cr>
hi OverLength ctermbg=none cterm=none
match OverLength /\%>80v/
fun! s:LongLineHLToggle()
if !exists('w:longlinehl')
let w:longlinehl = matchadd('ErrorMsg', '.\%>80v', 0)
echo "Long lines highlighted"
else
call matchdelete(w:longlinehl)
unl w:longlinehl
echo "Long lines unhighlighted"
endif
endfunction
"asciidoc
" Fold sections, default `0`.
let g:asciidoctor_folding = 1
" Fold options, default `0`.
let g:asciidoctor_fold_options = 1
" Conceal *bold*, _italic_, `code` and urls in lists and paragraphs, default `0`.
" See limitations in end of the README
let g:asciidoctor_syntax_conceal = 1
" Highlight indented text, default `1`.
let g:asciidoctor_syntax_indented = 0
" List of filetypes to highlight, default `[]`
let g:asciidoctor_fenced_languages = ['python', 'c', 'javascript']
" rust
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
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
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
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)
if !has('nvim')
set nocompatible " be iMproved, required
filetype off " required
set encoding=UTF-8
"add mouse support
set mouse=a
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
" vim private config
set smarttab
set hlsearch
endif
set cindent
set tabstop=2
set shiftwidth=2
" always uses spaces instead of tab characters
set expandtab
set number
set path+=**
set wildmenu
"FILE BROWSING:
filetype plugin on
" Tweaks for browsing
let g:netrw_banner=0 " disable annoying banner
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
"disable arrow keys
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
autocmd BufRead,BufNewFile *.tmuxtheme set filetype=tmux