Compare commits

..

1 commit

Author SHA1 Message Date
Ching Pei Yang
c7a66f0f8b
Merge b43c5f163c into 3a2edd1b75 2024-12-23 12:10:26 +03:00
5 changed files with 11 additions and 93 deletions

View file

@ -204,22 +204,6 @@
"type": "github"
}
},
"plugin-blink-compat": {
"flake": false,
"locked": {
"lastModified": 1734896240,
"narHash": "sha256-Rrrh+O3FbBnaAnCHwPuQyfhH+XueSkQp6ipEkn6esGY=",
"owner": "saghen",
"repo": "blink.compat",
"rev": "74b251a1e9478c4fa6d7c6bc2921d7124e6f6cbb",
"type": "github"
},
"original": {
"owner": "saghen",
"repo": "blink.compat",
"type": "github"
}
},
"plugin-bufdelete-nvim": {
"flake": false,
"locked": {
@ -2109,7 +2093,6 @@
"plugin-alpha-nvim": "plugin-alpha-nvim",
"plugin-base16": "plugin-base16",
"plugin-blink-cmp": "plugin-blink-cmp",
"plugin-blink-compat": "plugin-blink-compat",
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
"plugin-catppuccin": "plugin-catppuccin",
"plugin-ccc": "plugin-ccc",

View file

@ -293,11 +293,6 @@
flake = false;
};
plugin-blink-compat = {
url = "github:saghen/blink.compat";
flake = false;
};
plugin-nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;

View file

@ -1,9 +1,8 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) listOf str either attrsOf submodule enum anything int;
inherit (lib.types) listOf str either attrsOf submodule enum;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.config) mkBool;
keymapType = submodule {
freeformType = attrsOf (listOf (either str luaInline));
@ -15,16 +14,6 @@
};
};
};
providerType = submodule {
freeformType = anything;
options = {
module = mkOption {
type = str;
description = "module of the provider";
};
};
};
in {
options.vim.autocomplete.blink-cmp = {
enable = mkEnableOption "blink.cmp";
@ -32,25 +21,8 @@ in {
sources = {
default = mkOption {
type = listOf str;
default = ["lsp" "path" "snippets" "buffer"];
description = "Default list of sources to enable for completion.";
};
providers = mkOption {
type = attrsOf providerType;
default = {};
description = "Providers";
};
};
completion = {
documentation = {
auto_show = mkBool true "Show documentation whenever an item is selected";
auto_show_delay_ms = mkOption {
type = int;
default = 200;
description = "Delay before auto show triggers";
};
default = ["lsp" "path" "snippets" "buffer"];
};
};

View file

@ -3,57 +3,26 @@
config,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
cfg = config.vim.autocomplete.blink-cmp;
autocompleteCfg = config.vim.autocomplete;
inherit (cfg) mappings;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
in {
vim = mkIf cfg.enable {
startPlugins = ["blink-compat"];
lazy.plugins = {
blink-cmp = {
lazy.plugins.blink-cmp = {
package = "blink-cmp";
setupModule = "blink.cmp";
inherit (cfg) setupOpts;
# TODO: lazy disabled until lspconfig is lazy loaded
#
# event = ["InsertEnter" "CmdlineEnter"];
after = ''
${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
autocompleteCfg.sourcePlugins))}
'';
};
};
autocomplete = {
enableSharedCmpSources = true;
blink-cmp.setupOpts = {
sources = {
default = ["lsp" "path" "snippets" "buffer"] ++ (attrNames autocompleteCfg.nvim-cmp.sources);
providers =
mapAttrs (name: _: {
inherit name;
module = "blink.compat.source";
})
autocompleteCfg.nvim-cmp.sources;
};
snippets = mkIf config.vim.snippets.luasnip.enable {
expand = mkLuaInline ''
function(snippet)

View file

@ -20,8 +20,7 @@ in {
vim = {
startPlugins = ["nvim-treesitter"];
# cmp-treesitter doesn't work on blink.cmp
autocomplete = mkIf config.vim.autocomplete.nvim-cmp.enable {
autocomplete = {
nvim-cmp.sources = {treesitter = "[Treesitter]";};
sourcePlugins = ["cmp-treesitter"];
};