diff --git a/init.lua b/init.lua index c174d3c..4b3ce5b 100644 --- a/init.lua +++ b/init.lua @@ -21,5 +21,6 @@ require("lazy").setup({ { import = "plugins" } }) require("sets") require("remaps") require("filetypes") +require("commands") vim.notify("starting nvim 🏕️") diff --git a/lua/commands.lua b/lua/commands.lua new file mode 100644 index 0000000..67fff56 --- /dev/null +++ b/lua/commands.lua @@ -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 = "?" } +)