Skip to content

Commit

Permalink
refactor(ui.lua): only notify the user for conceallevel in markdown f…
Browse files Browse the repository at this point in the history
…iles once (#307)
  • Loading branch information
larrybotha authored Jan 7, 2024
1 parent e9a8fd0 commit 4c3f8c1
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions lua/obsidian/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4c3f8c1

Please sign in to comment.