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:
parent
c74468526a
commit
4b6c921768
3 changed files with 6 additions and 10 deletions
3
users/hu/packages/nvim/config/ftplugin/lua.lua
Normal file
3
users/hu/packages/nvim/config/ftplugin/lua.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
vim.bo.tabstop = 2
|
||||||
|
vim.bo.softtabstop = 2
|
||||||
|
vim.bo.shiftwidth = 2
|
3
users/hu/packages/nvim/config/ftplugin/nix.lua
Normal file
3
users/hu/packages/nvim/config/ftplugin/nix.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
vim.bo.tabstop = 2
|
||||||
|
vim.bo.softtabstop = 2
|
||||||
|
vim.bo.shiftwidth = 2
|
|
@ -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
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in a new issue