-
Hi, I'm trying to make a custom tab index component that will add the "ordinal suffix" ie: This should be fairly straightforward to do, I did it with my bufferline in neovim. The "Hello" example in the readme doesn't show using the Window or TabInformation objects though the documentation mentions they can get passed to your custom functions. Can anyone show any example of how this works to help me out? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Scratch that, I figured out why it wasn't working. I overlooked that Here is my code if anyone wants to do the same: -- Function to convert a number to its ordinal string representation
local function ordinal(n)
local suffixes = { "th", "st", "nd", "rd" }
local mod100 = n % 100
return n .. (suffixes[(mod100 - 20) % 10 + 1] or suffixes[1])
end Then this component: {
"index",
fmt = function(n)
return ordinal(n)
end,
padding = { left = 0, right = 0 },
}, |
Beta Was this translation helpful? Give feedback.
-
Yea, sorry for that change last night. I am not that good at how to announce breaking changes since I have not maintained something like this before. I tried to create a new release with the changes. I am glad you got it working |
Beta Was this translation helpful? Give feedback.
Scratch that, I figured out why it wasn't working.
I overlooked that
tab_index
was changed toindex
very recently and was trying to use the incorrect component name for my tabline version.Here is my code if anyone wants to do the same:
Then this component: