mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-08 13:13:55 +00:00
modules/languages: fix rust crates-nvim completion deprecation (#1247)
* modules/languages: fix rust crates-nvim deprecation move the completion into the lsp * plugins/languages: cleanup old FIXME, remove comments, complete completion config for crates-nvim * docs/rl: add entry for crates-nvim fix
This commit is contained in:
parent
f8dc16a29f
commit
e32bc41b85
3 changed files with 31 additions and 35 deletions
|
|
@ -69,7 +69,7 @@ isMaximal: {
|
||||||
typst.enable = isMaximal;
|
typst.enable = isMaximal;
|
||||||
rust = {
|
rust = {
|
||||||
enable = isMaximal;
|
enable = isMaximal;
|
||||||
crates.enable = isMaximal;
|
extensions.crates-nvim.enable = isMaximal;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Language modules that are not as common.
|
# Language modules that are not as common.
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,7 @@
|
||||||
- fix broken `neorg` grammars
|
- fix broken `neorg` grammars
|
||||||
- remove obsolete warning in the `otter` module
|
- remove obsolete warning in the `otter` module
|
||||||
- add mainProgram attribute to vala language server wrapper
|
- add mainProgram attribute to vala language server wrapper
|
||||||
|
- fix `crates-nvim`'s completions by using the in-program lsp
|
||||||
|
|
||||||
[JManch](https://github.com/JManch):
|
[JManch](https://github.com/JManch):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.attrsets) attrNames;
|
inherit (lib.attrsets) attrNames;
|
||||||
inherit (lib.types) bool package str listOf either enum;
|
inherit (lib.types) bool package str listOf either enum int;
|
||||||
inherit (lib.nvim.lua) expToLua toLuaObject;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption deprecatedSingleOrListOf;
|
||||||
|
|
@ -94,19 +94,26 @@ in {
|
||||||
enable = mkEnableOption "crates.io dependency management [crates-nvim]";
|
enable = mkEnableOption "crates.io dependency management [crates-nvim]";
|
||||||
|
|
||||||
setupOpts = mkPluginSetupOption "crates-nvim" {
|
setupOpts = mkPluginSetupOption "crates-nvim" {
|
||||||
completion.cmp.enable = mkOption {
|
lsp = {
|
||||||
type = bool;
|
enabled = mkEnableOption "crates.nvim's in-process language server" // {default = cfg.extensions.crates-nvim.enable;};
|
||||||
default = config.vim.autocomplete.nvim-cmp.enable;
|
actions = mkEnableOption "actions for crates-nvim's in-process language server" // {default = cfg.extensions.crates-nvim.enable;};
|
||||||
defaultText = "{option}`config.vim.autocomplete.nvim-cmp.enable`";
|
completion = mkEnableOption "completion for crates-nvim's in-process language server" // {default = cfg.extensions.crates-nvim.enable;};
|
||||||
description = ''
|
hover = mkEnableOption "hover actions for crates-nvim's in-process language server" // {default = cfg.extensions.crates-nvim.enable;};
|
||||||
Whether to add crates.nvim as a source for completion plugins. The following
|
};
|
||||||
plugins are supported by crates.nvim:
|
completion = {
|
||||||
|
crates = {
|
||||||
* nvim-cmp
|
enabled = mkEnableOption "completion for crates-nvim's in-process language server" // {default = cfg.extensions.crates-nvim.enable;};
|
||||||
* coq.nvim
|
max_results = mkOption {
|
||||||
|
description = "The maximum number of search results to display";
|
||||||
However nvf only supports auto-setup for nvim-cmp.
|
type = int;
|
||||||
'';
|
default = 8;
|
||||||
|
};
|
||||||
|
min_chars = mkOption {
|
||||||
|
description = "The minimum number of characters to type before completions begin appearing";
|
||||||
|
type = int;
|
||||||
|
default = 3;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -197,25 +204,13 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.extensions.crates-nvim.enable {
|
(mkIf cfg.extensions.crates-nvim.enable {
|
||||||
vim = let
|
vim = mkMerge [
|
||||||
withCompletion = cfg.extensions.crates-nvim.setupOpts.completion.cmp.enable;
|
|
||||||
in
|
|
||||||
mkMerge [
|
|
||||||
{
|
{
|
||||||
startPlugins = ["crates-nvim"];
|
startPlugins = ["crates-nvim"];
|
||||||
pluginRC.rust-crates = entryAnywhere ''
|
pluginRC.rust-crates = entryAnywhere ''
|
||||||
require("crates").setup(${toLuaObject cfg.extensions.crates-nvim.setupOpts})
|
require("crates").setup(${toLuaObject cfg.extensions.crates-nvim.setupOpts})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
# FIXME: this will not be necessary once crates.nvim creates a new release that
|
|
||||||
# ships improvements to the in-progress LSP module. If updating > 0.7.1, remember
|
|
||||||
# to update this section.
|
|
||||||
# See:
|
|
||||||
# <https://github.com/saecki/crates.nvim/wiki/Documentation-unstable#auto-completion>
|
|
||||||
(mkIf withCompletion {
|
|
||||||
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue