56 lines
1.7 KiB
Lua
56 lines
1.7 KiB
Lua
-- 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 = {
|
|
---@diagnostic disable-next-line: undefined-field
|
|
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,
|
|
},
|
|
lsp = {
|
|
enabled = true,
|
|
},
|
|
}
|
|
vim.o.autoread = true -- Required for `opts.events.reload`
|
|
end,
|
|
}
|