Skip to content

Commit b8e26f3

Browse files
chore(types): add extension type for vim.api.keyset.set_extmark
## Details Rather than working with opts type `vim.api.keyset.set_extmark` directly, add an extension type `render.md.MarkOpts` which provides more strict type definitions for: - `virt_text`: `any[]` -> `render.md.MarkLine` - `virt_text_pos`: `string` -> `'eol'|'inline'|'overlay'` - `virt_lines`: `any[]` -> `render.md.MarkLine[]` Minor other changes: - Remove `public` scope from fields - Rename `render.md.Text` -> `render.md.MarkText` - Rename `render.md.Line` -> `render.md.MarkLine`
1 parent a03ed82 commit b8e26f3

File tree

12 files changed

+477
-427
lines changed

12 files changed

+477
-427
lines changed

doc/custom-handlers.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,30 @@ needed, and concealing when the cursor enters.
1212
Each handler must conform to the following interface:
1313

1414
```lua
15+
---@class (exact) render.md.MarkText
16+
---@field [1] string text
17+
---@field [2] string|string[] highlights
18+
19+
---@alias render.md.MarkLine render.md.MarkText[]
20+
21+
---@class render.md.MarkOpts: vim.api.keyset.set_extmark
22+
---@field virt_text? render.md.MarkLine
23+
---@field virt_text_pos? 'eol'|'inline'|'overlay'
24+
---@field virt_lines? render.md.MarkLine[]
25+
1526
---@class (exact) render.md.Mark
16-
---@field public conceal boolean
17-
---@field public start_row integer
18-
---@field public start_col integer
19-
---@field public opts vim.api.keyset.set_extmark
27+
---@field conceal boolean
28+
---@field start_row integer
29+
---@field start_col integer
30+
---@field opts render.md.MarkOpts
2031

2132
---@class (exact) render.md.HandlerContext
22-
---@field public buf integer
23-
---@field public root TSNode
33+
---@field buf integer
34+
---@field root TSNode
2435

2536
---@class (exact) render.md.Handler
26-
---@field public extends? boolean
27-
---@field public parse fun(ctx: render.md.HandlerContext): render.md.Mark[]
37+
---@field extends? boolean
38+
---@field parse fun(ctx: render.md.HandlerContext): render.md.Mark[]
2839
```
2940

3041
The `parse` function takes a `ctx` parameter whose fields are:

doc/render-markdown.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2025 March 09
1+
*render-markdown.txt* For 0.10.0 Last change: 2025 March 10
22

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

lua/render-markdown/debug/marks.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local Iter = require('render-markdown.lib.iter')
22

33
---@class render.md.debug.Mark
44
---@field conceal boolean
5-
---@field opts vim.api.keyset.set_extmark
5+
---@field opts render.md.MarkOpts
66
---@field row { [1]: integer, [2]: integer }
77
---@field col { [1]: integer, [2]: integer }
88
local Mark = {}

lua/render-markdown/health.lua

+1-1
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.1.1'
8+
M.version = '8.1.2'
99

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

0 commit comments

Comments
 (0)