dotfiles

Cross platform dotfiles for linux, mac and windows
git clone git@getsh.org:dotfiles.git
Log | Files | Refs

commit 88c258a7f78d622972fa1be0a2d423da78b84c9a
parent 7f98c9f4e28483e42fd0867eab1e3e1b50778084
Author: Bharatvaj <bharatvaj@yahoo.com>
Date:   Thu,  1 Dec 2022 08:02:06 +0530

Proper debug configuration added for neovim

...with nvim-dap and nvim-dap-ui

Some untested plugins have been added as well, but checking those in too
for now.

Added [longhands] in .config/sh/aliases

Diffstat:
M.config/nvim/lua/keybindings.lua | 216+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
D.config/nvim/lua/utils.lua | 11-----------
M.config/sh/aliases | 7++++++-
M.gitmodules | 29+++++++++++++++++++++++++----
A.local/share/nvim/pack/dev/opt/nvim-dap | 1+
A.local/share/nvim/pack/dev/opt/nvim-dap-ui | 1+
D.local/share/nvim/pack/development/start/nvim-dap | 1-
D.local/share/nvim/pack/general/start/nvim-lspconfig | 1-
A.local/share/vimcommon/pack/dev/opt/clang_complete | 1+
A.local/share/vimcommon/pack/dev/opt/swift.vim | 1+
A.local/share/vimcommon/pack/dev/opt/tagbar | 1+
A.local/share/vimcommon/pack/dev/opt/vim-xcode | 1+
A.local/share/vimcommon/pack/dev/opt/xcodebuild.vim | 1+
A.local/share/vimcommon/pack/general/start/vim-pbxproj | 1+
A.local/share/vimcommon/pack/general/start/vim-submode | 1+
15 files changed, 185 insertions(+), 89 deletions(-)

diff --git a/.config/nvim/lua/keybindings.lua b/.config/nvim/lua/keybindings.lua @@ -1,10 +1,8 @@ --- keybindings -local set = vim.opt - +-- keybindings local set = vim.opt function save_and_build() -- TODO require vim-dispatch - vim.cmd('wall') - vim.cmd('Make') + vim.cmd('wall') + vim.cmd('Make') end function toggle_list(is_local_buffer) @@ -17,11 +15,74 @@ function toggle_list(is_local_buffer) end end --- function toggle_highlight() --- if vim.opt.highlight then --- vim. --- --- end +local map = vim.keymap.set + +-- Column Navigation/Scrolling +map('n', 'J', '<c-d>') +map('n', 'K', '<c-u>') +map('n', 'gJ', '<c-f>') +map('n', 'gK', '<c-b>') +-- map('n', '<c-d>', 'J') +-- map('n', 'g<c-d>', 'gJ') +-- map('n', '<c-u>', 'K') +-- map('n', 'g<c-u>', 'gK') + +-- Edit +-- map('n', "g<cr>", 'O') +-- map('n', "<cr>", 'o') + +-- send command upstream +map('n', "<esc>h", '<c-w>h') +map('n', "<esc>j", '<c-w>j') +map('n', "<esc>k", '<c-w>k') +map('n', "<esc>l", '<c-w>l') +map('n', "<esc>f", '<c-w>l') + +-- Horizonatal scrolling +map('n', "H", 'zH') +map('n', "L", 'zL') + +map('n', "zh", 'g0') +map('n', "zj", 'L') +map('n', "zk", 'H') +map('n', "zl", 'g$') +map('n', "zm", ":call cursor(0, len(getline('.'))/2)<cr>") +map('n', "zM", 'M') + +-- Line movements +map('n', "gh", '_') +map('n', "gl", '$') +map('n', "gm", 'M') + +map('n', "gM", 'M') + +map('n', "U", '<c-r>') +map('n', "<c-r>", '"') + +map('n', "<bs>", 's') +map('n', "z/", ':%s/') +map('n', "z?", ':%s?') + +map('n', "M", 'q') + +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + -- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + local lspbuf = vim.lsp.buf + local bufopts = { noremap=true, buffer=args.buf } + map({'n', 'v'}, '<a-CR>', lspbuf.code_action, bufopts) + map('n', 'gD', lspbuf.declaration, bufopts) + map('n', 'gd', lspbuf.definition, bufopts) + map('n', 'K', lspbuf.hover, bufopts) + map('n', 'gi', lspbuf.implementation, bufopts) + map('n', '<space>D', lspbuf.type_definition, bufopts) + map('n', '<space>rn', lspbuf.rename, bufopts) + map('n', '<space>ca', lspbuf.code_action, bufopts) + map('n', 'gr', lspbuf.references, bufopts) + map('n', '<space>f', function() lspbuf.format { async = true } end, bufopts) + end +}) vim.cmd([[ function! DiffWithSaved() @@ -37,72 +98,74 @@ function file_mv_helper() vim.cmd('normal! 0i"A"0y$A p0imv j0') end --- Run Make -local map = require("utils").map -- general -map("n", "<leader>co", ":copen<cr>", { silent = false }) -map("n", "<leader>cd", ":cdo<space>s/", { silent = false }) -map("n", "<leader>ec", ":edit $XDG_CONFIG_HOME/nvim/init.lua<cr>", { silent = true }) -map("n", "<leader>ek", ":edit $XDG_CONFIG_HOME/nvim/lua/keybindings.lua<cr>", { silent = false }) -map("n", "<leader>et", ":set expandtab<cr>", { silent = false }) -map("n", "<leader>lb", ":ls<CR>:b<space>", { silent = false }) -map("n", "<leader>lo", ":lopen<cr>", { silent = false }) -map("n", "<leader>ld", ":ldo<space>s/", { silent = false }) -map("n", "<leader>p", ":Rg<cr>", { silent = false }) -map("n", "<leader>sc", ":source $XDG_CONFIG_HOME/nvim/init.lua<cr>", { silent = false }) -map("n", "<leader>so", ":source %<cr>", { silent = false }) -map("n", "<leader>sp", ":set paste<cr>", { silent = false }) -map("n", "<leader>tl", ":lua toggle_list(true)<CR>", { silent = true }) -map("n", "<leader>tt", ":tabnew<cr>", { silent = false }) -map("n", "<leader>vg", ":vimgrep<space>", { silent = false }) -map("n", "<leader>wd", ":call DiffWithSaved()<cr>", { silent = false }); +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>ww", ":w<CR>", { silent = true }) -map("n", "<Leader>wq", ":wq<CR>", { silent = true }) -map("n", "<Leader>qq", ":q<CR>", { silent = true }) -map("n", "<leader><cr>", ":noh<CR>", { silent = true }) +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>", { silent = true }) -map("n", "<leader>ss", ":split<enter>", { silent = true }) -map("n", "<leader>vv", ":vsplit<enter>", { silent = true }) +map("n", "<leader>sc", ":source ~/.config/vim/vimrc<enter>") +map("n", "<leader>ss", ":split<enter>") +map("n", "<leader>vv", ":vsplit<enter>") --- vimspector -map("n", "<leader>dd", ":call vimspector#Launch()<CR>", { silent = true }) -map("n", "<leader>dc", ":call GotoWindow(g:vimspector_session_windows.code)<CR>", { silent = true }) -map("n", "<leader>dt", ":call GotoWindow(g:vimspector_session_windows.tagpage)<CR>", { silent = true }) -map("n", "<leader>dv", ":call GotoWindow(g:vimspector_session_windows.variables)<CR>", { silent = true }) -map("n", "<leader>dw", ":call GotoWindow(g:vimspector_session_windows.watches)<CR>", { silent = true }) -map("n", "<leader>ds", ":call GotoWindow(g:vimspector_session_windows.stack_trace)<CR>", { silent = true }) -map("n", "<leader>do", ":call GotoWindow(g:vimspector_session_windows.output)<CR>", { silent = true }) -map("n", "<leader>de", ":call vimspector#Reset()<CR>", { silent = true }) +-- nvim-dap +map("n", "<leader>dd", ":lua require'dap'.continue()<cr>") +map("n", "<leader>de", ":lua require'dap'.terminate()<cr> | :lua require'dap'.close()<cr>") +map("n", "<leader>dl", ":lua require'dap'.step_into()<cr>") +map("n", "<leader>dj", ":lua require'dap'.step_over()<cr>") +map("n", "<leader>dk", ":lua require'dap'.step_out()<cr>") +map("n", "<leader>dr", ":lua require'dap'.restart()<cr>") -map("n", "<leader>dtcb", ":call vimspector#CleanLineBreakpoint()<CR>", { silent = true }) +-- nvim-dap-ui +map("n", "<leader>du", ":lua require'dapui'.toggle()<cr>") -map("n", "<leader>dl", "<Plug>VimspectorStepInto", { silent = true }) -map("n", "<leader>dj", "<Plug>VimspectorStepOver", { silent = true }) -map("n", "<leader>dk", "<Plug>VimspectorStepOut", { silent = true }) -map("n", "<leader>d_", "<Plug>VimspectorRestart", { silent = true }) -map("n", "<leader>d<space>", ":call vimspector#Continue()<CR>", { silent = true }) +map("n", "<leader>drc", ":lua require'dap'.RunToCursor()") +map("n", "<leader>db" , ":lua require'dap'.toggle_breakpoint()<cr>") +map("n", "<leader>dcb", ":lua require'dap'.ToggleConditionalBreakpoint()") -map("n", "<leader>drc", "<Plug>VimspectorRunToCursor", { silent = true }) -map("n", "<leader>dbp" , "<Plug>VimspectorToggleBreakpoint", { silent = true }) -map("n", "<leader>dcbp", "<Plug>VimspectorToggleConditionalBreakpoint", { silent = true }) +-- map("n", "<leader>dc", ":call GotoWindow(require'dap'.session_windows.code)<CR>") +-- map("n", "<leader>dt", ":call GotoWindow(require'dap'.session_windows.tagpage)<CR>") +-- map("n", "<leader>dv", ":call GotoWindow(require'dap'.session_windows.variables)<CR>") +-- map("n", "<leader>dw", ":call GotoWindow(require'dap'.session_windows.watches)<CR>") +-- map("n", "<leader>ds", ":call GotoWindow(require'dap'.session_windows.stack_trace)<CR>") +-- 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>", { silent = false }) +map("n", "<leader>bb", ":lua save_and_build()<CR>") -- development -map("n", "<leader>oc", ":grepadd /:: %", { silent = false }) -map("n", "<leader>oh", ":grepadd /:: %", { silent = false }) +map("n", "<leader>oc", ":grepadd /:: %") +map("n", "<leader>oh", ":grepadd /:: %") -- quick navigation --- telscope.nvim -map("n", "<leader>ff", ":b *", { silent = false }) +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()", { silent = true }) +map("n", "<leader>fmv", "lua file_mv_helper()") -- doc functions function doc_quick_underline(n) @@ -117,28 +180,39 @@ function reverse_date() vim.cmd('normal! dt/wwpldeBP') end -map("n", "<leader>h1", ":lua doc_quick_underline(1)<cr>", { silent = true }); -map("n", "<leader>h2", ":lua doc_quick_underline(2)<cr>", { silent = true }); +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>", { silent = true }); -map("n", "<leader>ce", ":ChecklistEnableCheckbox<cr>", { silent = true }); --- map("n", "<leader>cd", ":ChecklistDisableCheckbox<cr>", { silent = true }); +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>gg", ":Ggrep<space>", { silent = false }); -map("n", "<leader>lg", ":Glgrep<space>", { silent = false }); -map("n", "<leader>gwq", ":Gwq<cr>", { silent = false }); +map("n", "<leader>gd", ":Gvdiff") +map("n", "<leader>gg", ":Ggrep<space>") +map("n", "<leader>lg", ":Glgrep<space>") +map("n", "<leader>gwq", ":Gwq<cr>") + +-- useful +map("n", "<leader>nn", ":set number<cr>") -- neovim diagnostics -map("n", "<leader>sd", ":lua vim.diagnostic.open_float()<cr>", { silent = false }); +map("n", "<leader>sd", ":lua vim.diagnostic.open_float()<cr>") -- netrw keybindings -map("n", "<leader>sf", ":Ex<cr>", { silent = false }); +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>", { silent = false }); - +map("n", "<leader>nb", ":chdir $NB_PATH<cr> | :pwd<cr>") diff --git a/.config/nvim/lua/utils.lua b/.config/nvim/lua/utils.lua @@ -1,11 +0,0 @@ -local M = {} - -function M.map(mode, lhs, rhs, opts) - local options = { noremap = true } - if opts then - options = vim.tbl_extend("force", options, opts) - end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) -end - -return M diff --git a/.config/sh/aliases b/.config/sh/aliases @@ -36,11 +36,16 @@ alias of="quickopen open f" # [shorthands] alias '?d'='sr duckduckgo' alias cls=clear -alias d='wget' +alias d='download' alias e='${EDITOR}' alias f='find . -name ' alias g='git' alias g=git alias l=lfcd +alias le=less +alias m=gmake alias v="VIMINIT='' nvim" alias x=extract_archive + +# [longhands] +alias girl='grep -irl' diff --git a/.gitmodules b/.gitmodules @@ -22,9 +22,6 @@ [submodule ".local/share/vim/pack/themes/start/gruvbox-material"] path = .local/share/vimcommon/pack/themes/opt/gruvbox-material url = https://git::@github.com/sainnhe/gruvbox-material.git -[submodule ".local/share/nvim/pack/general/start/nvim-lspconfig"] - path = .local/share/nvim/pack/general/start/nvim-lspconfig - url = https://github.com/neovim/nvim-lspconfig [submodule ".local/share/vim/pack/general/start/vim-unimpaired"] path = .local/share/vimcommon/pack/general/opt/vim-unimpaired url = https://github.com/tpope/vim-unimpaired @@ -44,7 +41,7 @@ path = .local/share/nvim/pack/general/start/vim-dispatch-neovim url = https://github.com/radenling/vim-dispatch-neovim [submodule ".local/share/nvim/pack/development/start/nvim-dap"] - path = .local/share/nvim/pack/development/start/nvim-dap + path = .local/share/nvim/pack/dev/opt/nvim-dap url = https://github.com/mfussenegger/nvim-dap [submodule ".local/share/nvim/pack/general/start/nvim-comment"] path = .local/share/nvim/pack/general/start/nvim-comment @@ -70,3 +67,27 @@ [submodule ".local/share/vimcommon/pack/general/start/vim-minisnip"] path = .local/share/vimcommon/pack/general/start/vim-minisnip url = https://github.com/joereynolds/vim-minisnip/ +[submodule ".local/share/vimcommon/pack/dev/opt/clang_complete"] + path = .local/share/vimcommon/pack/dev/opt/clang_complete + url = https://github.com/xavierd/clang_complete +[submodule ".local/share/vimcommon/pack/dev/opt/swift.vim"] + path = .local/share/vimcommon/pack/dev/opt/swift.vim + url = https://github.com/keith/swift.vim +[submodule ".local/share/vimcommon/pack/dev/opt/tagbar"] + path = .local/share/vimcommon/pack/dev/opt/tagbar + url = https://github.com/preservim/tagbar +[submodule ".local/share/vimcommon/pack/general/start/vim-pbxproj"] + path = .local/share/vimcommon/pack/general/start/vim-pbxproj + url = https://github.com/cfdrake/vim-pbxproj +[submodule ".local/share/vimcommon/pack/dev/opt/vim-submode"] + path = .local/share/vimcommon/pack/general/start/vim-submode + url = https://github.com/kana/vim-submode +[submodule ".local/share/vimcommon/pack/dev/opt/xcodebuild.vim"] + path = .local/share/vimcommon/pack/dev/opt/xcodebuild.vim + url = https://github.com/jerrymarino/xcodebuild.vim +[submodule ".local/share/nvim/pack/dev/opt/nvim-dap-ui"] + path = .local/share/nvim/pack/dev/opt/nvim-dap-ui + url = https://github.com/rcarriga/nvim-dap-ui +[submodule ".local/share/vimcommon/pack/dev/opt/vim-xcode"] + path = .local/share/vimcommon/pack/dev/opt/vim-xcode + url = https://github.com/gfontenot/vim-xcode diff --git a/.local/share/nvim/pack/dev/opt/nvim-dap b/.local/share/nvim/pack/dev/opt/nvim-dap @@ -0,0 +1 @@ +Subproject commit d2fcb949cd25fcdee0481a79672297082fc6c39e diff --git a/.local/share/nvim/pack/dev/opt/nvim-dap-ui b/.local/share/nvim/pack/dev/opt/nvim-dap-ui @@ -0,0 +1 @@ +Subproject commit 0f385f7f5268f408a546772c049271121b0d71c9 diff --git a/.local/share/nvim/pack/development/start/nvim-dap b/.local/share/nvim/pack/development/start/nvim-dap @@ -1 +0,0 @@ -Subproject commit d2fcb949cd25fcdee0481a79672297082fc6c39e diff --git a/.local/share/nvim/pack/general/start/nvim-lspconfig b/.local/share/nvim/pack/general/start/nvim-lspconfig @@ -1 +0,0 @@ -Subproject commit 54181ddb2709a4cd594e29bf82343c79196ec0c6 diff --git a/.local/share/vimcommon/pack/dev/opt/clang_complete b/.local/share/vimcommon/pack/dev/opt/clang_complete @@ -0,0 +1 @@ +Subproject commit e25b6a54e5cf648eb36d5be5b82c1bbb22260fde diff --git a/.local/share/vimcommon/pack/dev/opt/swift.vim b/.local/share/vimcommon/pack/dev/opt/swift.vim @@ -0,0 +1 @@ +Subproject commit 3e0529e1a97e3da24aabd18daf8ed92c6da8c68b diff --git a/.local/share/vimcommon/pack/dev/opt/tagbar b/.local/share/vimcommon/pack/dev/opt/tagbar @@ -0,0 +1 @@ +Subproject commit 83933d557409639df53fd2ca21484279b5854c1e diff --git a/.local/share/vimcommon/pack/dev/opt/vim-xcode b/.local/share/vimcommon/pack/dev/opt/vim-xcode @@ -0,0 +1 @@ +Subproject commit 2adc409bd7bb58499218f4f487c825e55306e46d diff --git a/.local/share/vimcommon/pack/dev/opt/xcodebuild.vim b/.local/share/vimcommon/pack/dev/opt/xcodebuild.vim @@ -0,0 +1 @@ +Subproject commit d62fa4cf952b4b8a1650778bdec284c35e468279 diff --git a/.local/share/vimcommon/pack/general/start/vim-pbxproj b/.local/share/vimcommon/pack/general/start/vim-pbxproj @@ -0,0 +1 @@ +Subproject commit d230f2cc70faf47ec0b97ffefa8235991438aca8 diff --git a/.local/share/vimcommon/pack/general/start/vim-submode b/.local/share/vimcommon/pack/general/start/vim-submode @@ -0,0 +1 @@ +Subproject commit d29de4f55c40a7a03af1d8134453a703d6affbd2