-
I've just set feline.nvim up, and it's great - exactly what I was looking for. I failed to create components that I still want to though: The first one would count how much stuff is selected in visual mode (characters if only selected in one line, lines if selecting multiple lines, width and height if selecting a block). There is functionality for this in noice.nvim (which is where I got the idea from), but I couldn't find it in the codebase, because it's probably 20 levels of abstractions deep in another repo, but I would still like to have a custom implementation instead of using that. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is outside of my Vim API knowledge so I could be way off here. If you look at the API documentation for Each call returns a table of values:
Perhaps with some arithmetic, you can determine the selection? For example, local start_pos = vim.fn.getpos("'<")
local end_pos = fin.fn.getpos("'>")
local start_line = start_pos[2]
local end_line = end_pos[2]
local start_col = start_pos[3]
local end_col = end_pos[3]
local lines_selected = end_line - start_line
local cols_selected = end_col - start_col NOTE: I have not tested this AT ALL! This is just me looking at the doc and trying to provide a starting point. :) |
Beta Was this translation helpful? Give feedback.
Thanks! That's broken for a few reasons because the Vim API is apparently a mess. Here is what I came up with: