-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot-vimrc
More file actions
305 lines (232 loc) · 8.37 KB
/
dot-vimrc
File metadata and controls
305 lines (232 loc) · 8.37 KB
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
" ============================ Vundle ========================================
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Indentwise, movement based on indentation level
Plugin 'jeetsukumaran/vim-indentwise'
" Buffer Explorer, to navigate opened buffers quickly
Plugin 'jlanzarotta/bufexplorer'
" Some Tim Pope's plugins
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-unimpaired'
" LightLine at the bottom of the screen
Plugin 'itchyny/lightline.vim'
" File tree at the left side
Plugin 'preservim/nerdtree'
" Plugion to make % command follow different language constructions
Plugin 'adelarsq/vim-matchit'
" Vim crystal support
Plugin 'vim-crystal/vim-crystal'
" GitGutter, line at the left of the buffer that shows git tracked changes
Plugin 'airblade/vim-gitgutter'
" YCM from GitHub
Plugin 'ycm-core/YouCompleteMe.git'
" Tagbar
Plugin 'preservim/tagbar'
" Minimap
Plugin 'severin-lemaignan/vim-minimap'
" Fzf
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
" FAR, Find And Replace plugin
Plugin 'brooth/far.vim'
" Voltrix color scheme
Plugin 'volbot/voltrix.vim'
Plugin 'rafi/awesome-vim-colorschemes'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" ============================== Common Vim setup =============================
set encoding=utf-8
" set ttymouse=xterm2
set mouse=a
set hlsearch
set incsearch
set ignorecase
set smartcase
set hidden
set wildmenu
set showcmd
" colorscheme tender
colorscheme voltrix
" Autoreload files
set autoread
au FocusGained,BufEnter * :silent! !
" Ctrl+C/+V clipboard
vnoremap <C-Insert> "+y
vnoremap <C-Del> "+d
" Close buffer without closing the window
nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
" Line numbers and stuff...
set number
set relativenumber
highlight LineNr term=bold cterm=NONE ctermbg=17 ctermfg=11
" Highlight extra whitespaces
highlight ExtraWhitespace ctermbg=darkred guibg=darkred
match ExtraWhitespace /\s\+$/
" Use 4 spaced for indentation by default
set shiftwidth=4
set softtabstop=4
set tabstop=4
set expandtab
set colorcolumn=80
highlight ColorColumn ctermbg=darkgrey guibg=darkgrey
" nnoremap <F9> za
" nnoremap <C-F9> zr
" nnoremap <S-F9> zm
set scrolloff=3
" Grep the word under the cursor
nnoremap <leader>gw :grep <C-R><C-W> . -Irn<CR>
" Grep the WORD under the cursor
nnoremap <leader>gW :grep <C-R><C-A> . -Irn<CR>
" ====================== Some scripts above standard vim =====================
function! UndoIfShellError()
if v:shell_error
undo
endif
endfunction
" Use F8 to format selected json fragment in visual mode, fallback on error
vnoremap <F8> :!python3 -m json.tool<CR>:call UndoIfShellError()<CR>
" Search for visually selected text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
" Hide highlight on Ctrl+/
nnoremap <silent> <c-_> :nohl<CR>
" Automatically recognize HAR files as JSON (which they really are)
au BufRead,BufNewFile *.har set ft=json
" Stolen from defaults.vim
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
augroup END
" Copy current file name to clipboard
nmap <leader>cf :let @+=expand("%")<CR>
nmap <leader>cp :let @+=expand("%:p")<CR>
nmap <leader>yf :let @*=expand("%")<CR>
nmap <leader>yp :let @*=expand("%:p")<CR>
" ========================== Per-filetype indentation =========================
" Use 2 spaced in .cr files
autocmd FileType crystal setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab
" Use 2 spaced in .yamlfiles
autocmd FileType yaml setlocal shiftwidth=2 softtabstop=2 tabstop=2 expandtab
filetype indent plugin on
" =========================== Per-filetype functions ==========================
" autocmd FileType crystal nnoremap <C-f> :g/def <CR>
" autocmd FileType crystal set foldmethod=syntax
" autocmd FileType crystal set foldlevel=5
" Use ':set foldlevel' ;)
" =============================== Bufer explorer ==============================
" Buffer explorer key mapping
nnoremap <F2> :ToggleBufExplorer<CR>
" =============================== LightLine ===================================
set laststatus=2
" ================================ NERDTree ===================================
nnoremap <F3> :NERDTreeFocus<CR>
" This is a tricky part: the 'ESCAPE' symbol has to be pasted.
" Press Ctrl+V and the desired keystroke
set <S-F3>=[1;2R
nnoremap <S-F3> :NERDTreeToggle<CR>
" ============================= NERD Commenter ================================
let g:NERDCustomDelimiters = { 'crystal': { 'left': '# '} }
" ================================= Tagbar ====================================
nnoremap <F4> :TagbarOpenAutoClose<CR>
set <S-F4>=[1;2S
nnoremap <S-F4> :TagbarToggle<CR>
let g:tagbar_type_crystal = {
\ 'ctagstype': 'crystal',
\ 'kinds' : [
\'d:defs',
\'f:functions',
\'c:classes',
\'m:modules',
\'l:libs',
\'s:structs'
\]
\}
" Some additional tags related stuff
" Regenerate tags on <leader><F4>
nnoremap <leader><F4> :!ctags -R .<CR>
" ================================== fzf ======================================
" Browse tags on <leader>p
" nnoremap <leader>p :CtrlPTag<CR>
nnoremap <C-p> :Files<CR>
nnoremap <leader>p :Tags<CR>
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" =============================== gitgutter ===================================
" shows git status marks in left column
let g:gitgutter_set_sign_backgrounds = 1
highlight SignColumn ctermbg=black
highlight GitGutterAdd ctermbg=black ctermfg=green guifg=#009900
highlight GitGutterChange ctermbg=black ctermfg=yellow guifg=#bbbb00
highlight GitGutterDelete ctermbg=black ctermfg=red guifg=#ff2222
" Integrate GitGutter status into LightLine
function! GitStatus()
let [a,m,r] = GitGutterGetHunkSummary()
return printf('git: +%d / ~ %d / - %d', a, m, r)
endfunction
let g:lightline = {
\ 'colorscheme': 'powerline',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified', 'gitgutter' ] ]
\ },
\ 'component': {
\ 'gitgutter': ''
\ },
\ 'component_function': {
\ 'gitgutter': 'GitStatus'
\ },
\ }
" ============================ YouCompleteMe setup ============================
command! YD :YcmComplete GoToDefinition
let g:ycm_auto_hover = ''
nnoremap <leader>h <plug>(YCMHover)
" let g:ycm_language_server =
" \ [
" \ {
" \ 'name': 'crystal',
" \ 'cmdline': [ 'crystalline'],
" \ 'project_root_files' : [ 'shard.yml' ],
" \ 'filetypes': [ 'crystal' ]
" \ }
" \ ]
" Uncomment to see YCM <-> LSP log in the stderr log of ycmd
" let g:ycm_log_level='debug'
let g:ycm_autoclose_preview_window_after_insertion = 1
" =============================== CoC setup ===================================
" source ~/.vim/coc_setup.vim
" ============================ debugger setup ================================
packadd termdebug
" ================================== FAR ======================================
" Search for visually selected text
vnoremap /F y:F <C-R>=escape(@",'/\')<CR><CR>