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