-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ee537a
commit 9e4a19f
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local M = {} | ||
|
||
M.buffer = require("neotest-golang.utils.buffer") | ||
|
||
return M |