add chat gpt keybindings

This commit is contained in:
ksyasuda 2023-08-13 02:12:02 -07:00
parent 0df26f6082
commit 5c61955c2d
No known key found for this signature in database
2 changed files with 177 additions and 146 deletions

View File

@ -1,5 +1,5 @@
nmap <F4> :set paste!<Bar>set paste?<CR> nnoremap <F4> :set paste!<Bar>set paste?<CR>
nmap <F5> :! nnoremap <F5> :set spell!<Bar>set spell?<CR>
" reselect visual selection after indent " reselect visual selection after indent
vnoremap < <gv vnoremap < <gv
@ -13,43 +13,56 @@ tnoremap <leader>tf <C-\><C-N>:FloatermToggle floatterm<CR>
tnoremap <leader>tp <C-\><C-N>:FloatermToggle ipython<CR> tnoremap <leader>tp <C-\><C-N>:FloatermToggle ipython<CR>
tnoremap <leader>tP <C-\><C-N>:FloatermToggle ipython-full<CR> tnoremap <leader>tP <C-\><C-N>:FloatermToggle ipython-full<CR>
nmap <C-J> :bnext<CR> nnoremap <C-J> :bnext<CR>
nmap <C-K> :bprev<CR> nnoremap <C-K> :bprev<CR>
nmap <C-T> :wa<CR>:FloatermToggle floatterm<CR> nnoremap <C-T> :wa<CR>:FloatermToggle floatterm<CR>
" open file under cursor, create if necessary " open file under cursor, create if necessary
nnoremap // :Telescope current_buffer_fuzzy_find<CR> nnoremap // :Telescope current_buffer_fuzzy_find<CR>
nnoremap ?? :BLines<CR> nnoremap ?? :BLines<CR>
nmap gA :lua vim.lsp.buf.code_actions()<CR> nnoremap gA :lua vim.lsp.buf.code_actions()<CR>
nmap gd :Telescope lsp_definitions<CR> nnoremap gd :Telescope lsp_definitions<CR>
nmap gDc :Telescope lsp_implementations<CR> nnoremap gDc :Telescope lsp_implementations<CR>
nmap gDf :Telescope lsp_definitions<CR> nnoremap gDf :Telescope lsp_definitions<CR>
nmap gF :edit <cfile><cr> nnoremap gF :edit <cfile><cr>
nmap gT :Telescope lsp_type_definitions<CR> nnoremap gT :Telescope lsp_type_definitions<CR>
nmap gb :Gitsigns blame_line<CR> nnoremap gb :Gitsigns blame_line<CR>
nmap gi :Telescope lsp_implementations<CR> nnoremap gi :Telescope lsp_implementations<CR>
nmap gj :Telescope jumplist<CR> nnoremap gj :Telescope jumplist<CR>
nmap gl :lua vim.lsp.buf.code_lens()<CR> nnoremap gl :lua vim.lsp.buf.code_lens()<CR>
nmap gr :Telescope lsp_references<CR> nnoremap gr :Telescope lsp_references<CR>
nmap gs :lua vim.lsp.buf.signature_help()<CR> nnoremap gs :lua vim.lsp.buf.signature_help()<CR>
nmap Q !!$SHELL<CR> nnoremap Q !!$SHELL<CR>
nmap rn :lua vim.lsp.buf.rename()<CR> nnoremap rn :lua vim.lsp.buf.rename()<CR>
nmap <leader>as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144<CR> nnoremap <leader>as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144<CR>
nmap <leader>ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144<CR> nnoremap <leader>ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144<CR>
nmap <leader>bb :Telescope buffers<CR> nnoremap <leader>bb :Telescope buffers<CR>
nmap <leader>bk :bdelete<CR> nnoremap <leader>bk :bdelete<CR>
nmap <leader>bn :bnext<CR> nnoremap <leader>bn :bnext<CR>
nmap <leader>bp :bprev<CR> nnoremap <leader>bp :bprev<CR>
nmap <leader>ca :lua vim.lsp.buf.code_action()<CR> nnoremap <leader>ca :lua vim.lsp.buf.code_action()<CR>
nmap <leader>cd :Telescope diagnostics<CR> nnoremap <leader>cd :Telescope diagnostics<CR>
nmap <leader>cp :vert Copilot panel<CR> nnoremap <silent> <leader>cp :vert Copilot panel<CR>
nmap <leader>cs :lua require("copilot.suggestion").toggle_auto_trigger()<CR> nnoremap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
nnoremap <silent> <leader>Cd :ChatGPTRun docstring<CR>
nnoremap <silent> <leader>Ct :ChatGPTRun add_tests<CR>
nnoremap <silent> <leader>Co :ChatGPTRun optimize_code<CR>
nnoremap <silent> <leader>Cs :ChatGPTRun summarize<CR>
nnoremap <silent> <leader>Cf :ChatGPTRun fix_bugs<CR>
nnoremap <silent> <leader>Ce :ChatGPTRun explain<CR>
xmap <silent> <leader>Ci :lua require('chatgpt').edit_with_instructions()<CR>
xmap <silent> <leader>Cd :ChatGPTRun docstring<CR>
xmap <silent> <leader>Ct :ChatGPTRun add_tests<CR>
xmap <silent> <leader>Co :ChatGPTRun optimize_code<CR>
xmap <silent> <leader>Cs :ChatGPTRun summarize<CR>
xmap <silent> <leader>Cf :ChatGPTRun fix_bugs<CR>
xmap <silent> <leader>Ce :ChatGPTRun explain<CR>
nnoremap <leader>fb :Telescope file_browser<cr> nnoremap <leader>fb :Telescope file_browser<cr>
nnoremap <leader>ff :Telescope find_files<cr> nnoremap <leader>ff :Telescope find_files<cr>
@ -57,73 +70,73 @@ nnoremap <leader>fg :Telescope live_grep<cr>
nnoremap <leader>fh :Telescope oldfiles<cr> nnoremap <leader>fh :Telescope oldfiles<cr>
nnoremap <leader>fd :e ~/.config/nvim/init.vim<cr> nnoremap <leader>fd :e ~/.config/nvim/init.vim<cr>
nmap <leader>gb :Gitsigns blame_line<CR> nnoremap <leader>gb :Gitsigns blame_line<CR>
nmap <leader>gc :Telescope git_commits<CR> nnoremap <leader>gc :Telescope git_commits<CR>
nmap <leader>gf :Telescope git_files<CR> nnoremap <leader>gf :Telescope git_files<CR>
nmap <leader>gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit<CR> nnoremap <leader>gg :FloatermNew --title=lazygit --width=1.0 --height=1.0 --opener=vsplit lazygit<CR>
nnoremap gP <cmd>lua require('goto-preview').close_all_win()<CR> nnoremap gP <cmd>lua require('goto-preview').close_all_win()<CR>
nnoremap gR <cmd>Telescope lsp_references<cr> nnoremap gR <cmd>Telescope lsp_references<cr>
nnoremap gpc <cmd>lua require('goto-preview').close_all_win()<CR> nnoremap gpc <cmd>lua require('goto-preview').close_all_win()<CR>
nnoremap gpd <cmd>lua require('goto-preview').goto_preview_definition()<CR> nnoremap gpd <cmd>lua require('goto-preview').goto_preview_definition()<CR>
nnoremap gpi <cmd>lua require('goto-preview').goto_preview_implementation()<CR> nnoremap gpi <cmd>lua require('goto-preview').goto_preview_implementation()<CR>
nmap <leader>hc :Telescope commands<CR> nnoremap <leader>hc :Telescope commands<CR>
nnoremap <leader>hv :Telescope help_tags<cr> nnoremap <leader>hv :Telescope help_tags<cr>
nmap <leader>hk :Telescope keymaps<CR> nnoremap <leader>hk :Telescope keymaps<CR>
nmap <leader>hs :Telescope spell_suggest<CR> nnoremap <leader>hs :Telescope spell_suggest<CR>
nmap <leader>isp :-1read $HOME/Templates/python.py<CR>4jw nnoremap <leader>isp :-1read $HOME/Templates/python.py<CR>4jw
nmap <leader>j :AnyJump<CR> nnoremap <leader>j :AnyJump<CR>
nmap K :lua vim.lsp.buf.hover()<CR> nnoremap K :lua vim.lsp.buf.hover()<CR>
nmap <leader>ld :Telescope lsp_definitions<CR> nnoremap <leader>ld :Telescope lsp_definitions<CR>
nmap <leader>la :lua vim.lsp.buf.code_action()<CR> nnoremap <leader>la :lua vim.lsp.buf.code_action()<CR>
nmap <leader>lci :Telescope lsp_incoming_calls<CR> nnoremap <leader>lci :Telescope lsp_incoming_calls<CR>
nmap <leader>lco :Telescope lsp_outgoing_calls<CR> nnoremap <leader>lco :Telescope lsp_outgoing_calls<CR>
nmap <leader>lh :lua vim.lsp.buf.signature_help()<CR> nnoremap <leader>lh :lua vim.lsp.buf.signature_help()<CR>
nmap <leader>li :Telescope lsp_implementations<CR> nnoremap <leader>li :Telescope lsp_implementations<CR>
nmap <leader>lr :Telescope lsp_references<CR> nnoremap <leader>lr :Telescope lsp_references<CR>
nmap <leader>lR :lua vim.lsp.buf.rename()<CR> nnoremap <leader>lR :lua vim.lsp.buf.rename()<CR>
nmap <leader>ls :Telescope lsp_document_symbols<CR> nnoremap <leader>ls :Telescope lsp_document_symbols<CR>
nmap <leader>lt :Telescope lsp_type_definitions<CR> nnoremap <leader>lt :Telescope lsp_type_definitions<CR>
nmap <leader>lw :Telescope lsp_dynamic_workspace_symbols<CR> nnoremap <leader>lw :Telescope lsp_dynamic_workspace_symbols<CR>
nmap <leader>n :NvimTreeToggle<CR> nnoremap <leader>n :NvimTreeToggle<CR>
nmap <leader>ob :Telescope file_browser<CR> nnoremap <leader>ob :Telescope file_browser<CR>
nmap <leader>oc :ChatGPT<CR> nnoremap <leader>oc :ChatGPT<CR>
nmap <leader>oB :FloatermNew --title=bpytop --opener=vsplit bpytop<CR> nnoremap <leader>oB :FloatermNew --title=bpytop --opener=vsplit bpytop<CR>
nmap <leader>od :FloatermNew --title=lazydocker --opener=vsplit lazydocker<CR> nnoremap <leader>od :FloatermNew --title=lazydocker --opener=vsplit lazydocker<CR>
nmap <leader>of :wa<CR>:FloatermToggle floatterm<CR> nnoremap <leader>of :wa<CR>:FloatermToggle floatterm<CR>
nmap <leader>oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45<CR> nnoremap <leader>oh :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=split --position=botright --height=0.45<CR>
nmap <leader>on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp<CR> nnoremap <leader>on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp<CR>
nmap <leader>op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython<CR> nnoremap <leader>op :FloatermNew --title=ipython --name=ipython --opener=split --wintype=vsplit --position=botright --width=0.5 ipython<CR>
nmap <leader>oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython<CR> nnoremap <leader>oP :FloatermNew --title=ipython-full --name=ipython-full --opener=edit --width=1.0 --height=1.0 ipython<CR>
nmap <leader>or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD"<CR> nnoremap <leader>or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD"<CR>
nmap <leader>ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5<CR> nnoremap <leader>ot :FloatermNew --title=floaterm --name=split-term --opener=edit --wintype=vsplit --position=botright --width=0.5<CR>
nmap <leader>r :NvimTreeRefresh<CR> nnoremap <leader>r :NvimTreeRefresh<CR>
nmap <Leader>sl :<C-u>SessionLoad<CR> nnoremap <Leader>sl :<C-u>SessionLoad<CR>
nmap <Leader>ss :<C-u>SessionSave<CR> nnoremap <Leader>ss :<C-u>SessionSave<CR>
nmap <leader>sc :nohls<Cr> nnoremap <leader>sc :nohls<Cr>
nmap <leader>sC :Telescope commands<Cr> nnoremap <leader>sC :Telescope commands<Cr>
nmap <leader>sf :Telescope find_files<Cr> nnoremap <leader>sf :Telescope find_files<Cr>
nmap <leader>sh :Telescope command_history<CR> nnoremap <leader>sh :Telescope command_history<CR>
nmap <leader>sm :Telescope man_pages<CR> nnoremap <leader>sm :Telescope man_pages<CR>
nmap <leader>s/ :Telescope search_history<CR> nnoremap <leader>s/ :Telescope search_history<CR>
nnoremap <silent> <Leader>tc :Telescope colorscheme<CR> nnoremap <silent> <Leader>tc :Telescope colorscheme<CR>
nmap <leader>tf :wa<CR>:FloatermToggle floatterm<CR> nnoremap <silent> <leader>tf :wa<CR>:FloatermToggle floatterm<CR>
nmap <leader>tp :FloatermToggle ipython<CR> nnoremap <silent> <leader>tp :FloatermToggle ipython<CR>
nmap <leader>tP :FloatermToggle ipython-full<CR> nnoremap <silent> <leader>tP :FloatermToggle ipython-full<CR>
nmap <leader>tt :FloatermToggle split-term<CR> nnoremap <silent> <leader>tt :FloatermToggle split-term<CR>
nmap <leader>wa :lua vim.lsp.buf.add_workspace_folder()<CR> nnoremap <leader>wa :lua vim.lsp.buf.add_workspace_folder()<CR>
nmap <leader>wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR> nnoremap <leader>wl :lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>
nmap <leader>wr :lua vim.lsp.buf.remove_workspace_folder()<CR> nnoremap <leader>wr :lua vim.lsp.buf.remove_workspace_folder()<CR>
nmap <leader>y "+ nnoremap <leader>y "+
vmap <leader>y "+ vmap <leader>y "+

