mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-07 08:59:50 +01:00
Compare commits
5 commits
b43c5f163c
...
2dc1a7fd19
Author | SHA1 | Date | |
---|---|---|---|
|
2dc1a7fd19 | ||
|
cb739be3fc | ||
|
03359ac3c6 | ||
|
5af402af98 | ||
|
1f82c55cd9 |
5 changed files with 93 additions and 11 deletions
17
flake.lock
17
flake.lock
|
@ -204,6 +204,22 @@
|
|||
"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": {
|
||||
|
@ -2093,6 +2109,7 @@
|
|||
"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",
|
||||
|
|
|
@ -293,6 +293,11 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-blink-compat = {
|
||||
url = "github:saghen/blink.compat";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-nvim-cmp = {
|
||||
url = "github:hrsh7th/nvim-cmp";
|
||||
flake = false;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||
inherit (lib.types) listOf str either attrsOf submodule enum;
|
||||
inherit (lib.types) listOf str either attrsOf submodule enum anything int;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
keymapType = submodule {
|
||||
freeformType = attrsOf (listOf (either str luaInline));
|
||||
|
@ -14,6 +15,16 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
providerType = submodule {
|
||||
freeformType = anything;
|
||||
options = {
|
||||
module = mkOption {
|
||||
type = str;
|
||||
description = "module of the provider";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.autocomplete.blink-cmp = {
|
||||
enable = mkEnableOption "blink.cmp";
|
||||
|
@ -21,8 +32,25 @@ in {
|
|||
sources = {
|
||||
default = mkOption {
|
||||
type = listOf str;
|
||||
description = "Default list of sources to enable for completion.";
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -3,26 +3,57 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.strings) optionalString;
|
||||
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 {
|
||||
lazy.plugins.blink-cmp = {
|
||||
package = "blink-cmp";
|
||||
setupModule = "blink.cmp";
|
||||
inherit (cfg) setupOpts;
|
||||
# TODO: lazy disabled until lspconfig is lazy loaded
|
||||
#
|
||||
# event = ["InsertEnter" "CmdlineEnter"];
|
||||
startPlugins = ["blink-compat"];
|
||||
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)
|
||||
|
|
|
@ -20,7 +20,8 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["nvim-treesitter"];
|
||||
|
||||
autocomplete = {
|
||||
# cmp-treesitter doesn't work on blink.cmp
|
||||
autocomplete = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
||||
nvim-cmp.sources = {treesitter = "[Treesitter]";};
|
||||
sourcePlugins = ["cmp-treesitter"];
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue