Skip to content

Commit a9643f4

Browse files
feat: add config api to print difference between current config and default
1 parent 37f52f0 commit a9643f4

File tree

8 files changed

+67
-4
lines changed

8 files changed

+67
-4
lines changed

Diff for: CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@
1515
- integrate with lazy.nvim filetypes [cb9a5e2](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/cb9a5e2412d21c7a89627e0d6da5459acbc0eb9c)
1616
- bullet left & right padding on all lines of items [#181](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/181)
1717
[3adb9d5](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/3adb9d539a016bc63fee83aa740e38fa4eeab094)
18-
18+
- heading margin / padding based on level [#182](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/182)
19+
& border virtual option [#183](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/183)
20+
[aad1a12](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/aad1a1220dc9da5757e3af3befbc7fc3869dd334)
1921

2022
### Bug Fixes
2123

2224
- window options on alternate buffer switch [#177](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/177)
2325
[f187721](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/f187721a5381f4443ef97ad1a7c0681a65511d28)
26+
- update when window scrolled [#185](https://github.com/MeanderingProgrammer/render-markdown.nvim/pull/185)
27+
28+
### Collaborator Shoutouts
29+
30+
- @Bekaboo
2431

2532
## 7.1.0 (2024-09-19)
2633

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ use({
106106
| `:RenderMarkdown expand` | `require('render-markdown').expand()` | Increase anti-conceal margin above and below by 1 |
107107
| `:RenderMarkdown contract` | `require('render-markdown').contract()` | Decrease anti-conceal margin above and below by 1 |
108108
| `:RenderMarkdown debug` | `require('render-markdown').debug()` | Prints information about marks on current line |
109+
| `:RenderMarkdown config` | `require('render-markdown').config()` | Prints difference between config and default |
109110

110111
# Setup
111112

Diff for: doc/render-markdown.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 September 24
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 September 25
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -150,6 +150,9 @@ PACKER.NVIM *render-markdown-install-packer.nvim*
150150

151151
:RenderMarkdown debug require('render-markdown').debug() Prints information about marks
152152
on current line
153+
154+
:RenderMarkdown config require('render-markdown').config() Prints difference between
155+
config and default
153156
-------------------------------------------------------------------------------------------------
154157

155158
==============================================================================

Diff for: lua/render-markdown/api.lua

+9
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@ function M.debug()
3636
require('render-markdown.debug.marks').debug(row, marks)
3737
end
3838

39+
function M.config()
40+
local difference = state.difference(require('render-markdown').default_config)
41+
if vim.tbl_count(difference) == 0 then
42+
vim.print('Default Configuration')
43+
else
44+
vim.print(difference)
45+
end
46+
end
47+
3948
return M

Diff for: lua/render-markdown/debug/diff.lua

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---@alias render.md.debug.Key string|integer
2+
3+
---@class render.md.debug.Diff
4+
local M = {}
5+
6+
---@param t1 table<render.md.debug.Key, any>
7+
---@param t2 table<render.md.debug.Key, any>
8+
---@return table<render.md.debug.Key, any>
9+
function M.get(t1, t2)
10+
local result, keys = {}, {}
11+
M.append_keys(keys, t1)
12+
M.append_keys(keys, t2)
13+
for _, key in ipairs(keys) do
14+
local v1, v2 = t1[key], t2[key]
15+
if type(v1) == 'table' and type(v2) == 'table' then
16+
local nested = M.get(v1, v2)
17+
if vim.tbl_count(nested) > 0 then
18+
result[key] = nested
19+
end
20+
elseif v1 ~= v2 then
21+
result[key] = v2
22+
end
23+
end
24+
return result
25+
end
26+
27+
---@private
28+
---@param keys render.md.debug.Key[]
29+
---@param t table<render.md.debug.Key, any>
30+
function M.append_keys(keys, t)
31+
for key in pairs(t) do
32+
if not vim.tbl_contains(keys, key) then
33+
table.insert(keys, key)
34+
end
35+
end
36+
end
37+
38+
return M

Diff for: lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local state = require('render-markdown.state')
44
local M = {}
55

66
---@private
7-
M.version = '7.1.11'
7+
M.version = '7.1.12'
88

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

Diff for: lua/render-markdown/init.lua

-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ local M = {}
194194
---@field public overrides? render.md.UserConfigOverrides
195195
---@field public custom_handlers? table<string, render.md.Handler>
196196

197-
---@private
198197
---@type render.md.Config
199198
M.default_config = {
200199
-- Whether Markdown should be rendered by default or not

Diff for: lua/render-markdown/state.lua

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function M.invalidate_cache()
6060
configs = {}
6161
end
6262

63+
---@param default_config render.md.Config
64+
---@return table
65+
function M.difference(default_config)
66+
return require('render-markdown.debug.diff').get(default_config, M.config)
67+
end
68+
6369
---@param amount integer
6470
function M.modify_anti_conceal(amount)
6571
---@param anti_conceal render.md.AntiConceal

0 commit comments

Comments
 (0)