View File

@ -1,70 +1,88 @@
require("which-key").setup { local wk = require("which-key")
plugins = {
marks = true, -- shows a list of your marks on ' and ` wk.setup {
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode plugins = {
spelling = { marks = true, -- shows a list of your marks on ' and `
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
suggestions = 20, -- how many suggestions should be shown in the list? 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 <c-w>
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 -- add operators that will trigger motion and text object completion
-- No actual key bindings are created -- to enable all native operators, set the preset / operators plugin above
presets = { operators = { gc = "Comments" },
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion key_labels = {
motions = true, -- adds help for motions -- override the label used to display some keys. It doesn't effect WK in any other way.
text_objects = true, -- help for text objects triggered after entering an operator -- For example:
windows = true, -- default bindings on <c-w> -- ["<space>"] = "SPC",
nav = true, -- misc bindings to work with windows -- ["<cr>"] = "RET",
z = true, -- bindings for folds, spelling and others prefixed with z -- ["<tab>"] = "TAB",
g = true, -- bindings for prefixed with g
}, },
}, icons = {
-- add operators that will trigger motion and text object completion breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
-- to enable all native operators, set the preset / operators plugin above separator = "", -- symbol used between a key and it's label
operators = { gc = "Comments" }, group = "+" -- symbol prepended to a group
key_labels = { },
-- override the label used to display some keys. It doesn't effect WK in any other way. popup_mappings = {
-- For example: scroll_down = '<c-d>', -- binding to scroll down inside the popup
-- ["<space>"] = "SPC", scroll_up = '<c-u>' -- binding to scroll up inside the popup
-- ["<cr>"] = "RET", },
-- ["<tab>"] = "TAB", window = {
}, border = "none", -- none, single, double, shadow
icons = { position = "bottom", -- bottom, top
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
separator = "", -- symbol used between a key and it's label padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
group = "+", -- symbol prepended to a group winblend = 0
}, },
popup_mappings = { layout = {
scroll_down = '<c-d>', -- binding to scroll down inside the popup height = { min = 4, max = 25 }, -- min and max height of the columns
scroll_up = '<c-u>', -- binding to scroll up inside the popup width = { min = 20, max = 50 }, -- min and max width of the columns
}, spacing = 3, -- spacing between columns
window = { align = "left" -- align columns left, center or right
border = "none", -- none, single, double, shadow },
position = "bottom", -- bottom, top ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] show_help = true, -- show help message on the command line when the popup is visible
winblend = 0 show_keys = true, -- show the key strokes for your commands
}, triggers = "auto", -- automatically setup triggers
layout = { -- triggers = {"<leader>"}, -- or specify a list manually
height = { min = 4, max = 25 }, -- min and max height of the columns triggers_blacklist = {
width = { min = 20, max = 50 }, -- min and max width of the columns -- list of mode / prefixes that should never be hooked by WhichKey
spacing = 3, -- spacing between columns -- this is mostly relevant for key maps that start with a native binding
align = "left", -- align columns left, center or right -- most people should not need to change this
}, i = { "j", "k" },
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label v = { "j", "k" }
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate },
show_help = true, -- show help message on the command line when the popup is visible disable = { buftypes = {}, filetypes = { "TelescopePrompt" } }
show_keys = true, -- show the key strokes for your commands
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"}, -- 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 = "<leader>" })