Skip to content

Commit c00cc1e

Browse files
feat: handle all list marker types in completions
## Details In completion node type check include all valid unordered list marker types instead of only the minus marker. Include the marker characters in the trigger characters list, there will be a future improvement to add the markers if they are missing but triggering off of them shouldn't be a problem, though there could be a missing space. Use the inline code highlight for padding instead of the normal padding.
1 parent 65b263d commit c00cc1e

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

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 = '7.7.8'
8+
M.version = '7.7.9'
99

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

lua/render-markdown/integ/cmp.lua

+1-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ end
2323
function Source:complete(params, callback)
2424
local context = params.context
2525
local items = source.items(context.bufnr, context.cursor.row - 1, context.cursor.col - 1)
26-
if items == nil then
27-
callback(nil)
28-
else
29-
callback(items)
30-
end
26+
callback(items)
3127
end
3228

3329
---@class render.md.integ.Cmp

lua/render-markdown/integ/source.lua

+12-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ local manager = require('render-markdown.manager')
22
local state = require('render-markdown.state')
33
local util = require('render-markdown.core.util')
44

5+
local list_markers = {
6+
'list_marker_minus',
7+
'list_marker_star',
8+
'list_marker_plus',
9+
}
10+
511
---@class render.md.Source
612
local M = {}
713

@@ -12,29 +18,26 @@ end
1218

1319
---@return string[]
1420
function M.trigger_characters()
15-
return { ' ', '[' }
21+
return { '-', '*', '+', '>', ' ', '[' }
1622
end
1723

1824
---@param buf integer
1925
---@param row integer
2026
---@param col integer
2127
---@return lsp.CompletionItem[]?
2228
function M.items(buf, row, col)
23-
local node = vim.treesitter.get_node({
24-
bufnr = buf,
25-
pos = { row, col },
26-
})
29+
local node = vim.treesitter.get_node({ bufnr = buf, pos = { row, col } })
2730
if node == nil then
2831
return nil
2932
end
30-
local node_type = node:type()
31-
local config = state.get(buf)
33+
3234
local items = {}
33-
if vim.tbl_contains({ 'block_quote', 'block_quote_marker' }, node_type) then
35+
local config = state.get(buf)
36+
if vim.tbl_contains({ 'block_quote', 'block_quote_marker' }, node:type()) then
3437
for _, component in pairs(config.callout) do
3538
table.insert(items, M.item(component.raw, component.rendered, nil))
3639
end
37-
elseif vim.tbl_contains({ 'list_item', 'list_marker_minus' }, node_type) then
40+
elseif node:type() == 'list_item' or vim.tbl_contains(list_markers, node:type()) then
3841
local checkbox = config.checkbox
3942
table.insert(items, M.item('[ ]', checkbox.unchecked.icon, 'unchecked'))
4043
table.insert(items, M.item('[x]', checkbox.checked.icon, 'checked'))

lua/render-markdown/render/code_inline.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ end
2626
---@param row integer
2727
---@param col integer
2828
function Render:side_padding(row, col)
29-
local padding = self.code.inline_pad
29+
local padding, highlight = self.code.inline_pad, self.code.highlight_inline
3030
if padding > 0 then
3131
self.marks:add(true, row, col, {
3232
priority = 0,
33-
virt_text = { self:padding_text(padding) },
33+
virt_text = { self:padding_text(padding, highlight) },
3434
virt_text_pos = 'inline',
3535
})
3636
end

0 commit comments

Comments
 (0)