Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gpt plugin #17

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require("autopairs-config")
require("diffview-config")
require("notify-config")
require("tint-config")
require("chatgpt-config")
require("debugger-config")
require("debugger-config.rust")
require("debugger-config.python")
3 changes: 3 additions & 0 deletions lua/chatgpt-config/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require("chatgpt").setup({
api_key_cmd = "op read op://private/OpenAI/credential --no-newline",
})
14 changes: 13 additions & 1 deletion lua/packer-config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,20 @@ return require("packer").startup(function(use)
use("rcarriga/nvim-dap-ui")
use("theHamsta/nvim-dap-virtual-text")
use({ "nvim-neotest/nvim-nio" })

--> AI
-- use("github/copilot.vim")
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup()
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"folke/trouble.nvim",
"nvim-telescope/telescope.nvim",
},
})

--> lsp
use("williamboman/mason.nvim")
Expand Down
204 changes: 110 additions & 94 deletions lua/which-config/init.lua
Original file line number Diff line number Diff line change
@@ -1,110 +1,126 @@
local wk = require("which-key")
wk.setup({
plugins = {
marks = false,
registers = false,
spelling = { enabled = false, suggestions = 20 },
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
plugins = {
marks = false,
registers = false,
spelling = { enabled = false, suggestions = 20 },
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
})

local Terminal = require("toggleterm.terminal").Terminal

local toggle_float = function()
local float = Terminal:new({ direction = "float" })
return float:toggle()
local float = Terminal:new({ direction = "float" })
return float:toggle()
end

local toggle_lazygit = function()
local lazygit = Terminal:new({ cmd = "lazygit", direction = "float" })
return lazygit:toggle()
local lazygit = Terminal:new({ cmd = "lazygit", direction = "float" })
return lazygit:toggle()
end

local mappings = {
["/"] = { ":CommentToggle<cr>", "Toggle Comment" },
c = { ":67,69CommentToggle<cr>", "Range Toggle Comment" },
q = { ":q<cr>", "Quit" },
Q = { ":wq<cr>", "Save & Quit" },
w = { ":w<cr>", "Save" },
x = { ":bdelete<cr>", "Close" },
-- d = { ":Dashboard<cr>", "Dashboard" },
E = { ":e ~/.config/nvim/init.lua<cr>", "Edit config" },
f = {
name = "Telescope",
f = { ":Telescope find_files<cr>", "Telescope Find Files" },
g = { ":Telescope live_grep<cr>", "Telescope Live Grep" },
o = { ":Telescope oldfiles<cr>", "Telescope Old Files" },
h = { ":Telescope keymaps<cr>", "Telescope Keymaps" },
b = { ":Telescope buffers<cr>", "Telescope Buffers" },
},
b = {
name = "Telescope Bookmarks",
m = { ":Telescope marks<cr>", "Bookmarks" },
},
t = {
name = "Terminal",
t = { ":ToggleTerm<cr>", "Split Below" },
f = { toggle_float, "Floating Terminal" },
l = { toggle_lazygit, "LazyGit" },
},
l = {
name = "LSP",
i = { ":LspInfo<cr>", "Connected Language Servers" },
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
K = { "<cmd>Lspsaga hover_doc<cr>", "Hover Commands" },
w = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", "Add Workspace Folder" },
W = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", "Remove Workspace Folder" },
l = {
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
"List Workspace Folders",
},
t = { "<cmd>lua vim.lsp.buf.type_definition()<cr>", "Type Definition" },
d = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Go To Definition" },
D = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Go To Declaration" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "References" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
e = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Show Line Diagnostics" },
n = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Go To Next Diagnostic" },
N = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Go To Previous Diagnostic" },
},
p = {
name = "Packer",
r = { ":PackerClean<cr>", "Remove Unused Plugins" },
c = { ":PackerCompile profile=true<cr>", "Recompile Plugins" },
i = { ":PackerInstall<cr>", "Install Plugins" },
p = { ":PackerProfile<cr>", "Packer Profile" },
s = { ":PackerSync<cr>", "Sync Plugins" },
S = { ":PackerStatus<cr>", "Packer Status" },
u = { ":PackerUpdate<cr>", "Update Plugins" },
},
-- debugger mappings --
d = {
name = "Debugger",
c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
O = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
s = {
"<cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>",
"Set Breakpoint condition",
},
B = {
"<cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>",
"Set Breakpoint log message",
},
n = { "<cmd>lua require'dap'.repl.open()<cr>", "Open" },
l = { "<cmd>lua require'dap'.run_last()<cr>", "Run Last" },
},
["/"] = { ":CommentToggle<cr>", "Toggle Comment" },
c = { ":67,69CommentToggle<cr>", "Range Toggle Comment" },
q = { ":q<cr>", "Quit" },
Q = { ":wq<cr>", "Save & Quit" },
w = { ":w<cr>", "Save" },
x = { ":bdelete<cr>", "Close" },
-- d = { ":Dashboard<cr>", "Dashboard" },
E = { ":e ~/.config/nvim/init.lua<cr>", "Edit config" },
f = {
name = "Telescope",
f = { ":Telescope find_files<cr>", "Telescope Find Files" },
g = { ":Telescope live_grep<cr>", "Telescope Live Grep" },
o = { ":Telescope oldfiles<cr>", "Telescope Old Files" },
h = { ":Telescope keymaps<cr>", "Telescope Keymaps" },
b = { ":Telescope buffers<cr>", "Telescope Buffers" },
},
g = {
name = "ChatGPT",
c = { "<cmd>ChatGPT<CR>", "ChatGPT" },
e = { "<cmd>ChatGPTEditWithInstruction<CR>", "Edit with instruction", mode = { "n", "v" } },
g = { "<cmd>ChatGPTRun grammar_correction<CR>", "Grammar Correction", mode = { "n", "v" } },
t = { "<cmd>ChatGPTRun translate<CR>", "Translate", mode = { "n", "v" } },
k = { "<cmd>ChatGPTRun keywords<CR>", "Keywords", mode = { "n", "v" } },
d = { "<cmd>ChatGPTRun docstring<CR>", "Docstring", mode = { "n", "v" } },
a = { "<cmd>ChatGPTRun add_tests<CR>", "Add Tests", mode = { "n", "v" } },
o = { "<cmd>ChatGPTRun optimize_code<CR>", "Optimize Code", mode = { "n", "v" } },
s = { "<cmd>ChatGPTRun summarize<CR>", "Summarize", mode = { "n", "v" } },
f = { "<cmd>ChatGPTRun fix_bugs<CR>", "Fix Bugs", mode = { "n", "v" } },
x = { "<cmd>ChatGPTRun explain_code<CR>", "Explain Code", mode = { "n", "v" } },
r = { "<cmd>ChatGPTRun roxygen_edit<CR>", "Roxygen Edit", mode = { "n", "v" } },
l = { "<cmd>ChatGPTRun code_readability_analysis<CR>", "Code Readability Analysis", mode = { "n", "v" } },
},
b = {
name = "Telescope Bookmarks",
m = { ":Telescope marks<cr>", "Bookmarks" },
},
t = {
name = "Terminal",
t = { ":ToggleTerm<cr>", "Split Below" },
f = { toggle_float, "Floating Terminal" },
l = { toggle_lazygit, "LazyGit" },
},
l = {
name = "LSP",
i = { ":LspInfo<cr>", "Connected Language Servers" },
k = { "<cmd>lua vim.lsp.buf.signature_help()<cr>", "Signature Help" },
K = { "<cmd>Lspsaga hover_doc<cr>", "Hover Commands" },
w = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>", "Add Workspace Folder" },
W = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<cr>", "Remove Workspace Folder" },
l = {
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
"List Workspace Folders",
},
t = { "<cmd>lua vim.lsp.buf.type_definition()<cr>", "Type Definition" },
d = { "<cmd>lua vim.lsp.buf.definition()<cr>", "Go To Definition" },
D = { "<cmd>lua vim.lsp.buf.declaration()<cr>", "Go To Declaration" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "References" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
e = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Show Line Diagnostics" },
n = { "<cmd>Lspsaga diagnostic_jump_next<cr>", "Go To Next Diagnostic" },
N = { "<cmd>Lspsaga diagnostic_jump_prev<cr>", "Go To Previous Diagnostic" },
},
p = {
name = "Packer",
r = { ":PackerClean<cr>", "Remove Unused Plugins" },
c = { ":PackerCompile profile=true<cr>", "Recompile Plugins" },
i = { ":PackerInstall<cr>", "Install Plugins" },
p = { ":PackerProfile<cr>", "Packer Profile" },
s = { ":PackerSync<cr>", "Sync Plugins" },
S = { ":PackerStatus<cr>", "Packer Status" },
u = { ":PackerUpdate<cr>", "Update Plugins" },
},
-- debugger mappings --
d = {
name = "Debugger",
c = { "<cmd>lua require'dap'.continue()<cr>", "Continue" },
o = { "<cmd>lua require'dap'.step_over()<cr>", "Step Over" },
i = { "<cmd>lua require'dap'.step_into()<cr>", "Step Into" },
O = { "<cmd>lua require'dap'.step_out()<cr>", "Step Out" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "Toggle Breakpoint" },
s = {
"<cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>",
"Set Breakpoint condition",
},
B = {
"<cmd>lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>",
"Set Breakpoint log message",
},
n = { "<cmd>lua require'dap'.repl.open()<cr>", "Open" },
l = { "<cmd>lua require'dap'.run_last()<cr>", "Run Last" },
},
}

local opts = { prefix = "<leader>" }
Expand Down
Loading