Compare commits

...

25 commits

Author SHA1 Message Date
Ching Pei Yang
c2185f25df
blink: disable cmdline completion 2024-12-26 05:46:07 +01:00
Ching Pei Yang
fb91b1bbaa
blink: do not inherit vim's lsp capabilities 2024-12-26 05:46:07 +01:00
Ching Pei Yang
90cb9b7293
lspsignature: add assertion against blink.cmp 2024-12-26 05:46:07 +01:00
Ching Pei Yang
af67523642
docs: udpate release notes 2024-12-26 05:46:06 +01:00
Ching Pei Yang
a0d75f9182
blink: auto-show docs by default 2024-12-26 05:46:06 +01:00
Ching Pei Yang
57a6abc063
blink: re-add default sources to cmp ones 2024-12-26 05:46:06 +01:00
Ching Pei Yang
4fd2ded18a
treesitter-cmp: disable on blink.cmp 2024-12-26 05:46:06 +01:00
Ching Pei Yang
1f8b49bcef
blink: add blink.compat support 2024-12-26 05:46:06 +01:00
Ching Pei Yang
9f6f191e07
flake: add blink.compat 2024-12-26 05:46:06 +01:00
Ching Pei Yang
244a560922
blink: disable lazy-loading 2024-12-26 05:46:06 +01:00
Ching Pei Yang
ddabc26c33
lsp: use blink.cmp capabilities 2024-12-26 05:46:05 +01:00
Ching Pei Yang
63ea5bd71f
blink: keymap wrapper 2024-12-26 05:46:05 +01:00
Ching Pei Yang
e2de9a1e27
blink: add luasnip integration 2024-12-26 05:46:05 +01:00
Ching Pei Yang
e280cdc8f3
blink: basic keymap option 2024-12-26 05:46:05 +01:00
Ching Pei Yang
8897e164ba
flake: add plugin blink.cmp 2024-12-26 05:46:05 +01:00
Ching Pei Yang
6e3c9cbc1e
completion: migrate to shared cmp source options 2024-12-26 05:46:05 +01:00
Ching Pei Yang
cb136a9485
cmp: move source plugin into parent option 2024-12-26 05:46:04 +01:00
Ching Pei Yang
05e5f5e399
blink: init 2024-12-26 05:46:04 +01:00
raf
aa1754d5cc
Merge pull request #513 from diniamo/update-run
flake: update run.nvim
2024-12-25 18:19:36 +03:00
diniamo
672630f680 flake: update run.nvim 2024-12-25 15:11:29 +01:00
raf
7dd2026b9d
Merge pull request #512 from diniamo/nvim-notify-explicit-function
nvim-notify: use explicit function for vim.notify
2024-12-25 00:52:53 +03:00
raf
edc887f0e3
Merge branch 'main' into nvim-notify-explicit-function 2024-12-25 00:51:18 +03:00
diniamo
a34d104e3f
languages/zig: disable lsp autosave (#511) 2024-12-24 14:19:08 +03:00
diniamo
f6a8cd968e nvim-notify: use explicit function for vim.notify 2024-12-24 11:43:23 +01:00
DamitusThyYeetus123
3a2edd1b75
filetree/nvim-tree: Open on directory (#462)
* nvim-tree: Add directory opening

* formatting

* Fix formatting

* format

Co-authored-by: raf <raf@notashelf.dev>

---------

Co-authored-by: Ching Pei Yang <59727193+horriblename@users.noreply.github.com>
Co-authored-by: raf <raf@notashelf.dev>
2024-12-23 08:56:19 +00:00
23 changed files with 483 additions and 133 deletions

View file

@ -15,6 +15,15 @@
- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]. - Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim].
[horriblename](https://github.com/horriblename):
[blink.cmp]: https://github.com/saghen/blink.cmp
- Add [blink.cmp] support
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
- Add Odin support under `vim.languages.odin`. - Add Odin support under `vim.languages.odin`.
- Disable the built-in format-on-save feature of zls. Use `vim.lsp.formatOnSave`
instead.

View file

@ -188,6 +188,38 @@
"type": "github" "type": "github"
} }
}, },
"plugin-blink-cmp": {
"flake": false,
"locked": {
"lastModified": 1734880418,
"narHash": "sha256-jR9fvo+I51DKYQb+N3nFvQ50N+lvYzfFaQtrn7cxDu4=",
"owner": "saghen",
"repo": "blink.cmp",
"rev": "f93af0f486ada13e8c34f42c911788b9232b811f",
"type": "github"
},
"original": {
"owner": "saghen",
"repo": "blink.cmp",
"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": { "plugin-bufdelete-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1729,11 +1761,11 @@
"plugin-run-nvim": { "plugin-run-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1734816675, "lastModified": 1735130195,
"narHash": "sha256-Wuk5HG+vHXAbifzp5YB5V/FxBhBRNWLeypkRczpXbvQ=", "narHash": "sha256-OaOSYyXSNCl9kJJVKhy0L4M06CQFc0NtZ8+AIgKBPik=",
"owner": "diniamo", "owner": "diniamo",
"repo": "run.nvim", "repo": "run.nvim",
"rev": "6cd971afdce6443d7a070dcc23af51da1cc932f9", "rev": "5888f31c5faf4776e598c0665470f5445510c59e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -2076,6 +2108,8 @@
"nmd": "nmd", "nmd": "nmd",
"plugin-alpha-nvim": "plugin-alpha-nvim", "plugin-alpha-nvim": "plugin-alpha-nvim",
"plugin-base16": "plugin-base16", "plugin-base16": "plugin-base16",
"plugin-blink-cmp": "plugin-blink-cmp",
"plugin-blink-compat": "plugin-blink-compat",
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim", "plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
"plugin-catppuccin": "plugin-catppuccin", "plugin-catppuccin": "plugin-catppuccin",
"plugin-ccc": "plugin-ccc", "plugin-ccc": "plugin-ccc",

View file

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

View file

@ -72,6 +72,37 @@
pname = "flutter-tools"; pname = "flutter-tools";
patches = [../patches/flutter-tools.patch]; patches = [../patches/flutter-tools.patch];
}; };
blink-cmp = let
version = inputs.plugin-blink-cmp.shortRev or inputs.plugin-blink-cmp.shortDirtyRev or "dirty";
src = inputs.plugin-blink-cmp;
blink-fuzzy-lib = pkgs.rustPlatform.buildRustPackage {
pname = "blink-fuzzy-lib";
inherit version src;
env = {
# TODO: remove this if plugin stops using nightly rust
RUSTC_BOOTSTRAP = true;
};
cargoLock = {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"frizbee-0.1.0" = "sha256-pt6sMsRyjXrbrTK7t/YvWeen/n3nU8UUaiNYTY1LczE=";
};
};
};
libExt =
if pkgs.hostPlatform.isDarwin
then "dylib"
else "so";
in
buildPlug {
pname = "blink-cmp";
inherit version src;
preInstall = ''
mkdir -p target/release
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
'';
};
}; };
buildConfigPlugins = plugins: buildConfigPlugins = plugins:

