Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukas-reineke/cmp-under-comparator
nvim-cmp comparator function for completion items that start with one or more underlines
https://github.com/lukas-reineke/cmp-under-comparator
neovim neovim-plugin nvim-cmp vim vim-plugin
Last synced: about 1 month ago
JSON representation
nvim-cmp comparator function for completion items that start with one or more underlines
- Host: GitHub
- URL: https://github.com/lukas-reineke/cmp-under-comparator
- Owner: lukas-reineke
- License: mit
- Created: 2021-10-22T15:25:53.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-04T08:38:10.000Z (almost 3 years ago)
- Last Synced: 2024-10-26T14:34:02.950Z (about 2 months ago)
- Topics: neovim, neovim-plugin, nvim-cmp, vim, vim-plugin
- Language: Lua
- Homepage:
- Size: 4.88 KB
- Stars: 185
- Watchers: 7
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
- awesome-neovim - lukas-reineke/cmp-under-comparator - A nvim-cmp function for better sorting. (Completion / (requires Neovim 0.5))
README
# cmp-under-comparator
A tiny function for [nvim-cmp](https://github.com/hrsh7th/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 |
| :--------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------: |
| ![](https://user-images.githubusercontent.com/12900252/138484425-93c14853-d45f-42e2-a5b8-8deaaa748330.png) | ![](https://user-images.githubusercontent.com/12900252/138484481-212b2478-c427-48b4-bc9f-0c0098be04b9.png) |## Install
Use your favourite plugin manager to install.
#### Example with Packer
[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
-- init.lua
require("packer").startup(
function()
use "lukas-reineke/cmp-under-comparator"
end
)
```#### Example with Plug
[junegunn/vim-plug](https://github.com/junegunn/vim-plug)
```vim
" 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.
```lua
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,
},
},
}
```