feat: refactor and separate LSP/language configurations

This commit is contained in:
NotAShelf 2023-04-17 23:27:27 +03:00
commit 6b512f132a
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
30 changed files with 1266 additions and 522 deletions

View file

@ -1,4 +1,5 @@
{
pkgs,
lib,
config,
...
@ -6,15 +7,22 @@
with lib;
with builtins; let
cfg = config.vim.autocomplete;
builtSources =
concatMapStringsSep "\n" (x: "{ name = '${x}'},") cfg.sources;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"vim-vsnip"
"nvim-cmp"
"cmp-buffer"
"cmp-vsnip"
"cmp-path"
"cmp-treesitter"
];
vim.autocomplete.sources = [
"nvim-cmp"
"vsnip"
"buffer"
"path"
];
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (nvim.dag.entryAnywhere ''
@ -35,12 +43,7 @@ in {
end,
},
sources = {
${optionalString (config.vim.lsp.enable) "{ name = 'nvim_lsp' },"}
${optionalString (config.vim.lsp.rust.enable) "{ name = 'crates' },"}
{ name = 'vsnip' },
{ name = 'treesitter' },
{ name = 'path' },
{ name = 'buffer' },
${builtSources}
},
mapping = {
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),

View file

@ -1,16 +1,21 @@
{
pkgs,
lib,
config,
...
}:
with lib;
with builtins; {
with builtins; let
cfg = config.vim.autocomplete;
builtSources =
concatMapStringsSep "\n" (x: "{ name = '${x}'},") cfg.sources;
in {
options.vim = {
autocomplete = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable autocomplete via nvim-cmp";
description = "enable autocomplete";
};
type = mkOption {
@ -18,6 +23,12 @@ with builtins; {
default = "nvim-cmp";
description = "Set the autocomplete plugin. Options: [nvim-cmp]";
};
sources = mkOption {
description = "List of source names for nvim-cmp";
type = with types; listOf str;
default = [];
};
};
};
}