Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 1 | set whichwrap=b,s,<,>,[,] |
| 2 | set mouse=a |
| 3 | |
| 4 | vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR> |
| 5 | |
| 6 | fun! SetupCommandAlias(from, to) |
| 7 | exec 'cnoreabbrev <expr> '.a:from |
| 8 | \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")' |
| 9 | \ .'? ("'.a:to.'") : ("'.a:from.'"))' |
| 10 | endfun |
| 11 | |
Skyler Grey | 3c6b6d6 | 2022-09-04 21:53:42 +0100 | [diff] [blame] | 12 | augroup vimrc-auto-mkdir |
| 13 | autocmd! |
| 14 | autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang) |
| 15 | function! s:auto_mkdir(dir, force) |
| 16 | if !isdirectory(a:dir) |
| 17 | \ && (a:force |
| 18 | \ || input("'" . a:dir . "' does not exist. Create? [y/N]") =~? '^y\%[es]$') |
| 19 | call mkdir(iconv(a:dir, &encoding, &termencoding), 'p') |
| 20 | endif |
| 21 | endfunction |
| 22 | augroup END |
| 23 | " https://stackoverflow.com/a/42872275/12293760 |
| 24 | |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 25 | augroup vimrc-auto-neoformat |
| 26 | autocmd! |
| 27 | autocmd BufWritePre * call s:auto_neoformat(v:cmdbang) |
| 28 | function! s:auto_neoformat(force) |
| 29 | if a:force |
| 30 | Neoformat |
| 31 | endif |
| 32 | endfunction |
| 33 | augroup END |
| 34 | |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 35 | command W w |
| 36 | command Wq wq |
| 37 | call SetupCommandAlias("git","Git") |
Skyler Grey | 55f8455 | 2022-09-05 11:04:39 +0100 | [diff] [blame] | 38 | call SetupCommandAlias("rg","Rg") |
Skyler Grey | a7feb6e | 2022-08-26 06:51:55 +0100 | [diff] [blame] | 39 | |
| 40 | set ignorecase |
| 41 | set smartcase |
| 42 | |
| 43 | set expandtab |
Skyler Grey | ee47c9f | 2022-09-05 07:01:33 +0100 | [diff] [blame] | 44 | |
| 45 | let g:cursorhold_updatetime = 1000 |
| 46 | autocmd CursorHoldI,CursorHold,BufLeave ?* silent! update |
Skyler Grey | 55f8455 | 2022-09-05 11:04:39 +0100 | [diff] [blame] | 47 | |
| 48 | set viewoptions-=options |
| 49 | autocmd BufWinLeave ?* silent! mkview! |
| 50 | |
| 51 | function! s:loadViewOrUnfold() |
| 52 | try |
| 53 | loadview |
| 54 | catch |
| 55 | folddoclosed foldopen |
| 56 | endtry |
| 57 | endfunction |
| 58 | |
| 59 | autocmd BufWinEnter ?* call s:loadViewOrUnfold() |