-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
163 lines (148 loc) · 5.61 KB
/
vimrc
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
set nocompatible
set wildcharm=<c-z> " Enable usage in map target
set backspace=indent,eol,start " Allow backspacing over everything in insert mode.
set showcmd " display incomplete commands
set wildmenu " display completion matches in a status line
set ttimeout " time out for key codes
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
set incsearch
set regexpengine=0 " needs to be explicitly set to always be active
set mouse+=a
set shortmess-=S " display short messages in ruler
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
syntax on
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
" Revert with: ":delcommand DiffOrig".
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Prevent that the langmap option applies to characters that result from a
" mapping. If set (default), this may break plugins (but it's backward
" compatible).
if has("langmap") && exists("+langremap")
set nolangremap
endif
" Set space as leader key
let mapleader=" "
" Source common vim/nvim config
source $HOME/.config/nvim/some.vim
" OPTIONS
set clipboard=unnamed " Sync system clioboard
set hlsearch " Highlight search matches
set omnifunc=syntaxcomplete#Complete " c-x c-o to complete syntax
set undodir=$HOME/.vimundo undofile
" NETRW OPTIONS
let g:netrw_banner=0 " Remove top banner
let g:netrw_preview=1 " Vertical preview
" COLORS - recommended (dual) lunaperche quiet (dark) habamax industry slate (light) zellner
try | set background=dark | colo lunaperche | catch | colo slate " fallback for older Vim versions
endtry
" KEYMAPS
" Core improve
nnoremap Y y$
nnoremap <silent> <c-l> :nohlsearch<cr><c-l>
" Additional esc map
tnoremap jk <c-w>N
" Find links
nn <leader>fl ?\v\S+[:\|.]\S+<cr>
" Fuzzy find files
nn <leader>s :call FuzzyFiles("rg --files", ":e")<cr>
" Git
nn <silent> <leader>gg :packadd vim-fugitive<bar>G<cr>
nn <silent> <leader>gp :packadd vim-fugitive<bar>G pull<cr>
nn <silent> <leader>gP :packadd vim-fugitive<bar>G push<cr>
" Easymotions
let g:EasyMotion_startofline = 0 " keep cursor colum JK motion
map <Leader>j :packadd vim-easymotion<cr><Plug>(easymotion-j)
map <Leader>k :packadd vim-easymotion<cr><Plug>(easymotion-k)
nmap <tab> <Plug>(easymotion-overwin-line)
" Codium
let g:codeium_disable_bindings = 1
imap <script><silent><nowait><expr> <tab> codeium#Accept()
imap <script><silent><nowait><expr> <c-f> codeium#Accept()
imap <c-j> <cmd>call codeium#CycleCompletions(1)<cr>
imap <c-k> <cmd>call codeium#CycleCompletions(-1)<cr>
imap <c-x> <cmd>call codeium#Clear()<cr>
" TERMINAL
nn <silent> <leader><cr> <cmd>call termcwd#spGet()<cr>
nn <silent> <leader>t<cr> <cmd>call termcwd#tabGet()<cr>
nn <silent> <leader>1 <cmd>call termcwd#spGet(0,'')<cr>
" LSP KEYMAPS
function! s:on_lsp_buffer_enabled() abort
let g:lsp_diagnostics_virtual_text_align="right"
setlocal omnifunc=lsp#complete
if exists("+tagfunc") | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> <leader>lr <plug>(lsp-references)
nmap <buffer> <leader>lt <plug>(lsp-type-definition)
nmap <buffer> <c-k> <plug>(lsp-previous-diagnostic)
nmap <buffer> <c-j> <plug>(lsp-next-diagnostic)
nmap <buffer> <leader>lh <plug>(lsp-hover)
endfunction
" NETRW KEYMAPS
function! SetNetrwKeymaps() abort
nn <buffer> s /
nmap <buffer> <c-j> <cr>
nmap <buffer> <c-k> v
endfunction
" AUTO COMMANDS
aug vim_config | au!
" FileTypes
au BufNewFile,BufRead *.mdx set ft=markdown
au TerminalWinOpen * setlocal bufhidden=hide
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
" Set netrw maps
autocmd filetype netrw call SetNetrwKeymaps()
augroup END
" FUZZY EDIT W/FZY
fu! FuzzyFiles(choice_command, vim_command) abort
try | let output = system(a:choice_command . " | fzy ")
catch /Vim:Interrupt/ | endtry | redraw!
if v:shell_error == 0 && !empty(output)
exec a:vim_command . " " . output
en
endf
" PLUGINS
fu! PackInit() abort
packadd minpac
call minpac#init()
call minpac#add("k-takata/minpac", {"type": "opt"})
call minpac#add("tpope/vim-sleuth")
call minpac#add("tpope/vim-surround")
call minpac#add("tpope/vim-commentary")
call minpac#add("easymotion/vim-easymotion", {"type": "opt"})
call minpac#add("tpope/vim-fugitive", {"type": "opt"})
call minpac#add("prabirshrestha/vim-lsp")
call minpac#add("mattn/vim-lsp-settings")
" call minpac#add("prabirshrestha/asyncomplete.vim")
" call minpac#add("prabirshrestha/asyncomplete-buffer.vim")
" call minpac#add("prabirshrestha/asyncomplete-lsp.vim")
" call minpac#add("yami-beta/asyncomplete-omni.vim")
call minpac#add("tpope/vim-vinegar")
call minpac#add("Exafunction/codeium.vim")
call minpac#add("tweekmonster/startuptime.vim")
" Filetypes
call minpac#add("othree/html5.vim")
call minpac#add("pangloss/vim-javascript")
call minpac#add("evanleck/vim-svelte")
call minpac#add("wuelnerdotexe/vim-astro")
endf
command! Update source $MYVIMRC | call PackInit() | call minpac#update()
command! Clean source $MYVIMRC | call PackInit() | call minpac#clean()
" Javascript
let g:javascript_plugin_jsdoc = 1
" Svelte
let g:svelte_preprocessors=[
\"postcss"] " "sass", "typescript"
" Astro
let g:astro_typescript = "enable"