-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc-dev
341 lines (324 loc) · 8.85 KB
/
vimrc-dev
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
" ==================================================
" .vimrc FOR DEVELOPMENT
" ==================================================
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'}
Plug 'junegunn/fzf.vim'
Plug 'github/copilot.vim'
Plug 'madox2/vim-ai'
Plug 'preservim/tagbar'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'chrisbra/vim-diff-enhanced'
Plug 'airblade/vim-gitgutter'
Plug 'szw/vim-maximizer'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-sensible'
Plug 'fatih/vim-go'
Plug 'mhinz/vim-mix-format'
Plug 'guns/xterm-color-table.vim'
call plug#end()
" --------------------------------------------------
" SETTINGS
" --------------------------------------------------
filetype off
filetype plugin indent off
set autoread
set autowrite
set autoindent
set wildmenu
set cursorline
set hidden
set hlsearch
set incsearch
set number
set showcmd
set smartcase
set splitright
set splitbelow
set splitright
set splitbelow
set ttyfast
set backspace=indent,eol,start
set omnifunc=syntaxcomplete#Complete
set completeopt-=preview
set foldmethod=syntax
set foldnestmax=4
set foldlevel=0
set shell=zsh
set mouse=a
set ttymouse=sgr
set ttyscroll=3
set laststatus=2
set encoding=utf-8
set shiftwidth=4
set tabstop=4
set timeoutlen=2000
set t_Co=256
set rtp+=/usr/local/opt/fzf
set signcolumn=number
set viminfo='1000,f1
set noexpandtab
set nobackup
set nocompatible
set nofoldenable
set noignorecase
set noswapfile
set nowritebackup
filetype plugin indent on
colorscheme muedark
syntax on
let mapleader = "+"
let maplocalleader = "#"
let $FZF_DEFAULT_OPTS = '--preview "bat --style=numbers --color=always --line-range :500 {}"'
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
let g:deoplete#enable_at_startup = 1
let g:airline#extensions#tabline#enabled = 0
let g:airline_theme = "sol"
let g:go_auto_type_info = 1
let g:go_metalinter_autosave = 0
let g:go_updatetime = 500
let g:go_def_mode = 'gopls'
let g:go_info_mode = 'gopls'
let g:go_fmt_command = "gopls"
let g:go_list_type = "quickfix"
let g:go_list_height = 10
let g:go_test_show_name = 1
let g:go_test_timeout = '60s'
let g:go_term_enabled = 1
let g:go_term_mode = "split"
let g:go_doc_balloon = 1
let g:mix_format_on_save = 1
let g:neural = {
\ 'source': {
\ 'openai': {
\ 'api_key': $OPENAI_API_KEY,
\ },
\ },
\}
" --------------------------------------------------
" CONDITIONAL SETTINGS
" --------------------------------------------------
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
endif
if has("gui_running")
set guioptions=Te
if has("gui_gtk2") || has("gui_gtk3")
set guifont=JetBrains\ Mono\ 15
elseif has("gui_photon")
set guifont=JetBrains\ Mono:h15
elseif has("x11")
set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
else
set guifont=JetBrains_Mono:h15
endif
endif
if has("macunix")
let g:tagbar_ctags_bin = "/opt/homebrew/bin/ctags"
endif
" --------------------------------------------------
" FUNCTIONS AND COMMANDS
" --------------------------------------------------
function! g:KbdGerman()
iunmap ü
iunmap ö
iunmap ä
iunmap Ö
iunmap Ä
iunmap ß
endfunction
function! g:KbdProgramming()
imap ü <C-[>
imap ö [
imap ä ]
imap Ö {
imap Ä }
imap ß /
endfunction
function! g:CheckTerminal(num)
if bufexists(str2nr(a:num))
exec ":buffer " . a:num
if &buftype == 'terminal'
exec 'bd'
endif
endif
endfunction
function! g:CloseTerminals()
let result = filter(range(1, bufnr('$')), 'CheckTerminal(v:val)')
endfunction
command! KbdGerman :call KbdGerman()
command! KbdProgramming :call KbdProgramming()
command! CloseTerminals :call CloseTerminals()
command! Todo noautocmd vimgrep /TODO\|FIXME/j ** | cw
command! MkTags noautocmd !gotags -R -sort * > tags
" --------------------------------------------------
" KEY MAPPINGS
" --------------------------------------------------
"
" Yank and paste
"
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
nnoremap <leader>yy "+yy
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
"
" Move visual block
"
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
"
" Ctrl-A
"
nnoremap <C-A>a :AI<CR>
xnoremap <C-A>a :AI<CR>
xnoremap <C-A>s :AIEdit fix grammar and spelling<CR>
nnoremap <C-A>s :AIEdit fix grammar and spelling<CR>
xnoremap <C-A>c :AIChat<CR>
nnoremap <C-A>c :AIChat<CR>
nnoremap <C-A>r :AIRedo<CR>
"
" Ctrl-P
"
nnoremap <C-P>a :TagbarToggle<CR>
nnoremap <C-P>b :Gblame<CR>
nnoremap <C-P>c :Commits<CR>
nnoremap <C-P>d :dig<CR>
nnoremap <C-P>f :GFiles<CR>
nnoremap <C-P>g :GFiles?<CR>
nnoremap <C-P>h :History:<CR>
nnoremap <C-P>l :Lines<CR>
nnoremap <C-P>m :Commands<CR>
nnoremap <C-P>n :BCommits<CR>
nnoremap <C-P>o :Files<CR>
nnoremap <C-P>p :Buffers<CR>
nnoremap <C-P>q :qa<CR>
nnoremap <C-P>t :BTags<CR>
nnoremap <C-P>v :Vexplore<CR>
nnoremap <C-P>w :Windows<CR>
inoremap <C-P>x :CloseTerminals
nnoremap <C-P>z :terminal<CR>
"
" Ctrl-S
"
nnoremap <C-S>s //gc<LEFT><LEFT><LEFT>
nnoremap <C-S>f /\<<C-r><C-w>\>//gc<CR>
nnoremap <C-S>r :%s///gc<LEFT><LEFT><LEFT><LEFT>
nnoremap <C-S>w :%s/\<<C-r><C-w>\>//g<LEFT><LEFT>
nnoremap <C-S>W :%S/\<<C-r><C-w>\>//g<LEFT><LEFT>
nnoremap <C-S>y :%sno/<C-r><C-o>"//g<LEFT><LEFT>
nnoremap <C-S>g :Ag <C-r><C-w><CR>
nnoremap <C-S>a :Ag<SPACE>
nnoremap <C-S><space> :nohlsearch<CR>
nnoremap <C-S>j :jumps<CR>
nnoremap <C-S>c :clear<CR>
nnoremap <C-S>J :%!python -m json.tool<CR>
"
" Ctrl-T
"
nnoremap <C-T>c :set cuc!<CR>
nnoremap <C-T>n :cnext<CR>
nnoremap <C-T>p :cprev<CR>
nnoremap <C-T>k :bnext<CR>
nnoremap <C-T>j :bprev<CR>
nnoremap <C-T>l :tabnext<CR>
nnoremap <C-T>h :tabprev<CR>
"
" Ctrl-W
"
nnoremap <C-W>h :sp<CR>
nnoremap <C-W>n :next<CR>
nnoremap <C-W>m :MaximizerToggle<CR>
nnoremap <C-W>o :only<CR>
nnoremap <C-W>p :previous<CR>
nnoremap <C-W>w :Windows<CR>
nnoremap <C-W>v :vsp<CR>
"
" Edit and source .vimrc
"
nmap <leader>ev :tabedit $MYVIMRC<CR>
nmap <leader>sv :source $MYVIMRC<CR>
"
" Misc
"
inoremap <leader>ww <ESC>:wa<CR>
nnoremap <leader>ww :wa<CR>
nmap <leader>xx :bdelete<CR>
nmap <leader>cc :cclose<CR>
nmap <leader>oo :only<CR>
nmap <leader>tt :terminal<CR>
nmap <leader>qq :qa<CR>
nnoremap <leader><space> :nohlsearch<CR>
nnoremap <leader>N :setlocal number!<CR>
inoremap jj <ESC>
nnoremap n nzzzv
nnoremap N Nzzzv
vnoremap < <gv
vnoremap > >gv
" --------------------------------------------------
" ACTIONS
" --------------------------------------------------
if has("autocmd")
" Write and read buffer.
autocmd BufWritePre * :%s/\s\+$//e
autocmd BufReadPost * if line("'\"") | exe "'\"" | endif
" Go / vim-go.
autocmd FileType go nmap <C-G>a :GoAddTabs<CR>
autocmd FileType go nmap <C-G>A :GoRemoveTags<CR>
autocmd FileType go nmap <C-G>b :GoBuild<CR>
autocmd FileType go nmap <C-G>B :GoTestCompile<CR>
autocmd FileType go nmap <C-G>c :GoCallers<CR>
autocmd FileType go nmap <C-G>C :GoCallees<CR>
autocmd FileType go nmap <C-G>d :GoDef<CR>
autocmd FileType go nmap <C-G>D :GoDefPop<CR>
autocmd FileType go nmap <C-G>e :GoErrCheck<CR>
autocmd FileType go nmap <C-G>f :GoFmt<CR>
autocmd FileType go nmap <C-G>F :GoImports<CR>
autocmd FileType go nmap <C-G>h :GoDoc<CR>
autocmd FileType go nmap <C-G>i :GoImplements<CR>
autocmd FileType go nmap <C-G>I :GoInstall<CR>
autocmd FileType go nmap <C-G>l :GoDecls<CR>
autocmd FileType go nmap <C-G>L :GoDeclsDir<CR>
autocmd FileType go nmap <C-G>m :GoMetaLinter<CR>
autocmd FileType go nmap <C-G>n :GoInfo<CR>
autocmd FileType go nmap <C-G>o :GoCoverage<CR>
autocmd FileType go nmap <C-G>O :GoCoverageBrowser<CR>
autocmd FileType go nmap <C-G>p :GoDeps<CR>
autocmd FileType go nmap <C-G>P :GoChannelPeers<CR>
autocmd FileType go nmap <C-G>r :GoReferrers<CR>
autocmd FileType go nmap <C-G>R :GoRename<CR>
autocmd FileType go nmap <C-G>s :GoCallstack<CR>
autocmd FileType go nmap <C-G>S :GoDescribe<CR>
autocmd FileType go nmap <C-G>t :GoTestFunc<CR>
autocmd FileType go nmap <C-G>T :GoTest<CR>
autocmd FileType go nmap <C-G>v :GoVet<CR>
autocmd FileType go nmap <C-G>x :GoRun %<CR>
endif
" Keep undo history across sessions by storing it in a file.
if has('persistent_undo')
let vimdir = '$HOME/.vim'
let vimundodir = expand(vimdir . '/undodir')
call system('mkdir ' . vimdir)
call system('mkdir ' . vimundodir)
let &undodir = vimundodir
set undofile
endif
" Standard keyboard for programming.
call KbdProgramming()
" ==================================================
" EOF
" ==================================================