From 4724ae262b2b9d3f14a80968c4f587de207b102a Mon Sep 17 00:00:00 2001 From: Dustin Blackman Date: Wed, 6 Dec 2023 22:39:14 -0500 Subject: [PATCH] feat: Configuable hotkey --- README.md | 8 ++++++-- lua/oatmeal.lua | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f0152eb..5ebe3d3 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,15 @@ use { ## Default Configuration -All configuration variables are optional and will default to what is set in the [CLI defaults](https://github.com/dustinblackman/oatmeal#usage). +All configuration variables are optional with defaults. All CLI options will default to what is set in the [tool itself](https://github.com/dustinblackman/oatmeal#usage). ```lua { + -- Set to empty string to disable. + hotkey = "om", + close_terminal_on_quit = true + + -- CLI backend = "", model = "", theme = "", @@ -72,7 +77,6 @@ All configuration variables are optional and will default to what is set in the ollama_url = "", openai_url = "", openai_token = "", - close_terminal_on_quit = true } ``` diff --git a/lua/oatmeal.lua b/lua/oatmeal.lua index a6fbc39..7e76e9d 100644 --- a/lua/oatmeal.lua +++ b/lua/oatmeal.lua @@ -129,6 +129,14 @@ end function M.setup(conf) config = conf + + if conf["hotkey"] == nil then + conf["hotkey"] = "om" + end + if conf["hotkey"] ~= "" then + vim.keymap.set("n", conf["hotkey"], M.start, { silent = true, noremap = true }) + vim.keymap.set("v", conf["hotkey"], M.start, { silent = true, noremap = true }) + end end _G.oatmeal_submit_changes = M.submit_changes @@ -136,6 +144,4 @@ _G.oatmeal_get_context = M.get_context _G.oatmeal_clear_context = M.clear_context vim.api.nvim_create_user_command("Oatmeal", M.start, { desc = "Start Oatmeal session", range = true }) -vim.keymap.set("n", "om", M.start, { silent = true, noremap = true }) -vim.keymap.set("v", "om", M.start, { silent = true, noremap = true }) return M