Closed aidancz closed 1 week ago
Thanks for the suggestion!
Although I do find it useful for some use cases, this doesn't look like a good fit for a separate module. I'll think about maybe adding it in some capacity to 'mini.misc', but currently I have doubts about this.
After sleeping on it, I don't think this is both non-trivial and useful UI to be added to 'mini.nvim' (either as a separate module or as part of 'mini.misc').
Closing as not planned.
Here is how I'd rewrite the code for a slightly better performance:
local eol_mark_ns_id = vim.api.nvim_create_namespace('eol_mark')
local extmark_opts = { virt_text = { { '○', 'Comment' } }, virt_text_pos = 'overlay' }
local eol_extmark_id
local show_eol_at_cursor_line = function(args)
if vim.api.nvim_get_current_buf() ~= args.buf then return end
extmark_opts.id = eol_extmark_id
local line = vim.fn.line('.') - 1
eol_extmark_id = vim.api.nvim_buf_set_extmark(args.buf, eol_mark_ns_id, line, -1, extmark_opts)
end
local eol_mark_augroup = vim.api.nvim_create_augroup('eol_mark', { clear = true })
vim.api.nvim_create_autocmd(
{ 'BufEnter', 'CursorMoved', 'CursorMovedI' },
{ group = eol_mark_augroup, callback = show_eol_at_cursor_line }
)
For further optimization, there is caching of current buffer-line pair and skipping doing something if current buffer-line pair is the same. This would account for a very frequent cursor movement within same line.
Contributing guidelines
Module(s)
mini.eolmark
Description
When using a block cursor, a visible eol mark can help distinguish between spaces and eol
But with:
The eol of each line is displayed, which makes the text messy
Displaying the eol mark only at cursor line would be nice
So I write this little script:
Will mini consider adding this module?