View file

@ -58,8 +58,8 @@ in {
}; };
}; };
autocomplete.nvim-cmp = { autocomplete = {
sources = {copilot = "[Copilot]";}; nvim-cmp.sources = {copilot = "[Copilot]";};
sourcePlugins = ["copilot-cmp"]; sourcePlugins = ["copilot-cmp"];
}; };

View file

@ -0,0 +1,98 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalMD;
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));
options = {
preset = mkOption {
type = enum ["default" "none" "super-tab" "enter"];
default = "none";
description = "keymap presets";
};
};
};
providerType = submodule {
freeformType = anything;
options = {
module = mkOption {
type = str;
description = "module of the provider";
};
};
};
in {
options.vim.autocomplete.blink-cmp = {
enable = mkEnableOption "blink.cmp";
setupOpts = mkPluginSetupOption "blink.cmp" {
sources = {
default = mkOption {
type = listOf str;
default = ["lsp" "path" "snippets" "buffer"];
description = "Default list of sources to enable for completion.";
};
cmdline = mkOption {
type = listOf str;
default = [];
description = "List of sources to enable for cmdline";
};
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";
};
};
};
keymap = mkOption {
type = keymapType;
default = {};
description = "blink.cmp keymap";
example = literalMD ''
```nix
vim.autocomplete.blink-cmp.setupOpts.keymap = {
preset = "none";
"<Up>" = ["select_prev" "fallback"];
"<C-n>" = [
(lib.generators.mkLuaInline ''''
function(cmp)
if some_condition then return end -- runs the next command
return true -- doesn't run the next command
end,
'''')
"select_next"
];
};
```
'';
};
};
mappings = {
complete = mkMappingOption "Complete [blink.cmp]" "<C-Space>";
confirm = mkMappingOption "Confirm [blink.cmp]" "<CR>";
next = mkMappingOption "Next item [blink.cmp]" "<Tab>";
previous = mkMappingOption "Previous item [blink.cmp]" "<S-Tab>";
close = mkMappingOption "Close [blink.cmp]" "<C-e>";
scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" "<C-d>";
scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" "<C-f>";
};
};
}

