Crate versions are lexicographically sorted in completion
Current behavior
The crates versions supplied to the completion are sorted lexicographically, which causes 0.1.9 to be given higher priority over 0.1.11 which is buries underneath the 0.1.1 version.
Expected behavior
The crates versions are returned in semantic version order, as the user most likely want't the most recent version when adding a crate.
E.g; 0.1.11, 0.1.10, 0.1.9 etc
Additional context/Screenshots
Neovim version
nvim --version
NVIM v0.10.0-dev-1769+g9dd48f783-Homebrew
Build type: Release
LuaJIT 2.1.0-beta3
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-9dd48f7/share/nvim"
Run :checkhealth for more info
I've also noticed that, but I'm not exactly sure what's the cause. We set sortText on versions and the client/completion provider is supposed to respect them. That used to work when I implemented it, but some time ago something broke.
Here is the line we set sortText:
https://github.com/Saecki/crates.nvim/blob/3648f8787656d7572740560331553abdaa8cb982/teal/crates/src/common.tl#L39
Here is the line nvim-cmp uses it to sort CompletionItems:
https://github.com/hrsh7th/nvim-cmp/blob/fc0f694af1a742ada77e5b1c91ff405c746f4a26/lua/cmp/config/compare.lua#L74
This needs some more investigation, I'll look into it sometime.
Found the issue, seems like the default config excludes scoring/sorting by sort_text:
https://github.com/hrsh7th/nvim-cmp/blob/fc0f694af1a742ada77e5b1c91ff405c746f4a26/lua/cmp/config/default.lua#L71
So whats the conclusion of this? Would it possible to patch cmp to enable sort_text or is there an other way?
I don't know, there is no answer to the issue I opened on the nvim-cmp repository. For now it seems like users will have to manually enable the sort_text comparator, if desired.
Thank you. Do you mind pasting the issue link in nvim-cmp here? Just for future reference
It's actually already linked above