summaryrefslogtreecommitdiffstats
path: root/.config/nvim/init.vim
blob: 991f708eb7078d6be1117812964053dd13a7e1d3 (plain)
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
"{{{ Plugs
call plug#begin('~/.local/share/nvim/plugged')

"completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'lionawurscht/deoplete-biblatex'
Plug 'deoplete-plugins/deoplete-jedi'

" ledger
Plug 'ledger/vim-ledger'
"language packs
Plug 'sheerun/vim-polyglot'
"syntax checking
Plug 'dense-analysis/ale'
"manages tag files
Plug 'ludovicchabant/vim-gutentags'
"run your tests
Plug 'janko/vim-test'
" latex
Plug 'lervag/vimtex'

"snippet solution
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"autopair plugin
Plug 'tmsvg/pear-tree'
"colored brackets
Plug 'luochen1990/rainbow'

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'

"tree explorer
Plug 'scrooloose/nerdtree'
"displays tags ordered by scope
Plug 'majutsushi/tagbar'
"status/tabline
Plug 'bling/vim-airline'

" " color theme
Plug 'joshdick/onedark.vim'

"Personal wiki
Plug 'vimwiki/vimwiki'
"distraction-free writing
Plug 'junegunn/goyo.vim'

"text alignment
Plug 'godlygeek/tabular'
"color code highlight
Plug 'chrisbra/Colorizer'
"move selections up and down
Plug 'matze/vim-move'
" search/select/edit sandwiched textobjects (vim-surround)
Plug 'machakann/vim-sandwich'
" provide additional text objects
Plug 'wellle/targets.vim'
" indentation level text object
Plug 'michaeljsmith/vim-indent-object'
" undo history visualizer
Plug 'mbbill/undotree'

"reopen files at your last edit position
Plug 'farmergreg/vim-lastplace'
"toggle, display and navigate marks
Plug 'kshenoy/vim-signature'
"git diff in the sign column
Plug 'airblade/vim-gitgutter'
"jump to location by 2 characters
Plug 'justinmk/vim-sneak'

"splits delete into cut and delete
Plug 'svermeulen/vim-cutlass'
"change text with yank
Plug 'svermeulen/vim-subversive'
"yank history
Plug 'svermeulen/vim-yoink'

"enable repeating supported plugin maps with '.'
Plug 'tpope/vim-repeat'
"pairs of handy bracket mappings
Plug 'tpope/vim-unimpaired'
"git wrapper
Plug 'tpope/vim-fugitive'
"increment dates, times & more
Plug 'tpope/vim-speeddating'
"search, substitute and abbreviate
Plug 'tpope/vim-abolish'
"provides ga, show unicode stuff of char under cursor
Plug 'tpope/vim-characterize'
"comment helper
Plug 'tpope/vim-commentary'
"asynchronous build and test dispatcher
Plug 'tpope/vim-dispatch'

"fancy start screen
Plug 'mhinz/vim-startify'
Plug 'ryanoasis/vim-devicons' " asks to be placed last, sure

call plug#end()            " required

"}}}

"{{{Auto Commands
" Remove any trailing whitespace that is in the file
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif

" Close vim if the only window left open is NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

" Resize all windows proportionally when the terminal is resized
" let terminal resize scale the internal windows
autocmd VimResized * :wincmd =
"}}}

"{{{Misc Settings

" Use deoplete.
let g:deoplete#enable_at_startup = 1

" interact with system clipboard
set clipboard=unnamed,unnamedplus

" required for yoink/cutlass/subversive interaction
let g:yoinkIncludeDeleteOperations = 1

" Tab stuff
set autoindent
set expandtab " Use appropriate number of spaces to insert a <Tab>
set shiftwidth=4
set softtabstop=4
set tabstop=8

" Use english for spellchecking, but don't spellcheck by default
set spell spelllang=en_gb
set nospell

" Cool tab completion stuff
set wildmode=list:longest,full
set wildignore=*.o,*.obj,*.class,*.aux,*.lof,*.log,*.lot,*.fls,*.toc,*.fmt,*.fot,*.cb,*.cb2,.*.lb,.dvi,*.xdv,*.bbl,*.bcf,*.blg,*-blx.aux,*-blx.bib,*.run.xml,*.fdb_latexmk,*.synctex,*.synctex(busy),*.synctex.gz,*.synctex.gz(busy),*.pdfsync
let g:NERDTreeRespectWildIgnore = 1
set nojoinspaces

set scrolloff=4 " Keep n lines above/below cursor
set number " line numbers
set foldmethod=marker " folding stuffs
set title " set terminal title
set showmatch " jump to the matching bracket briefly, REMOVE AFTER TESTING
set linebreak " wrap using 'breakat' character
set splitbelow " new split panes will split to below and right
set splitright
set cursorline

" persistent undo
set undodir=~/.vim/undodir
set undofile

" lower case searches ignore case, upper case searches do not
set ignorecase
set smartcase

" https://stackoverflow.com/a/3445040/
" switch case labels
set cinoptions=l1

" https://www.reddit.com/r/vim/comments/7bj837/favorite_console_tools_to_use_with_vim/
if executable('rg')
    set grepprg=rg\ --vimgrep\ --no-heading
endif

set diffopt+=internal,algorithm:patience

" }}}

"{{{Look and Feel

