-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
226 lines (182 loc) · 7.23 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
" VIM SETTINGS
set mouse=a
set encoding=utf-8
set scrolloff=5
set history=1000 " Keep 1000 lines of history.
set ruler " Always show the cursor position.
set number
set relativenumber " Show line numbers relative to cursor where cursor number is always zero.
set termguicolors
" OSX stupid backspace fix
set backspace=indent,eol,start
set expandtab " Use spaces instead of tabs when indenting.
set smarttab " Indent instead of tabbing at the beginning of a line.
set shiftwidth=4 " Indent by 2 spaces.
set tabstop=4 " Hard tab stop.
set softtabstop=4 " Soft tab stop.
set incsearch " Incrementally highlight search pattern as it is updated.
set hlsearch " Highlight search matches after entering search pattern.
set ignorecase " Use case insensitive search pattern matching by default.
set smartcase " Override 'ignorecase' setting if search pattern contains uppercase characters.
set spell " Enable spell checking.
set complete+=kspell " Enables use of CONTROL+N or CONTROL+P within Insert mode to complete words being typed.
set winwidth=120 " Default window width.
set winheight=10 " Default window height.
set winminheight=10 " Minimum window height.
set winheight=1000 " Reset window height.
set tags=./.tags; " Use CTags as generated by Sublime Text.
syntax on " Enable syntax highlighting.
filetype plugin indent on " Enable file type specific indentation.
" Buffer configuration
set hidden
colorscheme gruvbox
set bg=dark
" Vim-Airline Configuration
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='dark_minimal'
let g:hybrid_custom_term_colors = 1
let g:hybrid_reduced_contrast = 1
let g:airline_section_b = '%{strftime("%c")}'
let g:airline_section_y = 'BN: %{bufnr("%")}'
" Delete trailing whitespaces when saving
" http://vim.wikia.com/wiki/Remove_unwanted_spaces
autocmd FileType c,cpp,php,yaml,py autocmd BufWritePre <buffer> %s/\s\+$//e
" Auto-Commands
autocmd FileType gitcommit setlocal spell " Enables spell checking for Git commits.
autocmd FileType markdown setlocal spell " Enables spell checking for Markdown files.
" Extensions
" execute pathogen#infect()
runtime macros/matchit.vim
" Coc config
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-clangd',
\ 'coc-yaml',
\ 'coc-python',
\ 'coc-markdownlint',
\ ]
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
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 the symbol and its references when holding the
" cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current line.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Mappings using CoCList:
" Show all diagnostics.
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
map <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
map <silent> <space>p :<C-u>CocListResume<CR>
" Grepper config
let g:grepper = {}
let g:grepper.tools = ['rg', 'git']
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" NERDTree settings
" NERDTree shows when opening vim without file or with a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
:let g:NERDTreeWinSize=60 " NERDTree window width
let NERDTreeShowHidden=1 " NERDTree shows hidden files
" NERDTree toggle
map <C-n> :NERDTreeToggle<CR>
" Close VIM if NERDTree is the last opened window
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" sync open file with NERDTree
" Check if NERDTree is open or active
function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a
" modifiable file, and we're not in vimdiff
function! SyncTree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
" Highlight currently open buffer in NERDTree
autocmd BufEnter * call SyncTree()
" CtrlP settings
" Ignore files ignored by git
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" TagBar settings
map <C-m> :TagbarToggle<CR>
" UltiSnips default folder
let g:UltiSnipsSnippetDirectories = ['~/.vim/pack/gabriel/start/my-snippets', '../my-snippets', '~/.vim/pack/gabriel/start/vim-snippets', 'UltiSnips']
"Youcompleteme fix
let g:ycm_global_ycm_extra_conf = '~/.vim/pack/gcuendet/start/youcompleteme/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsEditSplit = "context"
" Leaders
map <Leader>i mmgg=G`m
map <Leader>cs :nohlsearch<cr>
" Remap
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" GoTo code navigation.