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()