Skip to content

Commit bffe418

Browse files
chore(refactor): schare width enum for code & heading
1 parent bd56575 commit bffe418

20 files changed

+45
-36
lines changed

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For NVIM v0.11.1 Last change: 2025 April 29
1+
*render-markdown.txt* For NVIM v0.11.1 Last change: 2025 April 30
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

lua/render-markdown/config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ end
107107
-- stylua: ignore
108108
---@param spec render.md.debug.ValidatorSpec
109109
function Config.validate(spec)
110-
require('render-markdown.config.base').validate(spec)
110+
local Base = require('render-markdown.config.base')
111+
Base.validate(spec)
111112
spec:type('max_file_size', 'number')
112113
spec:type('debounce', 'number')
113114
spec:nested('anti_conceal', require('render-markdown.config.anti_conceal').validate)

lua/render-markdown/config/base.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
---@class render.md.base
88
local M = {}
99

10+
---@enum render.md.base.Width
11+
M.Width = {
12+
full = 'full',
13+
block = 'block',
14+
}
15+
1016
---@param spec render.md.debug.ValidatorSpec
1117
function M.validate(spec)
1218
spec:type('enabled', 'boolean')

lua/render-markdown/config/bullet.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ M.default = {
6868

6969
---@param spec render.md.debug.ValidatorSpec
7070
function M.validate(spec)
71-
require('render-markdown.config.base').validate(spec)
71+
local Base = require('render-markdown.config.base')
72+
Base.validate(spec)
7273
spec:nested_list('icons', 'string', 'function')
7374
spec:nested_list('ordered_icons', 'string', 'function')
7475
spec:type('left_pad', { 'number', 'function' })

lua/render-markdown/config/checkbox.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ M.default = {
6060

6161
---@param spec render.md.debug.ValidatorSpec
6262
function M.validate(spec)
63-
require('render-markdown.config.base').validate(spec)
63+
local Base = require('render-markdown.config.base')
64+
Base.validate(spec)
6465
spec:type('right_pad', 'number')
6566
spec:nested({ 'unchecked', 'checked' }, function(box)
6667
box:type('icon', 'string')

lua/render-markdown/config/code.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
---@field language_icon boolean
77
---@field language_name boolean
88
---@field disable_background boolean|string[]
9-
---@field width render.md.code.Width
9+
---@field width render.md.base.Width
1010
---@field left_margin number
1111
---@field left_pad number
1212
---@field right_pad number
@@ -37,12 +37,6 @@ local Position = {
3737
right = 'right',
3838
}
3939

40-
---@enum render.md.code.Width
41-
local Width = {
42-
full = 'full',
43-
block = 'block',
44-
}
45-
4640
---@enum render.md.code.Border
4741
local Border = {
4842
hide = 'hide',
@@ -130,15 +124,16 @@ M.default = {
130124

131125
---@param spec render.md.debug.ValidatorSpec
132126
function M.validate(spec)
133-
require('render-markdown.config.base').validate(spec)
127+
local Base = require('render-markdown.config.base')
128+
Base.validate(spec)
134129
spec:type('sign', 'boolean')
135130
spec:one_of('style', vim.tbl_values(Style))
136131
spec:one_of('position', vim.tbl_values(Position))
137132
spec:type('language_pad', 'number')
138133
spec:type('language_icon', 'boolean')
139134
spec:type('language_name', 'boolean')
140135
spec:list('disable_background', 'string', 'boolean')
141-
spec:one_of('width', vim.tbl_values(Width))
136+
spec:one_of('width', vim.tbl_values(Base.Width))
142137
spec:type('left_margin', 'number')
143138
spec:type('left_pad', 'number')
144139
spec:type('right_pad', 'number')

lua/render-markdown/config/dash.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ M.default = {
3232

3333
---@param spec render.md.debug.ValidatorSpec
3434
function M.validate(spec)
35-
require('render-markdown.config.base').validate(spec)
35+
local Base = require('render-markdown.config.base')
36+
Base.validate(spec)
3637
spec:type('icon', 'string')
3738
spec:one_of('width', { 'full' }, 'number')
3839
spec:type('left_margin', 'number')

lua/render-markdown/config/document.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ M.default = {
2626

2727
---@param spec render.md.debug.ValidatorSpec
2828
function M.validate(spec)
29-
require('render-markdown.config.base').validate(spec)
29+
local Base = require('render-markdown.config.base')
30+
Base.validate(spec)
3031
spec:nested('conceal', function(conceal)
3132
conceal:list('char_patterns', 'string')
3233
conceal:list('line_patterns', 'string')

lua/render-markdown/config/heading.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
---@field icons render.md.heading.Icons
66
---@field position render.md.heading.Position
77
---@field signs string[]
8-
---@field width render.md.heading.Width|(render.md.heading.Width)[]
8+
---@field width render.md.base.Width|(render.md.base.Width)[]
99
---@field left_margin number|number[]
1010
---@field left_pad number|number[]
1111
---@field right_pad number|number[]
@@ -34,12 +34,6 @@ local Position = {
3434
right = 'right',
3535
}
3636

37-
---@enum render.md.heading.Width
38-
local Width = {
39-
full = 'full',
40-
block = 'block',
41-
}
42-
4337
---@class (exact) render.md.heading.Custom
4438
---@field pattern string
4539
---@field icon? string
@@ -140,14 +134,15 @@ M.default = {
140134

141135
---@param spec render.md.debug.ValidatorSpec
142136
function M.validate(spec)
143-
require('render-markdown.config.base').validate(spec)
137+
local Base = require('render-markdown.config.base')
138+
Base.validate(spec)
144139
spec:type('atx', 'boolean')
145140
spec:type('setext', 'boolean')
146141
spec:type('sign', 'boolean')
147142
spec:list('icons', 'string', 'function')
148143
spec:one_of('position', vim.tbl_values(Position))
149144
spec:list('signs', 'string')
150-
spec:one_or_list_of('width', vim.tbl_values(Width))
145+
spec:one_or_list_of('width', vim.tbl_values(Base.Width))
151146
spec:list('left_margin', 'number', 'number')
152147
spec:list('left_pad', 'number', 'number')
153148
spec:list('right_pad', 'number', 'number')

lua/render-markdown/config/html.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ M.default = {
3737

3838
---@param spec render.md.debug.ValidatorSpec
3939
function M.validate(spec)
40-
require('render-markdown.config.base').validate(spec)
40+
local Base = require('render-markdown.config.base')
41+
Base.validate(spec)
4142
spec:nested('comment', function(comment)
4243
comment:type('conceal', 'boolean')
4344
comment:type('text', { 'string', 'nil' })

0 commit comments

Comments
 (0)