diff --git a/.gitignore b/.gitignore index 485dee6..5249c81 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ .idea + +# Slack MCP +.channels_cache_v2.json +.users_cache.json diff --git a/README.md b/README.md index c0f2535..65febad 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. @@ -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). diff --git a/lua/amp/logger.lua b/lua/amp/logger.lua index 023bb31..22d4cf2 100644 --- a/lua/amp/logger.lua +++ b/lua/amp/logger.lua @@ -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