fix editorConfig indent opts not applying on certain fts #2633

This commit is contained in:
siduck
2024-01-28 21:33:38 +05:30
parent 0333185bfc
commit b2e2b15b45
4 changed files with 31 additions and 67 deletions
+24 -1
View File
@@ -11,7 +11,7 @@ opt.showmode = false
opt.clipboard = "unnamedplus"
opt.cursorline = true
opt.cursorlineopt = 'number'
opt.cursorlineopt = "number"
-- Indenting
opt.expandtab = true
@@ -104,6 +104,29 @@ autocmd("BufWritePost", {
end,
})
-- user event that loads after UIEnter + only if file buf is there
vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, {
group = vim.api.nvim_create_augroup("NvFilePost", { clear = true }),
callback = function(args)
local file = vim.api.nvim_buf_get_name(args.buf)
local buftype = vim.api.nvim_buf_get_option(args.buf, "buftype")
if not vim.g.ui_entered and args.event == "UIEnter" then
vim.g.ui_entered = true
end
if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then
vim.api.nvim_exec_autocmds("User", { pattern = "FilePost", modeline = false })
vim.api.nvim_del_augroup_by_name "NvFilePost"
vim.schedule(function()
vim.api.nvim_exec_autocmds("FileType", {})
require("editorconfig").config(args.buf)
end, 0)
end
end,
})
-------------------------------------- commands ------------------------------------------
local new_cmd = vim.api.nvim_create_user_command