From df30a0ba0a0d5af2d98e05f6014a5730d23b0396 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Mon, 15 Apr 2024 17:29:36 +0200 Subject: [PATCH] cleanup --- .config/nvim/lua/config/autocmds.lua | 7 --- .config/nvim/lua/plugins/editor.lua | 85 ++++++++++++++++------------ 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua index 09d54f5b5..583330dcf 100644 --- a/.config/nvim/lua/config/autocmds.lua +++ b/.config/nvim/lua/config/autocmds.lua @@ -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 }) diff --git a/.config/nvim/lua/plugins/editor.lua b/.config/nvim/lua/plugins/editor.lua index 1cb6ba846..f08d52803 100644 --- a/.config/nvim/lua/plugins/editor.lua +++ b/.config/nvim/lua/plugins/editor.lua @@ -12,14 +12,14 @@ return { }, }, keys = { - { "acc", "CopilotChatToggle", desc = "Toggle Chat", mode = { "n", "v" } }, - { "acx", "CopilotChatReset", desc = "Reset Chat", mode = { "n", "v" } }, - { "acf", "CopilotChatFix", desc = "Fix Selection", mode = { "v" } }, - { "ace", "CopilotChatExplain", desc = "Explain Selection", mode = { "v" } }, - { "acr", "CopilotChatExplain", desc = "Review Selection", mode = { "v" } }, + { "acc", "CopilotChatToggle", desc = "Toggle Chat", mode = { "n", "v" } }, + { "acx", "CopilotChatReset", desc = "Reset Chat", mode = { "n", "v" } }, + { "acf", "CopilotChatFix", desc = "Fix Selection", mode = { "v" } }, + { "ace", "CopilotChatExplain", desc = "Explain Selection", mode = { "v" } }, + { "acr", "CopilotChatExplain", desc = "Review Selection", mode = { "v" } }, { "aco", "CopilotChatOptimize", desc = "Optimize Selection", mode = { "v" } }, - { "acd", "CopilotChatDocs", desc = "Document Selection", mode = { "v" } }, - { "act", "CopilotChatTests", desc = "Unittest Selection", mode = { "v" } }, + { "acd", "CopilotChatDocs", desc = "Document Selection", mode = { "v" } }, + { "act", "CopilotChatTests", 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 = { - { "agc", function() require("chatgpt").openChat() end, desc = "Toggle Chat" }, - { "age", function() require("chatgpt").edit_with_instructions() end, desc = "Edit with instruction", mode = { "n", "v" } }, - { "agg", function() require("chatgpt").run_action("grammar_correction") end, desc = "Grammar Correction", mode = { "n", "v" } }, - { "agtg", function() require("chatgpt").run_action({ fargs = { "translate", "german" } }) end, desc = "German", mode = { "n", "v" } }, - { "agte", function() require("chatgpt").run_action({ fargs = { "translate", "english" } }) end, desc = "English", mode = { "n", "v" } }, - { "agtf", function() require("chatgpt").run_action({ fargs = { "translate", "french" } }) end, desc = "French", mode = { "n", "v" } }, - { "agtr", function() require("chatgpt").run_action({ fargs = { "translate", "russian" } }) end, desc = "Russian", mode = { "n", "v" } }, - { "agk", function() require("chatgpt").run_action({ fargs = { "keywords" } }) end, desc = "Keywords", mode = { "n", "v" } }, - { "agd", function() require("chatgpt").run_action({ fargs = { "docstring" } }) end, desc = "Docstring", mode = { "n", "v" } }, - { "aga", function() require("chatgpt").run_action({ fargs = { "add_tests" } }) end, desc = "Add Tests", mode = { "n", "v" } }, - { "ago", function() require("chatgpt").run_action({ fargs = { "optimize_code" } }) end, desc = "Optimize Code", mode = { "n", "v" } }, - { "ags", function() require("chatgpt").run_action({ fargs = { "summarize" } }) end, desc = "Summarize", mode = { "n", "v" } }, - { "agf", function() require("chatgpt").run_action({ fargs = { "fix_bugs" } }) end, desc = "Fix Bugs", mode = { "n", "v" } }, - { "agx", function() require("chatgpt").run_action({ fargs = { "explain_code" } }) end, desc = "Explain Code", mode = { "n", "v" } }, - { "agr", function() require("chatgpt").run_action({ fargs = { "roxygen_edit" } }) end, desc = "Roxygen Edit", mode = { "n", "v" } }, - { "agl", function() require("chatgpt").run_action({ fargs = { "code_readability_analysis" } }) end, desc = "Code Readability Analysis", mode = { "n", "v" } }, + { "agc", function() require("chatgpt").openChat() end, desc = "Toggle Chat" }, + { "age", function() require("chatgpt").edit_with_instructions() end, desc = "Edit with instruction", mode = { "n", "v" } }, + { "agg", function() require("chatgpt").run_action("grammar_correction") end, desc = "Grammar Correction", mode = { "n", "v" } }, + { "agtg", function() require("chatgpt").run_action({ fargs = { "translate", "german" } }) end, desc = "German", mode = { "n", "v" } }, + { "agte", function() require("chatgpt").run_action({ fargs = { "translate", "english" } }) end, desc = "English", mode = { "n", "v" } }, + { "agtf", function() require("chatgpt").run_action({ fargs = { "translate", "french" } }) end, desc = "French", mode = { "n", "v" } }, + { "agtr", function() require("chatgpt").run_action({ fargs = { "translate", "russian" } }) end, desc = "Russian", mode = { "n", "v" } }, + { "agk", function() require("chatgpt").run_action({ fargs = { "keywords" } }) end, desc = "Keywords", mode = { "n", "v" } }, + { "agd", function() require("chatgpt").run_action({ fargs = { "docstring" } }) end, desc = "Docstring", mode = { "n", "v" } }, + { "aga", function() require("chatgpt").run_action({ fargs = { "add_tests" } }) end, desc = "Add Tests", mode = { "n", "v" } }, + { "ago", function() require("chatgpt").run_action({ fargs = { "optimize_code" } }) end, desc = "Optimize Code", mode = { "n", "v" } }, + { "ags", function() require("chatgpt").run_action({ fargs = { "summarize" } }) end, desc = "Summarize", mode = { "n", "v" } }, + { "agf", function() require("chatgpt").run_action({ fargs = { "fix_bugs" } }) end, desc = "Fix Bugs", mode = { "n", "v" } }, + { "agx", function() require("chatgpt").run_action({ fargs = { "explain_code" } }) end, desc = "Explain Code", mode = { "n", "v" } }, + { "agr", function() require("chatgpt").run_action({ fargs = { "roxygen_edit" } }) end, desc = "Roxygen Edit", mode = { "n", "v" } }, + { "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 = "", @@ -268,16 +273,26 @@ return { }, --stylua: ignore keys = { - { "zn", function() require("zk.commands").get("ZkNew")({ title = vim.fn.input('Title: ') }) end, desc = "New Note", mode = { "n", "v" } }, - { "znt", function() require("zk.commands").get("ZkNewFromTitleSelection")() end, desc = "Title from selection", mode = { "v" } }, - { "znc", function() require("zk.commands").get("ZkNewFromContentSelection")({ title = vim.fn.input('Title: ') }) end, desc = "Content from selection", mode = { "v" } }, - { "zb", function() require("zk.commands").get("ZkBacklinks")() end, desc = "Links" }, - { "zl", function() require("zk.commands").get("ZkLinks")() end, desc = "Backlinks" }, - { "zx", function() require("zk.commands").get("ZkIndex")() end, desc = "Index" }, + { "zn", function() require("zk.commands").get("ZkNew")({ title = vim.fn.input('Title: ') }) end, desc = "New Note", mode = { "n", "v" } }, + { "znt", function() require("zk.commands").get("ZkNewFromTitleSelection")() end, desc = "Title from selection", mode = { "v" } }, + { + "znc", + function() + require("zk.commands").get("ZkNewFromContentSelection")({ + title = vim.fn.input( + 'Title: ') + }) + end, + desc = "Content from selection", + mode = { "v" } + }, + { "zb", function() require("zk.commands").get("ZkBacklinks")() end, desc = "Links" }, + { "zl", function() require("zk.commands").get("ZkLinks")() end, desc = "Backlinks" }, + { "zx", function() require("zk.commands").get("ZkIndex")() end, desc = "Index" }, { "zf", function() require("zk.commands").get("ZkNotes")({ sort = { 'modified' } }) end, desc = "Find Notes" }, - { "zt", function() require("zk.commands").get("ZkTags")() end, desc = "Find Note Tags" }, - { "zf", function() require("zk.commands").get("ZkMatch")() end, desc = "Find Notes (Match Selection)", mode = { "v" } }, - { "zi", function() require("zk.commands").get("ZkInsertLinkAtSelection")() end, desc = "Insert Link", mode = { "n", "v" } }, + { "zt", function() require("zk.commands").get("ZkTags")() end, desc = "Find Note Tags" }, + { "zf", function() require("zk.commands").get("ZkMatch")() end, desc = "Find Notes (Match Selection)", mode = { "v" } }, + { "zi", function() require("zk.commands").get("ZkInsertLinkAtSelection")() end, desc = "Insert Link", mode = { "n", "v" } }, }, }, }