diff --git a/README.md b/README.md index 6c9822c2..cac59fc8 100644 --- a/README.md +++ b/README.md @@ -321,7 +321,17 @@ debugging issues with Neotest. You can get ahold of the log file's path using `require("neotest.logging"):get_filename()`, which usually points to your -`~/.local/state/nvim/neotest.log`. +`~/.local/state/nvim/neotest.Log`. + +The logfile tends to be ginormous and if you are only looking for neotest-golang +related entries, you can either search for the `[neotest-golang]` prefix, or +open the log in a Neovim buffer and then filter out only the adapter-related +entries: + +```lua +:edit ~/.local/state/nvim/neotest.log +:lua require("neotest-golang.utils.buffer").filter("[neotest-golang]") +``` ### Neotest is slowing down Neovim diff --git a/lua/neotest-golang/utils/buffer.lua b/lua/neotest-golang/utils/buffer.lua new file mode 100644 index 00000000..742b712e --- /dev/null +++ b/lua/neotest-golang/utils/buffer.lua @@ -0,0 +1,29 @@ +local lib = require("neotest-golang.lib") + +local M = {} + +function M.filter(word) + -- Get the current buffer + local bufnr = vim.api.nvim_get_current_buf() + + -- Get all lines in the buffer + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) + + -- Create a new table to store lines containing the word + local new_lines = {} + + -- Iterate through all lines + for _, line in ipairs(lines) do + -- If the line contains "neotest-golang", add it to new_lines + if line:match(lib.convert.to_lua_pattern(word)) then + table.insert(new_lines, line) + end + end + + -- Replace the buffer contents with the new lines + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, new_lines) + + vim.notify("Removed lines not containing '" .. word .. "'") +end + +return M diff --git a/lua/neotest-golang/utils/init.lua b/lua/neotest-golang/utils/init.lua new file mode 100644 index 00000000..c04bf664 --- /dev/null +++ b/lua/neotest-golang/utils/init.lua @@ -0,0 +1,5 @@ +local M = {} + +M.buffer = require("neotest-golang.utils.buffer") + +return M