Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit b2a377d

Browse files
committed
feat: buffer customize lsp label
1 parent 226f3dd commit b2a377d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lua/completion.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ M.completionToggle = function()
159159
end
160160
end
161161

162+
M.customisze_buf_label = function(label)
163+
api.nvim_buf_set_var(0, "completion_buf_customize_lsp_label", label)
164+
end
165+
162166
M.on_attach = function()
163167
hover.modifyCallback()
164168
api.nvim_command [[augroup CompletionCommand]]

lua/completion/util.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@ end
4646

4747
function M.text_document_completion_list_to_complete_items(result, prefix)
4848
local items = vim.lsp.util.extract_completion_items(result)
49-
local customize_label = vim.g.completion_customize_lsp_label
5049
if vim.tbl_isempty(items) then
5150
return {}
5251
end
5352

53+
local customize_label = vim.g.completion_customize_lsp_label
54+
local buf_customize_label = api.nvim_call_function(
55+
'completion#get_buffer_variable', {'completion_buf_customize_lsp_label'})
56+
if buf_customize_label == nil then buf_customize_label = {} end
57+
5458
items = remove_unmatch_completion_items(items, prefix)
5559
-- sort_completion_items(items)
5660

@@ -83,7 +87,7 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
8387
table.insert(matches, {
8488
word = word,
8589
abbr = completion_item.label,
86-
kind = customize_label[kind] or kind or '',
90+
kind = buf_customize_label[kind] or customize_label[kind] or kind or '',
8791
menu = completion_item.detail or '',
8892
info = info,
8993
priority = priority,

0 commit comments

Comments
 (0)