Add opencode

This commit is contained in:
Valeriy Filippov
2026-03-11 18:50:00 +03:00
parent 59c0722f25
commit 32a5c2deb8
7 changed files with 89 additions and 58 deletions

View File

@@ -9,7 +9,7 @@ return {
-- configure lualine with modified theme
lualine.setup({
options = {
theme = 'auto',
theme = "auto",
},
sections = {
lualine_x = {
@@ -22,6 +22,11 @@ return {
{ "fileformat" },
{ "filetype" },
},
lualine_z = {
{
require("opencode").statusline,
},
},
},
})
end,

View 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,
}

View File

@@ -11,6 +11,7 @@ return {
-- or leave it empty to use the default settings
-- refer to the configuration section below
spec = {
{ "<leader>a", group = "[A]I" },
{ "<leader>c", group = "[C]lear / [C]all" },
{ "<leader>d", group = "[D]iagnostic" },
{ "<leader>e", group = "File [E]xplorer" },