Skip to content

Commit

Permalink
Add warning when 'conceallevel' not set correctly
Browse files Browse the repository at this point in the history
And add another note in the README. Closes #286.
  • Loading branch information
epwalsh committed Jan 4, 2024
1 parent f8b6bb9 commit 72d1ea1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ This is a complete list of all of the options that can be passed to `require("ob
open_notes_in = "current",

-- Optional, configure additional syntax highlighting / extmarks.
-- This requires you have `conceallevel` set to 1 or 2. See `:help conceallevel` for more details.
ui = {
enable = true, -- set to false to disable all additional syntax features
update_debounce = 200, -- update delay after a text change (in milliseconds)
Expand Down Expand Up @@ -476,7 +477,7 @@ If you use `vim-markdown` you'll probably want to disable its frontmatter syntax

#### Concealing characters

If you wish to use the formatting concealment features, you will need to have `conceallevel` set to a value that allows it, for example:
If you wish to use the formatting concealment features, you will need to have `conceallevel` set to a value that allows it (either `1` or `2`), for example:
`set conceallevel=1` in viml or `vim.opt.conceallevel = 1` in a lua config.

#### Note naming and location
Expand Down
10 changes: 10 additions & 0 deletions lua/obsidian/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ 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)
Expand Down

0 comments on commit 72d1ea1

Please sign in to comment.