dotfiles/nvim/lua/cmds.lua

18 lines
571 B
Lua
Raw Normal View History

local function set_indent(use_spaces, size)
vim.o.expandtab = use_spaces
vim.o.shiftwidth = size
vim.o.tabstop = size
end
vim.api.nvim_create_user_command('IndentTabs', function(opts)
local size = tonumber(opts.fargs[1])
set_indent(false, size)
print('Set buffer indentation to tabs with indent/tab size of', size)
end, { nargs = 1 })
vim.api.nvim_create_user_command('IndentSpaces', function(opts)
local size = tonumber(opts.fargs[1])
set_indent(true, size)
print('Set buffer indentation to spaces with indent/tab size of', size)
end, { nargs = 1 })