Skip to content

Add new actions#10

Open
kamack38 wants to merge 5 commits intodimtion:mainfrom
kamack38:feat/new-actions
Open

Add new actions#10
kamack38 wants to merge 5 commits intodimtion:mainfrom
kamack38:feat/new-actions

Conversation

@kamack38
Copy link
Copy Markdown

@kamack38 kamack38 commented May 3, 2026

This PR adds the following actions:

  • toggle specified mark at current position (M.toggle_mark)
  • delete specified mark
  • delete all marks on current line (awaits name change)
  • delete all marks in the current buffer (aka clean all marks)

Closes #9

Comment thread lua/guttermarks/actions.lua Outdated
bufnr = bufnr or vim.api.nvim_get_current_buf()

for _, m in ipairs(vim.fn.getmarklist(bufnr)) do
if M.is_lower(m.mark:sub(2)) then
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I should use m.mark:match("^'[A-Z]") or M.is_lower(m.mark:sub(2). I used is_lower because it may be faster than regex.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see that I have to import the utils module so it may not be faster. Feel free to comment.

Comment thread lua/guttermarks/actions.lua Outdated
end

for _, m in ipairs(vim.fn.getmarklist()) do
if m.pos[1] == bufnr and M.is_upper(m.mark:sub(2)) then
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Comment thread lua/guttermarks/actions.lua Outdated
---@param bufnr number|nil - buffer number to use (default to current buffer)
---@param cursor_pos [integer, integer]|nil # (row, col) tuple - mark position to use (default to cursor position)
M.toggle_mark = function(mark, bufnr, cursor_pos)
if mark == nil then
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be replaced with vim.fn.getcharstr(), but I don't know if that's a good idea

@kamack38
Copy link
Copy Markdown
Author

kamack38 commented May 3, 2026

Unfortunately delete_mark action already exists (but functions as delete_marks_on_line) so I created a new action delete_specified_mark. I did that to avoid breaking the API, although I think the action name should be changed.

@kamack38 kamack38 marked this pull request as ready for review May 3, 2026 13:25
@kamack38
Copy link
Copy Markdown
Author

kamack38 commented May 3, 2026

After a positive review I'll add tests for the new actions (or at least try to).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new actions

1 participant