From 5c61955c2dd765a36103f8fd95c6dba75c22bb91 Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Sun, 13 Aug 2023 02:12:02 -0700 Subject: [PATCH] add chat gpt keybindings --- keybindings.vim | 171 ++++++++++++++++++++------------------ plugin-confs/whichkey.lua | 152 ++++++++++++++++++--------------- 2 files changed, 177 insertions(+), 146 deletions(-) diff --git a/keybindings.vim b/keybindings.vim index 6b1cc84..a102012 100644 --- a/keybindings.vim +++ b/keybindings.vim @@ -1,5 +1,5 @@ -nmap :set paste!set paste? -nmap :! +nnoremap :set paste!set paste? +nnoremap :set spell!set spell? " reselect visual selection after indent vnoremap < tf :FloatermToggle floatterm tnoremap tp :FloatermToggle ipython tnoremap tP :FloatermToggle ipython-full -nmap :bnext -nmap :bprev -nmap :wa:FloatermToggle floatterm +nnoremap :bnext +nnoremap :bprev +nnoremap :wa:FloatermToggle floatterm " open file under cursor, create if necessary nnoremap // :Telescope current_buffer_fuzzy_find nnoremap ?? :BLines -nmap gA :lua vim.lsp.buf.code_actions() -nmap gd :Telescope lsp_definitions -nmap gDc :Telescope lsp_implementations -nmap gDf :Telescope lsp_definitions -nmap gF :edit -nmap gT :Telescope lsp_type_definitions -nmap gb :Gitsigns blame_line -nmap gi :Telescope lsp_implementations -nmap gj :Telescope jumplist -nmap gl :lua vim.lsp.buf.code_lens() -nmap gr :Telescope lsp_references -nmap gs :lua vim.lsp.buf.signature_help() +nnoremap gA :lua vim.lsp.buf.code_actions() +nnoremap gd :Telescope lsp_definitions +nnoremap gDc :Telescope lsp_implementations +nnoremap gDf :Telescope lsp_definitions +nnoremap gF :edit +nnoremap gT :Telescope lsp_type_definitions +nnoremap gb :Gitsigns blame_line +nnoremap gi :Telescope lsp_implementations +nnoremap gj :Telescope jumplist +nnoremap gl :lua vim.lsp.buf.code_lens() +nnoremap gr :Telescope lsp_references +nnoremap gs :lua vim.lsp.buf.signature_help() -nmap Q !!$SHELL +nnoremap Q !!$SHELL -nmap rn :lua vim.lsp.buf.rename() +nnoremap rn :lua vim.lsp.buf.rename() -nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 -nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 +nnoremap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 +nnoremap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 -nmap bb :Telescope buffers -nmap bk :bdelete -nmap bn :bnext -nmap bp :bprev +nnoremap bb :Telescope buffers +nnoremap bk :bdelete +nnoremap bn :bnext +nnoremap bp :bprev -nmap ca :lua vim.lsp.buf.code_action() -nmap cd :Telescope diagnostics -nmap cp :vert Copilot panel -nmap cs :lua require("copilot.suggestion").toggle_auto_trigger() +nnoremap ca :lua vim.lsp.buf.code_action() +nnoremap cd :Telescope diagnostics +nnoremap cp :vert Copilot panel +nnoremap Ci :lua require('chatgpt').edit_with_instructions() +nnoremap Cd :ChatGPTRun docstring +nnoremap Ct :ChatGPTRun add_tests +nnoremap Co :ChatGPTRun optimize_code +nnoremap Cs :ChatGPTRun summarize +nnoremap Cf :ChatGPTRun fix_bugs +nnoremap Ce :ChatGPTRun explain +xmap Ci :lua require('chatgpt').edit_with_instructions() +xmap Cd :ChatGPTRun docstring +xmap Ct :ChatGPTRun add_tests +xmap Co :ChatGPTRun optimize_code +xmap Cs :ChatGPTRun summarize +xmap Cf :ChatGPTRun fix_bugs +xmap Ce :ChatGPTRun explain nnoremap fb :Telescope file_browser nnoremap ff :Telescope find_files @@ -57,73 +70,73 @@ nnoremap fg :Telescope live_grep nnoremap fh :Telescope oldfiles nnoremap fd :e ~/.config/nvim/init.vim -nmap gb :Gitsigns blame_line -nmap gc :Telescope git_commits -nmap gf :Telescope git_files -nmap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit +nnoremap gb :Gitsigns blame_line +nnoremap gc :Telescope git_commits +nnoremap gf :Telescope git_files +nnoremap gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit nnoremap gP lua require('goto-preview').close_all_win() nnoremap gR Telescope lsp_references nnoremap gpc lua require('goto-preview').close_all_win() nnoremap gpd lua require('goto-preview').goto_preview_definition() nnoremap gpi lua require('goto-preview').goto_preview_implementation() -nmap hc :Telescope commands +nnoremap hc :Telescope commands nnoremap hv :Telescope help_tags -nmap hk :Telescope keymaps -nmap hs :Telescope spell_suggest +nnoremap hk :Telescope keymaps +nnoremap hs :Telescope spell_suggest -nmap isp :-1read $HOME/Templates/python.py4jw +nnoremap isp :-1read $HOME/Templates/python.py4jw -nmap j :AnyJump +nnoremap j :AnyJump -nmap K :lua vim.lsp.buf.hover() +nnoremap K :lua vim.lsp.buf.hover() -nmap ld :Telescope lsp_definitions -nmap la :lua vim.lsp.buf.code_action() -nmap lci :Telescope lsp_incoming_calls -nmap lco :Telescope lsp_outgoing_calls -nmap lh :lua vim.lsp.buf.signature_help() -nmap li :Telescope lsp_implementations -nmap lr :Telescope lsp_references -nmap lR :lua vim.lsp.buf.rename() -nmap ls :Telescope lsp_document_symbols -nmap lt :Telescope lsp_type_definitions -nmap lw :Telescope lsp_dynamic_workspace_symbols +nnoremap ld :Telescope lsp_definitions +nnoremap la :lua vim.lsp.buf.code_action() +nnoremap lci :Telescope lsp_incoming_calls +nnoremap lco :Telescope lsp_outgoing_calls +nnoremap lh :lua vim.lsp.buf.signature_help() +nnoremap li :Telescope lsp_implementations +nnoremap lr :Telescope lsp_references +nnoremap lR :lua vim.lsp.buf.rename() +nnoremap ls :Telescope lsp_document_symbols +nnoremap lt :Telescope lsp_type_definitions +nnoremap lw :Telescope lsp_dynamic_workspace_symbols -nmap n :NvimTreeToggle +nnoremap n :NvimTreeToggle -nmap ob :Telescope file_browser -nmap oc :ChatGPT -nmap oB :FloatermNew --title=bpytop --opener=vsplit bpytop -nmap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker -nmap of :wa:FloatermToggle floatterm -nmap oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45 -nmap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp -nmap op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython -nmap oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython -nmap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" -nmap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 +nnoremap ob :Telescope file_browser +nnoremap oc :ChatGPT +nnoremap oB :FloatermNew --title=bpytop --opener=vsplit bpytop +nnoremap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker +nnoremap of :wa:FloatermToggle floatterm +nnoremap oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45 +nnoremap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp +nnoremap op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython +nnoremap oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython +nnoremap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" +nnoremap ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5 -nmap r :NvimTreeRefresh +nnoremap r :NvimTreeRefresh -nmap sl :SessionLoad -nmap ss :SessionSave -nmap sc :nohls -nmap sC :Telescope commands -nmap sf :Telescope find_files -nmap sh :Telescope command_history -nmap sm :Telescope man_pages -nmap s/ :Telescope search_history +nnoremap sl :SessionLoad +nnoremap ss :SessionSave +nnoremap sc :nohls +nnoremap sC :Telescope commands +nnoremap sf :Telescope find_files +nnoremap sh :Telescope command_history +nnoremap sm :Telescope man_pages +nnoremap s/ :Telescope search_history nnoremap tc :Telescope colorscheme -nmap tf :wa:FloatermToggle floatterm -nmap tp :FloatermToggle ipython -nmap tP :FloatermToggle ipython-full -nmap tt :FloatermToggle split-term +nnoremap tf :wa:FloatermToggle floatterm +nnoremap tp :FloatermToggle ipython +nnoremap tP :FloatermToggle ipython-full +nnoremap tt :FloatermToggle split-term -nmap wa :lua vim.lsp.buf.add_workspace_folder() -nmap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) -nmap wr :lua vim.lsp.buf.remove_workspace_folder() +nnoremap wa :lua vim.lsp.buf.add_workspace_folder() +nnoremap wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +nnoremap wr :lua vim.lsp.buf.remove_workspace_folder() -nmap y "+ +nnoremap y "+ vmap y "+ diff --git a/plugin-confs/whichkey.lua b/plugin-confs/whichkey.lua index 9e33087..8abe422 100644 --- a/plugin-confs/whichkey.lua +++ b/plugin-confs/whichkey.lua @@ -1,70 +1,88 @@ -require("which-key").setup { - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = true, -- shows your registers on " in NORMAL or in INSERT mode - spelling = { - enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? +local wk = require("which-key") + +wk.setup { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + spelling = { + enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + suggestions = 20 -- how many suggestions should be shown in the list? + }, + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion + motions = true, -- adds help for motions + text_objects = true, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true -- bindings for prefixed with g + } }, - -- the presets plugin, adds help for a bunch of default keybindings in Neovim - -- No actual key bindings are created - presets = { - operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion - motions = true, -- adds help for motions - text_objects = true, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- [""] = "SPC", + -- [""] = "RET", + -- [""] = "TAB", }, - }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - operators = { gc = "Comments" }, - key_labels = { - -- override the label used to display some keys. It doesn't effect WK in any other way. - -- For example: - -- [""] = "SPC", - -- [""] = "RET", - -- [""] = "TAB", - }, - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "➜", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - popup_mappings = { - scroll_down = '', -- binding to scroll down inside the popup - scroll_up = '', -- binding to scroll up inside the popup - }, - window = { - border = "none", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0 - }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - align = "left", -- align columns left, center or right - }, - ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label - hidden = { "", "", "", "", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - show_keys = true, -- show the key strokes for your commands - triggers = "auto", -- automatically setup triggers - -- triggers = {""}, -- or specify a list manually - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for key maps that start with a native binding - -- most people should not need to change this - i = { "j", "k" }, - v = { "j", "k" }, - }, - disable = { - buftypes = {}, - filetypes = { "TelescopePrompt" }, - }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+" -- symbol prepended to a group + }, + popup_mappings = { + scroll_down = '', -- binding to scroll down inside the popup + scroll_up = '' -- binding to scroll up inside the popup + }, + window = { + border = "none", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 0 + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "left" -- align columns left, center or right + }, + ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + show_keys = true, -- show the key strokes for your commands + triggers = "auto", -- automatically setup triggers + -- triggers = {""}, -- or specify a list manually + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + i = { "j", "k" }, + v = { "j", "k" } + }, + disable = { buftypes = {}, filetypes = { "TelescopePrompt" } } } + +wk.register({ + c = { + name = "code", + a = "Code Action", + d = "Diagnostics", + p = "Copilot Panel" + }, + C = { + name = "ChatGPT", + i = "Edit with Instructions", + d = "Docstring", + t = "Add Tests", + o = "Optimize Code", + s = "Summarize", + f = "Fix Bugs", + e = "Explain Code" + } +}, { prefix = "" })