commit 9de1f6e4eedc7ef922d836a7a7d634b126801214
parent 51c9c0dbab434d6916c30b2ed74c3947e7a50815
Author: Bharatvaj <bharatvaj@yahoo.com>
Date: Mon, 5 Jun 2023 01:04:40 +0530
Merge common keybingdings in lua back to vim
... it becomes irritating to maintain after a while
Remove some env variables for programs that causes issues and gives me
too much work
Remove nvim-comment too! Just use the comment plugin used by vim
Add alias for voom with proper path
Add git aliases for remote operations
Remove env variables that relates TERMINFO. I don't what it does yet.
Until then it stays removed
Make the EDITOR as nvim or vim, based on availability. Add check for
availabiliy and unset in case the $EDITOR is missing from path.
Diffstat:
10 files changed, 106 insertions(+), 176 deletions(-)
diff --git a/.config/git/config b/.config/git/config
@@ -7,6 +7,8 @@
cl = clone
cm = commit --message
co = checkout
+ cot = checkout --theirs
+ coo = checkout --ours
con = config
d = diff
ds = diff --staged
@@ -20,9 +22,11 @@
pu = push
put = push --tags
puo = push -u origin
- rs = remote set-url
- rso = remote set-url origin
- rv = remote --verbose
+ r = reset
+ rs = reset --soft
+ res = remote set-url
+ reso = remote set-url origin
+ rev = remote --verbose
sm = submodule
st = status
suir = submodule update --init --recursive
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
@@ -2,8 +2,6 @@ vim.g.mapleader = ' '
local set = vim.opt
local g = vim.g
-set.packpath="$XDG_DATA_HOME/nvim"
-
g.loaded_node_provider = 0
g.loaded_ruby_provider = 0
g.loaded_perl_provider = 0
@@ -31,13 +29,11 @@ g.netrw_liststyle = 3
vim.cmd([[
" TODO use lua api
-source $XDG_DATA_HOME/vim/vimrc
function! s:load_plugins(t) abort
+ set packpath+=~/.local/share/vim
+ packadd fzf
packadd fzf.vim
- packadd nvim-dap
- packadd nvim-dap-ui
- packadd nvim-lspconfig
packadd vim-fugitive
packadd vim-ninja-feet
packadd vim-surround
@@ -45,6 +41,10 @@ function! s:load_plugins(t) abort
packadd vim-unimpaired
packadd vim-xcode
+ packadd nvim-dap
+ packadd nvim-dap-ui
+ packadd nvim-lspconfig
+
lua require"dapui".setup()
lua require"lspconfig".clangd.setup{}
lua require"unstaged"
diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua
@@ -1,26 +1,6 @@
--- keybindings local set = vim.opt
-function save_and_build()
--- TODO require vim-dispatch
- vim.cmd('wall')
- vim.cmd('Make')
-end
-
-function toggle_list(is_local_buffer)
- -- TODO implement toggle for all buffers
- local optset=vim.o
- if optset.list then
- optset.list=false
- else
- optset.list=true
- end
-end
-
local map = vim.keymap.set
-map('n', "U", '<c-r>')
-map('n', "<c-r>", '"')
-
-map('n', "z/", ':%s/')
+vim.cmd[[source $XDG_CONFIG_HOME/vim/keybindings.vim]]
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
@@ -41,49 +21,13 @@ vim.api.nvim_create_autocmd('LspAttach', {
end
})
-vim.cmd([[
-function! DiffWithSaved()
- let filetype=&ft
- diffthis
- vnew | r # | normal! 1Gdd
- diffthis
- exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
-endfunction
-]])
-
function file_mv_helper()
vim.cmd('normal! 0i"A"0y$A p0imv j0')
end
-- general
-map("n", "<leader>aa", ":argadd **<cr>")
-map("n", "<leader>co", ":copen<cr>")
-map("n", "<leader>cd", ":cdo<space>s/")
map("n", "<leader>ec", ":edit $XDG_CONFIG_HOME/nvim/init.lua<cr>")
-map("n", "<leader>ek", ":edit $XDG_CONFIG_HOME/nvim/lua/keybindings.lua<cr>")
-map("n", "<leader>et", ":set expandtab<cr>")
-map("n", "<leader>lb", ":ls<CR>:b<space>")
-map("n", "<leader>lo", ":lopen<cr>")
-map("n", "<leader>ld", ":ldo<space>s/")
-map("n", "<leader>p", ":Rg<cr>")
map("n", "<leader>sc", ":source $XDG_CONFIG_HOME/nvim/init.lua<cr>")
-map("n", "<leader>so", ":source %<cr>")
-map("n", "<leader>spp", ":set paste<cr>")
-map("n", "<leader>spa", ":set path+=**<cr>")
-map("n", "<leader>tl", ":lua toggle_list(true)<CR>")
-map("n", "<leader>tt", ":tabnew<cr>")
-map("n", "<leader>vg", ":vimgrep<space>")
-map("n", "<leader>wd", ":call DiffWithSaved()<cr>")
-
--- quick write and quit
-map("n", "<Leader>qq", ":q<CR>")
-map("n", "<Leader>ww", ":w<CR>")
-map("n", "<leader><cr>", ":noh<CR>")
-
--- buffers
-map("n", "<leader>sc", ":source ~/.config/vim/vimrc<enter>")
-map("n", "<leader>ss", ":split<enter>")
-map("n", "<leader>vv", ":vsplit<enter>")
-- nvim-dap
map("n", "<leader>dd", ":lua require'dap'.continue()<cr>")
@@ -108,77 +52,5 @@ map("n", "<leader>dcb", ":lua require'dap'.ToggleConditionalBreakpoint()")
-- map("n", "<leader>do", ":call GotoWindow(require'dap'.session_windows.output)<CR>")
-- map("n", "<leader>dtcb", ":call vimspector#CleanLineBreakpoint()<CR>")
-map("n", "<leader>bb", ":lua save_and_build()<CR>")
-map("n", "<leader>bc", ":Make clean<CR>")
-
-
--- development
-map("n", "<leader>oc", ":grepadd /:: %")
-map("n", "<leader>oh", ":grepadd /:: %")
-
-vim.keymap.set('n', '\\f', ":CommandTGit<cr>")
-vim.keymap.set('n', '\\F', ":CommandTFind<cr>")
-vim.keymap.set('n', '\\g', ":CommandTGit<cr>")
-vim.keymap.set('n', '\\b', ":CommandTBuffer<cr>")
-
-
--- quick navigation
-map("n", "<leader>fb", ":b *")
-map("n", "<leader>ff", ":find *")
-map("n", "<leader>fs", ":set foldmethod=syntax<cr>")
-
-
--- file helpers
-map("n", "<leader>fmv", "lua file_mv_helper()")
-
--- doc functions
-function doc_quick_underline(n)
- if (n == 1) then
- vim.cmd('normal! yypv$r=')
- else
- vim.cmd('normal! yypv$r-')
- end
-end
-
-function reverse_date()
- vim.cmd('normal! dt/wwpldeBP')
-end
-
-map("n", "<leader>h1", ":lua doc_quick_underline(1)<cr>")
-map("n", "<leader>h2", ":lua doc_quick_underline(2)<cr>")
-
-
-map("n", "<leader>ct", ":ChecklistToggleCheckbox<cr>")
-map("n", "<leader>ce", ":ChecklistEnableCheckbox<cr>")
--- map("n", "<leader>cd", ":ChecklistDisableCheckbox<cr>")
-
--- vim.g.checklist_filetypes:append('adoc', 'md')
-
--- vim-fugitive
-map("n", "<leader>gb", ":G blame<cr>")
-map("n", "<leader>gd", ":Gvdiff<cr>")
-map("n", "<leader>gg", ":Ggrep<space>")
-map("n", "<leader>gr", ":G reset %<cr>")
-map("n", "<leader>gwq", ":Gwq<cr>")
-map("n", "<leader>lg", ":Glgrep<space>")
-
--- useful
-map("n", "<leader>nn", ":set number<cr>")
-
-- neovim diagnostics
map("n", "<leader>sd", ":lua vim.diagnostic.open_float()<cr>")
-
--- netrw keybindings
-map("n", "<leader>sf", ":Ex<cr>")
-
--- subst with power
-map("n", "cn", "*``cgn")
-map("n", "cN", "*``cgN")
-vim.cmd([[
-let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>"
-vnoremap <expr> cn g:mc . "``cgn"
-]])
-
--- nb
--- TODO open a fuzzy finder quickly. Even better use fuzzy finder without chdir
-map("n", "<leader>nb", ":chdir $NB_PATH<cr> | :pwd<cr>")
diff --git a/.config/sh/aliases b/.config/sh/aliases
@@ -1,7 +1,6 @@
# [xdg]
alias abook='abook --config "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook'
alias abook='abook -C "$XDG_CONFIG_HOME"/abook/abookrc --datafile "$XDG_DATA_HOME"/abook/addressbook'
-alias btpd='btpd -d "$XDG_DATA_HOME"/btpd'
alias dict='dict -c "$XDG_CONFIG_HOME"/dict/dictrc'
alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc'
alias startx='startx "$XDG_CONFIG_HOME/X11/xinitrc" vt1'
@@ -52,3 +51,5 @@ alias x=extract_archive
# [longhands]
alias girl='grep -irl'
alias gir='grep -ir'
+
+alias voom='VIM_DIR=$XDG_DATA_HOME/vim voom'
diff --git a/.config/vim/keybindings.vim b/.config/vim/keybindings.vim
@@ -1,26 +1,33 @@
" General keybindings
nnoremap <leader>aa :argadd **<cr>
nnoremap <leader>co :copen<cr>
+nnoremap <leader>cd :cdo<space>s/
nnoremap <leader>cs :cdo<space>s/
nnoremap <leader>ec :edit $XDG_CONFIG_HOME/vim/vimrc<cr>
nnoremap <leader>ek :edit $XDG_CONFIG_HOME/vim/keybindings.vim<cr>
nnoremap <leader>et :set expandtab<cr>
nnoremap <leader>fa :find *
-nnoremap <leader>ff :b *
+nnoremap <leader>ff :find *
nnoremap <leader>lb :ls<cr>:b<space>
+nnoremap <leader>ld :ldo<space>s/
nnoremap <leader>lo :lopen<cr>
nnoremap <leader>ls :ldo<space>s/
nnoremap <leader>pp :Rg<cr>
nnoremap <leader>pv :packadd vimspector<cr>
nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr>
nnoremap <leader>so :source %<cr>
-nnoremap <leader>sp :set paste<cr>
+nnoremap <leader>spp :set paste<cr>
+nnoremap <leader>spa :set path+=**<cr>
nnoremap <leader>tt :tabnew<cr>
nnoremap <leader>vg :vimgrep<space>
" Buffer Creation
-nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<enter>
-nnoremap <leader>ss :split<enter>
-nnoremap <leader>vv :vsplit<enter>
+nnoremap <leader>sc :source $XDG_CONFIG_HOME/vim/vimrc<cr>
+nnoremap <leader>ss :split<cr>
+nnoremap <leader>vv :vsplit<cr>
+nnoremap <leader>wd :call DiffWithSaved()<cr>
+
+" netrw keybindings
+nnoremap <leader>sf :Ex<cr>
" Accessible completions
inoremap <c-f> <c-x><c-f>
@@ -31,6 +38,18 @@ inoremap <c-e> <c-o>A
" Behave vim
nnoremap Y y$
+" development
+nnoremap <leader>oc :grepadd /:: %
+nnoremap <leader>oh :grepadd /:: %
+
+nnoremap <leader>fb :b *
+
+" quick navigation
+nnoremap \f :GFiles<cr>
+nnoremap \F :Files<cr>
+" TODO setup this up with fzf
+nnoremap \g :Ggrep<cr>
+
fun! SetupCommandAlias(from, to)
exec 'cnoreabbrev <expr> '.a:from
\ .' ((getcmdtype() is# ":" && getcmdline() is# "'.a:from.'")'
@@ -43,6 +62,9 @@ call SetupCommandAlias("man","help")
nnoremap <leader>tb :call ToggleBackground()<CR>
nnoremap <leader>tl :call ToggleList()<CR>
+" useful
+nnoremap <leader>nn :set number<cr>
+
" development
nnoremap <leader>bb :call SaveAndBuild()<CR>
nnoremap <leader>bc :Make clean<CR>
@@ -54,18 +76,26 @@ nnoremap <leader>wq :wq<cr>
nnoremap <leader>ww :w<cr>
nnoremap <leader>qq :q<cr>
-" Fugitive
-nnoremap <space>gd :Gvdiff<CR>
+" vim-fugitive
+nnoremap <leader>gb :G blame<cr>
+nnoremap <leader>gd :Gvdiff<CR>
+nnoremap <leader>gg :Ggrep<space>
+nnoremap <leader>gr :G reset %<cr>
+nnoremap <leader>gwq :Gwq<cr>
+nnoremap <leader>lg :Glgrep<space>
" Generate ctags
-map <leader>gt :!sh -c "ctags `rg --files`"<CR>
+nnoremap<leader>gt :!sh -c "ctags `rg --files`"<CR>
set tags+=.git/tags
nnoremap <CR> :noh<CR><CR>:<backspace>
-" Markdown
+" Markdown - Add checkbox mode?
nnoremap <leader>cc :ChecklistToggleCheckbox<cr>
+nnoremap <leader>ct :ChecklistToggleCheckbox<cr>
+nnoremap <leader>ce :ChecklistEnableCheckbox<cr>
+"nnoremap <leader>cd :ChecklistDisableCheckbox<cr>
let g:gutentags_file_list_command = 'rg --files'
@@ -118,3 +148,12 @@ nnoremap <leader>d<space> :call vimspector#Continue()<CR>
nmap <leader>drc <Plug>VimspectorRunToCursor
nmap <leader>dbp <Plug>VimspectorToggleBreakpoint
nmap <leader>dcbp <Plug>VimspectorToggleConditionalBreakpoint
+
+" nb
+" TODO open a fuzzy finder quickly. Even better use fuzzy finder without chdir
+nnoremap <leader>nb :chdir $NB_PATH<cr>
+
+nnoremap cn *``cgn
+nnoremap cN *``cgN
+let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>"
+vnoremap <expr> cn g:mc . "``cgn"
diff --git a/.config/vim/plugin/plugin.vim b/.config/vim/plugin/plugin.vim
@@ -63,3 +63,14 @@ function! ChooseFile()
echo "Finding file..."
exec ":e " . root . "/" . selection
endfunction
+
+
+function! DiffWithSaved()
+ let filetype=&ft
+ diffthis
+ vnew | r # | normal! 1Gdd
+ diffthis
+ exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
+endfunction
+
+
diff --git a/.config/vim/vimrc b/.config/vim/vimrc
@@ -85,6 +85,8 @@ function! s:load_plugins(t) abort
set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p')
set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p')
+ packadd fzf
+ packadd fzf.vim
packadd vim-tmux-navigator
packadd vim-commentary
packadd vim-surround
diff --git a/.local/share/nvim/pack/general/start/nvim-comment b/.local/share/nvim/pack/general/start/nvim-comment
@@ -1 +0,0 @@
-Subproject commit 861921706a39144ea528a6200a059a549b02d8f0
diff --git a/.local/share/vim/plugins b/.local/share/vim/plugins
@@ -1,29 +1,29 @@
+cfdrake/vim-pbxproj
+christoomey/vim-tmux-navigator
+evansalter/vim-checklist
+ferranpm/vim-maildir
+gfontenot/vim-xcode
+jerrymarino/xcodebuild.vim
+joereynolds/vim-minisnip/
+junegunn/fzf
+junegunn/fzf.vim
+kana/vim-submode
+keith/swift.vim
+nachumk/systemverilog.vim
ntpeters/vim-better-whitespace.git
+omniSharp/omnisharp-vim
+pope/vim-repeat.git
+radenling/vim-dispatch-neovim
+tommcdo/vim-ninja-feet.git
tpope/vim-commentary.git
-tpope/vim-surround.git
+tpope/vim-dispatch
tpope/vim-fugitive
-tommcdo/vim-ninja-feet.git
+tpope/vim-surround.git
tpope/vim-unimpaired
-pope/vim-repeat.git
-christoomey/vim-tmux-navigator
-tpope/vim-dispatch
-yegappan/mru
-radenling/vim-dispatch-neovim
-evansalter/vim-checklist
tpope/vim-vinegar
tpope/vim-vinegar
-ferranpm/vim-maildir
-joereynolds/vim-minisnip/
-keith/swift.vim
-preservim/tagbar
-cfdrake/vim-pbxproj
-kana/vim-submode
-jerrymarino/xcodebuild.vim
-gfontenot/vim-xcode
-junegunn/fzf.vim
vim-scripts/gitignore
-OmniSharp/omnisharp-vim
-
+yegappan/mru
# https://git.sr.ht/~torresjrjr/birck.vim
# rcarriga/nvim-dap-ui
@@ -31,3 +31,6 @@ OmniSharp/omnisharp-vim
# terrortylor/nvim-comment
# neovim/nvim-lspconfig
# puremourning/vimspector
+# xolox/vim-misc
+# xolox/vim-easytags
+# preservim/tagbar
diff --git a/.profile b/.profile
@@ -7,6 +7,7 @@ export GREP_COLOR='1;35;40'
export XDG_CONFIG_HOME="$XDG_ROOT/.config"
export XDG_DATA_HOME="$XDG_ROOT/.local/share"
export XDG_CACHE_HOME="$XDG_ROOT/.cache"
+export XDG_RUNTIME_HOME="$XDG_ROOT/.runtime"
export XDG_DESKTOP_DIR="$XDG_DATA_HOME/desktop"
export XDG_DOCUMENTS_DIR="$XDG_DATA_HOME/documents"
@@ -41,7 +42,6 @@ export ELINKS_CONFDIR="$XDG_CONFIG_HOME/elinks"
export FFMPEG_DATADIR="$XDG_DATA_HOME"/ffmpeg
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
-export ATOM_HOME="$XDG_DATA_HOME"/atom
export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history
export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass
export HISTFILE="$XDG_DATA_HOME"/history
@@ -49,11 +49,8 @@ export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
export MACHINE_STORAGE_PATH="$XDG_DATA_HOME"/docker-machine
export GOPATH="$XDG_DATA_HOME"/go
export NB_PATH="$XDG_DATA_HOME/notebook"
-export EM_PORTS="$XDG_DATA_HOME"/emscripten/cache
export CARGO_HOME="$XDG_DATA_HOME"/cargo
export GEM_HOME="$XDG_DATA_HOME"/gem
-export TERMINFO="$XDG_DATA_HOME/terminfo"
-export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo":/usr/share/terminfo
export VSCODE_PORTABLE="$XDG_DATA_HOME/vscode"
export GRADLE_USER_HOME="$XDG_DATA_HOME"/gradle
export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history"
@@ -62,7 +59,6 @@ export SONGDL_HOME="${XDG_DATA_HOME}/music/"
export PSQL_HISTORY="$XDG_CACHE_HOME/pg/psql_history"
export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages
-export EM_CACHE="$XDG_CACHE_HOME"/emscripten/cache
export GEM_SPEC_CACHE="$XDG_CACHE_HOME"/gem
# Make `history` print timestamp
@@ -83,10 +79,13 @@ there() {
}
# Setup editor
-
+# TODO until I grok the shell and able to control the clipboard and
+# registers with terminal level keybings. I am not going back to vi/nvi
export VISUAL=vim
-export EDITOR="$(there nvi && echo nvi || echo vi)"
-export FUZZER=sk
+export EDITOR="$(there nvim && echo nvim || echo vim)"
+there $EDITOR || unset $EDITOR
+export FUZZER="$(there sk && echo sk || echo fzf)"
+there $FUZZER || unset $FUZZER
export BROWSER=lynx
export SURFRAW_browser="$BROWSER"