generated from ellisonleao/nvim-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Problem
When using opencode.nvim with LazyVim, the <C-j> key in terminal mode is mapped globally by LazyVim for window navigation. This prevents users from inserting a newline (LF) in the opencode terminal buffer.
Expected Behavior
<C-j> should send a newline character when inside the opencode terminal buffer, allowing users to create multi-line prompts.
Current Workaround
I've been using this workaround in my config:
-- Fix: Force <C-j> to be a newline in opencode buffers (overriding window navigation)
vim.api.nvim_create_autocmd({ "FileType", "BufEnter", "TermOpen" }, {
pattern = "*",
callback = function(ev)
local ft = vim.bo[ev.buf].filetype
local name = vim.api.nvim_buf_get_name(ev.buf)
-- Check if it is an opencode buffer by filetype or name
if (ft and ft:find("opencode")) or (name and name:find("opencode")) then
vim.keymap.set("t", "<C-j>", "<C-j>", { buffer = ev.buf, nowait = true })
vim.keymap.set("t", "<S-CR>", "<C-j>", { buffer = ev.buf, nowait = true })
vim.keymap.set("t", "<C-CR>", "<C-j>", { buffer = ev.buf, nowait = true })
end
end,
})Proposed Solutions
- Built-in fix: Handle this automatically in the plugin when creating the terminal buffer
- Documentation: Add a note in README for LazyVim users
Environment
- Neovim version: 0.10+
- LazyVim
- Provider: snacks
Would love to hear your thoughts on the preferred approach!
Metadata
Metadata
Assignees
Labels
No labels