cmp-under-comparator
A tiny function for nvim-cmp to better sort completion items that start with one or more underlines.
In most languages, especially Python, items that start with one or more underlines should be at the end of the completion suggestion.
Before | After |
---|---|
Install
Use your favourite plugin manager to install.
Example with Packer
-- init.lua
require("packer").startup(
function()
use "lukas-reineke/cmp-under-comparator"
end
)
Example with Plug
" init.vim
call plug#begin('~/.vim/plugged')
Plug 'lukas-reineke/cmp-under-comparator'
call plug#end()
Setup
Add the under
function to the list of comparators in the cmp setup function.
local cmp = require "cmp"
cmp.setup {
-- ... rest of your setup ...
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
require "cmp-under-comparator".under,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
}