For a plugin I’m writing, I need to get the text equivalent of a <tab>. However, tabs in Neovim has configured by a bunch of different options. I want to get validation from someone else if my logic here is correct or if there is a better way to do this.
local function tab()
if vim.bo.expandtab then
return string.rep(" ", vim.fn.shiftwidth())
else
return " " -- tab character
end
end
Oh, I didn’t read your question carefully. This is indeed a bit hard, as what a <Tab> inserts also depends on 'smarttab' and 'softtabstop'. The code for inserting a <Tab> is over 200 lines long.