From 832b55fa23ae1e49bd805b6e0e9f5d20b08f46a0 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Mon, 28 Jun 2021 11:39:37 -0400 Subject: less vimscript --- init.lua | 3 -- lua/lv-which-key/init.lua | 43 +++++++++++++++-------- utils/lv-vscode/init.vim | 84 ++++++++++++++++++++++++++++++++++++++++++++ vimscript/functions.vim | 50 -------------------------- vimscript/lv-vscode/init.vim | 84 -------------------------------------------- 5 files changed, 112 insertions(+), 152 deletions(-) create mode 100644 utils/lv-vscode/init.vim delete mode 100644 vimscript/functions.vim delete mode 100644 vimscript/lv-vscode/init.vim diff --git a/init.lua b/init.lua index 79e8022b..d066c27b 100644 --- a/init.lua +++ b/init.lua @@ -12,9 +12,6 @@ require('lv-treesitter') require('lv-autopairs') require('lv-which-key') --- TODO gotta get rid of this for speed -vim.cmd('source ' .. CONFIG_PATH .. '/vimscript/functions.vim') - -- LSP require('lsp') -- TODO should I put this in the filetype files? diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua index 50bc66ae..ab3a8dca 100644 --- a/lua/lv-which-key/init.lua +++ b/lua/lv-which-key/init.lua @@ -89,6 +89,7 @@ local mappings = { ["h"] = "No Highlight", ["p"] = "Projects", ["z"] = "Zen", + [";"] = "Dashboard", b = { name = "+Buffers", j = {"BufferPick", "jump to buffer"}, @@ -100,13 +101,6 @@ local mappings = { L = {"BufferOrderByLanguage", "sort BufferLines automatically by language"}, }, - -- ["/"] = {"CommentToggle", "Comment"}, - [";"] = {"Dashboard", "Dashboard"}, - -- ["c"] = {"BufferClose", "Close Buffer"}, - -- ["e"] = {"NvimTreeToggle", "Explorer"}, - -- ["f"] = {"Telescope find_files", "Find File"}, - -- ["h"] = {"set hlsearch!", "No Highlight"}, - -- ["p"] = {"lua require'telescope'.extensions.project.project{}", "Projects"}, d = { name = "Diagnostics", @@ -117,6 +111,24 @@ local mappings = { l = {"TroubleToggle loclist", "loclist"}, r = {"TroubleToggle lsp_references", "references"} }, + +-- " Available Debug Adapters: +-- " https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ +-- " +-- " Adapter configuration and installation instructions: +-- " https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation +-- " +-- " Debug Adapter protocol: +-- " https://microsoft.github.io/debug-adapter-protocol/ +-- " Debugging +-- command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint() +-- command! DebugStart lua require'dap'.continue() +-- command! DebugContinue lua require'dap'.continue() +-- command! DebugStepOver lua require'dap'.step_over() +-- command! DebugStepOut lua require'dap'.step_out() +-- command! DebugStepInto lua require'dap'.step_into() +-- command! DebugToggleRepl lua require'dap'.repl.toggle() +-- command! DebugGetSession lua require'dap'.session() D = { name = "Debug", b = {"DebugToggleBreakpoint", "Toggle Breakpoint"}, @@ -128,13 +140,14 @@ local mappings = { }, g = { name = "Git", - j = {"NextHunk", "Next Hunk"}, - k = {"PrevHunk", "Prev Hunk"}, - p = {"PreviewHunk", "Preview Hunk"}, - r = {"ResetHunk", "Reset Hunk"}, - R = {"ResetBuffer", "Reset Buffer"}, - s = {"StageHunk", "Stage Hunk"}, - u = {"UndoStageHunk", "Undo Stage Hunk"}, + j = {"lua require 'lv-utils'.next_hunk()", "Next Hunk"}, + k = {"lua require 'lv-utils'.prev_hunk()", "Prev Hunk"}, + l = {"lua require 'lv-utils'.blame_line()", "Blame"}, + p = {"lua require 'lv-utils'.preview_hunk()", "Preview Hunk"}, + r = {"lua require 'lv-utils'.reset_hunk()", "Reset Hunk"}, + R = {"lua require 'lv-utils'.reset_buffer()", "Reset Buffer"}, + s = {"lua require 'lv-utils'.stage_hunk()", "Stage Hunk"}, + u = {"lua require 'lv-utils'.undo_stage_hunk()", "Undo Stage Hunk"}, o = {"Telescope git_status", "Open changed file"}, b = {"Telescope git_branches", "Checkout branch"}, c = {"Telescope git_commits", "Checkout commit"}, @@ -146,7 +159,7 @@ local mappings = { A = {"Lspsaga range_code_action", "Selected Action"}, d = {"Telescope lsp_document_diagnostics", "Document Diagnostics"}, D = {"Telescope lsp_workspace_diagnostics", "Workspace Diagnostics"}, - f = {"LspFormatting", "Format"}, + f = {"lua require 'lv-utils'.formatting()", "Format"}, h = {"Lspsaga hover_doc", "Hover Doc"}, i = {"LspInfo", "Info"}, l = {"Lspsaga lsp_finder", "LSP Finder"}, diff --git a/utils/lv-vscode/init.vim b/utils/lv-vscode/init.vim new file mode 100644 index 00000000..1aa30934 --- /dev/null +++ b/utils/lv-vscode/init.vim @@ -0,0 +1,84 @@ +" packadd quickscope + +execute 'luafile ' . stdpath('config') . '/lua/settings.lua' + +function! s:manageEditorSize(...) + let count = a:1 + let to = a:2 + for i in range(1, count ? count : 1) + call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') + endfor +endfunction + +function! s:vscodeCommentary(...) abort + if !a:0 + let &operatorfunc = matchstr(expand(''), '[^. ]*$') + return 'g@' + elseif a:0 > 1 + let [line1, line2] = [a:1, a:2] + else + let [line1, line2] = [line("'["), line("']")] + endif + + call VSCodeCallRange("editor.action.commentLine", line1, line2, 0) +endfunction + +function! s:openVSCodeCommandsInVisualMode() + normal! gv + let visualmode = visualmode() + if visualmode == "V" + let startLine = line("v") + let endLine = line(".") + call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1) + else + let startPos = getpos("v") + let endPos = getpos(".") + call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1) + endif +endfunction + +function! s:openWhichKeyInVisualMode() + normal! gv + let visualmode = visualmode() + if visualmode == "V" + let startLine = line("v") + let endLine = line(".") + call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1) + else + let startPos = getpos("v") + let endPos = getpos(".") + call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1) + endif +endfunction + +" Better Navigation +nnoremap :call VSCodeNotify('workbench.action.navigateDown') +xnoremap :call VSCodeNotify('workbench.action.navigateDown') +nnoremap :call VSCodeNotify('workbench.action.navigateUp') +xnoremap :call VSCodeNotify('workbench.action.navigateUp') +nnoremap :call VSCodeNotify('workbench.action.navigateLeft') +xnoremap :call VSCodeNotify('workbench.action.navigateLeft') +nnoremap :call VSCodeNotify('workbench.action.navigateRight') +xnoremap :call VSCodeNotify('workbench.action.navigateRight') + +nnoremap gr call VSCodeNotify('editor.action.goToReferences') + +" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors +xnoremap vscodeCommentary() +nnoremap vscodeCommentary() . '_' + +nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') + +nnoremap :call VSCodeNotify('whichkey.show') +xnoremap :call openWhichKeyInVisualMode() + +xnoremap :call openVSCodeCommandsInVisualMode() + +xmap gc VSCodeCommentary +nmap gc VSCodeCommentary +omap gc VSCodeCommentary +nmap gcc VSCodeCommentaryLine + +" Simulate same TAB behavior in VSCode +nmap :Tabnext +nmap :Tabprev diff --git a/vimscript/functions.vim b/vimscript/functions.vim deleted file mode 100644 index c2edad21..00000000 --- a/vimscript/functions.vim +++ /dev/null @@ -1,50 +0,0 @@ -command! LspFormatting lua require 'lv-utils'.formatting() -command! NextHunk lua require 'lv-utils'.next_hunk() -command! PrevHunk lua require 'lv-utils'.prev_hunk() -command! StageHunk lua require 'lv-utils'.stage_hunk() -command! UndoStageHunk lua require 'lv-utils'.undo_stage_hunk() -command! ResetHunk lua require 'lv-utils'.reset_hunk() -command! ResetBuffer lua require 'lv-utils'.reset_buffer() -command! PreviewHunk lua require 'lv-utils'.preview_hunk() -command! BlameLine lua require 'lv-utils'.blame_line() - -" Debugging -command! DebugToggleBreakpoint lua require'dap'.toggle_breakpoint() -command! DebugStart lua require'dap'.continue() -command! DebugContinue lua require'dap'.continue() -command! DebugStepOver lua require'dap'.step_over() -command! DebugStepOut lua require'dap'.step_out() -command! DebugStepInto lua require'dap'.step_into() -command! DebugToggleRepl lua require'dap'.repl.toggle() -command! DebugGetSession lua require'dap'.session() - -" Available Debug Adapters: -" https://microsoft.github.io/debug-adapter-protocol/implementors/adapters/ -" -" Adapter configuration and installation instructions: -" https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation -" -" Debug Adapter protocol: -" https://microsoft.github.io/debug-adapter-protocol/ - -" TODO Add full support later -" nnoremap :lua require'dap'.continue() -" nnoremap :lua require'dap'.step_over() -" nnoremap :lua require'dap'.step_into() -" nnoremap :lua require'dap'.step_out() -" nnoremap b :lua require'dap'.toggle_breakpoint() -" nnoremap B :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) -" nnoremap lp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) -" nnoremap dr :lua require'dap'.repl.open() -" nnoremap dl :lua require'dap'.run_last() - -" autocmd! User GoyoEnter lua require('galaxyline').disable_galaxyline() -" autocmd! User GoyoLeave lua require('galaxyline').galaxyline_augroup() - -function! QuickFixToggle() - if empty(filter(getwininfo(), 'v:val.quickfix')) - copen - else - cclose - endif -endfunction diff --git a/vimscript/lv-vscode/init.vim b/vimscript/lv-vscode/init.vim deleted file mode 100644 index 1aa30934..00000000 --- a/vimscript/lv-vscode/init.vim +++ /dev/null @@ -1,84 +0,0 @@ -" packadd quickscope - -execute 'luafile ' . stdpath('config') . '/lua/settings.lua' - -function! s:manageEditorSize(...) - let count = a:1 - let to = a:2 - for i in range(1, count ? count : 1) - call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') - endfor -endfunction - -function! s:vscodeCommentary(...) abort - if !a:0 - let &operatorfunc = matchstr(expand(''), '[^. ]*$') - return 'g@' - elseif a:0 > 1 - let [line1, line2] = [a:1, a:2] - else - let [line1, line2] = [line("'["), line("']")] - endif - - call VSCodeCallRange("editor.action.commentLine", line1, line2, 0) -endfunction - -function! s:openVSCodeCommandsInVisualMode() - normal! gv - let visualmode = visualmode() - if visualmode == "V" - let startLine = line("v") - let endLine = line(".") - call VSCodeNotifyRange("workbench.action.showCommands", startLine, endLine, 1) - else - let startPos = getpos("v") - let endPos = getpos(".") - call VSCodeNotifyRangePos("workbench.action.showCommands", startPos[1], endPos[1], startPos[2], endPos[2], 1) - endif -endfunction - -function! s:openWhichKeyInVisualMode() - normal! gv - let visualmode = visualmode() - if visualmode == "V" - let startLine = line("v") - let endLine = line(".") - call VSCodeNotifyRange("whichkey.show", startLine, endLine, 1) - else - let startPos = getpos("v") - let endPos = getpos(".") - call VSCodeNotifyRangePos("whichkey.show", startPos[1], endPos[1], startPos[2], endPos[2], 1) - endif -endfunction - -" Better Navigation -nnoremap :call VSCodeNotify('workbench.action.navigateDown') -xnoremap :call VSCodeNotify('workbench.action.navigateDown') -nnoremap :call VSCodeNotify('workbench.action.navigateUp') -xnoremap :call VSCodeNotify('workbench.action.navigateUp') -nnoremap :call VSCodeNotify('workbench.action.navigateLeft') -xnoremap :call VSCodeNotify('workbench.action.navigateLeft') -nnoremap :call VSCodeNotify('workbench.action.navigateRight') -xnoremap :call VSCodeNotify('workbench.action.navigateRight') - -nnoremap gr call VSCodeNotify('editor.action.goToReferences') - -" Bind C-/ to vscode commentary since calling from vscode produces double comments due to multiple cursors -xnoremap vscodeCommentary() -nnoremap vscodeCommentary() . '_' - -nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') - -nnoremap :call VSCodeNotify('whichkey.show') -xnoremap :call openWhichKeyInVisualMode() - -xnoremap :call openVSCodeCommandsInVisualMode() - -xmap gc VSCodeCommentary -nmap gc VSCodeCommentary -omap gc VSCodeCommentary -nmap gcc VSCodeCommentaryLine - -" Simulate same TAB behavior in VSCode -nmap :Tabnext -nmap :Tabprev -- cgit v1.2.3