Skip to content

How to show variables which are parameters first? #1834

Answered by Otterpatsch
Otterpatsch asked this question in Q&A
Discussion options

You must be logged in to vote

thank you for your fast answer combined with #156 (comment)
I think i got now what i wanted.

local lspkind_comparator = function(conf)
	local lsp_types = require("cmp.types").lsp
	return function(entry1, entry2)
		if entry1.source.name ~= "nvim_lsp" then
			if entry2.source.name == "nvim_lsp" then
				return false
			else
				return nil
			end
		end
		local kind1 = lsp_types.CompletionItemKind[entry1:get_kind()]
		local kind2 = lsp_types.CompletionItemKind[entry2:get_kind()]
		if kind1 == "Variable" and entry1:get_completion_item().label:match("%w*=") then
			kind1 = "Parameter"
		end
		if kind2 == "Variable" and entry2:get_completion_item().label:match("%w*=") then
			kind2 = "Parameter"
		

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Otterpatsch
Comment options

Answer selected by Otterpatsch
@LZDQ
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants