Vonr / align.nvim

A minimal plugin for NeoVim for aligning lines
GNU General Public License v3.0
147 stars 4 forks source link

End with previous visual selection #8

Closed nyngwang closed 9 months ago

nyngwang commented 1 year ago

As title. After formatting a string, it's very likely that a user would like to visual-select those lines again. Could you add this feature? With current implementation, this naive-try doesn't work:

require'align'.align_to_string(true, true, true)
vim.cmd('normal! gv')

I would recommend providing a callback for users to do anything(in my case visual-selection), just like this:

require'align'.align_to_string(true, true, true, function()
  vim.cmd('normal! gv')
end)

OR

I would also be happy to know that entering a space-separated string to re-apply it multiple times:

Enter pattern: foo bar end
Vonr commented 1 year ago

I've been trying to get callbacks to work for the past half an hour without success. It appears to run but the example given with vim.cmd still does not work.

The second option is not too feasible as there may be cases where you want to match by multiple words.

I may attempt this again at a later date but for now I'll leave this issue open.