How to show variables which are parameters first? #1834
Answered
by
Otterpatsch
Otterpatsch
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
Otterpatsch
Feb 21, 2024
Replies: 1 comment 2 replies
-
You can add a comparetor to pick them over other entries. local compare = require('cmp.config.compare')
compare.python_var = function(entry1, entry2)
if vim.o.filetype ~= "python" then
return
end
-- needed because cmp sometimes gives you the same entry and you must return nil in that case
if entry1:get_completion_item().label == entry2:get_completion_item().label then
return
end
if (entry1:get_completion_item().label:match("%w*=")) then
-- return true to pick entry1 over entry2
return true
end
end
require('cmp').setup({
...
sorting = {
sorting = {
comparators = compare
},
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for your fast answer combined with #156 (comment)
I think i got now what i wanted.