Skip to content

Commit

Permalink
Improve label creation
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Aug 20, 2022
1 parent 57c4db7 commit 3dd4009
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/cmp_nvim_lsp_signature_help/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ source._item = function(self, signature, parameter_index)
return nil
end

local label = table.concat(arguments, ', ')
return {
label = table.concat(arguments, ', '),
label = label,
filterText = ' ',
insertText = '',
preselect = 1,
insertText = self:_matchstr(label, [[\k\+]]),
preselect = true,
documentation = self:_docs(signature, parameter_index),
}
end
Expand Down Expand Up @@ -204,4 +205,12 @@ source._get = function(_, root, paths)
return c
end

source._matchstr = function(_, str, pattern)
local s, e = vim.regex(pattern):match_str(str)
if s and e then
return string.sub(str, s+1, e)
end
return ''
end

return source

0 comments on commit 3dd4009

Please sign in to comment.