forked from obscure-shadow/neovimconf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim.old
719 lines (589 loc) · 20.6 KB
/
init.vim.old
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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
scriptencoding utf-8
" git config for neovim thanks to Adam Oswalt
" place in .config/nvim
" lets see if this works
" install plug if not found {{{1
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
augroup plug_install
autocmd VimEnter * PlugInstall
augroup end
endif
" plugins {{{1
call plug#begin('~/.config/nvim/plugged')
" allows seamless integration of tmux and vim splits, going to comment this
" pluggin out for now as I don't seem to be using tmux much but I will leave
" it here in the event that i decide that tmux is a direction that I want to
" go in.
Plug 'christoomey/vim-tmux-navigator'
"splits line to multiple lines with gS or joins multiple lines with gS
Plug 'AndrewRadev/splitjoin.vim'
"shows a visual working tree of undo history
Plug 'simnalamburt/vim-mundo'
"fuzzy finder and fuzzy finder vim config
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"git wrapper, needs further research
Plug 'tpope/vim-fugitive'
"vim linter
Plug 'w0rp/ale'
"autocompletion engine, currently throws random errors, need to look into this
"more
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"collection of language packs for vim
Plug 'sheerun/vim-polyglot'
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
"postgreSQL pluggin for vim
Plug 'exu/pgsql.vim'
"tern based javascript editing support
Plug 'ternjs/tern_for_vim', { 'do': 'npm install -g tern', 'for': ['javascript', 'javascript.jsx'] }
Plug 'carlitux/deoplete-ternjs', { 'for': ['javascript', 'javascript.jsx'] }
"hook for deoplete for python analisys
Plug 'zchee/deoplete-jedi', { 'for': 'python' }
"used to be required for deoplete but I'm not sure it still is. further
"investegation needed but perhaps work out the bugs with deoplete first.
Plug 'Shougo/neco-syntax'
Plug 'Shougo/neco-vim'
Plug 'Shougo/deoplete-zsh'
"needs further research
Plug 'tpope/vim-projectionist'
"Plug 'c-brenn/phoenix.vim', { 'for': 'elixir' }
Plug 'vim-scripts/ingo-library'
"can be used to set up buffers in the current file that use different syntax
"than the rest of the file. further research is needed.
Plug 'vim-scripts/SyntaxRange'
"defines new text objects besides word, paragraph, sentance
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-entire' "ae/ie for entire file
Plug 'kana/vim-textobj-indent' "ai/ii for indent block
Plug 'kana/vim-textobj-line' "al/il for line
Plug 'sgur/vim-textobj-parameter' "a,/i, for argument/parameter
"Plug 'aoswalt/vim-textobj-elixir' "aE/iE for Elixir blocks as remapped
Plug 'Julian/vim-textobj-variable-segment' "av/iv for variable part
Plug 'Chun-Yang/vim-textobj-chunk' "ac/ic for json-ish chunk
Plug 'whatyouhide/vim-textobj-xmlattr' "ax/ix for xml attribute
"this apparently can run a section of code. documentation in :h quickrun, this
"requires further research
" Plug 'thinca/vim-quickrun'
"this will build stuff and then run it and give an output, further research
"needed
" Plug 'tpope/vim-dispatch'
" Plug 'radenling/vim-dispatch-neovim'
"something to do with SQL... gonna leave it for now...
Plug 'vim-scripts/dbext.vim'
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
"shows markdown instantly in the browser... pretty badass honestly...
Plug 'suan/vim-instant-markdown', { 'do': 'npm install -g instant-markdown-d' }
"handles csv files
Plug 'chrisbra/csv.vim'
"shows a pop out tray with the double quote key that shows the contents of the
"registers
Plug 'junegunn/vim-peekaboo'
"powerline like status line
Plug 'itchyny/lightline.vim'
"shows which lines have been modified, added or where lines have been deleted
"for git...
Plug 'airblade/vim-gitgutter'
"colors indents
Plug 'nathanaelkane/vim-indent-guides'
"shows colors added in the color that they are, bot binary and color keyworkds
"eg: red green blue #00ff00
Plug 'systemmonkey42/vim-coloresque'
Plug 'guns/xterm-color-table.vim'
Plug 'vim-scripts/AnsiEsc.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'machakann/vim-highlightedyank'
Plug 'Raimondi/delimitMate'
"comment out a line using gcc or gc* for other sections/blocks of comments
Plug 'tpope/vim-commentary'
"highlight trailing whitespace and strip on save
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-rsi'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'tpope/vim-dadbod'
Plug 'aoswalt/onedark.vim'
Plug 'w0ng/vim-hybrid'
Plug 'wannesm/wmgraphviz.vim'
" ctags require https://github.com/universal-ctags/ctags
"Plug 'ludovicchabant/vim-gutentags', {'do': ':call plug#helptags()'}
"Plug 'majutsushi/tagbar'
call plug#end()
" vim settings {{{1
set noswapfile
set number "line numbers
set cursorline "highlight cursorline
set ruler "show line/column
set scrolloff=4 "keep more lines on screen while scrolling
set sidescroll=1 "horizontal scroll amount
set sidescrolloff=5 "horizontal scrolloff
set list "enable invisible characters
set nowrap "do not wrap lines by default
set mouse=a "use mouse in all modes
" QoL tweaks
set tabstop=2 "width of tabs
set shiftwidth=2 "amount for < and > commands
set shiftround "indent to the next multiple of shiftwidth
set expandtab "insert spaces instead of tabs
" set hidden "allow hiding a buffer instead of requring save
set splitbelow "default horizontal split to lower
set splitright "default vertical split to right
set ignorecase "ignore caps when searching
set smartcase "unless a capital is used
set infercase "smart auto-completion casing
set wildignorecase "ignore case on files and directories
set gdefault "global search by default
set lazyredraw "no need to redraw all the time
set nohlsearch "don't highlight searches by default
set inccommand=nosplit "show substitution while typing
set path+=** "include subdirectory globbing in path for :find
set diffopt+=vertical "vertical split for diffs
set noshowmode "do not show mode since using lightline
" characters for horizontal scrolled text
set listchars+=extends:»
set listchars+=precedes:«
set listchars+=nbsp:⣿
" more solid vertical bar
set fillchars=vert:\│
set completeopt=longest,menuone
let g:mapleader = ' ' "use space as leader
if isdirectory($HOME . '/.config/nvim/undo') == 0
:silent !mkdir -p ~/.config/nvim/undo > /dev/null 2>&1
endif
set undofile
set undodir=~/.config/nvim/undo/
" override $VISUAL to use nvr inside neovim
if executable('nvr')
let $VISUAL="nvr -cc split --remote-wait +'set bufhidden=wipe'"
endif
" fix to not require extra keypress for fzf in terminal
let $FZF_DEFAULT_OPTS .= ' --no-height'
" plugin settings {{{1
let g:netrw_altfile = 1 "allow <c-6> to go to the previously edited file
let g:netrw_preview = 1 "open preview window in a vertical split
let g:netrw_localrmdir='rm -r' "allow deleting non-empty directories
let g:ale_linters = {}
let g:ale_linters.javascript = ['eslint']
let g:ale_fixers = {}
let g:ale_fixers.javascript = ['eslint']
let g:ale_fixers.elixir = ['mix_format']
let g:indent_guides_auto_colors = 0
let g:indent_guides_enable_on_vim_startup = 1
let g:highlightedyank_highlight_duration = 350
let g:ultisnips_javascript = {
\ 'semi': 'never',
\ 'space-before-function-paren': 'never',
\ }
let g:surround_{char2nr('-')} = "<% \r %>"
let g:surround_{char2nr('=')} = "<%= \r %>"
let g:vim_textobj_elixir_mapping = 'E'
let g:tern_show_signature_in_pum = 1
let g:tern#filetypes = ['javascript', 'jsx', 'javascript.jsx']
let g:tern#command = ['tern']
let g:tern#arguments = ['--persistent']
let g:deoplete#sources#ternjs#types = 1
let g:deoplete#sources#ternjs#case_insensitive = 1
let g:deoplete#sources#ternjs#include_keywords = 1
let g:LanguageClient_serverCommands = {
\ 'javascript': ['javascript-typescript-stdio'],
\ 'jsx': ['javascript-typescript-stdio'],
\ 'javascript.jsx': ['javascript-typescript-stdio'],
\ 'elixir': ['elixir-ls'],
\ }
let g:LanguageClient_diagnosticsList = 'Location'
let g:tmux_navigator_no_mappings = 1
let g:deoplete#enable_at_startup = 1
let g:deoplete#min_pattern_length = 1
let g:deoplete#auto_complete_delay = 1
let g:delimitMate_expand_cr = 1
let g:delimitMate_expand_space = 1
let g:gutentags_cache_dir = '~/.tags_cache'
let b:csv_arrange_use_all_rows = 1
let g:quickrun_config = {}
let g:quickrun_config['javascript.jsx'] = { 'type': 'javascript' }
let g:quickrun_config['sh'] = { 'type': 'bash' }
let g:sql_type_default = 'pgsql'
let g:vimwiki_list = [{'syntax': 'markdown', 'ext': '.md'}]
let g:UltiSnipsEditSplit = 'horizontal'
" autocommands {{{1
augroup whitespace
" automatically strip trailiing whitespace on save
autocmd BufWritePre * StripWhitespace
augroup end
augroup dispatch_commands
autocmd FileType sh let b:dispatch = '$SHELL %'
autocmd FileType dot let b:dispatch = 'dot -Tpng % -o %:r.png'
augroup end
augroup ft_match_words
" add do/end as jumps for %
autocmd FileType elixir let b:match_words = '\<do\>:\<end\>'
augroup end
" switch to current file's parent directory
" set autochdir was causing issues with some plugins but needs reinvestigating
augroup vimrc_set_working_dir
au!
autocmd BufRead,BufEnter * silent! lcd %:p:h
augroup end
" only show cursor line one active window
augroup cursorLine
autocmd!
autocmd BufEnter * setlocal cursorline
autocmd BufLeave * setlocal nocursorline
augroup end
" use pgsql syntax inside elixir non-doc string blocks
augroup elixirSql
autocmd!
autocmd FileType elixir call SyntaxRange#Include('\s\{2,\}\"\"\"', '\"\"\"', 'pgsql', 'NonText')
augroup end
augroup pum
" auto-close preview pane
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
augroup end
augroup term_settings
autocmd TermOpen * setlocal nonumber norelativenumber bufhidden=hide
augroup end
augroup term_insert
" go into insert mode if switching to a terminal buffer
autocmd BufEnter term://* startinsert
autocmd BufLeave term://* stopinsert
augroup end
" colors {{{1
colorscheme onedark
highlight! IndentGuidesOdd ctermbg=233
highlight! IndentGuidesEven ctermbg=234
highlight! jsBlock ctermfg=150
highlight! jsObjectKey ctermfg=139
highlight! Constant ctermfg=37
highlight! Normal ctermbg=NONE
" highlight! link TermCursor Cursor
highlight! TermCursorNC ctermbg=0 ctermfg=15
highlight Pmenu ctermbg=240
highlight PmenuSel ctermbg=25
" lighten non-active windows
highlight NormalNC ctermbg=234
" keymappings {{{1
" swap ; and :
"noremap ; :
"noremap : ;
" pretty much always want very magic searches
nnoremap / /\v
nnoremap ? ?\v
cnoremap %s/ %s/\v
cnoremap s/ s/\v
" move cursor into wrapped lines
nnoremap k gk
nnoremap j gj
nnoremap <Up> gk
nnoremap <Down> gj
" warning mappings lke unimpaired
nmap <silent> [W <Plug>(ale_first)
nmap <silent> [w <Plug>(ale_previous)
nmap <silent> ]w <Plug>(ale_next)
nmap <silent> ]W <Plug>(ale_last)
" split navigation
nnoremap <silent> <m-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <m-j> :TmuxNavigateDown<cr>
nnoremap <silent> <m-k> :TmuxNavigateUp<cr>
nnoremap <silent> <m-l> :TmuxNavigateRight<cr>
nnoremap <silent> <m-\> :TmuxNavigatePrevious<cr>
inoremap <m-h> <esc>:TmuxNavigateLeft<cr>
inoremap <m-j> <esc>:TmuxNavigateDown<cr>
inoremap <m-k> <esc>:TmuxNavigateUp<cr>
inoremap <m-l> <esc>:TmuxNavigateRight<cr>
" terminal keybindings
tnoremap <leader><esc> <c-\><c-n>
tnoremap <m-[> <c-\><c-n>
tnoremap <m-h> <c-\><c-n><c-w>h
tnoremap <m-j> <c-\><c-n><c-w>j
tnoremap <m-k> <c-\><c-n><c-w>k
tnoremap <m-l> <c-\><c-n><c-w>l
" tab switching like tmux
nnoremap <leader><m-h> :tabprev<cr>
nnoremap <leader><m-l> :tabnext<cr>
" window resizing
nnoremap <M-S-h> <C-w><
nnoremap <M-S-j> <C-w>+
nnoremap <M-S-k> <C-w>-
nnoremap <M-S-l> <C-w>>
nnoremap <silent> <M-=> <c-w>=
nnoremap <silent> <c-w>' :call ZoomToggle()<cr>
nnoremap <silent> <c-w>z :call MaximizeWindow()<cr>
nnoremap <silent> <M-'> :call ZoomToggle()<cr>
nnoremap <silent> <M-z> :call MaximizeWindow()<cr>
" open file to side
nnoremap gF :vertical wincmd f<CR>
" mimic D,C (to end of line)
nnoremap Y y$
" use Q to play q macro
nnoremap Q @q
" allow range commands from searches - ex: /foo$m
cnoremap $t <CR>:t''<CR>
cnoremap $m <CR>:m''<CR>
cnoremap $d <CR>:d<CR>``
" reselect pasted content:
noremap gV `[v`]
" insert time / date
nnoremap <leader>it "=strftime("%H:%M")<CR>P
nnoremap <leader>id "=strftime("%Y-%m-%d")<CR>P
nnoremap <leader>iD "=strftime("%m.%d.%Y")<CR>P
" netrw splits
noremap <silent> <leader>x :Vexplore!<CR>:wincmd =<CR>
noremap <silent> <leader>X :Sexplore<CR>:wincmd =<CR>
" use sudo for file if forgot to when opened
nnoremap <leader>sw :w !sudo tee % >/dev/null<cr>
" super find
nnoremap <leader>f :GFiles -co --exclude-per-directory=.gitignore<CR>
nnoremap <leader>F :FZF<CR>
" super search
nnoremap <leader>/ :Ag<space>
nnoremap <leader>? :BLines<space>
" buffer management
nnoremap <leader>b :Buffers<cr>
nnoremap <c-up> :ls<cr>:b
nnoremap <c-right> :bn<cr>
nnoremap <c-left> :bp<cr>
nnoremap <c-down> :bn \| bd #<cr>
nnoremap <leader>w :w<cr>
nnoremap <leader>q :q<cr>
nnoremap <leader>Q :bd<cr>
" search for word under cursor with <leader>*
nnoremap <leader>* :Ag <c-r><c-w><CR>
" system clipboard yank
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>p "+p
vnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>P "+P
" put searches in middle of screen
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
xmap n nzz
xmap N Nzz
xmap * *zz
xmap # #zz
nmap g* g*zz
nmap g# g#zz
nnoremap <leader>d :Dispatch<cr>
vnoremap <leader>d :<c-u>execute ':Dispatch ' . substitute(b:dispatch, '%', shellescape(join(getline(line("'<"), line("'>")), "\n"), "\n"), "")<cr>
" search for visual selection
xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>/<C-R>=@/<CR><CR>
" pane toggles
nnoremap <F5> :MundoToggle<CR>
nnoremap <F8> :TagbarToggle<CR>
" edit vimrc/zshrc and source vimrc
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>ez :vsp ~/.zshrc<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
nnoremap <leader>sf :source %<CR>
" save session
nnoremap <leader>s :mksession<CR>
" term splits like tmux
nnoremap <leader>\ :VTerm<CR>
nnoremap <leader>- :STerm<CR>
nnoremap <leader>\| :VTermRepo<CR>
nnoremap <leader>_ :STermRepo<CR>
" inside template tags
onoremap <silent> iT :<c-u>execute "silent normal! ?\\v[{<][{%]\\=\\?\\zs.\rv/\\v.\\ze[%}][>}]\r"<cr>
vnoremap <silent> iT :<c-u>execute "silent normal! ?\\v[{<][{%]\\=\\?\\zs.\rv/\\v.\\ze[%}][>}]\r"<cr>
onoremap <silent> aT :<c-u>execute "silent normal! ?\\v[{<][{%]\\=\\?.\rv/\\v[%}][>}]/e\r"<cr>
vnoremap <silent> aT :<c-u>execute "silent normal! ?\\v[{<][{%]\\=\\?.\rv/\\v[%}][>}]/e\r"<cr>
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
" run 'q' macro on selection
xnoremap Q :normal @q<CR>
" port 8090
nnoremap <leader>md :InstantMarkdownPreview<CR>
fun! MapLCKeys()
" Don't map for built-in ones
if &ft =~ 'vim\|help\|shell'
return
endif
nnoremap <F2> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F3> :call LanguageClient#textDocument_rename()<CR>
endfun
autocmd FileType * call MapLCKeys()
" fzf
" Mapping selecting mappings
nnoremap <leader><tab> <plug>(fzf-maps-n)
xnoremap <leader><tab> <plug>(fzf-maps-x)
onoremap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
inoremap <c-x><c-k> <plug>(fzf-complete-word)
inoremap <c-x><c-f> <plug>(fzf-complete-path)
inoremap <c-x><c-j> <plug>(fzf-complete-file-ag)
inoremap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" commands {{{1
" close all other buffers
command! BufOnly :%bd|e#
command! BufCleanup :call BufCleanup()
command! SynStack :call SynStack()
" open a terminal in a different view while setting bufhidden to hide to keep alive
command! -nargs=* VTerm :vsp
\ | execute 'terminal' <args>
command! -nargs=* VTermRepo :vsp
\ | execute 'lcd' fnameescape(s:get_git_root())
\ | execute 'terminal' <args>
command! -nargs=* STerm :sp
\ | execute 'terminal' <args>
command! -nargs=* STermRepo :sp
\ | execute 'lcd' fnameescape(s:get_git_root())
\ | execute 'terminal' <args>
command! -nargs=* TTerm :tabnew
\ | execute 'terminal' <args>
command! -nargs=* TTermRepo :tabnew
\ | execute 'lcd' fnameescape(s:get_git_root())
\ | execute 'terminal' <args>
" amend without editing commit message
command! Gamend Gcommit --amend --no-edit
command! -range FormatJSON :<line1>,<line2>call FormatJSON()
" functions {{{1
function! MaximizeWindow()
vertical resize
resize
endfunction
let s:maximized=0
function! ZoomToggle()
if s:maximized
wincmd =
let s:maximized=0
else
call MaximizeWindow()
let s:maximized=1
endif
endfunction
" extracted from inside fzf
function! s:get_git_root()
try
return fugitive#repo().tree()
catch
return ''
endtry
endfunction
" override Ag command to search inside git repo
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>, {'dir': FugitiveWorkTree()}, <bang>0)
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>),
\ 1,
\ {'dir': FugitiveWorkTree()},
\ <bang>0
\ )
" from issue, but doesn't work at all in non-repo
"command! -bang -nargs=* GitAg\ call fzf#vim#ag(<q-args>, {'dir': systemlist('git rev-parse --show-toplevel')[0]}, <bang>0)
" run macro on selection
function! g:ExecuteMacroOverVisualRange()
echo '@'.getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
" search for visual selection - from practical vim
function! s:VSetSearch(cmdType)
let l:temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, a:cmdType.'\'), '\n', '\\n', 'g')
let @s = l:temp
endfunction
" show highlight stack
function! SynStack()
let l:syns = synstack(line('.'), col('.'))
call map(l:syns, {key, id -> [synIDattr(id, 'name'), synIDattr(synIDtrans(id), 'name')]})
call map(l:syns, {key, pair -> ('[' . get(pair, 0) . '->' . get(pair, 1) . ']')})
let l:stack = join(l:syns, ' => ')
echo l:stack
endfunction
" Delete buffers that are not displayed in any window or modified
function! BufCleanup()
let l:tabs = map(copy(gettabinfo()), 'v:val.tabnr')
let l:openBuffers = []
for l:i in l:tabs
call extend(l:openBuffers, tabpagebuflist(l:i))
endfor
let l:buffers = map(filter(filter(copy(getbufinfo()), 'v:val.listed'), {i, info -> info.changed == v:false}), 'v:val.bufnr')
for l:bnr in l:buffers
if index(l:openBuffers, l:bnr) < 0
exe 'bd '.l:bnr
endif
endfor
endfunction
" format a block of JSON with python's built-in function
function! FormatJSON() range
let l:fullRange = a:firstline.','.a:lastline
let l:singeLine = a:firstline.','.a:firstline
silent exe l:fullRange.'join | '.l:singeLine.'! python3 -m "json.tool"'
silent normal =}
endfunction
" statusline {{{1
"\ 'colorscheme': 'onedark',
let g:lightline = {
\ 'component': {
\ 'mode': '%{lightline#mode() . " " . ObsessionStatus()}',
\ 'readonly': '%{&readonly?"\ue0a2":""}',
\ },
\ 'component_function': {
\ 'filename': 'FilenameWithIcon',
\ 'gitversion': 'GitVersion',
\ },
\ 'active': {
\ 'right': [
\ [ 'lineinfo'],
\ [ 'gitversion', 'percent' ],
\ [ 'fileformat', 'filetype' ],
\ ]
\ },
\ 'inactive': {
\ 'right': [
\ [ 'lineinfo' ],
\ [ 'gitversion', 'percent' ],
\ ]
\ },
\ }
" custom icon overrides
let s:icons = {
\ 'jsx': "\ue7ba",
\ 'javascript.jsx': "\ue7ba",
\ 'nginx': "\ue776",
\ }
function! FilenameWithIcon()
if exists('*WebDevIconsGetFileTypeSymbol')
let l:icon = index(keys(s:icons), &filetype) > -1 ? s:icons[&filetype] : WebDevIconsGetFileTypeSymbol()
else
let l:icon = ''
endif
let l:filename = expand('%')
return len(l:filename) > 0 ? l:filename . ' ' . l:icon : '[No File]'
endfunction
function! GitVersion()
let l:fullname = expand('%')
let l:gitversion = ''
if l:fullname =~? 'fugitive://.*/\.git//0/.*'
let l:gitversion = 'git index'
elseif l:fullname =~? 'fugitive://.*/\.git//2/.*'
let l:gitversion = 'git target'
elseif l:fullname =~? 'fugitive://.*/\.git//3/.*'
let l:gitversion = 'git merge'
elseif &diff == 1
let l:gitversion = 'working copy'
endif
return l:gitversion
endfunction
" after.vim loading {{{1
" allow loading of device specific configs
if filereadable(expand('$HOME/init.after.vim'))
source $HOME/init.after.vim
endif