• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created about 3 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

nvim-cmp comparator function for completion items that start with one or more underlines

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

wbthomason/packer.nvim

-- init.lua
require("packer").startup(
    function()
        use "lukas-reineke/cmp-under-comparator"
    end
)

Example with Plug

junegunn/vim-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,
        },
    },
}