tabset.nvim
is a very simple plugin to easily control the width of Tab
between different file types.
Neovim v0.5 or newer is required for tabset
to work
Mostly for fun, since it's my first plugin. However, I have seen most people creating files under the ftplugin
folder to control the behaviour of tab. I wanted to avoid creating a file for every file type so I made this plugin. Do we really need a plugin for something like this? I don't know, maybe not, but I made it anyway.
Using packer.nvim
use {
"FotiadisM/tabset.nvim",
config = function()
require("tabset").setup()
end
}
You can define a default tab width with tabwidth
in the defaults
area, this sets the tabstop
and shiftwidth
settings in Neovim, as well as the option to expandtab
. This settings apply to all file types unless a custom configuration has been given in the languages
department, then the default settings are overwritten for that language.
{
defaults = {
tabwidth = 4,
expandtab = true
},
languages = {
go = {
tabwidth = 4,
expandtab = false
}
}
}
require("tabset").setup({
defaults = {
tabwidth = 4,
expandtab = true
},
languages = {
go = {
tabwidth = 4,
expandtab = false
},
{
filetypes = { "javascript", "typescript", "javascriptreact", "typescriptreact", "json", "yaml" },
config = {
tabwidth = 2
}
}
}
})
As you can see in the above example, if you want you can specify the same settings for multiple file types easily. Also, if a value is missing from config
, then is populated with the default value. For example, expandtab
is set to true for javascript
, typescript
, ... in the above example because the value was not specified.