Skip to content

Commit dd62056

Browse files
feat: allow anti conceal to be disabled in specific modes
## Details This change removes disabling anti conceal in command mode as a default behavior, I found it too jumpy when quickly saving with inlined marks. Instead of this the `anti_conceal` configuration now has an additional field `disabled_modes`, where users can set modes they would like to disable anti conceal in, the default value is `false` which means do not disable anti conceal in any modes. To replicate the old behavior you would need to set `anti_conceal = { disabled_modes = { 'c' } }`. Unrelated change, modified the call to `lazy_plugin.values` to be wrapped in a `pcall`. Since this comes from an external source `lazy.nvim`, I want to be extra careful relying on anything.
1 parent af1a7f0 commit dd62056

File tree

8 files changed

+43
-23
lines changed

8 files changed

+43
-23
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
- include highlight query files in checkhealth [4f05de7](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/4f05de7536571e231b66dd0363af347b162b5fd7)
1313
- pad suffix of latex so backgrounds are aligned [a212596](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/a2125961287c78dfc03cb628b7bed7f91b70fd45)
1414

15+
### Bug Fixes
16+
17+
- get correct list of ft and cmd from lazy [#442](https://github.com/MeanderingProgrammer/render-markdown.nvim/pull/442)
18+
19+
### Collaborator Shoutouts
20+
21+
- @carloscalla
22+
1523
## 8.4.0 (2025-05-08)
1624

1725
### Features

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ require('render-markdown').setup({
239239
anti_conceal = {
240240
-- This enables hiding any added text on the line the cursor is on.
241241
enabled = true,
242+
-- Modes to disable anti conceal feature.
243+
disabled_modes = false,
244+
-- Number of lines above cursor to show.
245+
above = 0,
246+
-- Number of lines below cursor to show.
247+
below = 0,
242248
-- Which elements to always show, ignoring anti conceal behavior. Values can either be
243249
-- booleans to fix the behavior or string lists representing modes where anti conceal
244250
-- behavior will be ignored. Valid values are:
@@ -248,10 +254,6 @@ require('render-markdown').setup({
248254
code_background = true,
249255
sign = true,
250256
},
251-
-- Number of lines above cursor to show.
252-
above = 0,
253-
-- Number of lines below cursor to show.
254-
below = 0,
255257
},
256258
padding = {
257259
-- Highlight to use when adding whitespace, should match background.

doc/render-markdown.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 May 31
1+
*render-markdown.txt* For NVIM v0.11.2 Last change: 2025 June 02
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -304,6 +304,12 @@ Default Configuration ~
304304
anti_conceal = {
305305
-- This enables hiding any added text on the line the cursor is on.
306306
enabled = true,
307+
-- Modes to disable anti conceal feature.
308+
disabled_modes = false,
309+
-- Number of lines above cursor to show.
310+
above = 0,
311+
-- Number of lines below cursor to show.
312+
below = 0,
307313
-- Which elements to always show, ignoring anti conceal behavior. Values can either be
308314
-- booleans to fix the behavior or string lists representing modes where anti conceal
309315
-- behavior will be ignored. Valid values are:
@@ -313,10 +319,6 @@ Default Configuration ~
313319
code_background = true,
314320
sign = true,
315321
},
316-
-- Number of lines above cursor to show.
317-
above = 0,
318-
-- Number of lines below cursor to show.
319-
below = 0,
320322
},
321323
padding = {
322324
-- Highlight to use when adding whitespace, should match background.

lua/render-markdown/config/anti_conceal.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---@class (exact) render.md.anti.conceal.Config
22
---@field enabled boolean
3-
---@field ignore render.md.conceal.Ignore
3+
---@field disabled_modes render.md.Modes
44
---@field above integer
55
---@field below integer
6+
---@field ignore render.md.conceal.Ignore
67

78
---@alias render.md.conceal.Ignore table<render.md.Element, render.md.Modes>
89

@@ -32,6 +33,12 @@ local M = {}
3233
M.default = {
3334
-- This enables hiding any added text on the line the cursor is on.
3435
enabled = true,
36+
-- Modes to disable anti conceal feature.
37+
disabled_modes = false,
38+
-- Number of lines above cursor to show.
39+
above = 0,
40+
-- Number of lines below cursor to show.
41+
below = 0,
3542
-- Which elements to always show, ignoring anti conceal behavior. Values can either be
3643
-- booleans to fix the behavior or string lists representing modes where anti conceal
3744
-- behavior will be ignored. Valid values are:
@@ -41,23 +48,20 @@ M.default = {
4148
code_background = true,
4249
sign = true,
4350
},
44-
-- Number of lines above cursor to show.
45-
above = 0,
46-
-- Number of lines below cursor to show.
47-
below = 0,
4851
}
4952

5053
---@param spec render.md.debug.ValidatorSpec
5154
function M.validate(spec)
5255
spec:type('enabled', 'boolean')
56+
spec:list('disabled_modes', 'string', 'boolean')
57+
spec:type('above', 'number')
58+
spec:type('below', 'number')
5359
spec:nested('ignore', function(ignore)
5460
for _, element in pairs(Element) do
5561
ignore:list(element, 'string', { 'boolean', 'nil' })
5662
end
5763
ignore:check()
5864
end)
59-
spec:type('above', 'number')
60-
spec:type('below', 'number')
6165
spec:check()
6266
end
6367

lua/render-markdown/core/ui.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,14 @@ end
180180
---@return render.md.Range?
181181
function Updater:hidden()
182182
-- anti-conceal is not enabled -> hide nothing
183-
-- row is not known -> buffer is not active -> hide nothing
184-
-- in command mode -> cursor is not in buffer -> hide nothing
183+
-- in disabled mode -> hide nothing
185184
local config = self.config.anti_conceal
185+
if not config.enabled or Env.mode.is(self.mode, config.disabled_modes) then
186+
return nil
187+
end
188+
-- row is not known -> buffer is not active -> hide nothing
186189
local row = Env.row.get(self.buf, self.win)
187-
if not config.enabled or not row or Env.mode.is(self.mode, { 'c' }) then
190+
if not row then
188191
return nil
189192
end
190193
if Env.mode.is(self.mode, { 'v', 'V', '\22' }) then

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.4.11'
8+
M.version = '8.4.12'
99

1010
function M.check()
1111
M.start('version')

lua/render-markdown/lib/env.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function M.lazy(key)
2020
if not plugin then
2121
return {}
2222
end
23-
24-
return lazy_plugin.values(plugin, key, true)
23+
local ok, values = pcall(lazy_plugin.values, plugin, key, true)
24+
return ok and values or {}
2525
end
2626

2727
---@param file string|integer

lua/render-markdown/types.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939

4040
---@class (exact) render.md.anti.conceal.UserConfig
4141
---@field enabled? boolean
42-
---@field ignore? render.md.conceal.Ignore
42+
---@field disabled_modes? render.md.Modes
4343
---@field above? integer
4444
---@field below? integer
45+
---@field ignore? render.md.conceal.Ignore
4546

4647
---@class (exact) render.md.base.UserConfig
4748
---@field enabled? boolean

0 commit comments

Comments
 (0)