-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
431 lines (346 loc) Β· 12.9 KB
/
vimrc
File metadata and controls
431 lines (346 loc) Β· 12.9 KB
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
let g:slime_no_mappings = 1
let g:copilot_enabled = 0
let mapleader = "\<Space>"
filetype plugin indent on " important options
syntax on " turn on syntax highlighting
let lightscheme = 'xcode'
let darkscheme = 'saturnite'
set background=dark
execute 'colorscheme ' . darkscheme
nnoremap gt :Tags<CR>
nnoremap gT :BTags<CR>
" i do this a lot: ggVG followed by <space>y
" TODO -DOES NOT WORK
nnoremap <C-S-c> ggVG<Space>y
" I want gL to run :Lines
nnoremap gl :Lines<CR>
set autoindent " dont need smartindent. syntax files do that
set encoding=utf-8 " encoding
set hidden " allow hidden buffers
set iskeyword+=-
set laststatus=2 " always show status bar
set linebreak " breaks on space + :set breakat?
set modelines=1 " security
set noequalalways " don't equalize window sizes when splitting
set ruler " show file stats
set signcolumn=number
set t_vb= " dont beep
set termguicolors
set visualbell " dont blink
set mouse=a " enable mouse
set cursorlineopt=screenline " highlights single line when line is wrapped
set display+=lastline " show as much of last line as possible, useful when statusline is disabled
" TODO don't offer to open certain files/directories
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png,*.ico
set wildignore+=*.pdf,*.psd,*.com,*.tdy,*.dll,*.exe
set wildignore+=*.o,*.obj,*.so,*.a,*.lib,*.i,*.s
set wildignore+=bower_components/*,*/.vim/junk/*
set wildignore+=**/node_modules/**,tags,**/dist/**
" use existing tab if possible when loading a file from quickfix
set switchbuf+=usetab
" whitespace
set nowrap
set textwidth=0
set formatoptions=tcqrn1
set shiftwidth=2
set softtabstop=2
set expandtab
set noshiftround
" ui
set lazyredraw " make things like macros run faster
set wildmenu
set wildmode=list:full
set shortmess+=WI
" cursor motion
set scrolloff=1
set backspace=indent,eol,start
set matchpairs+=<:> " use % to jump between pairs
set whichwrap+=<,>,h,l,[,] " wrap cursor on more shit
" folds
set foldmethod=indent
set foldnestmax=10
set foldlevelstart=10
" last line
set showmode
set showcmd
" searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
" formatting
set nojoinspaces
nnoremap <space>q gggqG
" visualize tabs and newlines
set listchars=tab:βΈ\ ,eol:Β¬
let &showbreak = 'β³ '
" set guitablabel=%f
set guitablabel=%t
" undo/backup shit
set backupdir=~/.vim/junk/backup// " double slash means files are stored with
set directory=~/.vim/junk/swp// " full path, to eliminate clobbering
set undodir=~/.vim/junk/undo//
set viewdir=~/.vim/junk/view//
set undofile
set undolevels=1000
set undoreload=10000
set backupcopy=yes
" change cursor from block to i-beam in insert mode
" https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes
" may need but idk: autocmd VimEnter * silent !echo -ne "\e[1 q"
let &t_SI = "\e[6 q" " steady i-beam in insert mode
let &t_EI = "\e[2 q" " steady block in normal mode
" window management
set splitright
nmap <c-n> :SC<cr>
nmap <c-c> :q<cr>
" maximize
nnoremap <C-w>\ <C-w>\|<C-w>_
" mode exit
imap jj <esc>
" kill highlight
map <space>l :let @/=''<cr>
nnoremap gf gF
nnoremap gF gf
" kill whitespace
nnoremap <silent> <space>W :%s/\s\+$//<cr>:let @/=''<cr>
" vimrc
nnoremap <silent> <space>ev :edit ~/.vim/vimrc<cr>
nnoremap <silent> <space>eq :edit ~/.config/qutebrowser<cr>
nnoremap <silent> <space>es :edit ~/.vim/after/plugin/settings.vim<cr>
nnoremap <silent> <space>rv :source ~/.vim/vimrc<cr>
nnoremap <silent> <space>er :edit ~/lisp/notes/learnxiny.rkt<cr>
nnoremap <silent> <space>eg :edit ~/.gitrc<cr>
nnoremap <silent> <space>el :edit ~/brain/journals/<cr>
nnoremap <silent> <space>eu :edit ~/txt/unicode.txt<cr>
nnoremap <silent> <space>ei :edit ~/.config/i3/config<cr>
nnoremap <silent> <space>eb :edit ~/.bashrc<cr>
nnoremap <silent> <space>ej :edit ~/matrix/brain/journals/<cr>:$<cr>
nnoremap <silent> <space>em :edit ~/matrix<cr>
nnoremap <silent> <space>ep :edit ~/.profile<cr>
nnoremap <silent> <space>ex :edit ~/.Xdefaults<cr>
nnoremap <silent> <space>ed :edit ~/dungeon/xom.world/frontend/txt/shmup.crawlrc<cr>
nnoremap <silent> <space>et :edit ~/.tmux.conf<cr>
nnoremap <silent> <space>ef :edit ~/.mozilla/firefox/jtm/chrome/userChrome.css<cr>
nnoremap <silent> <space>ec :edit ~/.vim/coc-settings.json<cr>
nnoremap <silent> <space>ea :edit ~/.config/alacritty/alacritty.toml<cr>
nnoremap <silent> <space>ew :edit ~/.config/wezterm/wezterm.lua<cr>
nnoremap <silent> <space>ek :edit ~/.config/kitty/kitty.conf<cr>
" alt-tab between two buffers
nnoremap <space><space> :b#<cr>
" better window changing
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" make Y like C/D
nnoremap Y y$
" toggles, also :help *unimpaired-toggling*
" https://github.com/tpope/vim-unimpaired/blob/master/doc/unimpaired.txt#L77-L95
nnoremap <silent><expr>yot printf(":set bg=%s \| colo %s\r", &bg ==# 'dark' ? 'light' : 'dark', &bg ==# 'dark' ? lightscheme : darkscheme)
nnoremap <silent>yog :GitGutterToggle<cr>
nnoremap <silent>yoG :Goyo<CR>
nmap <silent>yoo <Plug>(ReadingToggle)
nmap <silent>yoN <Plug>(TextNrToggle)
nmap <silent>yoW <Plug>(WiktListToggle)
nnoremap <silent>yoz :syntax sync fromstart<CR>
nnoremap <silent><buffer> yoe :let &l:conceallevel = 2 - &l:conceallevel<CR>
nmap ,q <Plug>(qf_qf_switch)
nmap ,Q <Plug>(qf_qf_toggle_stay)
" just do it
inoremap <C-x> β
nnoremap <leader>j :% !jq .<CR>
nnoremap j gj
nnoremap k gk
" easier change and replace word
nnoremap c* *Ncgn
nnoremap c# #NcgN
nnoremap cg* g*Ncgn
nnoremap cg# g#NcgN
" change to file dir, repo dir, or Z result
nnoremap <silent> ,cd :lcd %:p:h<cr>
nnoremap <silent> ,cr :lcd <c-r>=FugitiveWorkTree()<cr><cr>
nnoremap ,z :Z<space>
nnoremap ,e :silent Zedit<space>
" auto expansion
inoremap (<cr> (<cr>)<esc>O
inoremap `<cr> `<cr>`<esc>O
inoremap {<cr> {<cr>}<esc>O
inoremap {; {<cr>};<esc>O
" inoremap {, {<cr>},<esc>O
inoremap [<cr> [<cr>]<esc>O
inoremap [; [<cr>];<esc>O
" inoremap [, [<cr>],<esc>O
" keep cursor put
nnoremap * *``
nnoremap # #``
nnoremap g* g*``
nnoremap g# g#``
" quicker buffer
nnoremap gb :ls<cr>:buffer<space>
nnoremap gB :ls<cr>:sbuffer<space>
" find mappings
nnoremap ,f :find *
nnoremap ,s :sfind *
nnoremap ,v :vert sfind *
nnoremap ,F :find ./**/*
nnoremap ,S :sfind ./**/*
nnoremap ,V :vert sfind ./**/*
nnoremap ,t :tabfind *
nnoremap ,T :tabfind ./**/*
" code assistance
inoremap <silent> <C-l> <Plug>(copilot-suggest)
inoremap <silent> <C-j> <Plug>(copilot-next)
inoremap <silent> <S-C-j> <Plug>(copilot-accept-line)
nnoremap <silent> ,cw :Workspaced<CR>
nnoremap <silent> ,cp :let g:copilot_enabled = !g:copilot_enabled
\ <bar> echo "Copilot " . (g:copilot_enabled ? "enabled" : "disabled")
\ <CR>
" let me save with sudo when needed
cmap w!! %!sudo tee > /dev/null %
" yank and delete to system clipboard
vnoremap <space>y "+y
vnoremap <space>d "+d
" OSC52 clipboard copy (toggle with yoy)
let g:osc52_enabled = 0
function! OSC52Yank()
if g:osc52_enabled
call system("printf $'\\e]52;c;%s\\a' \"$(base64 <<< " . shellescape(join(v:event.regcontents, "\n")) . ")\" > /dev/tty", "")
endif
endfunction
autocmd! TextYankPost * call OSC52Yank()
nnoremap <silent> yoy :let g:osc52_enabled = !g:osc52_enabled
\ <bar> echo "OSC52 clipboard " . (g:osc52_enabled ? "enabled" : "disabled")<CR>
nnoremap <space>ty :%y+<CR>:echo "Yanked entire file!"<CR>
" it's a mood thing
command! BufOnly silent! execute "%bd|e#|bd#"
nnoremap <space>o :only<cr>
nnoremap <space>O :BufOnly<cr>
" tab nav
nnoremap <space>tn :tabnew<cr>:tabmove 0<cr>
nnoremap <space>tN :tabnew<cr>
nnoremap <space>tc :tabclose<cr>
nnoremap <space>to :tabonly<cr>
for i in range(1, 9)
execute 'nnoremap <Space>'.i.' '.i.'gt'
execute 'nnoremap <Space>tm'.i.' :tabmove '.(i-1).'<CR>'
endfor
" easy align
vmap <enter> <plug>(EasyAlign)
" xmap ga <plug>(EasyAlign)
" nmap ga <plug>(EasyAlign)
" GoTo code navigation.
" fugitive/rhubarb/gv
nmap <space>gb :G blame<cr>
nmap <space>gs :G<cr>
nmap <space>ge :Gedit<cr>
nmap <space>gl :BCommits<cr>
nmap <space>gL :GcLog<cr>
nmap <space>gd :Gdiffsplit<cr>
nmap <space>gw :Gwrite<cr>
nmap <space>gp :Git log -p -- %<cr>
" gutter
nmap [c <plug>(GitGutterPrevHunk)
nmap ]c <plug>(GitGutterNextHunk)
nmap <space>hs <Plug>(GitGutterStageHunk)
nmap <space>hu <Plug>(GitGutterUndoHunk)
nmap <space>hv <Plug>(GitGutterPreviewHunk)
set statusline=%3l " show the line number
set statusline+=, " and a comma
set statusline+=%v " show the virtual column number
set statusline+=\ " and two spaces
set statusline+=( " and a (
set statusline+=%{strlen(@\")} " byte count in register
set statusline+=)\ " and a )
set statusline+=%{printf('x%X',char2nr(getline('.')[getpos('.')[2]-1]))}
set statusline+=\ " and two spaces
set statusline+=%Y " show the filetype
set statusline+=\ " and two spaces
set statusline+=%{www#status()}
set statusline+=%{ObsessionStatus('πΎ','')}
set statusline+=%{g:coc_enabled?'π':'π'}
set statusline+=%{g:copilot_enabled?'π':'π'} " π π π π π
set statusline+=%{llm#ThinkingStatus()}
set statusline+=\ " and two spaces
set statusline+=%= " move to the right side
set statusline+=%<%F " (truncated) full path to the file we are editing
set statusline+=%m " [+] if the file is modified but not saved
set statusline+=%r " show [RO] if a file is read-only
nnoremap <silent> ,gg :Goyo<cr>
command! -range GOpen execute 'silent ! git browse ' . expand('%') . ' ' . <line1> . ' ' . <line2> | checktime | redraw!
" Show words and codes as colors, coc.nvim does this in some filetypes
command! CT silent! execute "ColorToggle"
" show the groupings under cursor
command! SS echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
" Tig current file
command! Tig execute "Start tig " . expand('%:p')
" scratch buffer
command! SC vnew | setlocal nobuflisted buftype=nofile nospell filetype=markdown bufhidden=wipe noswapfile
command! JS vsplit ~/tmp/tmp.js | setlocal nobuflisted nospell filetype=javascript bufhidden=wipe noswapfile
command! Workspaced let g:copilot_workspace_folders = FugitiveWorkTree()
augroup Convenience
" get completions from current syntax file
autocmd BufEnter * exec('setlocal complete+=k$VIMRUNTIME/syntax/'.&ft.'.vim')
" let ignorelist =['vim', 'help', 'perl', 'sh', 'racket']
" autocmd Filetype * if (index(ignorelist, &ft) == -1)
" \ | let &l:keywordprg=fnamemodify($MYVIMRC, ":h") . "/tools/search.sh " . &l:filetype | endif
" jump to last cursor position
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g'\"" | endif
" https://vi.stackexchange.com/a/69/287
" prevents unmodified buffer + crash = bullshit swap file
autocmd BufWritePost,CursorHold *
\ let &swapfile = &modified
augroup END
" augroup CursorLine
" autocmd!
" autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
" autocmd WinLeave * setlocal nocursorline
" augroup END
" generate help tags for all plugins
function! UpdatePluginDocs()
silent! helptags ALL
echo "Plugin documentation updated!"
endfunction
command! UpdatePluginDocs call UpdatePluginDocs()
function! WrapWithAsciiWalls(style) range
let l:start = a:firstline
let l:end = a:lastline
if a:firstline == 0 && a:lastline == 0
let l:start = line('.')
let l:end = l:start
endif
let l:lines = getline(l:start, l:end)
" Determine the wrapping characters based on the style parameter.
let l:wrap_chars = get({
\ 'H': ['ββββ ', ' ββββ'],
\ 'H2': ['βββ ', ' βββ'],
\ 'H3': ['ββ ', ' ββ'],
\ 'H4': ['β ', ' β'],
\ }, a:style, v:null)
if l:wrap_chars is v:null
throw "Invalid style: ".a:style
endif
" Apply wrapping characters to each line.
let l:wrapped_lines = map(l:lines, '"'.l:wrap_chars[0].'" . v:val . "'.l:wrap_chars[1].'"')
call setline(l:start, l:wrapped_lines)
endfunction
command! -range H <line1>,<line2>call WrapWithAsciiWalls('H')
command! -range H1 <line1>,<line2>call WrapWithAsciiWalls('H1')
command! -range H2 <line1>,<line2>call WrapWithAsciiWalls('H2')
command! -range H3 <line1>,<line2>call WrapWithAsciiWalls('H3')
command! -range H4 <line1>,<line2>call WrapWithAsciiWalls('H4')
command! -nargs=1 Figlet read !figlet -f $HOME/.vim/tools/elite.flf <args>
" nnoremap <silent> <S-Right> :vertical resize +5<CR>
" nnoremap <silent> <S-Left> :vertical resize -5<CR>
" nnoremap <silent> <S-Up> :resize +5<CR>
" nnoremap <silent> <S-Down> :resize -5<CR>
" uv fix
au BufRead,BufNewFile * if getline(1) =~# '^#!/usr/bin/env -S uv run --script' | set filetype=python | endif
" colors
hi SpellBad term=reverse ctermbg=226 ctermfg=0
let g:wikt_dictionaries = [
\ {'path': expand('~/projects/lotr/tools/silmarillion-index.txt'), 'name': 'The Silmarillion'},
\ ]
packadd! matchit