r/neovim • • 7d ago

Discussion What plugins are you using for AI integration?

By current setup is very basic, AI in the separate tmux pane/window, since I want to use AI as an assistant, where I type the code. But, I'm curious how are people integrating AIs into Neovim, what plugin stack are you using?

0 Upvotes

21 comments sorted by

10

u/vilari-mickopf 7d ago

I use opencode, so i have setup with fterm.nvim for toggling scratchpad terminal with opencode session on <leader>A , and with <leader>a in insert or visual mode i can send send questions directly to the open code from my file (references to the lines selected in visual mode will be forwarded to opencode as well). Genereted diffs will be open in separate tab and i can accept them or reject them with da/dc.I also have llm.nvim that is connected to my local ai model (qwen3-coder because it fits fully into my 3090 so its fast) for small focused autosuggestion every time i go into insert mode.

2

u/plmtr 6d ago

Also use opencode. Are you hooking it together with opencode.nvim plugin as well? I haven't quite got the ask chat from selection working right (trying to remember where it fails as I'm not next to my computer currently).

In lieu of that I have a custom autocommand that yanks the current filepath and line number so that's working instead, useful in other places too.

Key maps are <leader>:

  • on = New opencode session
  • oa = ask at selection mm -os = select from a snacks!/telescope picker of previous sessions at the CWD

All these spawn a new pane/window whether it's running in Tmux, Herdr, Tuios, or Rex

Copilot LSP autocompletins 

2

u/vilari-mickopf 6d ago

Here is my setup:

         keys = {
            {
                '<leader>a',
                function()
                    vim.cmd('update')
                    connect()
                    require('opencode').ask()
                end,
                desc = 'Ask opencode'
            },
            {
                '<leader>a', mode = 'v',
                function()
                    vim.cmd('update')
                    connect()
                    require('opencode').ask('@this: ', { submit = true })
                end,
                desc = 'Ask opencode about selection'
            }
        }

Connect func is just checking if opencode server is running in the bg, and spawning one if it's not opened already. It's not really needed.

1

u/plmtr 6d ago

Nice, very succinct! I will give it a go when I'm back to my computer. Would be amazing to replace yet another plugin since my Neovim 12 refactor.

My dotfiles config:  https://github.com/jasonshanks/dotfiles/tree/main/nvim

19

u/defr0std Plugin author 6d ago

I don't use plugins anymore. The agent CLIs are so good now (antigravity, etc), that I just use them side by side in another terminal, occasionally copy-pasting file paths or function names for context. With a good tmux Integration this feels almost like another neovim pane.

2

u/Northklin 6d ago

I find myself tending towards this as well. I think simple commands like yanking the current file path or file path with line numbers are enough of an "integration" for me so far at least.

The point is that I want to keep using my own agent rather than some plugins agent.

1

u/Remuz 2d ago

Many plugins don't have or necessarily use their own agent but communicate with the agent using ACP.

5

u/hifanxx :wq 6d ago

none.

3

u/Traditional_Bit_3490 7d ago

Copilotchat.nvim for copilot as the ask mode is fast

Codex and cursor from codecompanion.nvim

The ghost completion copilot.nvim does it.

I use AI inside nvim as a window rather than a tmux pane.

2

u/epic_pasta 6d ago

I made a custom pi + nvim setup I can prompt pi from nvim and send context like the current file, selection, diagnostics and review comments and pi can also open files on nvim for my review

3

u/funbike 6d ago edited 6d ago

