1
Fork 0

Use ftplugin instead of autocmds to set indent

The autocmds approach had the issue of overwriting the indentation
globally for all files. So if you opened a .nix file and then wanted to
edit a .c file, it would then still do 2 space indentation when it
should be 4. The autocmds approach was redundant in the first place as
the ftplugin directory already exists for this exact purpose and does it
without the aformentioned issue.
This commit is contained in:
caem 2024-05-26 11:43:53 +02:00
parent c74468526a
commit 4b6c921768
Signed by: caem
GPG key ID: 69A830D03203405F
3 changed files with 6 additions and 10 deletions

View file

@ -0,0 +1,3 @@
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
vim.bo.shiftwidth = 2

View file

@ -0,0 +1,3 @@
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
vim.bo.shiftwidth = 2

View file

@ -1,10 +0,0 @@
-- 2 indentation languages
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.lua", "*.nix"},
callback = function()
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
end
})