diff options
author | Yigit Sever | 2019-03-17 23:09:49 +0300 |
---|---|---|
committer | Yigit Sever | 2019-03-17 23:18:28 +0300 |
commit | ea211500227aa58f5e495777743c5d391cbc3110 (patch) | |
tree | afa2b455f9fea40b45dbf8a742c0d0d498024edb /.config/nvim | |
download | dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.tar.gz dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.tar.bz2 dotfiles-ea211500227aa58f5e495777743c5d391cbc3110.zip |
Initial commit
Diffstat (limited to '.config/nvim')
-rwxr-xr-x | .config/nvim/init.vim | 443 |
1 files changed, 443 insertions, 0 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim new file mode 100755 index 0000000..af2cedc --- /dev/null +++ b/.config/nvim/init.vim | |||
@@ -0,0 +1,443 @@ | |||
1 | "{{{ | ||
2 | |||
3 | call plug#begin('~/.local/share/nvim/plugged') | ||
4 | |||
5 | "A code-completion engine for Vim | ||
6 | Plug 'Valloric/YouCompleteMe' | ||
7 | "syntax checking | ||
8 | Plug 'w0rp/ale' | ||
9 | "manages tag files | ||
10 | Plug 'ludovicchabant/vim-gutentags' | ||
11 | "language pack | ||
12 | "Plug 'sheerun/vim-polyglot' | ||
13 | |||
14 | "snippet solution | ||
15 | Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' | ||
16 | "autopair plugin | ||
17 | Plug 'tmsvg/pear-tree' | ||
18 | |||
19 | " Plugin outside ~/.vim/plugged with post-update hook | ||
20 | Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | ||
21 | |||
22 | "tree explorer | ||
23 | Plug 'scrooloose/nerdtree' | ||
24 | "displays tags ordered by scope | ||
25 | Plug 'majutsushi/tagbar' | ||
26 | "status/tabline | ||
27 | Plug 'bling/vim-airline' | ||
28 | |||
29 | " color theme. | ||
30 | Plug 'morhetz/gruvbox' | ||
31 | |||
32 | "Personal wiki | ||
33 | Plug 'vimwiki/vimwiki' | ||
34 | "distraction-free writing | ||
35 | Plug 'junegunn/goyo.vim' | ||
36 | " latex | ||
37 | Plug 'lervag/vimtex' | ||
38 | |||
39 | "visual display of indent levels | ||
40 | Plug 'nathanaelkane/vim-indent-guides' | ||
41 | "text alignment | ||
42 | Plug 'godlygeek/tabular' | ||
43 | "access cheat.sh sheets | ||
44 | Plug 'dbeniamine/cheat.sh-vim' | ||
45 | "color code highlight | ||
46 | Plug 'chrisbra/Colorizer' | ||
47 | "comment helper | ||
48 | Plug 'scrooloose/nerdcommenter' | ||
49 | "folding ledger files | ||
50 | Plug 'ledger/vim-ledger' | ||
51 | "reporen files at your last edit position | ||
52 | Plug 'farmergreg/vim-lastplace' | ||
53 | "toggle, display and navigate marks | ||
54 | Plug 'kshenoy/vim-signature' | ||
55 | "git diff in the sign column | ||
56 | Plug 'airblade/vim-gitgutter' | ||
57 | |||
58 | Plug 'svermeulen/vim-cutlass' | ||
59 | Plug 'svermeulen/vim-subversive' | ||
60 | Plug 'svermeulen/vim-yoink' | ||
61 | |||
62 | "enable repeating supported plugin maps with '.' | ||
63 | Plug 'tpope/vim-repeat' | ||
64 | "quoting/parenthesizing made simple | ||
65 | Plug 'tpope/vim-surround' | ||
66 | "pairs of handy bracket mappings | ||
67 | Plug 'tpope/vim-unimpaired' | ||
68 | "git wrapper | ||
69 | Plug 'tpope/vim-fugitive' | ||
70 | "increment dates, times & more | ||
71 | Plug 'tpope/vim-speeddating' | ||
72 | "search, substitute and abbreviate | ||
73 | Plug 'tpope/vim-abolish' | ||
74 | "helpers for unix | ||
75 | Plug 'tpope/vim-eunuch' | ||
76 | "unicode character metadata | ||
77 | Plug 'tpope/vim-characterize' | ||
78 | |||
79 | "fancy start screen | ||
80 | Plug 'mhinz/vim-startify' | ||
81 | Plug 'ryanoasis/vim-devicons' " asks to be placed last, sure | ||
82 | |||
83 | call plug#end() " required | ||
84 | |||
85 | "}}} | ||
86 | |||
87 | "{{{Auto Commands | ||
88 | |||
89 | " Automatically cd into the directory that the file is in | ||
90 | autocmd BufEnter * silent! lcd %:p:h | ||
91 | |||
92 | " Remove any trailing whitespace that is in the file | ||
93 | autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif | ||
94 | |||
95 | " Close vim if the only window left open is NERDTree | ||
96 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
97 | |||
98 | "}}} | ||
99 | |||
100 | "{{{Misc Settings | ||
101 | |||
102 | let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' | ||
103 | |||
104 | " necesary for lots of cool vim things | ||
105 | set nocompatible | ||
106 | |||
107 | " See below | ||
108 | " https://stackoverflow.com/a/33380495 | ||
109 | if !exists("g:syntax_on") | ||
110 | syntax enable | ||
111 | endif | ||
112 | |||
113 | set grepprg=grep\ -nH\ $* " DONT KNOW WHAT THIS DOES | ||
114 | |||
115 | " Tab stuff | ||
116 | set autoindent | ||
117 | set expandtab " Use appropriate number of spaces to insert a <Tab> | ||
118 | set smarttab | ||
119 | set shiftwidth=4 | ||
120 | set softtabstop=4 | ||
121 | set tabstop=8 | ||
122 | |||
123 | " Visual aid to deter from typing past column 110 | ||
124 | "set colorcolumn=110 | ||
125 | |||
126 | " Use english for spellchecking, but don't spellcheck by default | ||
127 | set spell spelllang=en_us | ||
128 | set nospell | ||
129 | |||
130 | " Cool tab completion stuff | ||
131 | set wildmenu | ||
132 | set wildmode=list:longest,full | ||
133 | set wildignore=*.o,*.obj,*.class | ||
134 | |||
135 | set encoding=utf-8 | ||
136 | set scrolloff=4 " Keep n lines above/below cursor | ||
137 | set mouse=c | ||
138 | set backspace=2 " make backspace work like most other programs | ||
139 | set number " line numbers | ||
140 | set history=1000 " number of lines that are remembered | ||
141 | set showcmd " this shows what you are typing as a command. I love this! | ||
142 | set foldmethod=marker " folding stuffs | ||
143 | set incsearch " search as you type (before <CR>) | ||
144 | set hlsearch " highlight things that we find with the search | ||
145 | set nohidden " when i close a tab, remove the buffer | ||
146 | set title " set terminal title | ||
147 | set showmatch " jump to the matching bracket briefly, REMOVE AFTER TESTING | ||
148 | set linebreak " wrap using 'breakat' character | ||
149 | set splitbelow " new split panes will split to below and right | ||
150 | set splitright | ||
151 | |||
152 | " lower case searches ignore case, upper case searches do not | ||
153 | set ignorecase | ||
154 | set smartcase | ||
155 | |||
156 | " This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! | ||
157 | inoremap jj <Esc> | ||
158 | nnoremap JJJJ <Nop> | ||
159 | |||
160 | " https://stackoverflow.com/a/3445040/ | ||
161 | " switch case labels | ||
162 | set cinoptions=l1 | ||
163 | |||
164 | " }}} | ||
165 | |||
166 | "{{{Look and Feel | ||
167 | |||
168 | " Color Scheme | ||
169 | " gruvbox_color_column works as expected IF the order is: | ||
170 | " set termguicolors | ||
171 | " colorscheme gruvbox | ||
172 | " ... | ||
173 | " set background=dark | ||
174 | " Investigate later | ||
175 | |||
176 | "let $NVIM_TUI_ENABLE_TRUE_COLOR=1 | ||
177 | set termguicolors | ||
178 | |||
179 | colorscheme gruvbox | ||
180 | |||
181 | let g:gruvbox_bold=1 | ||
182 | let g:gruvbox_color_column='red' | ||
183 | let g:gruvbox_underline=1 | ||
184 | let g:gruvbox_contrast_dark='medium' | ||
185 | let g:gruvbox_contrast_light='hard' | ||
186 | let g:gruvbox_vert_split='aqua' | ||
187 | |||
188 | set background=dark " Setting dark mode | ||
189 | |||
190 | "highlight ColorColumn guibg='DarkRed' | ||
191 | highlight NormalNC guibg='Black' | ||
192 | "highlight NormalNC guifg='Cyan' | ||
193 | |||
194 | |||
195 | " }}} | ||
196 | |||
197 | "{{{ Functions | ||
198 | |||
199 | "{{{ Open URL in browser | ||
200 | |||
201 | function! Browser () | ||
202 | let line = getline (".") | ||
203 | let line = matchstr (line, "http[^ ]*") | ||
204 | exec "!firefox ".line | ||
205 | endfunction | ||
206 | |||
207 | "}}} | ||
208 | |||
209 | "{{{Theme Rotating | ||
210 | "let themeindex=0 | ||
211 | "function! RotateColorTheme() | ||
212 | "let y = -1 | ||
213 | "while y == -1 | ||
214 | "let colorstring = "#gotham#" | ||
215 | "let x = match( colorstring, "#", g:themeindex ) | ||
216 | "let y = match( colorstring, "#", x + 1 ) | ||
217 | "let g:themeindex = x + 1 | ||
218 | "if y == -1 | ||
219 | "let g:themeindex = 0 | ||
220 | "else | ||
221 | "let themestring = strpart(colorstring, x + 1, y - x - 1) | ||
222 | "return ":colorscheme ".themestring | ||
223 | "endif | ||
224 | "endwhile | ||
225 | "endfunction | ||
226 | " }}} | ||
227 | |||
228 | "}}} | ||
229 | |||
230 | "{{{ Mappings | ||
231 | |||
232 | " Open Url on this line with the browser \w | ||
233 | map <Leader>w :call Browser ()<CR> | ||
234 | |||
235 | " Open the TagBar Plugin <F3> | ||
236 | nnoremap <silent> <F3> :TagbarToggle<CR> | ||
237 | |||
238 | " Open NERDTree <F4> | ||
239 | nnoremap <silent> <F4> :NERDTreeToggle<CR> | ||
240 | |||
241 | " Next Tab | ||
242 | nnoremap <silent> <C-Right> :tabnext<CR> | ||
243 | |||
244 | " Previous Tab | ||
245 | nnoremap <silent> <C-Left> :tabprevious<CR> | ||
246 | |||
247 | " New Tab | ||
248 | nnoremap <silent> <C-t> :tabnew<CR> | ||
249 | |||
250 | " Rotate Color Scheme <F8> | ||
251 | "nnoremap <silent> <F8> :execute RotateColorTheme()<CR> | ||
252 | |||
253 | " FixIt from YCM | ||
254 | map <F9> :YcmCompleter FixIt<CR> | ||
255 | |||
256 | " Edit vimrc \ev | ||
257 | nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.config/nvim/init.vim<CR> | ||
258 | |||
259 | " Up and down are more logical with g.. | ||
260 | nnoremap <silent> k gk | ||
261 | nnoremap <silent> j gj | ||
262 | inoremap <silent> <Up> <Esc>gka | ||
263 | inoremap <silent> <Down> <Esc>gja | ||
264 | |||
265 | " quicker window movement | ||
266 | nnoremap <C-j> <C-w>j | ||
267 | nnoremap <C-k> <C-w>k | ||
268 | nnoremap <C-h> <C-w>h | ||
269 | nnoremap <C-l> <C-w>l | ||
270 | |||
271 | " Disable highlight when <leader><cr> is pressed | ||
272 | map <silent> <leader><cr> :noh<cr> | ||
273 | |||
274 | " Space will toggle folds! | ||
275 | nnoremap <space> za | ||
276 | |||
277 | " Search mappings: These will make it so that going to the next one in a | ||
278 | " search will center on the line it's found in. | ||
279 | map N Nzz | ||
280 | map n nzz | ||
281 | |||
282 | "Insert timestamp | ||
283 | nnoremap <F5> "=strftime("%F %T")<CR>P | ||
284 | inoremap <F5> <C-R>=strftime("%F %T")<CR> | ||
285 | |||
286 | nnoremap <Leader>t "=strftime("%F")<CR>P | ||
287 | |||
288 | "}}} | ||
289 | |||
290 | "{{{Tagbar | ||
291 | |||
292 | let g:tagbar_autofocus = 1 | ||
293 | let g:tagbar_compact = 1 | ||
294 | let g:tagbar_sort = 0 | ||
295 | let g:tagbar_width = 25 | ||
296 | |||
297 | "}}} | ||
298 | |||
299 | "{{{ Airline | ||
300 | |||
301 | let g:airline_powerline_fonts = 1 " fira code | ||
302 | |||
303 | let g:airline#extensions#tabline#formatter = 'unique_tail' | ||
304 | let g:airline#extensions#ycm#enabled = 1 | ||
305 | |||
306 | "}}} | ||
307 | |||
308 | "{{{ NERDTree | ||
309 | |||
310 | let g:NERDTreeWinSize=25 | ||
311 | |||
312 | "}}} | ||
313 | |||
314 | "{{{ Ale | ||
315 | |||
316 | let g:ale_sign_error = '✗' | ||
317 | let g:ale_sign_warning = '⚑' | ||
318 | |||
319 | "}}} | ||
320 | |||
321 | "{{{ YouCompleteMe | ||
322 | |||
323 | let g:ycm_autoclose_preview_window_after_completion = 1 | ||
324 | let g:ycm_always_populate_location_list = 1 | ||
325 | let g:ycm_error_symbol = '✗' | ||
326 | let g:ycm_warning_symbol = '⚑' | ||
327 | |||
328 | map <leader>g :YcmCompleter GoToDefinition<CR> | ||
329 | |||
330 | let g:ycm_filetype_blacklist = { | ||
331 | \ 'tagbar': 1, | ||
332 | \ 'qf': 1, | ||
333 | \ 'notes': 1, | ||
334 | \ 'markdown': 1, | ||
335 | \ 'unite': 1, | ||
336 | \ 'text': 1, | ||
337 | \ 'startify': 1, | ||
338 | \ 'vimwiki': 1, | ||
339 | \ 'pandoc': 1, | ||
340 | \ 'infolog': 1, | ||
341 | \ 'mail': 1 | ||
342 | \} | ||
343 | |||
344 | let g:ycm_filetype_specific_completion_to_disable = { | ||
345 | \ 'gitcommit': 1, | ||
346 | \ 'vim': 1 | ||
347 | \} | ||
348 | |||
349 | "}}} | ||
350 | |||
351 | "{{{ Ledger | ||
352 | |||
353 | let g:ledger_extra_options = '--pedantic --explicit --check-payees' | ||
354 | au FileType ledger noremap { ?^\d<CR> | ||
355 | au FileType ledger noremap } /^\d<CR> | ||
356 | |||
357 | "}}} | ||
358 | |||
359 | "{{{ UltiSnips/YouCompleteMe | ||
360 | set runtimepath+=~/.vim/my-snippets/ | ||
361 | let g:UltiSnipsEditSplit="vertical" | ||
362 | let g:UltiSnipsSnippetsDir=$HOME.'/.vim/my-snippets/UltiSnips' | ||
363 | |||
364 | " these navigate ycm | ||
365 | let g:ycm_key_list_select_completion = ['<TAB>', '<C-j>'] | ||
366 | let g:ycm_key_list_previous_completion = ['<S-TAB>', '<C-k>'] | ||
367 | |||
368 | " ctrl + l expands the snippet, c + j/k navigates placeholders | ||
369 | let g:UltiSnipsExpandTrigger = "<C-l>" | ||
370 | let g:UltiSnipsJumpForwardTrigger = "<C-j>" | ||
371 | let g:UltiSnipsJumpBackwardTrigger = "<C-k>" | ||
372 | let g:UltiSnipsListSnippets = "<C-h>" | ||
373 | "}}} | ||
374 | |||
375 | "{{{ vim-startify | ||
376 | |||
377 | function! StartifyEntryFormat() | ||
378 | return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path' | ||
379 | endfunction | ||
380 | |||
381 | let entry_format = "' ['. index .']'. repeat(' ', (3 - strlen(index)))" | ||
382 | |||
383 | if exists('*WebDevIconsGetFileTypeSymbol') " support for vim-devicons | ||
384 | let entry_format .= ". WebDevIconsGetFileTypeSymbol(entry_path) .' '. entry_path" | ||
385 | else | ||
386 | let entry_format .= '. entry_path' | ||
387 | endif | ||
388 | |||
389 | |||
390 | |||
391 | let g:ascii = [ | ||
392 | \' | ', | ||
393 | \'\ \ \ / -_) | _| _ \ ` \ -_)', | ||
394 | \' \_/\_/\___|_|\__|\___/_|_|_|\___|', | ||
395 | \ '', | ||
396 | \] | ||
397 | |||
398 | let g:startify_custom_header = | ||
399 | \ 'map(g:ascii + startify#fortune#boxed(), "\" \".v:val")' | ||
400 | |||
401 | "}}} | ||
402 | |||
403 | "{{{ vimwiki | ||
404 | let g:vimwiki_list = [{'path': '/home/yigit/Dropbox/personal_wiki', | ||
405 | \ 'path_html': '~/Dropbox/personal_wiki_html', | ||
406 | \ 'css_name': 'tufte.css', | ||
407 | \ 'auto_export': 1}] | ||
408 | let g:vimwiki_global_ext = 0 | ||
409 | map <Leader>b <Plug>VimwikiToggleListItem | ||
410 | "}}} | ||
411 | |||
412 | "{{{ yanks/registers and clips | ||
413 | |||
414 | set clipboard=unnamed,unnamedplus | ||
415 | |||
416 | " s for substitute | ||
417 | nmap s <plug>(SubversiveSubstitute) | ||
418 | nmap ss <plug>(SubversiveSubstituteLine) | ||
419 | nmap S <plug>(SubversiveSubstituteToEndOfLine) | ||
420 | |||
421 | nmap <leader>s <plug>(SubversiveSubstituteRange) | ||
422 | xmap <leader>s <plug>(SubversiveSubstituteRange) | ||
423 | nmap <leader>ss <plug>(SubversiveSubstituteWordRange) | ||
424 | |||
425 | nmap <c-n> <plug>(YoinkPostPasteSwapBack) | ||
426 | nmap <c-p> <plug>(YoinkPostPasteSwapForward) | ||
427 | |||
428 | let g:yoinkIncludeDeleteOperations = 1 | ||
429 | |||
430 | nmap p <plug>(YoinkPaste_p) | ||
431 | nmap P <plug>(YoinkPaste_P) | ||
432 | |||
433 | nnoremap x d | ||
434 | xnoremap x d | ||
435 | |||
436 | nnoremap xx dd | ||
437 | nnoremap X D | ||
438 | "}}} | ||
439 | |||
440 | " {{{ vimtex | ||
441 | let g:vimtex_view_method = 'zathura' | ||
442 | |||
443 | " }}} | ||