View file

@ -0,0 +1,105 @@
{
lib,
config,
...
}: let
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 {
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)
return require("luasnip").lsp_expand(snippet)
end
'';
active = mkLuaInline ''
function(filter)
if filter and filter.direction then
return require('luasnip').jumpable(filter.direction)
end
return require('luasnip').in_snippet()
end
'';
jump = mkLuaInline "function(direction) require('luasnip').jump(direction) end";
};
keymap = {
${mappings.complete} = ["show" "fallback"];
${mappings.close} = ["hide" "fallback"];
${mappings.scrollDocsUp} = ["scroll_documentation_up" "fallback"];
${mappings.scrollDocsDown} = ["scroll_documentation_down" "fallback"];
${mappings.confirm} = ["accept" "fallback"];
${mappings.next} = [
"select_next"
"snippet_forward"
(mkLuaInline ''
function(cmp)
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
if has_words_before then
return cmp.show()
end
end
'')
"fallback"
];
${mappings.previous} = [
"select_prev"
"snippet_backward"
"fallback"
];
};
};
};
};
}

View file

@ -0,0 +1,3 @@
{
imports = [./blink-cmp.nix ./config.nix];
}

View file

@ -0,0 +1,34 @@
{
lib,
config,
...
}: let
inherit (builtins) typeOf tryEval;
inherit (lib.modules) mkIf;
inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.autocomplete;
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.enableSharedCmpSources {
startPlugins = ["rtp-nvim"];
lazy.plugins =
mapListToAttrs (package: {
name = getPluginName package;
value = {
inherit package;
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.sourcePlugins;
};
}

View file

@ -1,5 +1,9 @@
{ {
imports = [ imports = [
./config.nix
./options.nix
./nvim-cmp ./nvim-cmp
./blink-cmp
]; ];
} }

View file

@ -3,16 +3,16 @@
config, config,
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) attrNames typeOf tryEval concatStringsSep; inherit (builtins) attrNames typeOf tryEval concatStringsSep;
borders = config.vim.ui.borders.plugins.nvim-cmp; borders = config.vim.ui.borders.plugins.nvim-cmp;
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;
autocompleteCfg = config.vim.autocomplete;
luasnipEnable = config.vim.snippets.luasnip.enable; luasnipEnable = config.vim.snippets.luasnip.enable;
getPluginName = plugin: getPluginName = plugin:
if typeOf plugin == "string" if typeOf plugin == "string"
@ -24,114 +24,102 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["rtp-nvim"]; lazy.plugins = {
lazy.plugins = mkMerge [ nvim-cmp = {
(mapListToAttrs (package: { package = "nvim-cmp";
name = getPluginName package; after = ''
value = { ${optionalString luasnipEnable "local luasnip = require('luasnip')"}
inherit package; local cmp = require("cmp")
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.sourcePlugins)
{
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
local kinds = require("cmp.types").lsp.CompletionItemKind local kinds = require("cmp.types").lsp.CompletionItemKind
local deprio = function(kind) local deprio = function(kind)
return function(e1, e2) return function(e1, e2)
if e1:get_kind() == kind then if e1:get_kind() == kind then
return false return false
end
if e2:get_kind() == kind then
return true
end
return nil
end end
if e2:get_kind() == kind then
return true
end
return nil
end end
end
cmp.setup(${toLuaObject cfg.setupOpts}) cmp.setup(${toLuaObject cfg.setupOpts})
${optionalString config.vim.lazy.enable ${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map (concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
cfg.sourcePlugins))} autocompleteCfg.sourcePlugins))}
''; '';
event = ["InsertEnter" "CmdlineEnter"]; event = ["InsertEnter" "CmdlineEnter"];
};
}
];
autocomplete.nvim-cmp = {
sources = {
nvim-cmp = null;
buffer = "[Buffer]";
path = "[Path]";
}; };
};
autocomplete = {
enableSharedCmpSources = true;
sourcePlugins = ["cmp-buffer" "cmp-path"]; sourcePlugins = ["cmp-buffer" "cmp-path"];
setupOpts = { nvim-cmp = {
sources = map (s: {name = s;}) (attrNames cfg.sources); sources = {
nvim-cmp = null;
window = mkIf borders.enable { buffer = "[Buffer]";
completion.border = borders.style; path = "[Path]";
documentation.border = borders.style;
}; };
formatting.format = cfg.format; setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources);
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section window = mkIf borders.enable {
mapping = { completion.border = borders.style;
${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; documentation.border = borders.style;
${mappings.close} = mkLuaInline "cmp.mapping.abort()"; };
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
${mappings.next} = mkLuaInline '' formatting.format = cfg.format;
cmp.mapping(function(fallback)
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
if cmp.visible() then # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
cmp.select_next_item() mapping = {
${optionalString luasnipEnable '' ${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
elseif luasnip.locally_jumpable(1) then ${mappings.close} = mkLuaInline "cmp.mapping.abort()";
luasnip.jump(1) ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
''} ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
elseif has_words_before() then ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
cmp.complete()
else
fallback()
end
end)
'';
${mappings.previous} = mkLuaInline '' ${mappings.next} = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
if cmp.visible() then local has_words_before = function()
cmp.select_prev_item() local line, col = unpack(vim.api.nvim_win_get_cursor(0))
${optionalString luasnipEnable '' return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
elseif luasnip.locally_jumpable(-1) then end
luasnip.jump(-1)
''} if cmp.visible() then
else cmp.select_next_item()
fallback() ${optionalString luasnipEnable ''
end elseif luasnip.locally_jumpable(1) then
end) luasnip.jump(1)
''; ''}
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
''}
else
fallback()
end
end)
'';
};
}; };
}; };
}; };

