From 3a831210d0dd38cfb1c0e14dbc4d5bc2e10a62a1 Mon Sep 17 00:00:00 2001 From: yzinchuk Date: Tue, 16 Jun 2026 22:46:17 -0400 Subject: [PATCH] relative line numbers, opencode plugin --- init.lua | 8 +++--- lua/custom/plugins/opencode.lua | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 lua/custom/plugins/opencode.lua diff --git a/init.lua b/init.lua index d50f622..c9b56e3 100644 --- a/init.lua +++ b/init.lua @@ -110,7 +110,7 @@ do vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! - -- vim.o.relativenumber = true + vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -527,7 +527,9 @@ do layout_config = { height = 0.95, width = 0.95, - preview_height = 0.5, + vertical = { + preview_height = 0.5, + }, }, }, -- pickers = {} @@ -1007,7 +1009,7 @@ do -- NOTE: You can add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- require 'custom.plugins' + require 'custom.plugins' end -- The line beneath this is called `modeline`. See `:help modeline` diff --git a/lua/custom/plugins/opencode.lua b/lua/custom/plugins/opencode.lua new file mode 100644 index 0000000..1654dfc --- /dev/null +++ b/lua/custom/plugins/opencode.lua @@ -0,0 +1,43 @@ +vim.pack.add { + { + src = 'https://github.com/nickjvandyke/opencode.nvim', + version = vim.version.range '*', + }, +} + +local opencode_port = 4096 +local opencode_url = 'http://127.0.0.1:' .. opencode_port + +---@type opencode.Opts +vim.g.opencode_opts = { + server = { + url = opencode_url, + start = false, + }, +} + +vim.o.autoread = true -- Required for `vim.g.opencode_opts.events.reload`. + +vim.keymap.set({ 'n', 'x' }, 'oa', function() + require('opencode').ask('@this: ') +end, { desc = 'Ask opencode' }) + +vim.keymap.set({ 'n', 'x' }, 'os', function() + require('opencode').select() +end, { desc = 'Select opencode action' }) + +vim.keymap.set({ 'n', 'x' }, 'go', function() + return require('opencode').operator('@this ') +end, { desc = 'Add range to opencode', expr = true }) + +vim.keymap.set('n', 'goo', function() + return require('opencode').operator('@this ') .. '_' +end, { desc = 'Add line to opencode', expr = true }) + +vim.keymap.set('n', '', function() + require('opencode').command('session.half.page.up') +end, { desc = 'Scroll opencode up' }) + +vim.keymap.set('n', '', function() + require('opencode').command('session.half.page.down') +end, { desc = 'Scroll opencode down' })