summaryrefslogtreecommitdiff
path: root/files/vim/vimrc
diff options
context:
space:
mode:
Diffstat (limited to 'files/vim/vimrc')
-rw-r--r--files/vim/vimrc52
1 files changed, 28 insertions, 24 deletions
diff --git a/files/vim/vimrc b/files/vim/vimrc
index 93d1215..dcf832b 100644
--- a/files/vim/vimrc
+++ b/files/vim/vimrc
@@ -1,3 +1,5 @@
+" @TODO: CullSubprojects from sessions command.
+
" Basic settings.
set nocompatible
set number
@@ -19,6 +21,7 @@ set splitright
set splitbelow
" Stop buffers from jumping when opening buffer selection.
set splitkeep=screen
+"set guicursor=n-v-c:block-Cursor,o:hor50,i-ci:hor15,r-cr:hor30,sm:block-Cursor
set termguicolors
colo lil_pablo
@@ -65,7 +68,6 @@ set title
au BufEnter * let &titlestring=expand("%:t")
" https://github.com/csdvrx/CuteVim/blob/main/.vimrc
-
" Allow distinguishing <C-i> from <Tab> in bindings.
" If using vim rather than neovim, this will disable the ability
" to map <C-h/j/k/l>. Apparently due to vim's lack of "CSI u"
@@ -116,7 +118,7 @@ if isdirectory(expand("~/c"))
endif
" Staggered backups.
- let backup_dir = "/mnt/store/backup/vim"
+ let backup_dir = "/mnt/store/backup/vim//"
if !isdirectory(backup_dir)
let backup_dir = expand("~/c/sessions/backup//")
if !isdirectory(backup_dir)
@@ -139,13 +141,13 @@ packadd vim-gitbranch
packadd vim-asciidoc-folding
packadd Colorizer
"if !empty($NIX_SHELL)
-"packadd lsp
-"call LspAddServer([#{
-"\ name: 'clangd',
-"\ filetype: ['c', 'cpp'],
-"\ path: 'clangd',
-"\ args: ['--background-index']
-"\}])
+" packadd lsp
+" call LspAddServer([#{
+" \ name: 'clangd',
+" \ filetype: ['c', 'cpp'],
+" \ path: 'clangd',
+" \ args: ['--background-index']
+" \}])
"endif
" Custom statusline.
@@ -210,7 +212,7 @@ nmap <silent> \ :call QNameInit(1)<CR>:~
nmap <silent> Y :vertical G<CR>
" Relative :e, :vs, and :s.
-fun OpenBasedOnRelativeArgument(A, CMD)
+function OpenBasedOnRelativeArgument(A, CMD)
" https://stackoverflow.com/a/14348204
let arg = a:A
if arg != ""
@@ -220,13 +222,13 @@ fun OpenBasedOnRelativeArgument(A, CMD)
exe "edit" arg
elseif a:CMD == "VERTICAL_SPLIT"
exe "vsplit" arg
- elseif a:CMD == "SPLIT"
+ elseif a:CMD == "HORIZONTAL_SPLIT"
exe "split" arg
endif
-endfun
+endfunction
command -nargs=* -complete=customlist,RelativeFileComplete E :call OpenBasedOnRelativeArgument("<args>", "EDIT")
command -nargs=* -complete=customlist,RelativeFileComplete VS :call OpenBasedOnRelativeArgument("<args>", "VERTICAL_SPLIT")
-command -nargs=* -complete=customlist,RelativeFileComplete S :call OpenBasedOnRelativeArgument("<args>", "SPLIT")
+command -nargs=* -complete=customlist,RelativeFileComplete HS :call OpenBasedOnRelativeArgument("<args>", "HORIZONTAL_SPLIT")
fun RelativeFileComplete(A,L,P)
let argpath = fnamemodify(a:A, ":h")
if argpath[0] == "~" || argpath[0] == "/"
@@ -244,13 +246,14 @@ fun RelativeFileComplete(A,L,P)
let files[i] = substitute(files[i], curpath, "", "")
let files[i] = substitute(files[i], "^./", "", "")
endif
+ let files[i] = fnameescape(files[i])
endfor
return files
-endfun
+endfunction
" https://stackoverflow.com/a/20564623
cnoreabbrev <expr> e getcmdtype() == ":" && getcmdline() == "e" ? "E" : "e"
cnoreabbrev <expr> vs getcmdtype() == ":" && getcmdline() == "vs" ? "VS" : "vs"
-cnoreabbrev <expr> s getcmdtype() == ":" && getcmdline() == "s" ? "S" : "s"
+cnoreabbrev <expr> hs getcmdtype() == ":" && getcmdline() == "hs" ? "HS" : "hs"
" :no -> :nohlsearch instead of :noremap.
cnoreabbrev <expr> no getcmdtype() == ":" && getcmdline() == "no" ? "nohlsearch" : "no"
@@ -271,25 +274,26 @@ command Hex :%!xxd
command Unhex :%!xxd -r
" https://stackoverflow.com/a/27721306
-"command -nargs=+ Ggr execute 'Ggrep! -q' <q-args>
-command -nargs=+ Ggr execute "silent Ggrep!" <q-args> | botright cwindow | redraw!
+command -nargs=+ Ggr exe "silent Ggrep!" <q-args> | botright cwindow | redraw!
" I had this mapped to <C-i> for the longest time. Sadly with OG vim
" (not neovim) the fix for mapping <Tab> and <C-i> seperately doesn't work.
" Changing this bind as the only concession to be compatible with vim
" seems well worth it.
nnoremap <C-o> :Ggr
-"" https://stackoverflow.com/a/37040415
-function! SyntaxGroup()
- let l:s = synID(line("."), col("."), 1)
- echo synIDattr(l:s, "name") . " -> " . synIDattr(synIDtrans(l:s), "name")
-endfun
-command Syn :call SyntaxGroup()
+command GrepWhitespace :Ggr '[[:blank:]]$'
" https://vi.stackexchange.com/a/456
function! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
-endfun
+endfunction
command Trim :call TrimWhitespace()
+
+"" https://stackoverflow.com/a/37040415
+function! SyntaxGroup()
+ let l:s = synID(line("."), col("."), 1)
+ echo synIDattr(l:s, "name") . " -> " . synIDattr(synIDtrans(l:s), "name")
+endfunction
+command Syn :call SyntaxGroup()