Compare commits

...

6 commits

Author SHA1 Message Date
raf
efc0ba8f97
Merge 3935189b79 into de20ff2c51 2024-08-11 23:59:49 +00:00
diniamo
de20ff2c51
style: improve modules/default.nix code, rename helper scripts (#351)
Co-authored-by: raf <raf@notashelf.dev>
2024-08-11 21:10:55 +00:00
poz
fd65c83956
plugins/new-file-template: init module (#350)
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
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
Validate flake & check formatting / Validate Flake (push) Has been cancelled
Validate flake & check formatting / Formatting via Alejandra (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
* plugins/new-file-template: init module

* docs: add release note entry about new-file-template.nvim

* docs: update jacekpoz's link

* plugins/new-file-template: remove _: in default.nix

* plugins/new-file-template: add example for disableSpecific

* plugins/new-file-template: add docs on how to add custom templates

* plugins/new-file-template: fix disableSpecific example

* plugins/new-file-template: improve documentation

* plugins/new-file-template: remove redundant example

* plugins/new-file-template: more compact docs

* plugins/new-file-template: more doc improvements

* plugins/new-file-template: fix formatting issue
2024-08-08 18:45:33 +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
19 changed files with 234 additions and 117 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

@ -83,7 +83,7 @@ Release notes for release 0.5
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule` - Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule`
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://jacekpoz.pl):
- Fixed scrollOffset not being used - Fixed scrollOffset not being used

View file

@ -62,7 +62,7 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added rose-pine theme. - Added rose-pine theme.
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://jacekpoz.pl):
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. - Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated.

View file

@ -62,14 +62,17 @@ configuration formats.
recommended to go through rustacean.nvim's README to take a closer look at its recommended to go through rustacean.nvim's README to take a closer look at its
features and usage features and usage
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://jacekpoz.pl):
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim
- Add [ocaml-lsp] support - Add [ocaml-lsp] support
- Fix "Emac" typo - Fix "Emac" typo
- Add [new-file-template.nvim] to automatically fill new file contents using templates.
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
- Move the `theme` dag entry to before `luaScript`. - Move the `theme` dag entry to before `luaScript`.
@ -140,10 +143,10 @@ configuration formats.
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available - Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
under `vim.filetree.neo-tree`, similar to nvimtree. under `vim.filetree.neo-tree`, similar to nvimtree.
- Add `print-nvf-config` & `print-nvf-config-path` helper scripts to Neovim - Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
closure. Both of those scripts have been automatically added to your PATH upon closure. Both of those scripts have been automatically added to your PATH upon
using neovimConfig or `programs.nvf.enable`. using neovimConfig or `programs.nvf.enable`.
- `print-nvf-config` will display your `init.lua`, in full. - `nvf-print-config` will display your `init.lua`, in full.
- `print-nvf-config-path` will display the path to _a clone_ of your - `nvf-print-config-path` will display the path to _a clone_ of your
`init.lua`. This is not the path used by the Neovim wrapper, but an `init.lua`. This is not the path used by the Neovim wrapper, but an
identical clone. identical clone.

View file

@ -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": {
@ -1839,6 +1855,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",

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;
@ -628,9 +633,15 @@
}; };
plugin-nvim-nio = { plugin-nvim-nio = {
# (required nvim-dap-ui) # (required by nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio"; url = "github:nvim-neotest/nvim-nio";
flake = false; flake = false;
}; };
plugin-new-file-template-nvim = {
# (required by new-file-template.nvim)
url = "github:otavioschwanck/new-file-template.nvim";
flake = false;
};
}; };
} }

View file

