I am trying to create an auto command that works for all filetypes but markdown. I know that vim.bo.filetype
gives me the filetype, so I have created this:
-- https://stackoverflow.com/a/60338380/2571881
-- autocmd WinEnter,BufEnter * if &ft != "md" | do things
vim.api.nvim_create_autocmd("ModeChanged", {
pattern = { "*:i*", "i*:*" },
group = group,
callback = function()
if not vim.bo.filetype == "markdown" then
vim.o.relativenumber = vim.v.event.new_mode:match("^i") == nil
end
end,
})
It is not working properly for markdown, it keeps changing something on this filetype. If I remove the if it will work for all filetypes but I have this on my ~/.config/nvim/after/markdown.lua:
vim.opt_local.number = false
vim.opt_local.relativenumber = false
That’s why I am trying to use an if statement inside my callback function