diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index f574207..88080cc 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -307,3 +307,20 @@ keymap( -- Leap keymap({ "n", "x", "o" }, "s", "(leap)") keymap("n", "S", "(leap-from-window)") + +-- Recommended/example keymaps +keymap({ "n", "x" }, "aa", function() + require("opencode").ask("@this: ", { submit = true }) +end, { desc = "Ask opencode…" }) +-- keymap({ "n", "x" }, "ax", function() +-- require("opencode").select() +-- end, { desc = "Execute opencode action…" }) +-- keymap({ "n", "t" }, "at", function() +-- require("opencode").toggle() +-- end, { desc = "Toggle opencode" }) +keymap({ "n", "x" }, "ar", function() + return require("opencode").operator("@this ") +end, { desc = "Add range to opencode", expr = true }) +keymap("n", "al", function() + return require("opencode").operator("@this ") .. "_" +end, { desc = "Add line to opencode", expr = true }) diff --git a/.config/nvim/lua/core/lazy.lua b/.config/nvim/lua/core/lazy.lua index cf07ff4..46d1efc 100644 --- a/.config/nvim/lua/core/lazy.lua +++ b/.config/nvim/lua/core/lazy.lua @@ -220,6 +220,10 @@ require("lazy").setup({ event = "InsertEnter", }, { "AndreM222/copilot-lualine" }, + { + "nickjvandyke/opencode.nvim", + version = "*", -- Latest stable release + }, -- Folding { diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua index bf5cb80..df12503 100644 --- a/.config/nvim/lua/core/options.lua +++ b/.config/nvim/lua/core/options.lua @@ -48,3 +48,4 @@ vim.opt.foldlevelstart = 99 vim.opt.foldcolumn = "1" vim.opt.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:,diff: ]] vim.opt.cmdheight = 0 -- Number of screen lines to use for the command-line +vim.o.autoread = true -- Required by Opencode plugin for `opts.events.reload` diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua index 03d7fa7..594c6fa 100644 --- a/.config/nvim/lua/plugins/snacks.lua +++ b/.config/nvim/lua/plugins/snacks.lua @@ -9,6 +9,18 @@ require("snacks").setup({ ignored = true, }, }, + actions = { + opencode_send = function(...) + return require("opencode").snacks_picker_send(...) + end, + }, + win = { + input = { + keys = { + [""] = { "opencode_send", mode = { "n", "i" } }, + }, + }, + }, }, indent = { indent = { char = "▏" }, @@ -42,7 +54,7 @@ require("snacks").setup({ indent = 2, }, { icon = "", desc = "Mason", action = ":Mason", key = "m", indent = 2 }, - -- { icon = "", desc = "Tree-sitter", action = ":TSUpdate", key = "t", indent = 2, padding = 2 }, + { icon = "", desc = "Tree-sitter", action = ":TSManager", key = "t", indent = 2, padding = 2 }, { section = "startup" }, },