Skip to content

Commit

Permalink
feat: add an UI option to ignore conceal warnings
Browse files Browse the repository at this point in the history
In #286 (comment)
it was suggested that a new config could be added to specifically not
warn if the conceal level is 0 and the UI is enabled.

This commit does this and guard against the conceal warning when the
option is set.

cc #492
  • Loading branch information
nobe4 committed Nov 26, 2024
1 parent 14e0427 commit 4d02dc5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ This is a complete list of all of the options that can be passed to `require("ob
-- 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
ignore_conceal_warn = false, -- set to true to disable conceallevel specific warning
update_debounce = 200, -- update delay after a text change (in milliseconds)
max_file_length = 5000, -- disable UI features for files with more than this many lines
-- Define how various check-boxes are displayed
Expand Down
2 changes: 2 additions & 0 deletions lua/obsidian/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ end
---@class obsidian.config.UIOpts
---
---@field enable boolean
---@field ignore_conceal_warn boolean
---@field update_debounce integer
---@field max_file_length integer|?
---@field checkboxes table<string, obsidian.config.CheckboxSpec>
Expand Down Expand Up @@ -438,6 +439,7 @@ config.UIOpts = {}
config.UIOpts.default = function()
return {
enable = true,
ignore_conceal_warn = false,
update_debounce = 200,
max_file_length = 5000,
checkboxes = {
Expand Down
2 changes: 1 addition & 1 deletion lua/obsidian/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ M.setup = function(workspace, ui_opts)
callback = function()
local conceallevel = vim.opt_local.conceallevel:get()

if conceallevel < 1 or conceallevel > 2 then
if (conceallevel < 1 or conceallevel > 2) and not ui_opts.ignore_conceal_warn then
log.warn_once(
"Obsidian additional syntax features require 'conceallevel' to be set to 1 or 2, "
.. "but you have 'conceallevel' set to '%s'.\n"
Expand Down

0 comments on commit 4d02dc5

Please sign in to comment.