View file

@ -4,10 +4,10 @@
... ...
}: let }: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) str attrsOf nullOr either listOf; inherit (lib.types) str attrsOf nullOr either;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType; inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) isString; inherit (builtins) isString;
@ -107,11 +107,5 @@ in {
} }
''; '';
}; };
sourcePlugins = mkOption {
type = listOf pluginType;
default = [];
description = "List of source plugins used by nvim-cmp.";
};
}; };
} }

View file

@ -0,0 +1,15 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) listOf;
inherit (lib.nvim.types) pluginType;
in {
options.vim.autocomplete = {
enableSharedCmpSources = mkEnableOption "cmp sources shared by nvim-cmp and blink.cmp";
sourcePlugins = mkOption {
type = listOf pluginType;
default = [];
description = "List of cmp source plugins.";
};
};
}

View file

@ -77,6 +77,9 @@ in {
-- buffer is a real file on the disk -- buffer is a real file on the disk
local real_file = vim.fn.filereadable(data.file) == 1 local real_file = vim.fn.filereadable(data.file) == 1
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
-- buffer is a [No Name] -- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
@ -84,7 +87,7 @@ in {
local filetype = vim.bo[data.buf].ft local filetype = vim.bo[data.buf].ft
-- only files please -- only files please
if not real_file and not no_name then if not real_file and not directory and not no_name then
return return
end end
@ -93,6 +96,10 @@ in {
return return
end end
-- cd if buffer is a directory
if directory then
vim.cmd.cd(data.file)
end
-- open the tree but don't focus it -- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false }) require("nvim-tree.api").tree.toggle({ focus = false })
end end

View file

@ -6,7 +6,7 @@
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) either listOf package str enum; inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
@ -60,13 +60,22 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {
vim.treesitter.enable = true; vim.treesitter = {
vim.treesitter.grammars = [cfg.treesitter.package]; enable = true;
grammars = [cfg.treesitter.package];
};
}) })
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true; vim = {
vim.lsp.lspconfig.sources.zig-lsp = servers.${cfg.lsp.server}.lspConfig; lsp.lspconfig = {
enable = true;
sources.zig-lsp = servers.${cfg.lsp.server}.lspConfig;
};
# nvf handles autosaving already
globals.zig_fmt_autosave = mkDefault 0;
};
}) })
]); ]);
} }

View file

@ -11,6 +11,7 @@
cfg = config.vim.lsp; cfg = config.vim.lsp;
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable; usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable;
self = import ./module.nix {inherit config lib pkgs;}; self = import ./module.nix {inherit config lib pkgs;};
mappingDefinitions = self.options.vim.lsp.mappings; mappingDefinitions = self.options.vim.lsp.mappings;
@ -22,8 +23,8 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
autocomplete.nvim-cmp = { autocomplete = mkIf usingNvimCmp {
sources = {nvim_lsp = "[LSP]";}; nvim-cmp.sources = {nvim_lsp = "[LSP]";};
sourcePlugins = ["cmp-nvim-lsp"]; sourcePlugins = ["cmp-nvim-lsp"];
}; };
@ -170,6 +171,10 @@ in {
}, },
} }
''} ''}
${optionalString usingBlinkCmp ''
capabilities = require('blink.cmp').get_lsp_capabilities()
''}
''; '';
}; };
}; };

View file

@ -10,6 +10,16 @@
cfg = config.vim.lsp; cfg = config.vim.lsp;
in { in {
config = mkIf (cfg.enable && cfg.lspSignature.enable) { config = mkIf (cfg.enable && cfg.lspSignature.enable) {
assertions = [
{
assertion = !config.vim.autocomplete.blink-cmp.enable;
message = ''
lsp-signature does not work with blink.cmp. Please use blink.cmp's builtin signature feature:
vim.autocomplete.blink-cmp.setupOpts.signature.enabled = true;
'';
}
];
vim = { vim = {
startPlugins = [ startPlugins = [
"lsp-signature" "lsp-signature"

View file

@ -8,11 +8,12 @@
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp.lspkind; cfg = config.vim.lsp.lspkind;
inherit (config.vim) autocomplete;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = config.vim.autocomplete.nvim-cmp.enable; assertion = autocomplete.nvim-cmp.enable || autocomplete.blink-cmp.enable;
message = '' message = ''
While lspkind supports Neovim's native lsp upstream, using that over While lspkind supports Neovim's native lsp upstream, using that over
nvim-cmp isn't recommended, nor supported by nvf. nvim-cmp isn't recommended, nor supported by nvf.

View file

@ -48,7 +48,7 @@ in {
# If using nvim-cmp, otherwise set to false # If using nvim-cmp, otherwise set to false
type = bool; type = bool;
description = "If using nvim-cmp, otherwise set to false"; description = "If using nvim-cmp, otherwise set to false";
default = config.vim.autocomplete.nvim-cmp.enable; default = config.vim.autocomplete.enableSharedCmpSources;
}; };
}; };
}; };

View file

@ -20,17 +20,9 @@ in {
cmd = "Run"; cmd = "Run";
keys = [ keys = [
(mkKeymap "n" cfg.mappings.run "<cmd>Run<CR>" {desc = mappings.run.description;}) (mkKeymap "n" cfg.mappings.run "<cmd>Run<cr>" {desc = mappings.run.description;})
(mkKeymap "n" cfg.mappings.runOverride "<cmd>Run!<CR>" {desc = mappings.runOverride.description;}) (mkKeymap "n" cfg.mappings.runOverride "<cmd>Run!<cr>" {desc = mappings.runOverride.description;})
(mkKeymap "n" cfg.mappings.runCommand '' (mkKeymap "n" cfg.mappings.runCommand "<cmd>RunPrompt<cr>" {desc = mappings.run.description;})
function()
local input = vim.fn.input("Run command: ")
if input ~= "" then require("run").run(input, false) end
end
'' {
desc = mappings.run.description;
lua = true;
})
]; ];
}; };

View file

@ -17,8 +17,8 @@ in {
}; };
}; };
startPlugins = cfg.providers; startPlugins = cfg.providers;
autocomplete.nvim-cmp = { autocomplete = {
sources = {luasnip = "[LuaSnip]";}; nvim-cmp.sources = {luasnip = "[LuaSnip]";};
sourcePlugins = ["cmp-luasnip"]; sourcePlugins = ["cmp-luasnip"];
}; };
}; };

View file

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

View file

@ -16,7 +16,7 @@ in {
pluginRC.nvim-notify = entryAnywhere '' pluginRC.nvim-notify = entryAnywhere ''
local notify = require("notify") local notify = require("notify")
notify.setup(${toLuaObject cfg.setupOpts}) notify.setup(${toLuaObject cfg.setupOpts})
vim.notify = notify vim.notify = notify.notify
''; '';
}; };
}; };