Skip to content

Commit

Permalink
feat: Configuable hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Dec 7, 2023
1 parent dbe6c2c commit 4724ae2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,22 @@ 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 = "<leader>om",
close_terminal_on_quit = true

-- CLI
backend = "",
model = "",
theme = "",
theme_file = "",
ollama_url = "",
openai_url = "",
openai_token = "",
close_terminal_on_quit = true
}
```

Expand Down
10 changes: 8 additions & 2 deletions lua/oatmeal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,19 @@ end

function M.setup(conf)
config = conf

if conf["hotkey"] == nil then
conf["hotkey"] = "<leader>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
_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", "<leader>om", M.start, { silent = true, noremap = true })
vim.keymap.set("v", "<leader>om", M.start, { silent = true, noremap = true })
return M

0 comments on commit 4724ae2

Please sign in to comment.