Add opencode
This commit is contained in:
51
nvim/lua/plugins/opencode.lua
Normal file
51
nvim/lua/plugins/opencode.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
-- https://github.com/nickjvandyke/opencode.nvim
|
||||
return {
|
||||
"nickjvandyke/opencode.nvim",
|
||||
version = "*", -- Latest stable release
|
||||
dependencies = {
|
||||
{
|
||||
-- `snacks.nvim` integration is recommended, but optional
|
||||
---@module "snacks" <- Loads `snacks.nvim` types for configuration intellisense
|
||||
"folke/snacks.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
input = {}, -- Enhances `ask()`
|
||||
picker = { -- Enhances `select()`
|
||||
actions = {
|
||||
opencode_send = function(...) return require("opencode").snacks_picker_send(...) end,
|
||||
},
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<a-a>"] = { "opencode_send", mode = { "n", "i" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local opencode_cmd = "opencode --port"
|
||||
---@type snacks.terminal.Opts
|
||||
local snacks_terminal_opts = {
|
||||
win = {
|
||||
position = "right",
|
||||
enter = false,
|
||||
on_win = function(win)
|
||||
-- Set up keymaps and cleanup for an arbitrary terminal
|
||||
require("opencode.terminal").setup(win.win)
|
||||
end,
|
||||
},
|
||||
}
|
||||
---@type opencode.Opts
|
||||
vim.g.opencode_opts = {
|
||||
server = {
|
||||
start = function() require("snacks.terminal").open(opencode_cmd, snacks_terminal_opts) end,
|
||||
stop = function() require("snacks.terminal").get(opencode_cmd, snacks_terminal_opts):close() end,
|
||||
toggle = function() require("snacks.terminal").toggle(opencode_cmd, snacks_terminal_opts) end,
|
||||
},
|
||||
}
|
||||
vim.o.autoread = true -- Required for `opts.events.reload`
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user