From 679a4bf80431c9cad6b2d457748816bc4876bf15 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 22 Feb 2026 21:28:53 -0500 Subject: [PATCH] fix: capture inline description for keywords like Host and User 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. --- lua/blink-cmp-ssh.lua | 6 +++++- spec/ssh_spec.lua | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lua/blink-cmp-ssh.lua b/lua/blink-cmp-ssh.lua index 9297dd7..64b7288 100644 --- a/lua/blink-cmp-ssh.lua +++ b/lua/blink-cmp-ssh.lua @@ -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 diff --git a/spec/ssh_spec.lua b/spec/ssh_spec.lua index 9a88a2a..f5d2f97 100644 --- a/spec/ssh_spec.lua +++ b/spec/ssh_spec.lua @@ -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()