[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-73387":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":35,"readmeContent":36,"aiSummary":37,"trendingCount":16,"starSnapshotCount":16,"syncStatus":15,"lastSyncTime":38,"discoverSource":39},73387,"opencode.nvim","nickjvandyke\u002Fopencode.nvim","nickjvandyke","Bridge Neovim and OpenCode AI to stay in your flow.","",null,"Lua",3556,132,7,2,0,17,40,155,51,108.37,"MIT License",false,"main",[26,27,28,29,30,31,32,33,34],"ai","ai-agents","ai-assistant","neovim","neovim-plugin","nvim","opencode","plugin","terminal","2026-06-12 04:01:09","# opencode.nvim\n\n\u003Chttps:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F077daa78-d401-4b8b-98d1-9ba9f94c2330>\n\n## ✨ Features\n\n- Connect to _any_ `opencode`, or provide an integrated instance\n- Share editor context (buffer, selection, diagnostics, etc.)\n- Input prompts with completions, highlights, and normal-mode support\n- Select prompts from a library and define your own\n- Execute commands\n- Monitor and respond to events\n- View, accept or reject, and reload edits\n- Interact with `opencode` via an in-process LSP\n- _Vim-y_ — supports ranges and dot-repeat\n- Simple, sensible defaults to get you started quickly\n\n## 📦 Setup\n\n### [lazy.nvim](https:\u002F\u002Fgithub.com\u002Ffolke\u002Flazy.nvim)\n\n```lua\n{\n  \"nickjvandyke\u002Fopencode.nvim\",\n  version = \"*\", -- Latest stable release\n  dependencies = {\n    {\n      -- `snacks.nvim` integration is recommended, but optional\n      ---@module \"snacks\" \u003C- Loads `snacks.nvim` types for configuration intellisense\n      \"folke\u002Fsnacks.nvim\",\n      optional = true,\n      opts = {\n        input = {}, -- Enhances `ask()`\n        picker = { -- Enhances `select()`\n          actions = {\n            opencode_send = function(...) return require(\"opencode\").snacks_picker_send(...) end,\n          },\n          win = {\n            input = {\n              keys = {\n                [\"\u003Ca-a>\"] = { \"opencode_send\", mode = { \"n\", \"i\" } },\n              },\n            },\n          },\n        },\n      },\n    },\n  },\n  config = function()\n    ---@type opencode.Opts\n    vim.g.opencode_opts = {\n      -- Your configuration, if any; goto definition on the type or field for details\n    }\n\n    vim.o.autoread = true -- Required for `opts.events.reload`\n\n    -- Recommended\u002Fexample keymaps\n    vim.keymap.set({ \"n\", \"x\" }, \"\u003CC-a>\", function() require(\"opencode\").ask(\"@this: \", { submit = true }) end, { desc = \"Ask opencode…\" })\n    vim.keymap.set({ \"n\", \"x\" }, \"\u003CC-x>\", function() require(\"opencode\").select() end,                          { desc = \"Select opencode…\" })\n    vim.keymap.set({ \"n\", \"t\" }, \"\u003CC-.>\", function() require(\"opencode\").toggle() end,                          { desc = \"Toggle opencode\" })\n\n    vim.keymap.set({ \"n\", \"x\" }, \"go\",  function() return require(\"opencode\").operator(\"@this \") end,        { desc = \"Add range to opencode\", expr = true })\n    vim.keymap.set(\"n\",          \"goo\", function() return require(\"opencode\").operator(\"@this \") .. \"_\" end, { desc = \"Add line to opencode\", expr = true })\n\n    vim.keymap.set(\"n\", \"\u003CS-C-u>\", function() require(\"opencode\").command(\"session.half.page.up\") end,   { desc = \"Scroll opencode up\" })\n    vim.keymap.set(\"n\", \"\u003CS-C-d>\", function() require(\"opencode\").command(\"session.half.page.down\") end, { desc = \"Scroll opencode down\" })\n\n    -- You may want these if you use the opinionated `\u003CC-a>` and `\u003CC-x>` keymaps above — otherwise consider `\u003Cleader>o…` (and remove terminal mode from the `toggle` keymap)\n    vim.keymap.set(\"n\", \"+\", \"\u003CC-a>\", { desc = \"Increment under cursor\", noremap = true })\n    vim.keymap.set(\"n\", \"-\", \"\u003CC-x>\", { desc = \"Decrement under cursor\", noremap = true })\n  end,\n}\n```\n\n### [nixvim](https:\u002F\u002Fgithub.com\u002Fnix-community\u002Fnixvim)\n\n```nix\nprograms.nixvim = {\n  extraPlugins = [\n    pkgs.vimPlugins.opencode-nvim\n  ];\n};\n```\n\n> [!TIP]\n> Run `:checkhealth opencode` after setup.\n\n## ⚙️ Configuration\n\n`opencode.nvim` provides a rich and reliable default experience — see all available options and their defaults [here](.\u002Flua\u002Fopencode\u002Fconfig.lua).\n\n### Contexts\n\n`opencode.nvim` replaces placeholders in prompts with the corresponding context:\n\n| Placeholder    | Context                                                         |\n| -------------- | --------------------------------------------------------------- |\n| `@this`        | Operator range or visual selection if any, else cursor position |\n| `@buffer`      | Current buffer                                                  |\n| `@buffers`     | Open buffers                                                    |\n| `@visible`     | Visible text                                                    |\n| `@diagnostics` | Current buffer diagnostics                                      |\n| `@quickfix`    | Quickfix list                                                   |\n| `@diff`        | Git diff                                                        |\n| `@marks`       | Global marks                                                    |\n| `@grapple`     | [grapple.nvim](https:\u002F\u002Fgithub.com\u002Fcbochs\u002Fgrapple.nvim) tags     |\n\n> [!TIP]\n> `opencode` reads referenced files from disk — save your changes!\n\n### Prompts\n\nSelect prompts to review, explain, and improve your code:\n\n| Name          | Prompt                                                                 |\n| ------------- | ---------------------------------------------------------------------- |\n| `diagnostics` | Explain `@diagnostics`                                                 |\n| `diff`        | Review the following git diff for correctness and readability: `@diff` |\n| `document`    | Add comments documenting `@this`                                       |\n| `explain`     | Explain `@this` and its context                                        |\n| `fix`         | Fix `@diagnostics`                                                     |\n| `implement`   | Implement `@this`                                                      |\n| `optimize`    | Optimize `@this` for performance and readability                       |\n| `review`      | Review `@this` for correctness and readability                         |\n| `test`        | Add tests for `@this`                                                  |\n\n### Server\n\nYou can manually run `opencode`s however you like and `opencode.nvim` will find them!\n\n> [!IMPORTANT]\n> You _must_ run `opencode` with the `--port` flag to expose its server.\n\nIf `opencode.nvim` can't find an existing `opencode`, it uses the configured server to start one for you, defaulting to an embedded terminal.\n\n#### Keymaps\n\n`opencode.nvim` sets these normal-mode keymaps in the embedded terminal for Neovim-like message navigation:\n\n| Keymap  | Command                  | Description           |\n| ------- | ------------------------ | --------------------- |\n| `\u003CC-u>` | `session.half.page.up`   | Scroll up half page   |\n| `\u003CC-d>` | `session.half.page.down` | Scroll down half page |\n| `gg`    | `session.first`          | Go to first message   |\n| `G`     | `session.last`           | Go to last message    |\n| `\u003CEsc>` | `session.interrupt`      | Interrupt             |\n\n#### Customization\n\nExample using [`snacks.terminal`](https:\u002F\u002Fgithub.com\u002Ffolke\u002Fsnacks.nvim\u002Fblob\u002Fmain\u002Fdocs\u002Fterminal.md) instead:\n\n```lua\nlocal opencode_cmd = 'opencode --port'\n---@type snacks.terminal.Opts\nlocal snacks_terminal_opts = {\n  win = {\n    position = 'right',\n    enter = false,\n    on_win = function(win)\n      -- Set up keymaps and cleanup for an arbitrary terminal\n      require('opencode.terminal').setup(win.win)\n    end,\n  },\n}\n---@type opencode.Opts\nvim.g.opencode_opts = {\n  server = {\n    start = function()\n      require('snacks.terminal').open(opencode_cmd, snacks_terminal_opts)\n    end,\n    stop = function()\n      require('snacks.terminal').get(opencode_cmd, snacks_terminal_opts):close()\n    end,\n    toggle = function()\n      require('snacks.terminal').toggle(opencode_cmd, snacks_terminal_opts)\n    end,\n  },\n}\n```\n\n## 🚀 Usage\n\n### Ask — `require(\"opencode\").ask()`\n\nInput a prompt for `opencode`.\n\n- End the prompt with a space to append instead of submit.\n- Press `\u003CUp>` to browse recent asks.\n- Highlights and completes contexts and `opencode` subagents.\n  - Press `\u003CTab>` to trigger built-in completion.\n  - Provided by in-process LSP when using `snacks.input`.\n\n### Select — `require(\"opencode\").select()`\n\nSelect from all `opencode.nvim` functionality.\n\n- Prompts\n- Commands\n- Server controls\n\nHighlights and previews items when using `snacks.picker`.\n\n### Prompt — `require(\"opencode\").prompt()`\n\nPrompt `opencode`.\n\n- End the prompt with a space to append instead of submit.\n- Injects configured contexts.\n- `opencode` will interpret references to files or subagents.\n\n### Operator — `require(\"opencode\").operator()`\n\nWraps `prompt` as an operator, supporting ranges and dot-repeat.\n\n### Command — `require(\"opencode\").command()`\n\nCommand `opencode`:\n\n| Command                  | Description                                        |\n| ------------------------ | -------------------------------------------------- |\n| `session.list`           | List sessions                                      |\n| `session.new`            | Start a new session                                |\n| `session.select`         | Select a session                                   |\n| `session.share`          | Share the current session                          |\n| `session.interrupt`      | Interrupt the current session                      |\n| `session.compact`        | Compact the current session (reduce context size)  |\n| `session.page.up`        | Scroll messages up by one page                     |\n| `session.page.down`      | Scroll messages down by one page                   |\n| `session.half.page.up`   | Scroll messages up by half a page                  |\n| `session.half.page.down` | Scroll messages down by half a page                |\n| `session.first`          | Jump to the first message in the session           |\n| `session.last`           | Jump to the last message in the session            |\n| `session.undo`           | Undo the last action in the current session        |\n| `session.redo`           | Redo the last undone action in the current session |\n| `prompt.submit`          | Submit the TUI input                               |\n| `prompt.clear`           | Clear the TUI input                                |\n| `agent.cycle`            | Cycle the selected agent                           |\n\n### LSP\n\n> [!WARNING]\n> This feature is experimental! Try it out with `vim.g.opencode_opts.lsp.enabled = true`.\n\n`opencode.nvim` provides an in-process LSP to interact with `opencode` via the LSP functions you're used to!\n\n| LSP Function | `opencode.nvim` Handler                                                |\n| ------------ | ---------------------------------------------------------------------- |\n| Hover        | Asks `opencode` for a brief explanation of the symbol under the cursor |\n| Code Actions | Asks `opencode` to explain or fix diagnostics under the cursor         |\n\n## 👀 Events\n\n`opencode.nvim` forwards `opencode`'s Server-Sent-Events as an `OpencodeEvent` autocmd:\n\n```lua\n-- Handle `opencode` events\nvim.api.nvim_create_autocmd(\"User\", {\n  pattern = \"OpencodeEvent:*\", -- Optionally filter event types\n  callback = function(args)\n    ---@type opencode.server.Event\n    local event = args.data.event\n    ---@type string\n    local url = args.data.url\n\n    -- See the available event types and their properties\n    vim.notify(vim.inspect(event))\n    -- Do something useful\n    if event.type == \"session.idle\" then\n      vim.notify(\"`opencode` finished responding\")\n    end\n  end,\n})\n```\n\n### Edits\n\nWhen `opencode` edits a file, `opencode.nvim` automatically reloads the corresponding buffer.\n\n### Permissions\n\nWhen `opencode` requests a permission, `opencode.nvim` waits for idle to ask you to approve or deny it.\n\n#### Edits\n\nFor edit requests, `opencode.nvim` opens the target file in a new tab and uses Neovim's `:diffpatch` to display the proposed changes side-by-side. See `:h 'diffopt'` for customization.\n\n| Keymap  | Function                                                                      |\n| ------- | ----------------------------------------------------------------------------- |\n| `da`    | Accept the entire edit request                                                |\n| `dr`    | Reject the entire edit request                                                |\n| `]c\u002F[c` | Next\u002Fprev change                                                              |\n| `dp`    | Natively accept _only_ the hunk under the cursor, and reject the edit request |\n| `do`    | Natively reject _only_ the hunk under the cursor, and reject the edit request |\n| `q`     | Close the diff                                                                |\n\n### Statusline\n\n```lua\nrequire(\"lualine\").setup({\n  sections = {\n    lualine_z = {\n      {\n        require(\"opencode\").statusline,\n      },\n    }\n  }\n})\n```\n\n## 🙏 Acknowledgments\n\n- Inspired by [nvim-aider](https:\u002F\u002Fgithub.com\u002FGeorgesAlkhouri\u002Fnvim-aider), [neopencode.nvim](https:\u002F\u002Fgithub.com\u002Floukotal\u002Fneopencode.nvim), and [sidekick.nvim](https:\u002F\u002Fgithub.com\u002Ffolke\u002Fsidekick.nvim).\n- Uses `opencode`'s TUI for simplicity — see [sudo-tee\u002Fopencode.nvim](https:\u002F\u002Fgithub.com\u002Fsudo-tee\u002Fopencode.nvim) for a Neovim frontend.\n- [mcp-neovim-server](https:\u002F\u002Fgithub.com\u002Fbigcodegen\u002Fmcp-neovim-server) may better suit you, but it lacks customization and tool calls are slow and unreliable.\n","opencode.nvim 是一个将 Neovim 与 OpenCode AI 集成的插件，旨在提高开发者的编码效率。它支持连接到任何 OpenCode 实例，并能够共享编辑器上下文信息如缓冲区、选中内容及诊断结果等。此外，该插件还提供了输入提示补全、高亮显示以及正常模式下的支持功能；用户可以从预设库中选择或自定义提示，并执行命令和响应事件。通过内嵌的LSP实现与OpenCode交互，确保了操作流畅性同时保持了Vim的传统特性，如范围选择和点重复。此项目非常适合需要在编写代码时获得即时帮助的开发者使用，尤其是在探索新技术或解决复杂问题时。","2026-06-11 03:45:17","high_star"]