feat: Create a user command for switching between tabs indent and spaces

This commit is contained in:
kalmenn 2024-11-20 14:09:37 +01:00
parent e1ec30f328
commit 818765d45b
Signed by: kalmenn
GPG key ID: F500055C44BC3834
2 changed files with 22 additions and 0 deletions

21
lua/commands.lua Normal file
View file

@ -0,0 +1,21 @@
vim.api.nvim_create_user_command("Tabs",
function(opts)
vim.bo[0].expandtab = false
if (opts.fargs[1] ~= nil) then
vim.bo[0].shiftwidth = tonumber(opts.fargs[1])
vim.bo[0].tabstop = tonumber(opts.fargs[1])
end
end,
{ nargs = "?" }
)
vim.api.nvim_create_user_command("NoTabs",
function(opts)
vim.bo[0].expandtab = true
if (opts.fargs[1] ~= nil) then
vim.bo[0].shiftwidth = tonumber(opts.fargs[1])
vim.bo[0].tabstop = tonumber(opts.fargs[1])
end
end,
{ nargs = "?" }
)