Skip to content

Commit

Permalink
feat: support LSP item defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Oct 21, 2024
1 parent 3cb084c commit ffc4282
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/blink/cmp/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ function lsp:get_completions(context, callback)
end
end

-- add client_id to the items
-- add client_id and defaults to the items
for client_id, response in pairs(responses) do
local defaults = response.result and response.result.itemDefaults or {}
for _, item in ipairs(response.items) do
-- todo: terraform lsp doesn't return a .kind in situations like `toset`, is there a default value we need to grab?
-- it doesn't seem to return itemDefaults either
Expand All @@ -123,6 +124,11 @@ function lsp:get_completions(context, callback)

-- todo: make configurable
if item.deprecated or (item.tags and vim.tbl_contains(item.tags, 1)) then item.score_offset = -2 end

-- add defaults to the item
for key, value in pairs(defaults) do
item[key] = value
end
end
end

Expand Down

0 comments on commit ffc4282

Please sign in to comment.