mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00:00
Compare commits
4 commits
c917eae4d4
...
13d3065597
Author | SHA1 | Date | |
---|---|---|---|
|
13d3065597 | ||
|
3c4eced9d1 | ||
|
ff9b0eeb1f | ||
|
617cc7d482 |
4 changed files with 39 additions and 39 deletions
|
@ -63,8 +63,20 @@ Note that we are looking to add more alternatives in the future like
|
||||||
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
|
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
|
||||||
everyone.
|
everyone.
|
||||||
|
|
||||||
|
### `type` based modules removed {#sec-type-based-modules-removed}
|
||||||
|
|
||||||
|
As part of the autocompletion rewrite, modules that used to use a `type` option
|
||||||
|
have been replaced by per-plugin modules instead. Since both modules only had
|
||||||
|
one type, you can simply change
|
||||||
|
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
|
||||||
|
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
|
||||||
|
|
||||||
## Changelog {#sec-release-0.7-changelog}
|
## Changelog {#sec-release-0.7-changelog}
|
||||||
|
|
||||||
|
[nezia1](https://github.com/nezia1):
|
||||||
|
|
||||||
|
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).
|
||||||
|
|
||||||
[ItsSorae](https://github.com/ItsSorae):
|
[ItsSorae](https://github.com/ItsSorae):
|
||||||
|
|
||||||
- Add support for [typst](https://typst.app/) under `vim.languages.typst` This
|
- Add support for [typst](https://typst.app/) under `vim.languages.typst` This
|
||||||
|
|
|
@ -31,6 +31,11 @@ in {
|
||||||
vim.autocomplete.type has been removed in favor of per-plugin modules.
|
vim.autocomplete.type has been removed in favor of per-plugin modules.
|
||||||
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
|
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
|
||||||
'')
|
'')
|
||||||
|
(mkRemovedOptionModule ["vim" "autocomplete" "sources"] ''
|
||||||
|
vim.autocomplete.sources has been removed in favor of per-plugin modules.
|
||||||
|
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
|
||||||
|
instead.
|
||||||
|
'')
|
||||||
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
|
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
|
||||||
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
|
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
|
||||||
'')
|
'')
|
||||||
|
|
|
@ -6,17 +6,13 @@
|
||||||
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.nvim.binds) addDescriptionsToMappings;
|
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
|
|
||||||
cfg = config.vim.autocomplete.nvim-cmp;
|
cfg = config.vim.autocomplete.nvim-cmp;
|
||||||
luasnipEnable = config.vim.snippets.luasnip.enable;
|
luasnipEnable = config.vim.snippets.luasnip.enable;
|
||||||
|
inherit (cfg) mappings;
|
||||||
self = import ./nvim-cmp.nix {inherit lib config;};
|
|
||||||
mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings;
|
|
||||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
|
@ -45,39 +41,20 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
|
pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
|
||||||
local luasnip = require("luasnip")
|
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
'');
|
'');
|
||||||
|
|
||||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||||
autocomplete.nvim-cmp.setupOpts.mapping = {
|
autocomplete.nvim-cmp.setupOpts.mapping = {
|
||||||
${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()";
|
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||||
${mappings.close.value} = mkLuaInline "cmp.mapping.abort()";
|
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||||
${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||||
${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||||
|
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||||
|
|
||||||
${mappings.confirm.value} = mkLuaInline ''
|
${mappings.next} = mkLuaInline ''
|
||||||
cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
${
|
|
||||||
if luasnipEnable
|
|
||||||
then ''
|
|
||||||
if luasnip.expandable() then
|
|
||||||
luasnip.expand()
|
|
||||||
else
|
|
||||||
cmp.confirm({ select = true })
|
|
||||||
end
|
|
||||||
''
|
|
||||||
else "cmp.confirm({ select = true })"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
'';
|
|
||||||
|
|
||||||
${mappings.next.value} = mkLuaInline ''
|
|
||||||
cmp.mapping(function(fallback)
|
cmp.mapping(function(fallback)
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
@ -98,7 +75,7 @@ in {
|
||||||
end)
|
end)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
${mappings.previous.value} = mkLuaInline ''
|
${mappings.previous} = mkLuaInline ''
|
||||||
cmp.mapping(function(fallback)
|
cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
servers = {
|
servers = {
|
||||||
rnix = {
|
rnix = {
|
||||||
package = pkgs.rnix-lsp;
|
package = pkgs.rnix-lsp;
|
||||||
internalFormatter = cfg.format.type == "nixpkgs-fmt";
|
internalFormatter = cfg.format.type == "nixfmt";
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.rnix.setup{
|
lspconfig.rnix.setup{
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
${
|
${
|
||||||
if (cfg.format.enable && cfg.format.type == "nixpkgs-fmt")
|
if (cfg.format.enable && cfg.format.type == "nixfmt")
|
||||||
then useFormat
|
then useFormat
|
||||||
else noFormat
|
else noFormat
|
||||||
},
|
},
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
${optionalString (cfg.format.type == "nixpkgs-fmt")
|
${optionalString (cfg.format.type == "nixfmt")
|
||||||
''
|
''
|
||||||
formatting = {
|
formatting = {
|
||||||
command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
|
command = {"${cfg.format.package}/bin/nixfmt"},
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
},
|
},
|
||||||
|
@ -90,9 +90,9 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nixpkgs-fmt = {
|
nixfmt = {
|
||||||
package = pkgs.nixpkgs-fmt;
|
package = pkgs.nixfmt-rfc-style;
|
||||||
# Never need to use null-ls for nixpkgs-fmt
|
# Never need to use null-ls for nixfmt
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,6 +175,12 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
{
|
{
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = cfg.format.type != "nixpkgs-fmt";
|
||||||
|
message = "nixpkgs-fmt has been deprecated.";
|
||||||
|
}
|
||||||
|
];
|
||||||
vim.pluginRC.nix = ''
|
vim.pluginRC.nix = ''
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = "nix",
|
pattern = "nix",
|
||||||
|
|
Loading…
Reference in a new issue