mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-09 16:39:51 +01:00
completion: migrate to shared cmp source options
This commit is contained in:
parent
593ac3b751
commit
0d0c885d70
8 changed files with 75 additions and 67 deletions
|
@ -58,8 +58,8 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete = {
|
||||||
sources = {copilot = "[Copilot]";};
|
nvim-cmp.sources = {copilot = "[Copilot]";};
|
||||||
sourcePlugins = ["copilot-cmp"];
|
sourcePlugins = ["copilot-cmp"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
borders = config.vim.ui.borders.plugins.nvim-cmp;
|
borders = config.vim.ui.borders.plugins.nvim-cmp;
|
||||||
|
|
||||||
cfg = config.vim.autocomplete.nvim-cmp;
|
cfg = config.vim.autocomplete.nvim-cmp;
|
||||||
|
autocompleteCfg = config.vim.autocomplete;
|
||||||
luasnipEnable = config.vim.snippets.luasnip.enable;
|
luasnipEnable = config.vim.snippets.luasnip.enable;
|
||||||
getPluginName = plugin:
|
getPluginName = plugin:
|
||||||
if typeOf plugin == "string"
|
if typeOf plugin == "string"
|
||||||
|
@ -23,8 +24,6 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
autocomplete.enableSharedCmpSources = true;
|
|
||||||
|
|
||||||
lazy.plugins = {
|
lazy.plugins = {
|
||||||
nvim-cmp = {
|
nvim-cmp = {
|
||||||
package = "nvim-cmp";
|
package = "nvim-cmp";
|
||||||
|
@ -50,22 +49,24 @@ in {
|
||||||
${optionalString config.vim.lazy.enable
|
${optionalString config.vim.lazy.enable
|
||||||
(concatStringsSep "\n" (map
|
(concatStringsSep "\n" (map
|
||||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||||
cfg.sourcePlugins))}
|
autocompleteCfg.sourcePlugins))}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
event = ["InsertEnter" "CmdlineEnter"];
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete = {
|
||||||
|
enableSharedCmpSources = true;
|
||||||
|
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||||
|
|
||||||
|
nvim-cmp = {
|
||||||
sources = {
|
sources = {
|
||||||
nvim-cmp = null;
|
nvim-cmp = null;
|
||||||
buffer = "[Buffer]";
|
buffer = "[Buffer]";
|
||||||
path = "[Path]";
|
path = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
|
||||||
|
|
||||||
setupOpts = {
|
setupOpts = {
|
||||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||||
|
|
||||||
|
@ -123,4 +124,5 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ in {
|
||||||
options.vim.autocomplete = {
|
options.vim.autocomplete = {
|
||||||
enableSharedCmpSources = mkEnableOption "cmp sources shared by nvim-cmp and blink.cmp";
|
enableSharedCmpSources = mkEnableOption "cmp sources shared by nvim-cmp and blink.cmp";
|
||||||
|
|
||||||
cmpSourcePlugins = mkOption {
|
sourcePlugins = mkOption {
|
||||||
type = listOf pluginType;
|
type = listOf pluginType;
|
||||||
default = [];
|
default = [];
|
||||||
description = "List of cmp source plugins.";
|
description = "List of cmp source plugins.";
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
||||||
|
usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable;
|
||||||
self = import ./module.nix {inherit config lib pkgs;};
|
self = import ./module.nix {inherit config lib pkgs;};
|
||||||
|
|
||||||
mappingDefinitions = self.options.vim.lsp.mappings;
|
mappingDefinitions = self.options.vim.lsp.mappings;
|
||||||
|
@ -22,8 +23,8 @@
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete = mkIf usingNvimCmp {
|
||||||
sources = {nvim_lsp = "[LSP]";};
|
nvim-cmp.sources = {nvim_lsp = "[LSP]";};
|
||||||
sourcePlugins = ["cmp-nvim-lsp"];
|
sourcePlugins = ["cmp-nvim-lsp"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -170,6 +171,10 @@ in {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
${optionalString usingBlinkCmp ''
|
||||||
|
-- TODO
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.lsp.lspkind;
|
cfg = config.vim.lsp.lspkind;
|
||||||
|
inherit (config.vim) autocomplete;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = config.vim.autocomplete.nvim-cmp.enable;
|
assertion = autocomplete.nvim-cmp.enable || autocomplete.blink-cmp.enable;
|
||||||
message = ''
|
message = ''
|
||||||
While lspkind supports Neovim's native lsp upstream, using that over
|
While lspkind supports Neovim's native lsp upstream, using that over
|
||||||
nvim-cmp isn't recommended, nor supported by nvf.
|
nvim-cmp isn't recommended, nor supported by nvf.
|
||||||
|
|
|
@ -48,7 +48,7 @@ in {
|
||||||
# If using nvim-cmp, otherwise set to false
|
# If using nvim-cmp, otherwise set to false
|
||||||
type = bool;
|
type = bool;
|
||||||
description = "If using nvim-cmp, otherwise set to false";
|
description = "If using nvim-cmp, otherwise set to false";
|
||||||
default = config.vim.autocomplete.nvim-cmp.enable;
|
default = config.vim.autocomplete.enableSharedCmpSources;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,8 +17,8 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
startPlugins = cfg.providers;
|
startPlugins = cfg.providers;
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete = {
|
||||||
sources = {luasnip = "[LuaSnip]";};
|
nvim-cmp.sources = {luasnip = "[LuaSnip]";};
|
||||||
sourcePlugins = ["cmp-luasnip"];
|
sourcePlugins = ["cmp-luasnip"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,8 +20,8 @@ in {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["nvim-treesitter"];
|
startPlugins = ["nvim-treesitter"];
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete = {
|
||||||
sources = {treesitter = "[Treesitter]";};
|
nvim-cmp.sources = {treesitter = "[Treesitter]";};
|
||||||
sourcePlugins = ["cmp-treesitter"];
|
sourcePlugins = ["cmp-treesitter"];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue