1
0
Fork 0
This commit is contained in:
Luca Bilke 2024-04-15 17:29:36 +02:00
parent 22ebf19899
commit e189eae311
No known key found for this signature in database
GPG Key ID: B753481DA0B6FA47
2 changed files with 50 additions and 42 deletions

View File

@ -41,13 +41,6 @@ local autocmds = {
command = "silent!!xrdb %",
},
},
{ -- Trigger asciidoctor-pdf
"BufWritePost",
{
pattern = { "*.adoc" },
command = "silent!!asciidoctor -r asciidoctor-pdf -r asciidoctor-diagram -b pdf % &",
},
},
}
vim.api.nvim_create_augroup("user_config", { clear = true })

View File

@ -12,14 +12,14 @@ return {
},
},
keys = {
{ "<leader>acc", "<cmd>CopilotChatToggle<cr>", desc = "Toggle Chat", mode = { "n", "v" } },
{ "<leader>acx", "<cmd>CopilotChatReset<cr>", desc = "Reset Chat", mode = { "n", "v" } },
{ "<leader>acf", "<cmd>CopilotChatFix<cr>", desc = "Fix Selection", mode = { "v" } },
{ "<leader>ace", "<cmd>CopilotChatExplain<cr>", desc = "Explain Selection", mode = { "v" } },
{ "<leader>acr", "<cmd>CopilotChatExplain<cr>", desc = "Review Selection", mode = { "v" } },
{ "<leader>acc", "<cmd>CopilotChatToggle<cr>", desc = "Toggle Chat", mode = { "n", "v" } },
{ "<leader>acx", "<cmd>CopilotChatReset<cr>", desc = "Reset Chat", mode = { "n", "v" } },
{ "<leader>acf", "<cmd>CopilotChatFix<cr>", desc = "Fix Selection", mode = { "v" } },
{ "<leader>ace", "<cmd>CopilotChatExplain<cr>", desc = "Explain Selection", mode = { "v" } },
{ "<leader>acr", "<cmd>CopilotChatExplain<cr>", desc = "Review Selection", mode = { "v" } },
{ "<leader>aco", "<cmd>CopilotChatOptimize<cr>", desc = "Optimize Selection", mode = { "v" } },
{ "<leader>acd", "<cmd>CopilotChatDocs<cr>", desc = "Document Selection", mode = { "v" } },
{ "<leader>act", "<cmd>CopilotChatTests<cr>", desc = "Unittest Selection", mode = { "v" } },
{ "<leader>acd", "<cmd>CopilotChatDocs<cr>", desc = "Document Selection", mode = { "v" } },
{ "<leader>act", "<cmd>CopilotChatTests<cr>", desc = "Unittest Selection", mode = { "v" } },
},
opts = {
window = {
@ -85,28 +85,30 @@ return {
},
config = function(_, opts)
local key = Lib.get_secret("openai")
require("chatgpt.api").OPENAI_API_KEY = key
require("chatgpt.api").AUTHORIZATION_HEADER = "Authorization: Bearer " .. key
require("chatgpt").setup(opts)
if key then
require("chatgpt.api").OPENAI_API_KEY = key
require("chatgpt.api").AUTHORIZATION_HEADER = "Authorization: Bearer " .. key
require("chatgpt").setup(opts)
end
end,
--stylua: ignore
keys = {
{ "<leader>agc", function() require("chatgpt").openChat() end, desc = "Toggle Chat" },
{ "<leader>age", function() require("chatgpt").edit_with_instructions() end, desc = "Edit with instruction", mode = { "n", "v" } },
{ "<leader>agg", function() require("chatgpt").run_action("grammar_correction") end, desc = "Grammar Correction", mode = { "n", "v" } },
{ "<leader>agtg", function() require("chatgpt").run_action({ fargs = { "translate", "german" } }) end, desc = "German", mode = { "n", "v" } },
{ "<leader>agte", function() require("chatgpt").run_action({ fargs = { "translate", "english" } }) end, desc = "English", mode = { "n", "v" } },
{ "<leader>agtf", function() require("chatgpt").run_action({ fargs = { "translate", "french" } }) end, desc = "French", mode = { "n", "v" } },
{ "<leader>agtr", function() require("chatgpt").run_action({ fargs = { "translate", "russian" } }) end, desc = "Russian", mode = { "n", "v" } },
{ "<leader>agk", function() require("chatgpt").run_action({ fargs = { "keywords" } }) end, desc = "Keywords", mode = { "n", "v" } },
{ "<leader>agd", function() require("chatgpt").run_action({ fargs = { "docstring" } }) end, desc = "Docstring", mode = { "n", "v" } },
{ "<leader>aga", function() require("chatgpt").run_action({ fargs = { "add_tests" } }) end, desc = "Add Tests", mode = { "n", "v" } },
{ "<leader>ago", function() require("chatgpt").run_action({ fargs = { "optimize_code" } }) end, desc = "Optimize Code", mode = { "n", "v" } },
{ "<leader>ags", function() require("chatgpt").run_action({ fargs = { "summarize" } }) end, desc = "Summarize", mode = { "n", "v" } },
{ "<leader>agf", function() require("chatgpt").run_action({ fargs = { "fix_bugs" } }) end, desc = "Fix Bugs", mode = { "n", "v" } },
{ "<leader>agx", function() require("chatgpt").run_action({ fargs = { "explain_code" } }) end, desc = "Explain Code", mode = { "n", "v" } },
{ "<leader>agr", function() require("chatgpt").run_action({ fargs = { "roxygen_edit" } }) end, desc = "Roxygen Edit", mode = { "n", "v" } },
{ "<leader>agl", function() require("chatgpt").run_action({ fargs = { "code_readability_analysis" } }) end, desc = "Code Readability Analysis", mode = { "n", "v" } },
{ "<leader>agc", function() require("chatgpt").openChat() end, desc = "Toggle Chat" },
{ "<leader>age", function() require("chatgpt").edit_with_instructions() end, desc = "Edit with instruction", mode = { "n", "v" } },
{ "<leader>agg", function() require("chatgpt").run_action("grammar_correction") end, desc = "Grammar Correction", mode = { "n", "v" } },
{ "<leader>agtg", function() require("chatgpt").run_action({ fargs = { "translate", "german" } }) end, desc = "German", mode = { "n", "v" } },
{ "<leader>agte", function() require("chatgpt").run_action({ fargs = { "translate", "english" } }) end, desc = "English", mode = { "n", "v" } },
{ "<leader>agtf", function() require("chatgpt").run_action({ fargs = { "translate", "french" } }) end, desc = "French", mode = { "n", "v" } },
{ "<leader>agtr", function() require("chatgpt").run_action({ fargs = { "translate", "russian" } }) end, desc = "Russian", mode = { "n", "v" } },
{ "<leader>agk", function() require("chatgpt").run_action({ fargs = { "keywords" } }) end, desc = "Keywords", mode = { "n", "v" } },
{ "<leader>agd", function() require("chatgpt").run_action({ fargs = { "docstring" } }) end, desc = "Docstring", mode = { "n", "v" } },
{ "<leader>aga", function() require("chatgpt").run_action({ fargs = { "add_tests" } }) end, desc = "Add Tests", mode = { "n", "v" } },
{ "<leader>ago", function() require("chatgpt").run_action({ fargs = { "optimize_code" } }) end, desc = "Optimize Code", mode = { "n", "v" } },
{ "<leader>ags", function() require("chatgpt").run_action({ fargs = { "summarize" } }) end, desc = "Summarize", mode = { "n", "v" } },
{ "<leader>agf", function() require("chatgpt").run_action({ fargs = { "fix_bugs" } }) end, desc = "Fix Bugs", mode = { "n", "v" } },
{ "<leader>agx", function() require("chatgpt").run_action({ fargs = { "explain_code" } }) end, desc = "Explain Code", mode = { "n", "v" } },
{ "<leader>agr", function() require("chatgpt").run_action({ fargs = { "roxygen_edit" } }) end, desc = "Roxygen Edit", mode = { "n", "v" } },
{ "<leader>agl", function() require("chatgpt").run_action({ fargs = { "code_readability_analysis" } }) end, desc = "Code Readability Analysis", mode = { "n", "v" } },
},
opts = {
edit_with_instructions = {
@ -130,6 +132,9 @@ return {
border = {
style = "single",
},
win_options = {
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder",
},
},
keymaps = {
close = "<C-c>",
@ -268,16 +273,26 @@ return {
},
--stylua: ignore
keys = {
{ "<leader>zn", function() require("zk.commands").get("ZkNew")({ title = vim.fn.input('Title: ') }) end, desc = "New Note", mode = { "n", "v" } },
{ "<leader>znt", function() require("zk.commands").get("ZkNewFromTitleSelection")() end, desc = "Title from selection", mode = { "v" } },
{ "<leader>znc", function() require("zk.commands").get("ZkNewFromContentSelection")({ title = vim.fn.input('Title: ') }) end, desc = "Content from selection", mode = { "v" } },
{ "<leader>zb", function() require("zk.commands").get("ZkBacklinks")() end, desc = "Links" },
{ "<leader>zl", function() require("zk.commands").get("ZkLinks")() end, desc = "Backlinks" },
{ "<leader>zx", function() require("zk.commands").get("ZkIndex")() end, desc = "Index" },
{ "<leader>zn", function() require("zk.commands").get("ZkNew")({ title = vim.fn.input('Title: ') }) end, desc = "New Note", mode = { "n", "v" } },
{ "<leader>znt", function() require("zk.commands").get("ZkNewFromTitleSelection")() end, desc = "Title from selection", mode = { "v" } },
{
"<leader>znc",
function()
require("zk.commands").get("ZkNewFromContentSelection")({
title = vim.fn.input(
'Title: ')
})
end,
desc = "Content from selection",
mode = { "v" }
},
{ "<leader>zb", function() require("zk.commands").get("ZkBacklinks")() end, desc = "Links" },
{ "<leader>zl", function() require("zk.commands").get("ZkLinks")() end, desc = "Backlinks" },
{ "<leader>zx", function() require("zk.commands").get("ZkIndex")() end, desc = "Index" },
{ "<leader>zf", function() require("zk.commands").get("ZkNotes")({ sort = { 'modified' } }) end, desc = "Find Notes" },
{ "<leader>zt", function() require("zk.commands").get("ZkTags")() end, desc = "Find Note Tags" },
{ "<leader>zf", function() require("zk.commands").get("ZkMatch")() end, desc = "Find Notes (Match Selection)", mode = { "v" } },
{ "<leader>zi", function() require("zk.commands").get("ZkInsertLinkAtSelection")() end, desc = "Insert Link", mode = { "n", "v" } },
{ "<leader>zt", function() require("zk.commands").get("ZkTags")() end, desc = "Find Note Tags" },
{ "<leader>zf", function() require("zk.commands").get("ZkMatch")() end, desc = "Find Notes (Match Selection)", mode = { "v" } },
{ "<leader>zi", function() require("zk.commands").get("ZkInsertLinkAtSelection")() end, desc = "Insert Link", mode = { "n", "v" } },
},
},
}