diff --git a/lua/obsidian/ui.lua b/lua/obsidian/ui.lua index 16a632aa6..5a69d3e4c 100644 --- a/lua/obsidian/ui.lua +++ b/lua/obsidian/ui.lua @@ -567,20 +567,30 @@ M.setup = function(ui_opts) return end - local conceallevel = vim.opt_local.conceallevel:get() - if conceallevel < 1 or conceallevel > 2 then - log.warn( - "Obsidian additional syntax features require 'conceallevel' to be set to 1 or 2, " - .. "but you have 'conceallevel' set to '%s'.\n" - .. "See https://github.com/epwalsh/obsidian.nvim/issues/286 for more details.", - conceallevel - ) - end - local group = vim.api.nvim_create_augroup("obsidian_ui", { clear = true }) install_hl_groups(ui_opts) + vim.api.nvim_create_autocmd({ "BufEnter" }, { + group = group, + pattern = "*.md", + callback = function() + local conceallevel = vim.opt_local.conceallevel:get() + + if conceallevel < 1 or conceallevel > 2 then + log.warn( + "Obsidian additional syntax features require 'conceallevel' to be set to 1 or 2, " + .. "but you have 'conceallevel' set to '%s'.\n" + .. "See https://github.com/epwalsh/obsidian.nvim/issues/286 for more details.", + conceallevel + ) + end + + -- delete the autocommand + return true + end, + }) + vim.api.nvim_create_autocmd({ "BufEnter" }, { group = group, pattern = "*.md",