Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.idea

# Slack MCP
.channels_cache_v2.json
.users_cache.json
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ When installed, this plugin allows Neovim to:
- Provide Neovim diagnostics to Amp on request
- Send messages to the Amp agent (see [Sending Messages to Amp](#sending-messages-to-amp))
- Read and edit files through the Neovim buffers
- Automatically reconnects when you restart Neovim in the same directory

## Installation

Expand Down Expand Up @@ -137,10 +138,6 @@ end, {

Do you have a feature request or an idea? Submit an issue in this repo!

- Better reconnect: Nvim users are much more likely to reopen their IDE than JetBrains users. Because of that, we should check if we can automatically reconnect to an IDE in the same path that we had the last connection with.
- When I ask Amp to show me a particular section of code, it would be nice if Amp could open that file and select the code for me.
- Should we keep the code selection when moving between tab? Currently you can't switch to a split terminal if you don't want to loose the selection, i.e. making the built in terminal unfeasible for code selection.

## Development

Uses `stylua` for general formatting, and `lua-language-server` for linting.
Expand All @@ -159,6 +156,10 @@ The plugin uses the same lockfile directory pattern as the main Amp repository:

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

Contributors should follow the [Sourcegraph Community Code of Conduct](https://sourcegraph.notion.site/Sourcegraph-Community-Code-of-Conduct-c7cef6b270c84fb2882808d4d82995dd).
20 changes: 17 additions & 3 deletions lua/amp/logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,31 @@ local log_levels = {
error = 5,
}

local current_level = 3 -- info
local current_level = log_levels.info
local last_error = nil
local log_file = nil

function M.setup(config)
current_level = log_levels[config.log_level] or 3
current_level = log_levels[config.log_level] or log_levels.info
if not log_file then
local log_path = vim.fn.stdpath("cache") .. "/amp.log"
log_file = io.open(log_path, "w+")
if log_file then
log_file:setvbuf("line")
end
end
end

local function log(level, context, ...)
if log_levels[level] >= current_level then
local message = table.concat({ ... }, " ")
print(string.format("[%s] %s: %s", level:upper(), context, message))
local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local log_line = string.format("[%s] [%s] %s: %s\n", timestamp, level:upper(), context, message)

if log_file then
log_file:write(log_line)
log_file:flush()
end
end
end

Expand Down