Skip to content

lukas-reineke/cmp-under-comparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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,
        },
    },
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages