mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-23 13:50:44 +00:00
nvim-cmp: move text and snippet completions to the bottom
This doesn't guarantee that snippets will be above text completions, but that should still be the case, since the `kind` comparator sorts snippets above text.
This commit is contained in:
parent
af9f09762a
commit
3dfd83f389
2 changed files with 22 additions and 0 deletions
|
@ -42,6 +42,20 @@ in {
|
||||||
after = ''
|
after = ''
|
||||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
local kinds = require("cmp.types").lsp.CompletionItemKind
|
||||||
|
local deprio = function(kind)
|
||||||
|
return function(e1, e2)
|
||||||
|
if e1:get_kind() == kind then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if e2:get_kind() == kind then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
|
||||||
${optionalString config.vim.lazy.enable
|
${optionalString config.vim.lazy.enable
|
||||||
|
|
|
@ -29,6 +29,8 @@ in {
|
||||||
sorting.comparators = mkOption {
|
sorting.comparators = mkOption {
|
||||||
type = mergelessListOf (either str luaInline);
|
type = mergelessListOf (either str luaInline);
|
||||||
default = [
|
default = [
|
||||||
|
(mkLuaInline "deprio(kinds.Text)")
|
||||||
|
(mkLuaInline "deprio(kinds.Snippet)")
|
||||||
"offset"
|
"offset"
|
||||||
"exact"
|
"exact"
|
||||||
"score"
|
"score"
|
||||||
|
@ -43,6 +45,12 @@ in {
|
||||||
(see `:help cmp-config.sorting.comparators`),
|
(see `:help cmp-config.sorting.comparators`),
|
||||||
or a string, in which case the builtin comparator with that name will
|
or a string, in which case the builtin comparator with that name will
|
||||||
be used.
|
be used.
|
||||||
|
|
||||||
|
A `deprio` function and a `kinds`
|
||||||
|
(`require("cmp.types").lsp.CompletionItemKind`) variable is provided
|
||||||
|
above `setupOpts`. By passing a type to the funcion, the returned
|
||||||
|
funciton will be a comparator that always ranks the specified kind the
|
||||||
|
lowest.
|
||||||
'';
|
'';
|
||||||
apply = map (
|
apply = map (
|
||||||
c:
|
c:
|
||||||
|
|
Loading…
Reference in a new issue