diff options
Diffstat (limited to '.config/nvim/init.vim')
-rwxr-xr-x | .config/nvim/init.vim | 199 |
1 files changed, 74 insertions, 125 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index ee6007c..24fe7ba 100755 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim | |||
@@ -1,8 +1,8 @@ | |||
1 | "{{{ Plugs | 1 | "{{{ Plugs |
2 | call plug#begin('~/.local/share/nvim/plugged') | 2 | call plug#begin('~/.local/share/nvim/plugged') |
3 | 3 | ||
4 | "A code-completion engine for Vim | 4 | "completion |
5 | Plug 'Valloric/YouCompleteMe' | 5 | Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } |
6 | "syntax checking | 6 | "syntax checking |
7 | Plug 'w0rp/ale' | 7 | Plug 'w0rp/ale' |
8 | "manages tag files | 8 | "manages tag files |
@@ -25,7 +25,7 @@ Plug 'majutsushi/tagbar' | |||
25 | "status/tabline | 25 | "status/tabline |
26 | Plug 'bling/vim-airline' | 26 | Plug 'bling/vim-airline' |
27 | 27 | ||
28 | " color theme. | 28 | " color themes |
29 | Plug 'arcticicestudio/nord-vim' | 29 | Plug 'arcticicestudio/nord-vim' |
30 | Plug 'aonemd/kuroi.vim' | 30 | Plug 'aonemd/kuroi.vim' |
31 | 31 | ||
@@ -40,8 +40,6 @@ Plug 'lervag/vimtex' | |||
40 | Plug 'nathanaelkane/vim-indent-guides' | 40 | Plug 'nathanaelkane/vim-indent-guides' |
41 | "text alignment | 41 | "text alignment |
42 | Plug 'godlygeek/tabular' | 42 | Plug 'godlygeek/tabular' |
43 | "access cheat.sh sheets | ||
44 | Plug 'dbeniamine/cheat.sh-vim' | ||
45 | "color code highlight | 43 | "color code highlight |
46 | Plug 'chrisbra/Colorizer' | 44 | Plug 'chrisbra/Colorizer' |
47 | "move selections up and down | 45 | "move selections up and down |
@@ -49,7 +47,7 @@ Plug 'matze/vim-move' | |||
49 | 47 | ||
50 | "folding ledger files | 48 | "folding ledger files |
51 | Plug 'ledger/vim-ledger' | 49 | Plug 'ledger/vim-ledger' |
52 | "reporen files at your last edit position | 50 | "reopen files at your last edit position |
53 | Plug 'farmergreg/vim-lastplace' | 51 | Plug 'farmergreg/vim-lastplace' |
54 | "toggle, display and navigate marks | 52 | "toggle, display and navigate marks |
55 | Plug 'kshenoy/vim-signature' | 53 | Plug 'kshenoy/vim-signature' |
@@ -91,9 +89,6 @@ call plug#end() " required | |||
91 | "}}} | 89 | "}}} |
92 | 90 | ||
93 | "{{{Auto Commands | 91 | "{{{Auto Commands |
94 | " Automatically cd into the directory that the file is in | ||
95 | autocmd BufEnter * silent! lcd %:p:h | ||
96 | |||
97 | " Remove any trailing whitespace that is in the file | 92 | " Remove any trailing whitespace that is in the file |
98 | autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | 93 | autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif |
99 | 94 | ||
@@ -106,7 +101,15 @@ autocmd VimResized * :wincmd = | |||
106 | "}}} | 101 | "}}} |
107 | 102 | ||
108 | "{{{Misc Settings | 103 | "{{{Misc Settings |
109 | let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' | 104 | |
105 | " Use deoplete. | ||
106 | let g:deoplete#enable_at_startup = 1 | ||
107 | |||
108 | " interact with system clipboard | ||
109 | set clipboard=unnamed,unnamedplus | ||
110 | |||
111 | " required for yoink/cutlass/subversive interaction | ||
112 | let g:yoinkIncludeDeleteOperations = 1 | ||
110 | 113 | ||
111 | " Tab stuff | 114 | " Tab stuff |
112 | set autoindent | 115 | set autoindent |
@@ -114,14 +117,17 @@ set expandtab " Use appropriate number of spaces to insert a <Tab> | |||
114 | set shiftwidth=4 | 117 | set shiftwidth=4 |
115 | set softtabstop=4 | 118 | set softtabstop=4 |
116 | set tabstop=8 | 119 | set tabstop=8 |
120 | |||
117 | " Use english for spellchecking, but don't spellcheck by default | 121 | " Use english for spellchecking, but don't spellcheck by default |
118 | set spell spelllang=en_us | 122 | set spell spelllang=en_us |
119 | set nospell | 123 | set nospell |
124 | |||
120 | " Cool tab completion stuff | 125 | " Cool tab completion stuff |
121 | set wildmode=list:longest,full | 126 | set wildmode=list:longest,full |
122 | set wildignore=*.o,*.obj,*.class | 127 | set wildignore=*.o,*.obj,*.class |
128 | set nojoinspaces | ||
129 | |||
123 | set scrolloff=4 " Keep n lines above/below cursor | 130 | set scrolloff=4 " Keep n lines above/below cursor |
124 | set mouse=c | ||
125 | set number " line numbers | 131 | set number " line numbers |
126 | set foldmethod=marker " folding stuffs | 132 | set foldmethod=marker " folding stuffs |
127 | set title " set terminal title | 133 | set title " set terminal title |
@@ -129,20 +135,30 @@ set showmatch " jump to the matching bracket briefly, REMOVE AFTER TESTING | |||
129 | set linebreak " wrap using 'breakat' character | 135 | set linebreak " wrap using 'breakat' character |
130 | set splitbelow " new split panes will split to below and right | 136 | set splitbelow " new split panes will split to below and right |
131 | set splitright | 137 | set splitright |
138 | set cursorline | ||
139 | |||
132 | " persistent undo | 140 | " persistent undo |
133 | set undodir=~/.vim/undodir | 141 | set undodir=~/.vim/undodir |
134 | set undofile | 142 | set undofile |
143 | |||
135 | " lower case searches ignore case, upper case searches do not | 144 | " lower case searches ignore case, upper case searches do not |
136 | set ignorecase | 145 | set ignorecase |
137 | set smartcase | 146 | set smartcase |
147 | |||
138 | " https://stackoverflow.com/a/3445040/ | 148 | " https://stackoverflow.com/a/3445040/ |
139 | " switch case labels | 149 | " switch case labels |
140 | set cinoptions=l1 | 150 | set cinoptions=l1 |
151 | |||
152 | " https://www.reddit.com/r/vim/comments/7bj837/favorite_console_tools_to_use_with_vim/ | ||
153 | if executable('rg') | ||
154 | set grepprg=rg\ --vimgrep\ --no-heading | ||
155 | endif | ||
156 | |||
141 | " }}} | 157 | " }}} |
142 | 158 | ||
143 | "{{{Look and Feel | 159 | "{{{Look and Feel |
160 | |||
144 | set termguicolors | 161 | set termguicolors |
145 | "highlight NormalNC guibg='Black' | ||
146 | 162 | ||
147 | let g:nord_underline = 1 | 163 | let g:nord_underline = 1 |
148 | let g:nord_italic = 1 | 164 | let g:nord_italic = 1 |
@@ -150,75 +166,40 @@ let g:nord_italic_comments = 1 | |||
150 | let g:nord_cursor_line_number_background = 1 | 166 | let g:nord_cursor_line_number_background = 1 |
151 | 167 | ||
152 | colorscheme nord | 168 | colorscheme nord |
153 | " }}} | ||
154 | 169 | ||
155 | "{{{ Functions | ||
156 | |||
157 | "{{{ Open URL in browser | ||
158 | |||
159 | function! Browser () | ||
160 | let line = getline (".") | ||
161 | let line = matchstr (line, "http[^ ]*") | ||
162 | exec "!firefox ".line | ||
163 | endfunction | ||
164 | |||
165 | "}}} | ||
166 | |||
167 | "{{{Theme Rotating | ||
168 | let themeindex=0 | ||
169 | function! RotateColorTheme() | ||
170 | let y = -1 | ||
171 | while y == -1 | ||
172 | let colorstring = "#nord#kuroi#" | ||
173 | let x = match( colorstring, "#", g:themeindex ) | ||
174 | let y = match( colorstring, "#", x + 1 ) | ||
175 | let g:themeindex = x + 1 | ||
176 | if y == -1 | ||
177 | let g:themeindex = 0 | ||
178 | else | ||
179 | let themestring = strpart(colorstring, x + 1, y - x - 1) | ||
180 | return ":colorscheme ".themestring | ||
181 | endif | ||
182 | endwhile | ||
183 | endfunction | ||
184 | " }}} | 170 | " }}} |
185 | 171 | ||
186 | "}}} | ||
187 | |||
188 | "{{{ Mappings | 172 | "{{{ Mappings |
189 | " Open Url on this line with the browser \w | 173 | |
190 | map <Leader>w :call Browser ()<CR> | ||
191 | " Open the TagBar Plugin <F3> | 174 | " Open the TagBar Plugin <F3> |
192 | nnoremap <silent> <F3> :TagbarToggle<CR> | 175 | nnoremap <silent> <F3> :TagbarToggle<CR> |
193 | " Open NERDTree <F4> | 176 | " Open NERDTree <F4> |
194 | nnoremap <silent> <F4> :NERDTreeToggle<CR> | 177 | nnoremap <silent> <F4> :NERDTreeToggle<CR> |
195 | " Next Tab | ||
196 | nnoremap <silent> <C-Right> :tabnext<CR> | ||
197 | " Previous Tab | ||
198 | nnoremap <silent> <C-Left> :tabprevious<CR> | ||
199 | " New Tab | 178 | " New Tab |
200 | nnoremap <silent> <C-t> :tabnew<CR> | 179 | nnoremap <silent> <C-t> :tabnew<CR> |
201 | " Rotate Color Scheme <F8> | ||
202 | nnoremap <silent> <F8> :execute RotateColorTheme()<CR> | ||
203 | " FixIt from YCM | 180 | " FixIt from YCM |
204 | map <F9> :YcmCompleter FixIt<CR> | 181 | map <F9> :YcmCompleter FixIt<CR> |
205 | " Edit vimrc \ev | 182 | " Edit vimrc \ev |
206 | nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.config/nvim/init.vim<CR> | 183 | nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.config/nvim/init.vim<CR> |
184 | |||
207 | " Up and down are more logical with g.. | 185 | " Up and down are more logical with g.. |
208 | nnoremap <silent> k gk | 186 | nnoremap <silent> k gk |
209 | nnoremap <silent> j gj | 187 | nnoremap <silent> j gj |
210 | inoremap <silent> <Up> <Esc>gka | 188 | inoremap <silent> <Up> <Esc>gka |
211 | inoremap <silent> <Down> <Esc>gja | 189 | inoremap <silent> <Down> <Esc>gja |
190 | |||
212 | " This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! | 191 | " This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! |
213 | inoremap jj <Esc> | 192 | inoremap jj <Esc> |
214 | nnoremap JJJJ <Nop> | 193 | nnoremap JJJJ <Nop> |
194 | |||
215 | " quicker window movement | 195 | " quicker window movement |
216 | nnoremap <C-j> <C-w>j | 196 | nnoremap <C-j> <C-w>j |
217 | nnoremap <C-k> <C-w>k | 197 | nnoremap <C-k> <C-w>k |
218 | nnoremap <C-h> <C-w>h | 198 | nnoremap <C-h> <C-w>h |
219 | nnoremap <C-l> <C-w>l | 199 | nnoremap <C-l> <C-w>l |
200 | |||
220 | " Disable highlight when <leader><cr> is pressed | 201 | " Disable highlight when <leader><cr> is pressed |
221 | nnoremap <Leader><cr> :noh<cr> | 202 | nnoremap <silent> <Leader><cr> :noh<cr> |
222 | " Space will toggle folds! | 203 | " Space will toggle folds! |
223 | nnoremap <space> za | 204 | nnoremap <space> za |
224 | " Search mappings: These will make it so that going to the next one in a | 205 | " Search mappings: These will make it so that going to the next one in a |
@@ -226,6 +207,44 @@ nnoremap <space> za | |||
226 | map N Nzz | 207 | map N Nzz |
227 | map n nzz | 208 | map n nzz |
228 | 209 | ||
210 | " checkmarks on vimwiki | ||
211 | nnoremap <Leader>c <Plug>VimwikiToggleListItem | ||
212 | |||
213 | """"""""""""""""""""""""""" | ||
214 | " yanks/registers/clips " | ||
215 | """"""""""""""""""""""""""" | ||
216 | " separate cut and delete | ||
217 | nnoremap x d | ||
218 | xnoremap x d | ||
219 | nnoremap xx dd | ||
220 | nnoremap X D | ||
221 | |||
222 | " use the special yoink paste | ||
223 | nmap p <plug>(YoinkPaste_p) | ||
224 | nmap P <plug>(YoinkPaste_P) | ||
225 | |||
226 | " substitute from yank | ||
227 | nnoremap <leader>ys <plug>(SubversiveSubstitute) | ||
228 | nnoremap <leader>yss <plug>(SubversiveSubstituteLine) | ||
229 | nnoremap <leader>yS <plug>(SubversiveSubstituteToEndOfLine) | ||
230 | |||
231 | " substitute over range | ||
232 | nnoremap <leader>s <plug>(SubversiveSubstituteRange) | ||
233 | xnoremap <leader>s <plug>(SubversiveSubstituteRange) | ||
234 | nnoremap <leader>ss <plug>(SubversiveSubstituteWordRange) | ||
235 | |||
236 | " subvert over range | ||
237 | nnoremap <leader><Leader>s <plug>(SubversiveSubvertRange) | ||
238 | xnoremap <leader><leader>s <plug>(SubversiveSubvertRange) | ||
239 | nnoremap <leader><leader>ss <plug>(SubversiveSubvertWordRange) | ||
240 | |||
241 | " iterate over yank list | ||
242 | nnoremap <c-n> <plug>(YoinkPostPasteSwapBack) | ||
243 | nnoremap <c-p> <plug>(YoinkPostPasteSwapForward) | ||
244 | |||
245 | " change into pwd of current directory | ||
246 | nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR> | ||
247 | |||
229 | "}}} | 248 | "}}} |
230 | 249 | ||
231 | "{{{Tagbar | 250 | "{{{Tagbar |
@@ -251,56 +270,19 @@ let g:ale_sign_error = '✗' | |||
251 | let g:ale_sign_warning = '⚑' | 270 | let g:ale_sign_warning = '⚑' |
252 | "}}} | 271 | "}}} |
253 | 272 | ||
254 | "{{{ YouCompleteMe | ||
255 | let g:ycm_always_populate_location_list = 1 | ||
256 | let g:ycm_error_symbol = '✗' | ||
257 | let g:ycm_warning_symbol = '⚑' | ||
258 | |||
259 | map <leader>g :YcmCompleter GoToDefinition<CR> | ||
260 | |||
261 | let g:ycm_filetype_blacklist = { | ||
262 | \ 'tagbar': 1, | ||
263 | \ 'qf': 1, | ||
264 | \ 'notes': 1, | ||
265 | \ 'markdown': 1, | ||
266 | \ 'unite': 1, | ||
267 | \ 'text': 1, | ||
268 | \ 'startify': 1, | ||
269 | \ 'vimwiki': 1, | ||
270 | \ 'pandoc': 1, | ||
271 | \ 'infolog': 1, | ||
272 | \ 'mail': 1 | ||
273 | \} | ||
274 | |||
275 | let g:ycm_filetype_specific_completion_to_disable = { | ||
276 | \ 'gitcommit': 1, | ||
277 | \ 'vim': 1 | ||
278 | \} | ||
279 | |||
280 | "}}} | ||
281 | |||
282 | "{{{ Ledger | 273 | "{{{ Ledger |
283 | let g:ledger_extra_options = '--pedantic --explicit --check-payees' | 274 | " let g:ledger_extra_options = '--pedantic --explicit --check-payees' |
284 | au FileType ledger noremap { ?^\d<CR> | ||
285 | au FileType ledger noremap } /^\d<CR> | ||
286 | let g:ledger_maxwidth = 48 | 275 | let g:ledger_maxwidth = 48 |
287 | let g:ledger_fillstring = ' ~' | 276 | let g:ledger_fillstring = ' ~' |
288 | "}}} | 277 | "}}} |
289 | 278 | ||
290 | "{{{ UltiSnips/YouCompleteMe | 279 | "{{{ UltiSnips |
291 | set runtimepath+=~/.vim/my-snippets/ | 280 | set runtimepath+=~/.vim/my-snippets/ |
292 | let g:UltiSnipsEditSplit="vertical" | 281 | let g:UltiSnipsEditSplit="vertical" |
293 | let g:UltiSnipsSnippetsDir=$HOME.'/.vim/my-snippets/UltiSnips' | 282 | let g:UltiSnipsSnippetsDir=$HOME.'/.vim/my-snippets/UltiSnips' |
294 | 283 | ||
295 | " these navigate ycm | ||
296 | let g:ycm_key_list_select_completion = ['<TAB>', '<C-j>'] | ||
297 | let g:ycm_key_list_previous_completion = ['<S-TAB>', '<C-k>'] | ||
298 | |||
299 | " ctrl + l expands the snippet, c + j/k navigates placeholders | 284 | " ctrl + l expands the snippet, c + j/k navigates placeholders |
300 | let g:UltiSnipsExpandTrigger = "<C-l>" | 285 | let g:UltiSnipsExpandTrigger = "<C-l>" |
301 | let g:UltiSnipsJumpForwardTrigger = "<C-j>" | ||
302 | let g:UltiSnipsJumpBackwardTrigger = "<C-k>" | ||
303 | let g:UltiSnipsListSnippets = "<C-h>" | ||
304 | "}}} | 286 | "}}} |
305 | 287 | ||
306 | "{{{ vim-startify | 288 | "{{{ vim-startify |
@@ -334,39 +316,6 @@ let g:vimwiki_list = [{'path': '/home/yigit/Dropbox/personal_wiki', | |||
334 | \ 'css_name': 'tufte.css', | 316 | \ 'css_name': 'tufte.css', |
335 | \ 'auto_export': 1}] | 317 | \ 'auto_export': 1}] |
336 | let g:vimwiki_global_ext = 0 | 318 | let g:vimwiki_global_ext = 0 |
337 | map <Leader>c <Plug>VimwikiToggleListItem | ||
338 | "}}} | ||
339 | |||
340 | "{{{ yanks/registers and clips | ||
341 | |||
342 | set clipboard=unnamed,unnamedplus | ||
343 | |||
344 | " s for substitute | ||
345 | nmap <leader>ys <plug>(SubversiveSubstitute) | ||
346 | nmap <leader>yss <plug>(SubversiveSubstituteLine) | ||
347 | nmap <leader>yS <plug>(SubversiveSubstituteToEndOfLine) | ||
348 | |||
349 | nmap <leader>s <plug>(SubversiveSubstituteRange) | ||
350 | xmap <leader>s <plug>(SubversiveSubstituteRange) | ||
351 | nmap <leader>ss <plug>(SubversiveSubstituteWordRange) | ||
352 | |||
353 | nmap <leader><leader>s <plug>(SubversiveSubvertRange) | ||
354 | xmap <leader><leader>s <plug>(SubversiveSubvertRange) | ||
355 | nmap <leader><leader>ss <plug>(SubversiveSubvertWordRange) | ||
356 | |||
357 | nmap <c-n> <plug>(YoinkPostPasteSwapBack) | ||
358 | nmap <c-p> <plug>(YoinkPostPasteSwapForward) | ||
359 | |||
360 | let g:yoinkIncludeDeleteOperations = 1 | ||
361 | |||
362 | nmap p <plug>(YoinkPaste_p) | ||
363 | nmap P <plug>(YoinkPaste_P) | ||
364 | |||
365 | nnoremap x d | ||
366 | xnoremap x d | ||
367 | |||
368 | nnoremap xx dd | ||
369 | nnoremap X D | ||
370 | "}}} | 319 | "}}} |
371 | 320 | ||
372 | " {{{ vimtex | 321 | " {{{ vimtex |