Skip to content

Commit 75cdf9d

Browse files
chore: generate docs for coq_nvim integration
1 parent ba251d6 commit 75cdf9d

File tree

4 files changed

+33
-42
lines changed

4 files changed

+33
-42
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ require('blink.cmp').setup({
149149
## coq_nvim
150150

151151
```lua
152-
require("render-markdown.integ.coq").setup()
152+
require('render-markdown.integ.coq').setup()
153153
```
154154

155155
# Setup

doc/render-markdown.txt

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Table of Contents *render-markdown-table-of-contents*
1414
6. Completions |render-markdown-completions|
1515
- nvim-cmp |render-markdown-completions-nvim-cmp|
1616
- blink.cmp |render-markdown-completions-blink.cmp|
17+
- coq_nvim |render-markdown-completions-coq_nvim|
1718
7. Setup |render-markdown-setup|
1819
- Headings |render-markdown-setup-headings|
1920
- Paragraphs |render-markdown-setup-paragraphs|
@@ -199,6 +200,13 @@ BLINK.CMP *render-markdown-completions-blink.cmp*
199200
<
200201

201202

203+
COQ_NVIM *render-markdown-completions-coq_nvim*
204+
205+
>lua
206+
require('render-markdown.integ.coq').setup()
207+
<
208+
209+
202210
==============================================================================
203211
7. Setup *render-markdown-setup*
204212

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.7.2'
7+
M.version = '7.7.3'
88

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

lua/render-markdown/integ/coq.lua

+23-40
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
local source = require('render-markdown.integ.source')
22

3-
local M = {}
4-
5-
---@class coq.Args
6-
---@field pos {[1]: integer, [2]:integer}
7-
---@field line string
8-
9-
---@class coq.CallbackArgs
10-
---@field isIncomplete boolean
11-
---@field items vim.lsp.CompletionResult
12-
13-
---@class coq.Source
14-
---@field name string
15-
---@field fn fun(args: coq.Args, callback: fun(args?: coq.CallbackArgs)): fun()|nil
16-
17-
---@alias coq.Sources table<integer, coq.Source>
18-
19-
---@param map coq.Sources
3+
---@param map table<integer, table>
4+
---@return integer
205
local function new_uid(map)
21-
local key ---@type integer|nil
6+
---@type integer|nil
7+
local key = nil
228
while true do
239
if not key or map[key] then
2410
key = math.floor(math.random() * 10000)
@@ -28,39 +14,36 @@ local function new_uid(map)
2814
end
2915
end
3016

17+
---@param args { line: string, pos: { [1]: integer, [2]: integer } }
18+
---@param callback fun(response?: lsp.CompletionItem[])
3119
local function complete(args, callback)
32-
if not source.enabled() then
33-
callback(nil)
34-
return
35-
end
36-
37-
local last_char = args.line:sub(#args.line, #args.line)
38-
if not vim.list_contains(source:trigger_characters(), last_char) then
39-
callback(nil)
40-
return
41-
end
42-
43-
local row, col = unpack(args.pos) ---@type integer, integer
44-
45-
local items = source.items(0, row, col)
46-
47-
if items == nil then
48-
callback(nil)
49-
return
20+
---@return lsp.CompletionItem[]?
21+
local function get_items()
22+
if not source.enabled() then
23+
return nil
24+
end
25+
local character = args.line:sub(#args.line, #args.line)
26+
if not vim.tbl_contains(source.trigger_characters(), character) then
27+
return nil
28+
end
29+
return source.items(0, args.pos[1], args.pos[2])
5030
end
51-
52-
callback(items)
31+
callback(get_items())
5332
end
5433

34+
---@class render.md.cmp.Coq
35+
local M = {}
36+
5537
---Should only be called by a user to enable the integration
5638
function M.setup()
5739
local has_coq = pcall(require, 'coq')
5840
if not has_coq then
5941
return
6042
end
61-
COQsources = COQsources or {} ---@type coq.Sources
43+
---@type table<integer, table>
44+
COQsources = COQsources or {}
6245
COQsources[new_uid(COQsources)] = {
63-
name = 'rMD',
46+
name = 'markdown',
6447
fn = complete,
6548
}
6649
end

0 commit comments

Comments
 (0)