@ -7,11 +7,9 @@ inputs: {
extraModules ? [], extraModules ? [],
}: let }: let
inherit (pkgs) vimPlugins; inherit (pkgs) vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin;
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 getAttr; inherit (lib.attrsets) recursiveUpdate;
inherit (lib.asserts) assertMsg;
# 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
@ -33,12 +31,21 @@ inputs: {
# 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 = {pname, ...} @ attrs: let buildPlug = attrs: let
src = getAttr ("plugin-" + pname) inputs; src = inputs."plugin-${attrs.pname}";
in in
pkgs.stdenvNoCC.mkDerivation ({ pkgs.stdenvNoCC.mkDerivation ({
inherit src;
version = src.shortRev or src.shortDirtyRev or "dirty"; version = src.shortRev or src.shortDirtyRev or "dirty";
inherit src;
nativeBuildInputs = with pkgs.vimUtils; [
vimCommandCheckHook
vimGenDocHook
neovimRequireCheckHook
];
passthru.vimPlugin = true;
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
@ -50,41 +57,27 @@ inputs: {
} }
// attrs); // attrs);
noBuildPlug = {pname, ...} @ attrs: let
input = getAttr ("plugin-" + pname) inputs;
in
{
version = input.shortRev or input.shortDirtyRev or "dirty";
outPath = getAttr ("plugin-" + pname) inputs;
}
// attrs;
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
pluginBuilders = {
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
flutter-tools-patched =
buildPlug
{
pname = "flutter-tools";
patches = [../patches/flutter-tools.patch];
};
};
buildConfigPlugins = plugins: buildConfigPlugins = plugins:
map map
(plug: ( (
if (isString plug) plug:
then if (isString plug)
( then pluginBuilders.${plug} or (buildPlug {pname = plug;})
if (plug == "nvim-treesitter") else plug
then (buildTreesitterPlug vimOptions.treesitter.grammars) )
else if (plug == "flutter-tools-patched") (filter (f: f != null) plugins);
then
(
buildPlug
{
pname = "flutter-tools";
patches = [../patches/flutter-tools.patch];
}
)
else noBuildPlug {pname = plug;}
)
else plug
))
(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;
@ -114,20 +107,11 @@ inputs: {
inherit extraLuaPackages extraPython3Packages; inherit extraLuaPackages extraPython3Packages;
}; };
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
# Additional helper scripts for printing and displaying nvf configuration # Additional helper scripts for printing and displaying nvf configuration
# in your commandline. # in your commandline.
printConfig = pkgs.writers.writeDashBin "print-nvf-config" '' printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
cat << EOF printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
${vimOptions.builtLuaConfigRC}
EOF
'';
printConfigPath = pkgs.writers.writeDashBin "print-nvf-config-path" ''
realpath ${pkgs.writeTextFile {
name = "nvf-init.lua";
text = vimOptions.builtLuaConfigRC;
}}
'';
in { in {
inherit (module) options config; inherit (module) options config;
inherit (module._module.args) pkgs; inherit (module._module.args) pkgs;
@ -137,7 +121,7 @@ in {
neovim = pkgs.symlinkJoin { neovim = pkgs.symlinkJoin {
name = "nvf-with-helpers"; name = "nvf-with-helpers";
paths = [neovim-wrapped printConfig printConfigPath]; paths = [neovim-wrapped printConfig printConfigPath];
postBuild = "echo helpers added"; postBuild = "echo Helpers added";
meta = { meta = {
description = "Wrapped version of Neovim with additional helper scripts"; description = "Wrapped version of Neovim with additional helper scripts";

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

@ -4,6 +4,7 @@
./ccc ./ccc
./gestures ./gestures
./motion ./motion
./new-file-template
./telescope ./telescope
./icon-picker ./icon-picker
./images ./images

View file

@ -0,0 +1,23 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.utility.new-file-template;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"new-file-template-nvim"
];
pluginRC.new-file-template = entryAnywhere ''
require('new-file-template').setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./new-file-template.nix
];
}

View file

@ -0,0 +1,54 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) attrsOf bool listOf str;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.utility.new-file-template = {
enable = mkOption {
type = bool;
default = false;
description = ''
new-file-template.nvim: Automatically insert a template on new files in neovim.
::: {.note}
For custom templates add a directory containing `lua/templates/*.lua`
to `vim.additionalRuntimePaths`.
:::
[custom-template-docs]: https://github.com/otavioschwanck/new-file-template.nvim?tab=readme-ov-file#creating-new-templates
More documentation on the templates available at [custom-template-docs]
'';
};
setupOpts = mkPluginSetupOption "nvim-file-template.nvim" {
disableInsert = mkOption {
type = bool;
default = false;
description = "Enter insert mode after inserting the template";
};
disableAutocmd = mkOption {
type = bool;
default = false;
description = "Disable the autocmd that creates the template";
};
disableFiletype = mkOption {
type = listOf str;
default = [];
description = "Disable default templates for specific filetypes";
};
disableSpecific = mkOption {
type = attrsOf (listOf str);
default = {};
description = "Disable specific regexp for the default templates.";
example = "{ ruby = [\".*\"]; }";
};
suffixAsFiletype = mkOption {
type = bool;
default = false;
description = "Use suffix of filename rather than `vim.bo.filetype` as filetype";
};
};
};
}