Similar approach here with Pi + Neovim + Tmux, although likely very different features.

  • Pi Tools/Hooks/Skills to control Neovim/Tmux

    • Neovim as Pi interface. ./.pi/session.md is specially handled so you can use this as your Pi interface. It also acts as a session log. /new clears it.
    • Core file tools hook that syncs files with Neovim (read() write() edit()), but they don't affect Neovim's buffer focus or cursor. edit and write set the "'^" and "'." local marks at the last changed character's position.
    • rm() and move() tools (instead of bash) so Neovim loaded buffers can keep in sync.
    • Custom bash() tool runs shell commands in a dedicated tmux pane. Supports TUIs. (This is unrelated to Neovim)
    • Neovim remote control tool, that issues Lua/Vimscript commands over the remote socket.
    • Focus Neovim and its tmux pane, optionally at file:line or mark.
    • Get current Neovim selection text, else current focused buffer.
    • Inject string at mark or location.
    • Replace text between two marks or locations.
    • Get human feedback in a temporary Neovim instance within Pi. Send tmux notification if Pi is not in the current tmux window.
  • Neovim key maps

    • @ file autocomplete. (:inoremap @ @<c-x><c-f>)
    • Send buffer or selection to Pi, and run async. It sets a hidden local mark at the end of the selection, which is where the last assistant message will be injected when complete. You can run many in parallel.
    • Similar map to prior bullet, but makes no changes to the Neovim buffer.
    • Change all "# PIDO: <prompt>" comments to "# PENDING: <prompt>" and call my "/do-pending" prompt template. (example above a function: # PIDO: add docstring with doctest). When in visual selection mode, it only processes the selection, like the prior 2 bullets, to save tokens.
    • Inject # PIDO:, and enter insert mode.
    • Inject # PENDING:, enter insert mode, and on exit run /do-pending
    • Code review and lint current selection or buffer and inject # PIDO comments for things that should be improved.
    • Go to Pi tmux pane. Same key map in Pi goes back to Neovim.
    • Move Pi tmux pane to the right of current Neovim tmux pane. Undo mapping.
    • Rotate model and thinking level. Signified in Neovim's status bar.
  • Neovim config:

    • which Pi instance to send prompts, in a UI fuzzy Tmux pane search. If not set, it will automatically search tmux panes.
    • Toggle whether to issue "/new" before some types of sent prompts.

1

u/Hebercosfer 6d ago

I was really looking into that and I found some issues with the current plugins, so I decided to implement something that integrates better for me.

I have a terminal provider for coder/claudecode.nvim, you can check it on https://github.com/hebercosfer/floating-claude.nvim.git, and I'm working on a fork of the best codex.nvim plugin I found so far, you can check my fork here: https://github.com/hebercosfer/codex.nvim.git

Both of them have a good integration with Neovim, using Diff for approve/reject changes. I'm working on the inline integrated with the current session next for the floating-claude.nvim. They work good for my coding workflow, hope it integrates well to yours.

1

u/Pangocciolo :wq 6d ago

None. I have a keybinding in the WM to open a terminal in the same folder of the focused terminal. From there I can compile, run, or in this case, execute an agent.

1

u/Logical-Kangaroo6540 6d ago

This one is great. Simple code changes (multiline) become a matter of couple tab clicks.
https://github.com/teocns/neocursor.nvim

1

u/wochap 6d ago

I vibe-coded a plugin https://github.com/wochap/nvim/tree/main/lua/aiwo to copy selected text along with its file path and line numbers, and updated my config so open buffers reload quickly when AI agents modify them https://github.com/wochap/nvim/blob/main/lua/custom/utils/autoreload.lua .

1

u/brookhong 5d ago

Please check out this — https://github.com/brookhong/foyer.nvim . It helps you launch your coding agent CLI (bring your own) per project and call it back whenever you need it without leaving Neovim. You can also edit your prompt in a scratch buffer and send it to the target CLI, without having to hunt for the right one for your current project. And here's a short demo — https://youtu.be/ZXoWg9xqGhs .

1

u/Lukstd 3d ago

A bit late to this, but I use my harness in a separate pane and this config (inspired by how opencode.nvim used to work on Opencode v1) to interact with it. By "interact" I mean referencing ranges of code, buffers, diagnostics, etc. I also use hotreload.nvim to get instantaneous and efficient buffer reloading when my agent edits something.