set termguicolors
colorscheme onedark

" }}}

"{{{ Mappings

" Open the TagBar Plugin <F3>
nnoremap <silent> <F3> :TagbarToggle<CR>
" Open NERDTree <F4>
nnoremap <silent> <F4> :NERDTreeToggle<CR>
" Fix whole buffer via ALE
nmap <F9> <Plug>(ale_fix)

" these "Ctrl mappings" work well when Caps Lock is mapped to Ctrl
nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>

" New Tab
nnoremap <silent> <C-t> :tabnew<CR>
" Edit vimrc \ev
nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.config/nvim/init.vim<CR>

" Up and down are more logical with g..
nnoremap <silent> k gk
nnoremap <silent> j gj
inoremap <silent> <Up> <Esc>gka
inoremap <silent> <Down> <Esc>gja

" quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l

" Disable highlight when <leader><cr> is pressed
nnoremap <silent> <Leader><cr> :noh<cr>
" Space will toggle folds!
nnoremap <space> za
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
" map N Nzz
" map n nzz

" checkmarks on vimwiki
nmap <Leader>v <Plug>VimwikiToggleListItem

nmap ` <Plug>Sneak_s
nmap <leader>` <Plug>Sneak_S
nnoremap ' `

nmap <leader>i :IndentGuidesToggle<CR>

" separate cut and delete
nnoremap x d
xnoremap x d
nnoremap xx dd
nnoremap X D

" use the special yoink paste
nmap p <plug>(YoinkPaste_p)
nmap P <plug>(YoinkPaste_P)

" substitute from yank
nmap <leader>ys <plug>(SubversiveSubstitute)
nmap <leader>yss <plug>(SubversiveSubstituteLine)
nmap <leader>yS <plug>(SubversiveSubstituteToEndOfLine)

" substitute over range
nmap <leader>s <plug>(SubversiveSubstituteRange)
xmap <leader>s <plug>(SubversiveSubstituteRange)
nmap <leader>ss <plug>(SubversiveSubstituteWordRange)

" subvert over range
nmap <leader><Leader>s <plug>(SubversiveSubvertRange)
xmap <leader><leader>s <plug>(SubversiveSubvertRange)
nmap <leader><leader>ss <plug>(SubversiveSubvertWordRange)

" iterate over yank list
nmap <c-n> <plug>(YoinkPostPasteSwapBack)
nmap <c-p> <plug>(YoinkPostPasteSwapForward)

" change into pwd of current directory
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>

"}}}

"{{{Tagbar
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
let g:tagbar_sort = 0
let g:tagbar_width = 25
"}}}

"{{{ Airline
let g:airline_powerline_fonts = 1

let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#ycm#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_mode_map = {}
let g:airline_mode_map['ic'] = 'INSERT'
"}}}

"{{{ NERDTree
let g:NERDTreeWinSize=25
"}}}

"{{{ Ale
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚑'
let g:ale_lint_on_text_changed = 'insert'
let g:ale_lint_on_enter = 0
"}}}

"{{{ Ledger
" let g:ledger_extra_options = '--pedantic --explicit --check-payees'
let g:ledger_maxwidth = 48
let g:ledger_fillstring = '   ~'
"}}}

"{{{ UltiSnips
set runtimepath+=~/.vim/my-snippets/
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetsDir=$HOME.'/.vim/my-snippets/UltiSnips'

" ctrl + l expands the snippet, c + j/k navigates placeholders
let g:UltiSnipsExpandTrigger = "<C-l>"
"}}}

"{{{ vim-startify
function! StartifyEntryFormat()
    return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path'
endfunction

let entry_format = "'   ['. index .']'. repeat(' ', (3 - strlen(index)))"

if exists('*WebDevIconsGetFileTypeSymbol')  " support for vim-devicons
    let entry_format .= ". WebDevIconsGetFileTypeSymbol(entry_path) .' '.  entry_path"
else
    let entry_format .= '. entry_path'
endif

let g:ascii = [
            \'             |                    ',
            \'\ \  \ / -_) |  _|  _ \  ` \   -_)',
            \' \_/\_/\___|_|\__|\___/_|_|_|\___|',
            \ '',
            \]

let g:startify_custom_header =
            \ 'map(g:ascii + startify#fortune#boxed(), "\"   \".v:val")'

"}}}

"{{{ vimwiki
let g:vimwiki_list = [{'path': '/home/yigit/Nextcloud/personal_wiki',
            \ 'path_html': '/home/yigit/Nextcloud/personal_wiki_html',
            \ 'css_name': 'tufte.css',
            \ 'auto_export': 1}]
let g:vimwiki_global_ext = 0
"}}}

" {{{ vimtex
let g:vimtex_view_method = 'zathura'
let g:tex_flavor='latex'
let g:vimtex_quickfix_mode = 0
let g:polyglot_disabled = ['latex', 'tex', 'ledger']
" }}}

" {{{ rainbow
let g:rainbow_active = 0
" }}}

" {{{ Gutentags
let g:gutentags_add_default_project_roots = 0
let g:gutentags_project_root = ['Makefile', '.git']
let g:gutentags_generate_on_new = 1
let g:gutentags_generate_on_missing = 1
let g:gutentags_generate_on_write = 1
let g:gutentags_generate_on_empty_buffer = 0
" }}}