From 35f07230765136988a112b51bf50cced8b42a7b2 Mon Sep 17 00:00:00 2001 From: Marco Dalla Stella Date: Fri, 27 Feb 2026 10:29:46 +0100 Subject: [PATCH] Add opencode and notes/todo configuration --- plugin/20_keymaps.lua | 38 +++++++++---------- plugin/40_plugins.lua | 88 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 91 insertions(+), 35 deletions(-) diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua index 2085d20..9309059 100644 --- a/plugin/20_keymaps.lua +++ b/plugin/20_keymaps.lua @@ -47,14 +47,10 @@ _G.Config.leader_group_clues = { { mode = 'n', keys = 'm', desc = '+Map' }, { mode = 'n', keys = 'o', desc = '+Other' }, { mode = 'n', keys = 's', desc = '+Session' }, - { mode = 'n', keys = 't', desc = '+Terminal' }, { mode = 'x', keys = 'g', desc = '+Git' }, + { mode = 'x', keys = 'z', desc = '+Notes' }, } --- Comodities -vim.keymap.set({'n', 'x'}, 'y', '"y', { desc = "Yank" }) -vim.keymap.set({'n', 'x'}, 'd', '"d', { desc = "Cut" }) - -- Helpers for a more concise `` mappings. -- Most of the mappings use `...` string as a right hand side (RHS) in -- an attempt to be more concise yet descriptive. See `:h `. @@ -63,14 +59,20 @@ vim.keymap.set({'n', 'x'}, 'd', '"d', { desc = "Cut" }) local nmap_leader = function(suffix, rhs, desc) vim.keymap.set('n', '' .. suffix, rhs, { desc = desc }) end + local xmap_leader = function(suffix, rhs, desc) vim.keymap.set('x', '' .. suffix, rhs, { desc = desc }) end +local vmap_leader = function(suffix, rhs, desc) + vim.keymap.set('v', '' .. suffix, rhs, { desc = desc }) +end + -- a is for 'AI' -nmap_leader('ac', ':ClaudeCode', 'Toggle Claude') -nmap_leader('af', ':ClaudeCodeFocus', 'Focus Claude') -nmap_leader('ar', ':ClaudeCode --resume', 'Resume Claude') + +nmap_leader('ac', ':lua require("opencode").toggle()', 'Toggle Opencode') +nmap_leader('af', ':lua require("opencode").select()', 'Execute Opencode action...') +nmap_leader('aa', ':luat require("opencode").ask("@this: ", { submit = true })', 'Ask Opencode') -- b is for 'Buffer'. Common usage: -- - `bs` - create scratch (temporary) buffer @@ -176,19 +178,13 @@ nmap_leader('oz', 'lua MiniMisc.zoom()', 'Zoom toggle') nmap_leader('om', 'Mason', 'Open Mason') nmap_leader('ou', 'DepsUpdate', 'Update plugins') --- s is for 'Session'. Common usage: --- - `sn` - start new session --- - `sr` - read previously started session --- - `sd` - delete previously started session -local session_new = 'MiniSessions.write(vim.fn.input("Session name: "))' -nmap_leader('sd', 'lua MiniSessions.select("delete")', 'Delete') -nmap_leader('sn', 'lua ' .. session_new .. '', 'New') -nmap_leader('sr', 'lua MiniSessions.select("read")', 'Read') -nmap_leader('sw', 'lua MiniSessions.write()', 'Write current') - --- t is for 'Terminal' -nmap_leader('tT', 'horizontal term', 'Terminal (horizontal)') -nmap_leader('tt', 'vertical term', 'Terminal (vertical)') +-- z if for notes and todos +nmap_leader('zz', "ZkNotes {sort={'modified'}}", 'Notes picker') +nmap_leader('zn', "ZkNew {title = vim.fn.input('Title: ')}", 'New note') +nmap_leader('zt', "ZkTags", 'Notes tags') +nmap_leader('zf', "ZkNotes {sort={'modified'}, match={vim.fn.input('Search: ')}}", 'Search') +vmap_leader('zm', "'<,'>ZkMatch", "Search match") +nmap_leader('zt', "e ~/notes/TODO.md", "Open TODOs") -- stylua: ignore end diff --git a/plugin/40_plugins.lua b/plugin/40_plugins.lua index e508129..f2c8e79 100644 --- a/plugin/40_plugins.lua +++ b/plugin/40_plugins.lua @@ -35,7 +35,8 @@ now_if_args(function() local languages = { -- These are already pre-installed with Neovim. Used as an example. 'lua', - 'vimdoc', + 'html', + 'css', 'markdown', 'yaml', 'toml', @@ -84,6 +85,10 @@ now_if_args(function() 'lua_ls', 'basedpyright', 'ruff', + 'html', + 'css', + 'toml', + 'marksman', }) end) @@ -105,9 +110,9 @@ later(function() require('conform').setup({ -- Map of filetype to formatters -- Make sure that necessary CLI tool is available - formatters_by_ft = { + formatters_by_ft = { lua = { 'stylua' }, - python = { 'ruff' } + python = { 'ruff' }, }, }) end) @@ -120,7 +125,7 @@ end) -- Catppuccin ================================================================= now_if_args(function() - add({ source = "catppuccin/nvim", name = "catppuccin" }) + add({ source = 'catppuccin/nvim', name = 'catppuccin' }) require('catppuccin').setup({ flavour = 'mocha', transparent_background = true, @@ -130,6 +135,7 @@ now_if_args(function() float = { transparent = true, }, + compile_path = vim.fn.stdpath "cache" .. "/catppuccin", }) vim.cmd('colorscheme catppuccin') end) @@ -152,14 +158,48 @@ later(function() end) -- claudecode ================================================================= -later(function () +-- later(function () +-- add({ +-- source = 'coder/claudecode.nvim', +-- depends = { 'folke/snacks.nvim' }, +-- }) +-- require('claudecode').setup({}) +-- end) +-- +-- open code ================================================================== +later(function() add({ - source = 'coder/claudecode.nvim', + source = 'nickjvandyke/opencode.nvim', depends = { 'folke/snacks.nvim' }, }) - require('claudecode').setup({}) -end -) + + vim.g.opencode_opts = { + provider = { + enabled = 'terminal', + terminal = { + width = math.floor(vim.o.columns * 0.5), + }, + }, + } + + -- Handle `opencode` events + -- vim.api.nvim_create_autocmd('User', { + -- pattern = 'OpencodeEvent:*', -- Optionally filter event types + -- callback = function(args) + -- ---@type opencode.cli.client.Event + -- local event = args.data.event + -- ---@type number + -- local port = args.data.port + -- + -- -- See the available event types and their properties + -- vim.notify(vim.inspect(event)) + -- -- Do something useful + -- if event.type == 'session.idle' then + -- vim.notify('`opencode` finished responding') + -- end + -- end, + -- }) +end) -- zk ========================================================================= later(function() @@ -167,18 +207,38 @@ later(function() source = 'zk-org/zk-nvim', }) require('zk').setup({ - picker = "minipick", + picker = 'minipick', + enabled = 'snacks', lsp = { config = { name = 'zk', - cmd = {'zk', 'lsp' }, + cmd = { 'zk', 'lsp' }, filetypes = { 'markdown' }, }, }, auto_attach = { enabled = true, - } + }, }) -end -) +end) +-- checkmate ==================================================================== +now_if_args(function() + add({ + source = 'bngarren/checkmate.nvim', + }) + require('checkmate').setup({ + files = { '/home/mds/notes/TODO.md' }, + }) +end) + +-- render-markdown.nvim ======================================================== +now_if_args(function () + add({ + source = 'MeanderingProgrammer/render-markdown.nvim', + }) + require('render-markdown').setup({ + enabled = true, + file_types = {'markdown', 'vimwiki'}, + }) +end)