fix: capture inline description for keywords like Host and User
Some checks are pending
quality / changes (push) Waiting to run
quality / Lua Format Check (push) Blocked by required conditions
quality / Lua Lint Check (push) Blocked by required conditions
quality / Lua Type Check (push) Blocked by required conditions
quality / Markdown Format Check (push) Blocked by required conditions
test / Test (Neovim nightly) (push) Waiting to run
test / Test (Neovim stable) (push) Waiting to run

Problem: keywords with description text on the same line (e.g.
"Host    Restricts the following...") had their first line of
documentation silently dropped because the parser started collecting
at the line after the keyword.

Solution: extract trailing text from the keyword line and prepend it
to the description block.
This commit is contained in:
Barrett Ruth 2026-02-22 21:28:53 -05:00
parent ff0b4ee048
commit 679a4bf804
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 20 additions and 1 deletions

View file

@ -96,7 +96,8 @@ local function parse_keywords(stdout)
for i, line in ipairs(lines) do
local kw = line:match('^ (%u%a+)%s*$') or line:match('^ (%u%a+) ')
if kw then
defs[#defs + 1] = { line = i, keyword = kw }
local inline = line:match('^ %u%a+%s%s%s+(.+)')
defs[#defs + 1] = { line = i, keyword = kw, inline = inline }
end
end
@ -105,6 +106,9 @@ local function parse_keywords(stdout)
local block_end = (defs[idx + 1] and defs[idx + 1].line or #lines) - 1
local desc_lines = {}
if def.inline then
desc_lines[#desc_lines + 1] = ' ' .. def.inline
end
for k = def.line + 1, block_end do
desc_lines[#desc_lines + 1] = lines[k]
end

View file

@ -146,6 +146,21 @@ describe('blink-cmp-ssh', function()
assert.is_truthy(strict.documentation.value:find('known_hosts'))
end)
it('includes inline description for keywords with text on the same line', function()
restores[#restores + 1] = mock_system()
local source = require('blink-cmp-ssh').new()
local items
source:get_completions({ line = '', cursor = { 1, 0 } }, function(response)
items = response.items
end)
local host = vim.iter(items):find(function(item)
return item.label == 'Host'
end)
assert.is_not_nil(host)
assert.is_not_nil(host.documentation)
assert.is_truthy(host.documentation.value:find('Restricts'))
end)
it('returns enum values after a known keyword', function()
restores[#restores + 1] = mock_system()
local source = require('blink-cmp-ssh').new()