blob: 794659c3c147907f21f60aba128903fd61dc590f [file] [log] [blame]
Skyler Greya7feb6e2022-08-26 06:51:55 +01001set whichwrap=b,s,<,>,[,]
2set mouse=a
3
4vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
5
6fun! SetupCommandAlias(from, to)
7 exec 'cnoreabbrev <expr> '.a:from
8 \ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
9 \ .'? ("'.a:to.'") : ("'.a:from.'"))'
10endfun
11
Skyler Grey3c6b6d62022-09-04 21:53:42 +010012augroup 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
22augroup END
23" https://stackoverflow.com/a/42872275/12293760
24
Skyler Greyee47c9f2022-09-05 07:01:33 +010025augroup 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
33augroup END
34
Skyler Greya7feb6e2022-08-26 06:51:55 +010035command W w
36command Wq wq
37call SetupCommandAlias("git","Git")
Skyler Grey55f84552022-09-05 11:04:39 +010038call SetupCommandAlias("rg","Rg")
Skyler Greya7feb6e2022-08-26 06:51:55 +010039
40set ignorecase
41set smartcase
42
43set expandtab
Skyler Greyee47c9f2022-09-05 07:01:33 +010044
45let g:cursorhold_updatetime = 1000
46autocmd CursorHoldI,CursorHold,BufLeave ?* silent! update
Skyler Grey55f84552022-09-05 11:04:39 +010047
48set viewoptions-=options
49autocmd BufWinLeave ?* silent! mkview!
50
51function! s:loadViewOrUnfold()
52 try
53 loadview
54 catch
55 folddoclosed foldopen
56 endtry
57endfunction
58
59autocmd BufWinEnter ?* call s:loadViewOrUnfold()
Skyler Greye42f4352022-10-30 23:09:36 +000060
61tnoremap <Esc><Esc> <C-\><C-n>