Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

53 Commits

Repository files navigation

amp.nvim (deprecated)

Warning

amp.nvim is deprecated and unmaintained. Amp no longer maintains editor extensions. Use Amp on the web or the Amp CLI instead. For context, read The Coding Agent Is Dead.

The documentation below is retained for existing users, but new installations are not recommended.

This plugin allows the Amp CLI to see the file you currently have open in your Neovim instance, along with your cursor position and your text selection.

amp.nvim.mp4

When installed, this plugin allows Neovim to:

  • Notify Amp about currently open file
  • Notify Amp about selected code
  • Send messages to the Amp agent (see Sending Messages to Amp)
  • Read and edit files through the Neovim buffers
  • Provide Neovim LSP diagnostics to Amp through the companion Amp plugin
  • Automatically reconnects when you restart Neovim in the same directory

Legacy Installation (not recommended)

Using lazy.nvim

Install the plugin by adding this code to your lazy.vim config:

-- Amp Plugin
{
"sourcegraph/amp.nvim",
branch="main",
lazy=false,
opts= { auto_start=true, log_level="info" },
}

Using mini.deps

localMiniDeps=require('mini.deps')
MiniDeps.add({
source='sourcegraph/amp.nvim',
})
require('amp').setup({ auto_start=true, log_level="info" })

Using Neovim's Native Package System

# For automatic loading on startup
git clone https://github.com/sourcegraph/amp.nvim.git \
~/.local/share/nvim/site/pack/plugins/start/amp.nvim
# Or for optional loading (use :packadd amp.nvim to load)
git clone https://github.com/sourcegraph/amp.nvim.git \
~/.local/share/nvim/site/pack/plugins/opt/amp.nvim

Then add to your init.lua:

require('amp').setup({ auto_start=true, log_level="info" })

Once installed, run amp --ide.

LSP Diagnostics

This step is optional. The Neovim plugin works without it, but if you want Amp to read Neovim LSP diagnostics, install the companion Amp plugin included in this repo:

mkdir -p ~/.config/amp/plugins
cp plugin/amp-neovim-diagnostics.ts ~/.config/amp/plugins/

Then start Neovim with this plugin enabled and run amp --ide in the same workspace. The companion plugin registers a get_diagnostics tool in Amp and pulls diagnostics from the running Neovim instance through amp.nvim's local WebSocket protocol.

Healthcheck

Check the health of the plugin by running :checkhealth amp or to run all healthchecks run :checkhealth

Sending Messages to Amp

The plugin provides a simple send_message function that you can use to create your own commands and workflows. Here are two example commands you can add to your configuration, one to send a quick message, and one to send the contents of a buffer (useful for drafting longer messages):

Example Commands

-- Send a quick message to the agentvim.api.nvim_create_user_command("AmpSend", function(opts)
localmessage=opts.argsifmessage=="" thenprint("Please provide a message to send")
returnendlocalamp_message=require("amp.message")
amp_message.send_message(message)
end, {
nargs="*",
desc="Send a message to Amp",
})
-- Send entire buffer contentsvim.api.nvim_create_user_command("AmpSendBuffer", function(opts)
localbuf=vim.api.nvim_get_current_buf()
locallines=vim.api.nvim_buf_get_lines(buf, 0, -1, false)
localcontent=table.concat(lines, "\n")
localamp_message=require("amp.message")
amp_message.send_message(content)
end, {
nargs="?",
desc="Send current buffer contents to Amp",
})
-- Add selected text directly to promptvim.api.nvim_create_user_command("AmpPromptSelection", function(opts)
locallines=vim.api.nvim_buf_get_lines(0, opts.line1-1, opts.line2, false)
localtext=table.concat(lines, "\n")
localamp_message=require("amp.message")
amp_message.send_to_prompt(text)
end, {
range=true,
desc="Add selected text to Amp prompt",
})
-- Add file+selection reference to promptvim.api.nvim_create_user_command("AmpPromptRef", function(opts)
localbufname=vim.api.nvim_buf_get_name(0)
ifbufname=="" thenprint("Current buffer has no filename")
returnendlocalrelative_path=vim.fn.fnamemodify(bufname, ":.")
localref="@" ..relative_pathifopts.line1~=opts.line2thenref=ref.."#L" ..opts.line1.."-" ..opts.line2elseifopts.line1>1thenref=ref.."#L" ..opts.line1endlocalamp_message=require("amp.message")
amp_message.send_to_prompt(ref)
end, {
range=true,
desc="Add file reference (with selection) to Amp prompt",
})

Maintenance Status

This plugin is unmaintained. No new features or fixes are planned. Use the Amp CLI instead.

Development

Uses stylua for general formatting, and lua-language-server for linting.

stylua .
nvim --headless --clean -c ':!lua-language-server --check .' -c 'qa'

Cross-Platform Support

The plugin uses the same lockfile directory pattern as the main Amp repository:

  • Windows & macOS: ~/.local/share/amp/ide
  • Linux: $XDG_DATA_HOME/amp/ide or ~/.local/share/amp/ide

You can override the data directory by setting the AMP_DATA_HOME environment variable for testing or custom setups.

Logging

The amp.nvim plugin logs to ~/.cache/nvim/amp.log.

Contributing

This plugin is deprecated and unmaintained, so new feature contributions are not being accepted.

About

No description, website, or topics provided.

Resources

Stars

201 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages