mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-03-30 18:01:52 +00:00
blink-cmp: apply Nix patch; use new fetcher (#714)
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Validate flake & check documentation / Validate Flake Documentation (push) Has been cancelled
Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Has been cancelled
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Check for typos in the source tree / check-typos (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Validate flake & check documentation / Validate Flake Documentation (push) Has been cancelled
Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Has been cancelled
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Check for typos in the source tree / check-typos (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
* blink-cmp: apply Nix patch; use new fetcher * completion/blink: don't break when modifying built-in sources.providers (#683) * completion/blink-cmp: add missing options **Blink breaks again, 11985891th recorded incident** --------- Co-authored-by: Alfarel <alfarelcynthesis@proton.me>
This commit is contained in:
parent
71081d084b
commit
a5dee946a9
4 changed files with 80 additions and 14 deletions
|
@ -244,8 +244,9 @@
|
||||||
syncing of nvim shell environment with direnv's.
|
syncing of nvim shell environment with direnv's.
|
||||||
- Add [blink.cmp] source options and some default-disabled sources.
|
- Add [blink.cmp] source options and some default-disabled sources.
|
||||||
- Add [blink.cmp] option to add
|
- Add [blink.cmp] option to add
|
||||||
[friendly-snippets](https://github.com/rafamadriz/friendly-snippets) so
|
[friendly-snippets](https://github.com/rafamadriz/friendly-snippets)
|
||||||
blink.cmp can source snippets from it.
|
so blink.cmp can source snippets from it.
|
||||||
|
- Fix [blink.cmp] breaking when built-in sources were modified.
|
||||||
|
|
||||||
[TheColorman](https://github.com/TheColorman):
|
[TheColorman](https://github.com/TheColorman):
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
git,
|
git,
|
||||||
src,
|
src,
|
||||||
version,
|
version,
|
||||||
|
fetchpatch,
|
||||||
}: let
|
}: let
|
||||||
blink-fuzzy-lib = rustPlatform.buildRustPackage {
|
blink-fuzzy-lib = rustPlatform.buildRustPackage {
|
||||||
pname = "blink-fuzzy-lib";
|
pname = "blink-fuzzy-lib";
|
||||||
|
@ -13,11 +14,10 @@
|
||||||
# TODO: remove this if plugin stops using nightly rust
|
# TODO: remove this if plugin stops using nightly rust
|
||||||
env.RUSTC_BOOTSTRAP = true;
|
env.RUSTC_BOOTSTRAP = true;
|
||||||
|
|
||||||
|
useFetchCargoVendor = true;
|
||||||
|
cargoHash = "sha256-F1wh/TjYoiIbDY3J/prVF367MKk3vwM7LqOpRobOs7I=";
|
||||||
|
|
||||||
nativeBuildInputs = [git];
|
nativeBuildInputs = [git];
|
||||||
cargoLock = {
|
|
||||||
lockFile = "${src}/Cargo.lock";
|
|
||||||
allowBuiltinFetchGit = true;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
libExt =
|
libExt =
|
||||||
|
@ -34,5 +34,19 @@ in
|
||||||
preInstall = ''
|
preInstall = ''
|
||||||
mkdir -p target/release
|
mkdir -p target/release
|
||||||
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
|
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
|
||||||
|
echo -n "nix" > target/release/version
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
# Borrowed from nixpkgs
|
||||||
|
# TODO: Remove this patch when updating to next version
|
||||||
|
patches = [
|
||||||
|
(fetchpatch {
|
||||||
|
name = "blink-add-bypass-for-nix.patch";
|
||||||
|
url = "https://github.com/Saghen/blink.cmp/commit/6c83ef1ae34abd7ef9a32bfcd9595ac77b61037c.diff?full_index=1";
|
||||||
|
hash = "sha256-304F1gDDKVI1nXRvvQ0T1xBN+kHr3jdmwMMp8CNl+GU=";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# Module for reproducing issues
|
||||||
|
nvimSkipModule = ["repro"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||||
inherit (lib.types) listOf str either attrsOf submodule enum anything int nullOr;
|
inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
|
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
|
||||||
inherit (lib.nvim.binds) mkMappingOption;
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
|
@ -21,8 +21,9 @@
|
||||||
freeformType = anything;
|
freeformType = anything;
|
||||||
options = {
|
options = {
|
||||||
module = mkOption {
|
module = mkOption {
|
||||||
type = str;
|
type = nullOr str;
|
||||||
description = "module of the provider";
|
default = null;
|
||||||
|
description = "Provider module.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -40,7 +41,7 @@ in {
|
||||||
providers = mkOption {
|
providers = mkOption {
|
||||||
type = attrsOf providerType;
|
type = attrsOf providerType;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Settings for completion providers";
|
description = "Settings for completion providers.";
|
||||||
};
|
};
|
||||||
|
|
||||||
transform_items = mkOption {
|
transform_items = mkOption {
|
||||||
|
@ -63,6 +64,12 @@ in {
|
||||||
default = [];
|
default = [];
|
||||||
description = "List of sources to enable for cmdline. Null means use default source list.";
|
description = "List of sources to enable for cmdline. Null means use default source list.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
keymap = mkOption {
|
||||||
|
type = keymapType;
|
||||||
|
default = {};
|
||||||
|
description = "blink.cmp cmdline keymap";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
completion = {
|
completion = {
|
||||||
|
@ -74,6 +81,16 @@ in {
|
||||||
description = "Delay before auto show triggers";
|
description = "Delay before auto show triggers";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
menu.auto_show = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Manages the appearance of the completion menu. You may prevent the menu
|
||||||
|
from automatically showing by this option to `false` and manually showing
|
||||||
|
it with the show keymap command.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
keymap = mkOption {
|
keymap = mkOption {
|
||||||
|
@ -103,7 +120,25 @@ in {
|
||||||
fuzzy = {
|
fuzzy = {
|
||||||
prebuilt_binaries = {
|
prebuilt_binaries = {
|
||||||
download = mkBool false ''
|
download = mkBool false ''
|
||||||
Auto-downloads prebuilt binaries. Do not enable, it doesn't work on nix
|
Auto-downloads prebuilt binaries.
|
||||||
|
|
||||||
|
::: .{warning}
|
||||||
|
Do not enable this option, as it does **not work** on Nix!
|
||||||
|
:::
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
implementation = mkOption {
|
||||||
|
type = enum ["lua" "prefer_rust" "rust" "prefer_rust_with_warning"];
|
||||||
|
default = "prefer_rust";
|
||||||
|
description = ''
|
||||||
|
fuzzy matcher implementation for Blink.
|
||||||
|
|
||||||
|
* `"lua"`: slower, Lua native fuzzy matcher implementation
|
||||||
|
* `"rust": use the SIMD fuzzy matcher, 'frizbee'
|
||||||
|
* `"prefer_rust"`: use the rust implementation, but fall back to lua
|
||||||
|
* `"prefer_rust_with_warning"`: use the rust implementation, and fall back to lua
|
||||||
|
if it is not available after emitting a warning.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -122,12 +157,14 @@ in {
|
||||||
sourcePlugins = let
|
sourcePlugins = let
|
||||||
sourcePluginType = submodule {
|
sourcePluginType = submodule {
|
||||||
options = {
|
options = {
|
||||||
|
enable = mkEnableOption "this source";
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = pluginType;
|
type = pluginType;
|
||||||
description = ''
|
description = ''
|
||||||
`blink-cmp` source plugin package.
|
`blink-cmp` source plugin package.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
module = mkOption {
|
module = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -136,7 +173,6 @@ in {
|
||||||
Should be present in the source's documentation.
|
Should be present in the source's documentation.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
enable = mkEnableOption "this source";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.attrsets) attrValues filterAttrs;
|
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
|
||||||
inherit (lib.lists) map optional;
|
inherit (lib.lists) map optional elem;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
|
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
|
||||||
|
|
||||||
|
@ -24,7 +24,22 @@
|
||||||
|
|
||||||
enabledBlinkSources = filterAttrs (_source: definition: definition.enable) cfg.sourcePlugins;
|
enabledBlinkSources = filterAttrs (_source: definition: definition.enable) cfg.sourcePlugins;
|
||||||
blinkSourcePlugins = map (definition: definition.package) (attrValues enabledBlinkSources);
|
blinkSourcePlugins = map (definition: definition.package) (attrValues enabledBlinkSources);
|
||||||
|
|
||||||
|
blinkBuiltins = [
|
||||||
|
"path"
|
||||||
|
"lsp"
|
||||||
|
"snippets"
|
||||||
|
"buffer"
|
||||||
|
"omni"
|
||||||
|
];
|
||||||
in {
|
in {
|
||||||
|
assertions =
|
||||||
|
mapAttrsToList (provider: definition: {
|
||||||
|
assertion = elem provider blinkBuiltins || definition.module != null;
|
||||||
|
message = "`config.vim.autocomplete.blink-cmp.setupOpts.sources.providers.${provider}.module` is `null`: non-builtin providers must set `module`.";
|
||||||
|
})
|
||||||
|
cfg.setupOpts.sources.providers;
|
||||||
|
|
||||||
vim = mkIf cfg.enable {
|
vim = mkIf cfg.enable {
|
||||||
startPlugins = ["blink-compat"] ++ blinkSourcePlugins ++ (optional cfg.friendly-snippets.enable "friendly-snippets");
|
startPlugins = ["blink-compat"] ++ blinkSourcePlugins ++ (optional cfg.friendly-snippets.enable "friendly-snippets");
|
||||||
lazy.plugins = {
|
lazy.plugins = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue