Compare commits

...

5 commits

Author SHA1 Message Date
raf
734ced398e
Merge 3935189b79 into 7d824d6711 2024-08-12 11:47:53 -04:00
Gerg-L
7d824d6711
modules: fix build (#353)
Some checks failed
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs) (push) Has been cancelled
Validate flake & check documentation / Validate Flake Documentation (docs-html) (push) Has been cancelled
Validate flake & check documentation / Validate Flake Documentation (docs-json) (push) Has been cancelled
Validate flake & check documentation / Validate Flake Documentation (docs-manpages) (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
* flake.lock: lock

* remove ussage of mapAttrsFlatten

* flake.lock: update mnw

* modules/default.nix makeNeovimConfig -> mnw

* modules/default.nix use buildVimPlugin (sad)

dont build when possible
2024-08-12 00:08:53 +00:00
3935189b79
fastaction-nvim: move range_code_action to visual maps 2024-07-20 17:24:00 +03:00
97dabab4d9
deprecate nvimCodeActionMenu 2024-07-20 17:03:24 +03:00
346e6f535e
plugins/lsp: add code-actions module; add fastaction.nvim 2024-07-20 17:03:23 +03:00
13 changed files with 147 additions and 103 deletions

View file

@ -17,11 +17,16 @@ isMaximal: {
lspkind.enable = false; lspkind.enable = false;
lightbulb.enable = true; lightbulb.enable = true;
lspsaga.enable = false; lspsaga.enable = false;
nvimCodeActionMenu.enable = isMaximal;
trouble.enable = true; trouble.enable = true;
lspSignature.enable = true; lspSignature.enable = true;
lsplines.enable = isMaximal; lsplines.enable = isMaximal;
nvim-docs-view.enable = isMaximal; nvim-docs-view.enable = isMaximal;
# Code Actions
code-actions = {
enable = true;
fastaction-nvim.enable = true;
};
}; };
debugger = { debugger = {

View file

@ -69,11 +69,11 @@
}, },
"mnw": { "mnw": {
"locked": { "locked": {
"lastModified": 1722191188, "lastModified": 1723419050,
"narHash": "sha256-YF//iMALbrd2Ni9aju7w8NniH16Qz6RFTRD6md5UkDc=", "narHash": "sha256-Eb8jBUgHwpte+bGsqeXNbKMBfZaDB7RiPQwyb1vzJK8=",
"owner": "Gerg-L", "owner": "Gerg-L",
"repo": "mnw", "repo": "mnw",
"rev": "c7b289f3f5a31b6e744be37d83fc231816621231", "rev": "e625f5965567f16102bc52897c7600dcde53c6c3",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -571,6 +571,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-fastaction-nvim": {
"flake": false,
"locked": {
"lastModified": 1721396662,
"narHash": "sha256-L7na78FsE+QHlEwxMpiwQcoOPhtmrknvdTZfzUoDANI=",
"owner": "Chaitanyabsprip",
"repo": "fastaction.nvim",
"rev": "2384dea7ba81d2709d0bee0e4bc7a8831ff13a9d",
"type": "github"
},
"original": {
"owner": "Chaitanyabsprip",
"repo": "fastaction.nvim",
"type": "github"
}
},
"plugin-fidget-nvim": { "plugin-fidget-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -939,6 +955,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-new-file-template-nvim": {
"flake": false,
"locked": {
"lastModified": 1721518222,
"narHash": "sha256-g0IjJrHRXw7U9goVLzVYUyHBSsDZGHMpi3YZPhg64zA=",
"owner": "otavioschwanck",
"repo": "new-file-template.nvim",
"rev": "6ac66669dbf2dc5cdee184a4fe76d22465ca67e8",
"type": "github"
},
"original": {
"owner": "otavioschwanck",
"repo": "new-file-template.nvim",
"type": "github"
}
},
"plugin-noice-nvim": { "plugin-noice-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1839,6 +1871,7 @@
"plugin-dracula": "plugin-dracula", "plugin-dracula": "plugin-dracula",
"plugin-dressing-nvim": "plugin-dressing-nvim", "plugin-dressing-nvim": "plugin-dressing-nvim",
"plugin-elixir-tools": "plugin-elixir-tools", "plugin-elixir-tools": "plugin-elixir-tools",
"plugin-fastaction-nvim": "plugin-fastaction-nvim",
"plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-fidget-nvim": "plugin-fidget-nvim",
"plugin-flutter-tools": "plugin-flutter-tools", "plugin-flutter-tools": "plugin-flutter-tools",
"plugin-gesture-nvim": "plugin-gesture-nvim", "plugin-gesture-nvim": "plugin-gesture-nvim",
@ -1862,6 +1895,7 @@
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
"plugin-neocord": "plugin-neocord", "plugin-neocord": "plugin-neocord",
"plugin-neodev-nvim": "plugin-neodev-nvim", "plugin-neodev-nvim": "plugin-neodev-nvim",
"plugin-new-file-template-nvim": "plugin-new-file-template-nvim",
"plugin-noice-nvim": "plugin-noice-nvim", "plugin-noice-nvim": "plugin-noice-nvim",
"plugin-none-ls": "plugin-none-ls", "plugin-none-ls": "plugin-none-ls",
"plugin-nui-nvim": "plugin-nui-nvim", "plugin-nui-nvim": "plugin-nui-nvim",

View file

@ -138,6 +138,11 @@
flake = false; flake = false;
}; };
plugin-fastaction-nvim = {
url = "github:Chaitanyabsprip/fastaction.nvim";
flake = false;
};
plugin-lsp-signature = { plugin-lsp-signature = {
url = "github:ray-x/lsp_signature.nvim"; url = "github:ray-x/lsp_signature.nvim";
flake = false; flake = false;

View file

@ -9,75 +9,63 @@ inputs: {
inherit (pkgs) vimPlugins; inherit (pkgs) vimPlugins;
inherit (lib.strings) isString toString; inherit (lib.strings) isString toString;
inherit (lib.lists) filter map concatLists; inherit (lib.lists) filter map concatLists;
inherit (lib.attrsets) recursiveUpdate;
# import modules.nix with `check`, `pkgs` and `lib` as arguments # import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called # check can be disabled while calling this file is called
# to avoid checking in all modules # to avoid checking in all modules
nvimModules = import ./modules.nix { nvimModules = import ./modules.nix {inherit pkgs check lib;};
inherit pkgs check lib;
};
# evaluate the extended library with the modules # evaluate the extended library with the modules
# optionally with any additional modules passed by the user # optionally with any additional modules passed by the user
module = lib.evalModules { module = lib.evalModules {
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs; specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
modules = concatLists [[configuration] nvimModules extraModules]; modules = concatLists [[configuration] nvimModules extraModules];
}; };
# alias to the internal configuration # alias to the internal configuration
vimOptions = module.config.vim; vimOptions = module.config.vim;
noBuildPlug = {pname, ...} @ attrs: let
src = inputs."plugin-${attrs.pname}";
in
{
version = src.shortRev or src.shortDirtyRev or "dirty";
outPath = src;
passthru.vimPlugin = false;
}
// attrs;
# build a vim plugin with the given name and arguments # build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead # instead
buildPlug = attrs: let buildPlug = attrs: let
src = inputs."plugin-${attrs.pname}"; src = inputs."plugin-${attrs.pname}";
in in
pkgs.stdenvNoCC.mkDerivation ({ pkgs.vimUtils.buildVimPlugin (
{
version = src.shortRev or src.shortDirtyRev or "dirty"; version = src.shortRev or src.shortDirtyRev or "dirty";
inherit src; inherit src;
nativeBuildInputs = with pkgs.vimUtils; [
vimCommandCheckHook
vimGenDocHook
neovimRequireCheckHook
];
passthru.vimPlugin = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r . $out
runHook postInstall
'';
} }
// attrs); // attrs
);
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
pluginBuilders = { pluginBuilders = {
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars; nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
flutter-tools-patched = flutter-tools-patched = buildPlug {
buildPlug pname = "flutter-tools";
{ patches = [../patches/flutter-tools.patch];
pname = "flutter-tools"; };
patches = [../patches/flutter-tools.patch];
};
}; };
buildConfigPlugins = plugins: buildConfigPlugins = plugins:
map map (
(
plug: plug:
if (isString plug) if (isString plug)
then pluginBuilders.${plug} or (buildPlug {pname = plug;}) then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
else plug else plug
) ) (filter (f: f != null) plugins);
(filter (f: f != null) plugins);
# built (or "normalized") plugins that are modified # built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
@ -87,7 +75,7 @@ inputs: {
}) (buildConfigPlugins vimOptions.optPlugins); }) (buildConfigPlugins vimOptions.optPlugins);
# additional Lua and Python3 packages, mapped to their respective functions # additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format makeNeovimConfig expects. end user should # to conform to the format mnw expects. end user should
# only ever need to pass a list of packages, which are modified # only ever need to pass a list of packages, which are modified
# here # here
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
@ -97,7 +85,7 @@ inputs: {
# generate a wrapped Neovim package. # generate a wrapped Neovim package.
neovim-wrapped = inputs.mnw.lib.wrap pkgs { neovim-wrapped = inputs.mnw.lib.wrap pkgs {
neovim = vimOptions.package; neovim = vimOptions.package;
plugins = concatLists [builtStartPlugins builtOptPlugins]; plugins = builtStartPlugins ++ builtOptPlugins;
appName = "nvf"; appName = "nvf";
extraBinPath = vimOptions.extraPackages; extraBinPath = vimOptions.extraPackages;
initLua = vimOptions.builtLuaConfigRC; initLua = vimOptions.builtLuaConfigRC;

View file

@ -7,5 +7,12 @@ in {
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
you depended on this functionality, please open an issue. you depended on this functionality, please open an issue.
'') '')
# 2024-07-20
(mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] ''
nvimCodeActionMenu has been deprecated and archived upstream. As of 0.7, code-actions will be
available under `vim.lsp.code-actions.enable` and `vim.lsp.code.actions.<plugin>.enable`.
Please take a look at the nvf manual for more details.
'')
]; ];
} }

View file

@ -0,0 +1,10 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
imports = [
./fastaction-nvim
];
options.vim.lsp.code-actions = {
enable = mkEnableOption "code-actions. Setting this to `false` will disable all code action plugins.";
};
}

View file

@ -0,0 +1,36 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding pushDownDefault;
cfg = config.vim.lsp.code-actions;
self = import ./fastaction-nvim.nix {inherit lib;};
mappingDefinitions = self.options.vim.lsp.code-actions.fastaction-nvim.mappings;
mappings = addDescriptionsToMappings cfg.fastaction-nvim.mappings mappingDefinitions;
in {
config = mkIf (cfg.enable && cfg.fastaction-nvim.enable) {
vim = {
startPlugins = ["fastaction-nvim"];
binds.whichKey.register = pushDownDefault {
"<leader>c" = "Code Actions";
};
maps = {
normal = mkSetLuaBinding mappings.code_action "require('fastaction').code_action";
visual = mkSetLuaBinding mappings.range_action "require('fastaction').range_code_action";
};
pluginRC.fastaction-nvim = entryAnywhere ''
-- Enable trouble diagnostics viewer
require('fastaction').setup(${toLuaObject cfg.fastaction-nvim.setupOpts})
'';
};
};
}

View file

@ -1,6 +1,6 @@
{ {
imports = [ imports = [
./nvim-code-action-menu.nix
./config.nix ./config.nix
./fastaction-nvim.nix
]; ];
} }

View file

@ -0,0 +1,15 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.lsp.code-actions.fastaction-nvim = {
enable = mkEnableOption "code actions for Neovim via fastaction.nvim";
setupOpts = mkPluginSetupOption "fastaction-nvim" {};
mappings = {
code_action = mkMappingOption "Displays code action popup [Fastaction.nvim]" "<leader>cfa";
range_action = mkMappingOption " Displays code actions for visual range [Fastaction.nvim]" "<leader>cra";
};
};
}

View file

@ -10,12 +10,14 @@
# lsp plugins # lsp plugins
./lspsaga ./lspsaga
./nvim-code-action-menu
./trouble ./trouble
./lsp-signature ./lsp-signature
./lightbulb ./lightbulb
./lspkind ./lspkind
./lsplines ./lsplines
./nvim-docs-view ./nvim-docs-view
# Code Actions
./code-actions
]; ];
} }

View file

@ -1,37 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault;
cfg = config.vim.lsp;
self = import ./nvim-code-action-menu.nix {inherit lib;};
mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings;
mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions;
in {
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
vim = {
startPlugins = ["nvim-code-action-menu"];
maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
binds.whichKey.register = pushDownDefault {
"<leader>c" = "+CodeAction";
};
pluginRC.code-action-menu = entryAnywhere ''
-- border configuration
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'
-- show individual sections of the code action menu
${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"}
${lib.optionalString cfg.nvimCodeActionMenu.show.diff "vim.g.code_action_menu_show_diff = true"}
${lib.optionalString cfg.nvimCodeActionMenu.show.actionKind "vim.g.code_action_menu_show_action_kind = true"}
'';
};
};
}

View file

@ -1,20 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.lsp = {
nvimCodeActionMenu = {
enable = mkEnableOption "nvim code action menu";
show = {
details = mkEnableOption "Show details" // {default = true;};
diff = mkEnableOption "Show diff" // {default = true;};
actionKind = mkEnableOption "Show action kind" // {default = true;};
};
mappings = {
open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "<leader>ca";
};
};
};
}

View file

@ -5,9 +5,8 @@
}: let }: let
inherit (builtins) map mapAttrs filter; inherit (builtins) map mapAttrs filter;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames; inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.strings) concatLines concatMapStringsSep;
inherit (lib.misc) mapAttrsFlatten;
inherit (lib.trivial) showWarnings; inherit (lib.trivial) showWarnings;
inherit (lib.types) str nullOr; inherit (lib.types) str nullOr;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
@ -83,7 +82,7 @@ in {
config = let config = let
filterNonNull = attrs: filterAttrs (_: value: value != null) attrs; filterNonNull = attrs: filterAttrs (_: value: value != null) attrs;
globalsScript = globalsScript =
mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}") mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}")
(filterNonNull cfg.globals); (filterNonNull cfg.globals);
extraPluginConfigs = resolveDag { extraPluginConfigs = resolveDag {