-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
executable file
·253 lines (197 loc) · 7.76 KB
/
init.vim
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
call plug#begin()
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()
scriptencoding utf-8
" ============================================================================ "
" === EDITING OPTIONS === "
" ============================================================================ "
" Remap leader key to ,
let g:mapleader=','
" Don't show last command
set noshowcmd
" Yank and paste with the system clipboard
set clipboard=unnamed
" Hides buffers instead of closing them
set hidden
" === TAB/Space settings === "
" Insert spaces when TAB is pressed.
set expandtab
" Change number of spaces that a <Tab> counts for during editing ops
set softtabstop=4
" Indentation amount for < and > commands.
set shiftwidth=4
" do not wrap long lines by default
set nowrap
" Disable line/column number in status line
" Shows up in preview window when airline is disabled if not
set noruler
" Only one line for command line
set cmdheight=1
" === Completion Settings === "
" Don't give completion messages like 'match 1 of 2'
" or 'The only match'
set shortmess+=c
" ============================================================================ "
" === PLUGIN SETUP === "
" ============================================================================ "
" === Coc.nvim === "
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ?
\ "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
"Close preview window when completion is done.
" autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
" Wrap in try/catch to avoid errors on initial install before plugin is available
try
" === Vim airline ==== "
" Enable extensions
let g:airline_extensions = ['branch', 'hunks', 'coc']
" Update section z to just have line number
let g:airline_section_z = airline#section#create(['linenr'])
" Do not draw separators for empty sections (only for the active window) >
let g:airline_skip_empty_sections = 1
" Smartly uniquify buffers names with similar filename, suppressing common parts of paths.
let g:airline#extensions#tabline#formatter = 'unique_tail'
" Custom setup that removes filetype/whitespace from default vim airline bar
let g:airline#extensions#default#layout = [['a', 'b', 'c'], ['x', 'z', 'warning', 'error']]
" Enable powerline fonts
let g:airline_powerline_fonts = 1
" Enable caching of syntax highlighting groups
let g:airline_highlighting_cache = 1
" Define custom airline symbols
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" Don't show git changes to current file in airline
let g:airline#extensions#hunks#enabled=0
catch
echo 'Airline not installed. It should work after running :PlugInstall'
endtry
" ============================================================================ "
" === UI === "
" ============================================================================ "
" Enable true color support
set termguicolors
" Vim airline theme
let g:airline_theme='minimalist'
" Change vertical split character to be a space (essentially hide it)
set fillchars+=vert:.
" Set preview window to appear at bottom
set splitbelow
" Don't dispay mode in command line (airilne already shows it)
set noshowmode
" Set floating window to be slightly transparent
set winbl=10
" ============================================================================ "
" === CUSTOM COLORSCHEME CHANGES === "
" ============================================================================ "
"
" Add custom highlights in method that is executed every time a colorscheme is sourced
" See https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f for details
function! TrailingSpaceHighlights() abort
" Hightlight trailing whitespace
highlight Trail ctermbg=red guibg=red
call matchadd('Trail', '\s\+$', 100)
endfunction
function! s:custom_jarvis_colors()
" coc.nvim color changes
hi link CocErrorSign WarningMsg
hi link CocWarningSign Number
hi link CocInfoSign Type
" Make background transparent for many things
hi Normal ctermbg=NONE guibg=NONE
hi NonText ctermbg=NONE guibg=NONE
hi LineNr ctermfg=NONE guibg=NONE
hi SignColumn ctermfg=NONE guibg=NONE
hi StatusLine guifg=#16252b guibg=#6699CC
hi StatusLineNC guifg=#16252b guibg=#16252b
" Try to hide vertical spit and end of buffer symbol
hi VertSplit gui=NONE guifg=#17252c guibg=#17252c
hi EndOfBuffer ctermbg=NONE ctermfg=NONE guibg=#17252c guifg=#17252c
" Make background color transparent for git changes
hi SignifySignAdd guibg=NONE
hi SignifySignDelete guibg=NONE
hi SignifySignChange guibg=NONE
" Highlight git change signs
hi SignifySignAdd guifg=#99c794
hi SignifySignDelete guifg=#ec5f67
hi SignifySignChange guifg=#c594c5
endfunction
autocmd! ColorScheme * call TrailingSpaceHighlights()
autocmd! ColorScheme OceanicNext call s:custom_jarvis_colors()
" Call method on window enter
augroup WindowManagement
autocmd!
autocmd WinEnter * call Handle_Win_Enter()
augroup END
" Change highlight group of preview window when open
function! Handle_Win_Enter()
if &previewwindow
setlocal winhighlight=Normal:MarkdownError
endif
endfunction
" Editor theme
set background=dark
try
colorscheme OceanicNext
catch
colorscheme slate
endtry
" ============================================================================ "
" === KEY MAPPINGS === "
" ============================================================================ "
" === coc.nvim === "
" <leader>dd - Jump to definition of current symbol
" <leader>dr - Jump to references of current symbol
" <leader>dj - Jump to implementation of current symbol
" <leader>ds - Fuzzy search current project symbols
nmap <silent> <leader>dd <Plug>(coc-definition)
nmap <silent> <leader>dr <Plug>(coc-references)
nmap <silent> <leader>dj <Plug>(coc-implementation)
nnoremap <silent> <leader>ds :<C-u>CocList -I -N --top symbols<CR>
" Allows you to save files you opened without write permissions via sudo
cmap w!! w !sudo tee %
" Delete current visual selection and dump in black hole buffer before pasting
" Used when you want to paste over something without it getting copied to
" Vim's default buffer
vnoremap <leader>p "_dP
" In windows, <C-v> is used for pasting. We map <C-b> to <C-v> to enable
" visual block mode.
" ============================================================================ "
" === MISC. === "
" ============================================================================ "
" === Search === "
" ignore case when searching
set ignorecase
" if the search string has an upper case letter in it, the search will be case sensitive
set smartcase
" Automatically re-read file if a change was detected outside of vim
set autoread
" Enable line numbers
set number
" Enable spellcheck for markdown files
autocmd BufRead,BufNewFile *.md setlocal spell
" Set backups
if has('persistent_undo')
set undofile
set undolevels=3000
set undoreload=10000
endif
set backupdir=~/.local/share/nvim/backup " Don't put backups in current dir
set backup
set noswapfile
" Reload icons after init source
if exists('g:loaded_webdevicons')
call webdevicons#refresh()
endif