-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
local utils = require("colorful-menu.utils") | ||
local Kind = require("colorful-menu").Kind | ||
local config = require("colorful-menu").config | ||
|
||
local M = {} | ||
|
||
---@param completion_item lsp.CompletionItem | ||
---@param ls string | ||
---@return CMHighlights | ||
function M.roslyn(completion_item, ls) | ||
local label = completion_item.label | ||
local description = completion_item.labelDetails and completion_item.labelDetails.description | ||
local kind = completion_item.kind | ||
|
||
local text = label | ||
|
||
if not kind then | ||
return utils.highlight_range(text, ls, 0, #text) | ||
end | ||
|
||
local highlight_name | ||
if kind == Kind.Class or kind == Kind.Interface or kind == Kind.Enum then | ||
highlight_name = "@type" | ||
elseif kind == Kind.Constructor then | ||
highlight_name = "@type" | ||
elseif kind == Kind.Constant then | ||
highlight_name = "@constant" | ||
elseif kind == Kind.Function or kind == Kind.Method then | ||
highlight_name = "@function" | ||
elseif kind == Kind.Property or kind == Kind.Field then | ||
highlight_name = "@property" | ||
elseif kind == Kind.Variable then | ||
highlight_name = "@variable" | ||
else | ||
highlight_name = config.fallback_highlight | ||
end | ||
|
||
local highlights = { | ||
{ | ||
highlight_name, | ||
range = { 0, #label }, | ||
}, | ||
} | ||
|
||
if description then | ||
text = label .. " " .. description | ||
table.insert(highlights, { | ||
config.ls.roslyn.extra_info_hl, | ||
range = { #label + 1, #text }, | ||
}) | ||
end | ||
|
||
return { | ||
text = text, | ||
highlights = highlights, | ||
} | ||
end | ||
|
||
return M |