From 264de8cefb76404b5c2f52bcee861eab1e513245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Mon, 20 Feb 2023 11:42:13 +0100 Subject: [PATCH] added formatter + reformat existing codebase (#175) --- default.nix | 14 +- docs.nix | 46 +- example.nix | 9 +- flake.nix | 154 +++--- lib/helpers.nix | 253 ++++++---- lib/option-warnings.nix | 123 ++--- modules/autocmd.nix | 82 +-- modules/colorscheme.nix | 7 +- modules/highlights.nix | 100 ++-- modules/keymaps.nix | 77 +-- modules/options.nix | 52 +- modules/output.nix | 124 ++--- modules/plugins.nix | 3 +- modules/warnings.nix | 6 +- plugins/bufferlines/barbar.nix | 59 +-- plugins/bufferlines/bufferline.nix | 190 +++---- plugins/colorschemes/base16.nix | 17 +- plugins/colorschemes/gruvbox.nix | 24 +- plugins/colorschemes/nord.nix | 32 +- plugins/colorschemes/one.nix | 17 +- plugins/colorschemes/onedark.nix | 17 +- plugins/colorschemes/tokyonight.nix | 98 ++-- plugins/completion/copilot.nix | 42 +- plugins/completion/coq.nix | 43 +- plugins/completion/lspkind.nix | 52 +- plugins/completion/nvim-cmp/cmp-helpers.nix | 114 +++-- plugins/completion/nvim-cmp/default.nix | 294 ++++++----- .../completion/nvim-cmp/sources/default.nix | 20 +- plugins/git/fugitive.nix | 29 +- plugins/git/gitgutter.nix | 44 +- plugins/git/gitmessenger.nix | 27 +- plugins/git/gitsigns.nix | 286 ++++++----- plugins/git/neogit.nix | 47 +- plugins/languages/clangd-extensions.nix | 2 +- plugins/languages/ledger.nix | 61 +-- plugins/languages/markdown-preview.nix | 30 +- plugins/languages/nix.nix | 27 +- plugins/languages/plantuml-syntax.nix | 23 +- plugins/languages/rust.nix | 384 +++++++------- plugins/languages/tagbar.nix | 53 +- plugins/languages/treesitter-context.nix | 29 +- plugins/languages/treesitter-refactor.nix | 214 ++++---- plugins/languages/treesitter.nix | 113 +++-- plugins/languages/vimtex.nix | 66 ++- plugins/languages/zig.nix | 39 +- plugins/null-ls/default.nix | 30 +- plugins/null-ls/helpers.nix | 79 +-- plugins/null-ls/servers.nix | 30 +- plugins/nvim-lsp/basic-servers.nix | 41 +- plugins/nvim-lsp/default.nix | 62 +-- plugins/nvim-lsp/helpers.nix | 92 ++-- plugins/nvim-lsp/lsp-lines.nix | 40 +- plugins/nvim-lsp/lspsaga.nix | 182 +++---- plugins/nvim-lsp/nvim-lightbulb.nix | 109 ++-- plugins/nvim-lsp/rust-analyzer-config.nix | 31 +- plugins/nvim-lsp/trouble.nix | 46 +- plugins/plugin-defs.nix | 54 +- plugins/pluginmanagers/packer.nix | 127 ++--- plugins/snippets/luasnip/default.nix | 67 +-- plugins/statuslines/airline.nix | 67 +-- plugins/statuslines/lightline.nix | 58 +-- plugins/statuslines/lualine.nix | 91 ++-- plugins/telescope/default.nix | 51 +- plugins/telescope/frecency.nix | 42 +- plugins/telescope/fzf-native.nix | 28 +- plugins/telescope/fzy-native.nix | 24 +- plugins/telescope/media-files.nix | 17 +- plugins/telescope/project-nvim.nix | 16 +- plugins/utils/comment-nvim.nix | 47 +- plugins/utils/commentary.nix | 17 +- plugins/utils/dashboard.nix | 55 +- plugins/utils/easyescape.nix | 15 +- plugins/utils/emmet.nix | 61 +-- plugins/utils/endwise.nix | 27 +- plugins/utils/floaterm.nix | 23 +- plugins/utils/goyo.nix | 57 ++- plugins/utils/harpoon.nix | 81 +-- plugins/utils/indent-blankline.nix | 29 +- plugins/utils/intellitab.nix | 19 +- plugins/utils/magma-nvim.nix | 68 ++- plugins/utils/mark-radar.nix | 35 +- plugins/utils/notify.nix | 50 +- plugins/utils/nvim-autopairs.nix | 36 +- plugins/utils/nvim-colorizer.nix | 68 +-- plugins/utils/nvim-tree.nix | 133 ++--- plugins/utils/project-nvim.nix | 109 ++-- plugins/utils/specs.nix | 87 ++-- plugins/utils/startify.nix | 453 +++++++++-------- plugins/utils/surround.nix | 25 +- plugins/utils/undotree.nix | 17 +- tests/flake.nix | 468 +++++++++--------- wrappers/_shared.nix | 13 +- wrappers/darwin.nix | 26 +- wrappers/hm.nix | 31 +- wrappers/nixos.nix | 31 +- wrappers/standalone.nix | 16 +- 96 files changed, 3705 insertions(+), 3319 deletions(-) diff --git a/default.nix b/default.nix index 801474b615..3321d7dff6 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,9 @@ (import ( - fetchTarball { - url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz"; - sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; } -) { - src = ./.; -}).defaultNix + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz"; + sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; + } + ) { + src = ./.; + }) +.defaultNix diff --git a/docs.nix b/docs.nix index fff79cd877..939e9b5852 100644 --- a/docs.nix +++ b/docs.nix @@ -1,8 +1,12 @@ -{ pkgs, lib, modules, ... }: -let +{ + pkgs, + lib, + modules, + ... +}: let options = lib.evalModules { modules = modules; - specialArgs = { inherit pkgs lib; }; + specialArgs = {inherit pkgs lib;}; }; docs = pkgs.nixosOptionsDoc { # If we don't do this, we end up with _module.args on the generated options, which we do not want @@ -11,25 +15,25 @@ let }; asciidoc = docs.optionsAsciiDoc; in -pkgs.stdenv.mkDerivation { - name = "nixvim-docs"; + pkgs.stdenv.mkDerivation { + name = "nixvim-docs"; - src = asciidoc; - buildInputs = [ - pkgs.asciidoctor - ]; + src = asciidoc; + buildInputs = [ + pkgs.asciidoctor + ]; - phases = [ "buildPhase" ]; + phases = ["buildPhase"]; - buildPhase = '' - mkdir -p $out/share/doc - cat < header.adoc - = NixVim options - This lists all the options available for NixVim. - :toc: + buildPhase = '' + mkdir -p $out/share/doc + cat < header.adoc + = NixVim options + This lists all the options available for NixVim. + :toc: - EOF - cat header.adoc $src > tmp.adoc - asciidoctor tmp.adoc -o $out/share/doc/index.html - ''; -} + EOF + cat header.adoc $src > tmp.adoc + asciidoctor tmp.adoc -o $out/share/doc/index.html + ''; + } diff --git a/example.nix b/example.nix index 20a89dc2f7..8df6d81836 100644 --- a/example.nix +++ b/example.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{pkgs, ...}: { programs.nixvim = { # This just enables NixVim. # If all you have is this, then there will be little visible difference @@ -53,8 +52,8 @@ # This is one of lightline's example configurations active = { left = [ - [ "mode" "paste" ] - [ "redaonly" "filename" "modified" "helloworld" ] + ["mode" "paste"] + ["redaonly" "filename" "modified" "helloworld"] ]; }; @@ -73,7 +72,7 @@ # What about plugins not available as a module? # Use extraPlugins: - extraPlugins = with pkgs.vimPlugins; [ vim-toml ]; + extraPlugins = with pkgs.vimPlugins; [vim-toml]; }; }; } diff --git a/flake.nix b/flake.nix index 98783ffe58..5aa10fd617 100644 --- a/flake.nix +++ b/flake.nix @@ -6,92 +6,108 @@ inputs.beautysh.url = "github:lovesegfault/beautysh"; inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs"; - outputs = { self, nixpkgs, flake-utils, ... }@inputs: + outputs = { + self, + nixpkgs, + flake-utils, + ... + } @ inputs: with nixpkgs.lib; - with builtins; - let + with builtins; let # TODO: Support nesting nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules)); - modules = pkgs: nixvimModules ++ [ - (rec { - _file = ./flake.nix; - key = _file; - config = { - _module.args = { - pkgs = mkForce pkgs; - inherit (pkgs) lib; - helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; }; - inputs = inputs; + modules = pkgs: + nixvimModules + ++ [ + rec { + _file = ./flake.nix; + key = _file; + config = { + _module.args = { + pkgs = mkForce pkgs; + inherit (pkgs) lib; + helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;}; + inputs = inputs; + }; }; - }; - }) + } - # ./plugins/default.nix - ]; + # ./plugins/default.nix + ]; flakeOutput = flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { inherit system; }; - extractRustAnalyzer = { stdenv, pkgs }: stdenv.mkDerivation { - pname = "extract_rust_analyzer"; - version = "master"; + (system: let + pkgs = import nixpkgs {inherit system;}; + extractRustAnalyzer = { + stdenv, + pkgs, + }: + stdenv.mkDerivation { + pname = "extract_rust_analyzer"; + version = "master"; - dontUnpack = true; - dontBuild = true; + dontUnpack = true; + dontBuild = true; - buildInputs = [ pkgs.python3 ]; + buildInputs = [pkgs.python3]; - installPhase = '' - ls -la - mkdir -p $out/bin - cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py - ''; - }; - extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer { }; - in - { - packages = { - docs = pkgs.callPackage (import ./docs.nix) { - modules = nixvimModules; - }; - runUpdates = pkgs.callPackage - ({ pkgs, stdenv }: stdenv.mkDerivation { - pname = "run-updates"; - version = pkgs.rust-analyzer.version; + installPhase = '' + ls -la + mkdir -p $out/bin + cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py + ''; + }; + extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {}; + in { + packages = { + docs = pkgs.callPackage (import ./docs.nix) { + modules = nixvimModules; + }; + runUpdates = + pkgs.callPackage + ({ + pkgs, + stdenv, + }: + stdenv.mkDerivation { + pname = "run-updates"; + version = pkgs.rust-analyzer.version; - src = pkgs.rust-analyzer.src; + src = pkgs.rust-analyzer.src; - nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra nixpkgs-fmt]; + nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra nixpkgs-fmt]; - buildPhase = '' - extract_rust_analyzer.py editors/code/package.json | - alejandra --quiet | - nixpkgs-fmt > rust-analyzer-config.nix - ''; + buildPhase = '' + extract_rust_analyzer.py editors/code/package.json | + alejandra --quiet | + nixpkgs-fmt > rust-analyzer-config.nix + ''; - installPhase = '' - mkdir -p $out/share - cp rust-analyzer-config.nix $out/share - ''; - }) - { }; - }; - legacyPackages = rec { - makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules; - makeNixvim = configuration: makeNixvimWithModule { - module = { - config = configuration; - }; + installPhase = '' + mkdir -p $out/share + cp rust-analyzer-config.nix $out/share + ''; + }) + {}; + }; + legacyPackages = rec { + makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules; + makeNixvim = configuration: + makeNixvimWithModule { + module = { + config = configuration; }; }; - }); + }; + formatter = pkgs.alejandra; + }); in - flakeOutput // { - nixosModules.nixvim = import ./wrappers/nixos.nix modules; - homeManagerModules.nixvim = import ./wrappers/hm.nix modules; - nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules; - }; + flakeOutput + // { + nixosModules.nixvim = import ./wrappers/nixos.nix modules; + homeManagerModules.nixvim = import ./wrappers/hm.nix modules; + nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules; + }; } diff --git a/lib/helpers.nix b/lib/helpers.nix index 7e8b44a0ad..87f4f5cbc1 100644 --- a/lib/helpers.nix +++ b/lib/helpers.nix @@ -1,146 +1,185 @@ -{ lib, ... }: -with lib; -rec { +{lib, ...}: +with lib; rec { # vim dictionaries are, in theory, compatible with JSON - toVimDict = args: toJSON + toVimDict = args: + toJSON (lib.filterAttrs (n: v: !isNull v) args); # Black functional magic that converts a bunch of different Nix types to their # lua equivalents! toLuaObject = args: - if builtins.isAttrs args then - if hasAttr "__raw" args then - args.__raw + if builtins.isAttrs args + then + if hasAttr "__raw" args + then args.__raw else - "{" + (concatStringsSep "," + "{" + + (concatStringsSep "," (mapAttrsToList (n: v: - if head (stringToCharacters n) == "@" then - toLuaObject v + if head (stringToCharacters n) == "@" + then toLuaObject v else "[${toLuaObject n}] = " + (toLuaObject v)) - (filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args))) + "}" - else if builtins.isList args then - "{" + concatMapStringsSep "," toLuaObject args + "}" - else if builtins.isString args then - # This should be enough! + (filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args))) + + "}" + else if builtins.isList args + then "{" + concatMapStringsSep "," toLuaObject args + "}" + else if builtins.isString args + then + # This should be enough! builtins.toJSON args - else if builtins.isPath args then - builtins.toJSON (toString args) - else if builtins.isBool args then - "${ boolToString args }" - else if builtins.isFloat args then - "${ toString args }" - else if builtins.isInt args then - "${ toString args }" - else if isNull args then - "nil" + else if builtins.isPath args + then builtins.toJSON (toString args) + else if builtins.isBool args + then "${boolToString args}" + else if builtins.isFloat args + then "${toString args}" + else if builtins.isInt args + then "${toString args}" + else if isNull args + then "nil" else ""; # Generates maps for a lua config - genMaps = mode: maps: - let - normalized = builtins.mapAttrs - (key: action: - if builtins.isString action then - { - silent = false; - expr = false; - unique = false; - noremap = true; - script = false; - nowait = false; - action = action; - } - else action) - maps; - in - builtins.attrValues (builtins.mapAttrs + genMaps = mode: maps: let + normalized = + builtins.mapAttrs (key: action: - { - action = action.action; - config = lib.filterAttrs (_: v: v) { - inherit (action) silent expr unique noremap script nowait; - }; - key = key; - mode = mode; - }) + if builtins.isString action + then { + silent = false; + expr = false; + unique = false; + noremap = true; + script = false; + nowait = false; + action = action; + } + else action) + maps; + in + builtins.attrValues (builtins.mapAttrs + (key: action: { + action = action.action; + config = lib.filterAttrs (_: v: v) { + inherit (action) silent expr unique noremap script nowait; + }; + key = key; + mode = mode; + }) normalized); # Creates an option with a nullable type that defaults to null. - mkNullOrOption = type: desc: lib.mkOption { - type = lib.types.nullOr type; - default = null; - description = desc; - }; + mkNullOrOption = type: desc: + lib.mkOption { + type = lib.types.nullOr type; + default = null; + description = desc; + }; mkIfNonNull = c: mkIf (!isNull c) c; defaultNullOpts = rec { - mkNullable = type: default: desc: mkNullOrOption type ( - let - defaultDesc = "default: `${default}`"; - in - if desc == "" then defaultDesc else '' - ${desc} - - ${defaultDesc} - '' - ); + mkNullable = type: default: desc: + mkNullOrOption type ( + let + defaultDesc = "default: `${default}`"; + in + if desc == "" + then defaultDesc + else '' + ${desc} + + ${defaultDesc} + '' + ); mkInt = default: mkNullable lib.types.int (toString default); - mkBool = default: mkNullable lib.types.bool (if default then "true" else "false"); + mkBool = default: + mkNullable lib.types.bool ( + if default + then "true" + else "false" + ); mkStr = default: mkNullable lib.types.str ''${builtins.toString default}''; mkEnum = enum: default: mkNullable (lib.types.enum enum) ''"${default}"''; mkEnumFirstDefault = enum: mkEnum enum (head enum); }; - mkPackageOption = name: default: mkOption { - type = types.package; - inherit default; - description = "Plugin to use for ${name}"; - }; + mkPackageOption = name: default: + mkOption { + type = types.package; + inherit default; + description = "Plugin to use for ${name}"; + }; - mkPlugin = { config, lib, ... }: { name - , description - , package ? null - , extraPlugins ? [ ] - , extraPackages ? [ ] - , options ? { } - , ... - }: - let - cfg = config.plugins.${name}; - # TODO support nested options! - pluginOptions = mapAttrs (k: v: v.option) options; - globals = mapAttrs' - (name: opt: { - name = opt.global; - value = if cfg.${name} != null then opt.value cfg.${name} else null; - }) - options; - # does this evaluate package? - packageOption = if package == null then { } else { + mkPlugin = { + config, + lib, + ... + }: { + name, + description, + package ? null, + extraPlugins ? [], + extraPackages ? [], + options ? {}, + ... + }: let + cfg = config.plugins.${name}; + # TODO support nested options! + pluginOptions = mapAttrs (k: v: v.option) options; + globals = + mapAttrs' + (name: opt: { + name = opt.global; + value = + if cfg.${name} != null + then opt.value cfg.${name} + else null; + }) + options; + # does this evaluate package? + packageOption = + if package == null + then {} + else { package = mkPackageOption name package; }; - in - { - options.plugins.${name} = { + in { + options.plugins.${name} = + { enable = mkEnableOption description; - } // packageOption // pluginOptions; - - config = mkIf cfg.enable { - inherit extraPackages globals; - # does this evaluate package? it would not be desired to evaluate pacakge if we use another package. - extraPlugins = extraPlugins ++ optional (package != null) cfg.package; - }; + } + // packageOption + // pluginOptions; + + config = mkIf cfg.enable { + inherit extraPackages globals; + # does this evaluate package? it would not be desired to evaluate pacakge if we use another package. + extraPlugins = extraPlugins ++ optional (package != null) cfg.package; }; + }; globalVal = val: - if builtins.isBool val then - (if val == false then 0 else 1) + if builtins.isBool val + then + ( + if val == false + then 0 + else 1 + ) else val; - mkDefaultOpt = { type, global, description ? null, example ? null, default ? null, value ? v: (globalVal v), ... }: { + mkDefaultOpt = { + type, + global, + description ? null, + example ? null, + default ? null, + value ? v: (globalVal v), + ... + }: { option = mkOption { type = types.nullOr type; default = default; @@ -153,7 +192,7 @@ rec { extraOptionsOptions = { extraOptions = mkOption { - default = { }; + default = {}; type = types.attrs; description = '' These attributes will be added to the table parameter for the setup function. @@ -162,7 +201,7 @@ rec { }; }; - mkRaw = r: { __raw = r; }; + mkRaw = r: {__raw = r;}; wrapDo = string: '' do diff --git a/lib/option-warnings.nix b/lib/option-warnings.nix index 68bb56667e..f4d776349a 100644 --- a/lib/option-warnings.nix +++ b/lib/option-warnings.nix @@ -1,73 +1,74 @@ -{ lib, ... }: -with lib; - -rec { +{lib, ...}: +with lib; rec { # This should be used instead of mkRemovedOptionModule, when the option still works, # but is just deprecated and should be changed now and for the future - mkDeprecatedOption = - { option # an array of the path to the option - , alternative ? null - , message ? null - , visible ? false - }: - { options, config, ... }: - let - fromOpt = getAttrFromPath option options; - fromValue = getAttrFromPath option config; - fullMessage = "The option `${showOption option}` has been deprecated, but might still work." + - (optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") + - (optionalString (message != null) " Message: ${message}"); - in - { - config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) { - warnings = [ - ("Nixvim: ${fullMessage}") - ]; - }; + mkDeprecatedOption = { + option, # an array of the path to the option + alternative ? null, + message ? null, + visible ? false, + }: { + options, + config, + ... + }: let + fromOpt = getAttrFromPath option options; + fromValue = getAttrFromPath option config; + fullMessage = + "The option `${showOption option}` has been deprecated, but might still work." + + (optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") + + (optionalString (message != null) " Message: ${message}"); + in { + config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) { + warnings = [ + "Nixvim: ${fullMessage}" + ]; }; + }; - mkRenamedOption = - { option - , newOption - , visible ? false - , warn ? true - , overrideDescription ? null - }: - { options, ... }: - let - fromOpt = getAttrFromPath option options; - # toOf = attrByPath newOption - # (abort "Renaming error: option `${showOption newOption}` does not exist."); - toType = let opt = attrByPath newOption { } options; in - opt.type or (types.submodule { }); - message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility"; + mkRenamedOption = { + option, + newOption, + visible ? false, + warn ? true, + overrideDescription ? null, + }: {options, ...}: let + fromOpt = getAttrFromPath option options; + # toOf = attrByPath newOption + # (abort "Renaming error: option `${showOption newOption}` does not exist."); + toType = let + opt = attrByPath newOption {} options; in - { - options = setAttrByPath option (mkOption - { - inherit visible; - description = - if overrideDescription == null - then message - else overrideDescription; - } // optionalAttrs (toType != null) { + opt.type or (types.submodule {}); + message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility"; + in { + options = setAttrByPath option (mkOption + { + inherit visible; + description = + if overrideDescription == null + then message + else overrideDescription; + } + // optionalAttrs (toType != null) { type = toType; }); - config = mkMerge [ - { - warnings = mkIf (warn && fromOpt.isDefined) [ "Nixvim: ${message}" ]; - } - (mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt) - ]; - }; - - mkAliasOption = option: newOption: mkRenamedOption { - inherit option newOption; - visible = true; - warn = false; - overrideDescription = "Alias of ${showOption newOption}"; + config = mkMerge [ + { + warnings = mkIf (warn && fromOpt.isDefined) ["Nixvim: ${message}"]; + } + (mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt) + ]; }; + mkAliasOption = option: newOption: + mkRenamedOption { + inherit option newOption; + visible = true; + warn = false; + overrideDescription = "Alias of ${showOption newOption}"; + }; + # TODO: # mkRemovedOption = # { option diff --git a/modules/autocmd.nix b/modules/autocmd.nix index 8a7ebc3ee0..6a596ec385 100644 --- a/modules/autocmd.nix +++ b/modules/autocmd.nix @@ -1,7 +1,10 @@ -{ config, lib, ... }: -with lib; -let - helpers = import ../lib/helpers.nix { inherit lib; }; +{ + config, + lib, + ... +}: +with lib; let + helpers = import ../lib/helpers.nix {inherit lib;}; autoGroupOption = types.submodule { options = { @@ -47,13 +50,11 @@ let nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands."; }; }; - -in -{ +in { options = { autoGroups = mkOption { type = types.attrsOf autoGroupOption; - default = { }; + default = {}; description = "augroup definitions"; example = '' autoGroups = { @@ -66,7 +67,7 @@ in autoCmd = mkOption { type = types.listOf autoCmdOption; - default = [ ]; + default = []; description = "autocmd definitions"; example = '' autoCmd = [ @@ -80,40 +81,41 @@ in }; }; - config = mkIf (config.autoGroups != { } || config.autoCmd != { }) { - extraConfigLuaPost = (optionalString (config.autoGroups != { }) '' - -- Set up autogroups {{ - do - local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups} + config = mkIf (config.autoGroups != {} || config.autoCmd != {}) { + extraConfigLuaPost = + (optionalString (config.autoGroups != {}) '' + -- Set up autogroups {{ + do + local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups} - for group_name, options in pairs(__nixvim_autogroups) do - vim.api.nvim_create_augroup(group_name, options) + for group_name, options in pairs(__nixvim_autogroups) do + vim.api.nvim_create_augroup(group_name, options) + end end - end - -- }} - '') + - (optionalString (config.autoCmd != [ ]) '' - -- Set up autocommands {{ - do - local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd} + -- }} + '') + + (optionalString (config.autoCmd != []) '' + -- Set up autocommands {{ + do + local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd} - for _, autocmd in ipairs(__nixvim_autocommands) do - vim.api.nvim_create_autocmd( - autocmd.event, - { - group = autocmd.group, - pattern = autocmd.pattern, - buffer = autocmd.buffer, - desc = autocmd.desc, - callback = autocmd.callback, - command = autocmd.command, - once = autocmd.once, - nested = autocmd.nested - } - ) + for _, autocmd in ipairs(__nixvim_autocommands) do + vim.api.nvim_create_autocmd( + autocmd.event, + { + group = autocmd.group, + pattern = autocmd.pattern, + buffer = autocmd.buffer, + desc = autocmd.desc, + callback = autocmd.callback, + command = autocmd.command, + once = autocmd.once, + nested = autocmd.nested + } + ) + end end - end - -- }} - ''); + -- }} + ''); }; } diff --git a/modules/colorscheme.nix b/modules/colorscheme.nix index 8036d2ab0b..cfebe94d74 100644 --- a/modules/colorscheme.nix +++ b/modules/colorscheme.nix @@ -1,6 +1,9 @@ -{ config, lib, ... }: -with lib; { + config, + lib, + ... +}: +with lib; { options = { colorscheme = mkOption { type = types.nullOr types.str; diff --git a/modules/highlights.nix b/modules/highlights.nix index 1015b26367..c09f239a9e 100644 --- a/modules/highlights.nix +++ b/modules/highlights.nix @@ -1,56 +1,58 @@ -{ config, lib, ... }: -let - helpers = import ../lib/helpers.nix { inherit lib; }; -in -with lib; { - options = { - highlight = mkOption { - type = types.attrsOf types.anything; - default = { }; - description = "Define highlight groups"; - example = '' - highlight = { - Comment.fg = '#ff0000'; - }; - ''; - }; + config, + lib, + ... +}: let + helpers = import ../lib/helpers.nix {inherit lib;}; +in + with lib; { + options = { + highlight = mkOption { + type = types.attrsOf types.anything; + default = {}; + description = "Define highlight groups"; + example = '' + highlight = { + Comment.fg = '#ff0000'; + }; + ''; + }; - match = mkOption { - type = types.attrsOf types.str; - default = { }; - description = "Define match groups"; - example = '' - match = { - ExtraWhitespace = '\\s\\+$'; - }; - ''; + match = mkOption { + type = types.attrsOf types.str; + default = {}; + description = "Define match groups"; + example = '' + match = { + ExtraWhitespace = '\\s\\+$'; + }; + ''; + }; }; - }; - config = mkIf (config.highlight != { } || config.match != { }) { - extraConfigLuaPost = (optionalString (config.highlight != { }) '' - -- Highlight groups {{ - do - local highlights = ${helpers.toLuaObject config.highlight} + config = mkIf (config.highlight != {} || config.match != {}) { + extraConfigLuaPost = + (optionalString (config.highlight != {}) '' + -- Highlight groups {{ + do + local highlights = ${helpers.toLuaObject config.highlight} - for k,v in pairs(highlights) do - vim.api.nvim_set_hl(0, k, v) - end - end - -- }} - '') + - (optionalString (config.match != { }) '' - -- Match groups {{ - do - local match = ${helpers.toLuaObject config.match} - - for k,v in pairs(match) do - vim.fn.matchadd(k, v) + for k,v in pairs(highlights) do + vim.api.nvim_set_hl(0, k, v) + end end - end - -- }} - ''); - }; -} + -- }} + '') + + (optionalString (config.match != {}) '' + -- Match groups {{ + do + local match = ${helpers.toLuaObject config.match} + for k,v in pairs(match) do + vim.fn.matchadd(k, v) + end + end + -- }} + ''); + }; + } diff --git a/modules/keymaps.nix b/modules/keymaps.nix index c407c3a883..c95e0fed45 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -1,7 +1,10 @@ -{ config, lib, ... }: -with lib; -let - helpers = import ../lib/helpers.nix { inherit lib; }; +{ + config, + lib, + ... +}: +with lib; let + helpers = import ../lib/helpers.nix {inherit lib;}; mapOption = types.oneOf [ types.str @@ -57,13 +60,13 @@ let }) ]; - mapOptions = mode: mkOption { - description = "Mappings for ${mode} mode"; - type = types.attrsOf mapOption; - default = { }; - }; -in -{ + mapOptions = mode: + mkOption { + description = "Mappings for ${mode} mode"; + type = types.attrsOf mapOption; + default = {}; + }; +in { options = { maps = mkOption { type = types.submodule { @@ -82,7 +85,7 @@ in command = mapOptions "command-line"; }; }; - default = { }; + default = {}; description = '' Custom keybindings for any mode. @@ -101,32 +104,30 @@ in }; }; - config = - let - mappings = - (helpers.genMaps "" config.maps.normalVisualOp) ++ - (helpers.genMaps "n" config.maps.normal) ++ - (helpers.genMaps "i" config.maps.insert) ++ - (helpers.genMaps "v" config.maps.visual) ++ - (helpers.genMaps "x" config.maps.visualOnly) ++ - (helpers.genMaps "s" config.maps.select) ++ - (helpers.genMaps "t" config.maps.terminal) ++ - (helpers.genMaps "o" config.maps.operator) ++ - (helpers.genMaps "l" config.maps.lang) ++ - (helpers.genMaps "!" config.maps.insertCommand) ++ - (helpers.genMaps "c" config.maps.command); - in - { - extraConfigLua = optionalString (mappings != [ ]) '' - -- Set up keybinds {{{ - do - local __nixvim_binds = ${helpers.toLuaObject mappings} + config = let + mappings = + (helpers.genMaps "" config.maps.normalVisualOp) + ++ (helpers.genMaps "n" config.maps.normal) + ++ (helpers.genMaps "i" config.maps.insert) + ++ (helpers.genMaps "v" config.maps.visual) + ++ (helpers.genMaps "x" config.maps.visualOnly) + ++ (helpers.genMaps "s" config.maps.select) + ++ (helpers.genMaps "t" config.maps.terminal) + ++ (helpers.genMaps "o" config.maps.operator) + ++ (helpers.genMaps "l" config.maps.lang) + ++ (helpers.genMaps "!" config.maps.insertCommand) + ++ (helpers.genMaps "c" config.maps.command); + in { + extraConfigLua = optionalString (mappings != []) '' + -- Set up keybinds {{{ + do + local __nixvim_binds = ${helpers.toLuaObject mappings} - for i, map in ipairs(__nixvim_binds) do - vim.keymap.set(map.mode, map.key, map.action, map.config) - end + for i, map in ipairs(__nixvim_binds) do + vim.keymap.set(map.mode, map.key, map.action, map.config) end - -- }}} - ''; - }; + end + -- }}} + ''; + }; } diff --git a/modules/options.nix b/modules/options.nix index e448db1791..f99d072767 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -1,44 +1,48 @@ -{ config, lib, ... }: -with lib; -let - helpers = import ../lib/helpers.nix { inherit lib; }; -in { + config, + lib, + ... +}: +with lib; let + helpers = import ../lib/helpers.nix {inherit lib;}; +in { options = { options = mkOption { type = types.attrsOf types.anything; - default = { }; + default = {}; description = "The configuration options, e.g. line numbers"; }; globals = mkOption { type = types.attrsOf types.anything; - default = { }; + default = {}; description = "Global variables"; }; }; config = { - extraConfigLuaPre = optionalString (config.globals != { }) '' - -- Set up globals {{{ - do - local nixvim_globals = ${helpers.toLuaObject config.globals} + extraConfigLuaPre = + optionalString (config.globals != {}) '' + -- Set up globals {{{ + do + local nixvim_globals = ${helpers.toLuaObject config.globals} - for k,v in pairs(nixvim_globals) do - vim.g[k] = v + for k,v in pairs(nixvim_globals) do + vim.g[k] = v + end end - end - -- }}} - '' + optionalString (config.options != { }) '' - -- Set up options {{{ - do - local nixvim_options = ${helpers.toLuaObject config.options} + -- }}} + '' + + optionalString (config.options != {}) '' + -- Set up options {{{ + do + local nixvim_options = ${helpers.toLuaObject config.options} - for k,v in pairs(nixvim_options) do - vim.opt[k] = v + for k,v in pairs(nixvim_options) do + vim.opt[k] = v + end end - end - -- }}} - ''; + -- }}} + ''; }; } diff --git a/modules/output.nix b/modules/output.nix index 516607b626..b20ab57d62 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -1,6 +1,10 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let pluginWithConfigType = types.submodule { options = { config = mkOption { @@ -9,9 +13,11 @@ let default = ""; }; - optional = mkEnableOption "optional" // { - description = "Don't load by default (load with :packadd)"; - }; + optional = + mkEnableOption "optional" + // { + description = "Don't load by default (load with :packadd)"; + }; plugin = mkOption { type = types.package; @@ -19,8 +25,7 @@ let }; }; }; -in -{ +in { options = { viAlias = mkOption { type = types.bool; @@ -46,13 +51,13 @@ in extraPlugins = mkOption { type = with types; listOf (either package pluginWithConfigType); - default = [ ]; + default = []; description = "List of vim plugins to install"; }; extraPackages = mkOption { type = types.listOf types.package; - default = [ ]; + default = []; description = "Extra packages to be made available to neovim"; }; @@ -74,7 +79,6 @@ in description = "Extra contents for init.lua after everything else"; }; - extraConfigVim = mkOption { type = types.lines; default = ""; @@ -101,18 +105,23 @@ in }; }; - config = - let - - defaultPlugin = { - plugin = null; - config = ""; - optional = false; - }; + config = let + defaultPlugin = { + plugin = null; + config = ""; + optional = false; + }; - normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins; + normalizedPlugins = map (x: + defaultPlugin + // ( + if x ? plugin + then x + else {plugin = x;} + )) + config.extraPlugins; - neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({ + neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({ inherit (config) viAlias vimAlias; # inherit customRC; plugins = normalizedPlugins; @@ -121,44 +130,47 @@ in # or more generally before the commit: # cda1f8ae468 - neovim: pass packpath via the wrapper // optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) { - configure.packages = - { nixvim = { start = map (x: x.plugin) normalizedPlugins; opt = [ ]; }; }; + configure.packages = { + nixvim = { + start = map (x: x.plugin) normalizedPlugins; + opt = []; + }; + }; }); - customRC = - '' - vim.cmd([[ - ${neovimConfig.neovimRcContent} - ]]) - '' + - (optionalString (config.extraConfigLuaPre != "") '' - ${config.extraConfigLuaPre} - '') + - (optionalString (config.extraConfigVim != "") '' - vim.cmd([[ - ${config.extraConfigVim} - ]]) - '') + - (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") '' - ${config.extraConfigLua} - ${config.extraConfigLuaPost} - ''); - - extraWrapperArgs = builtins.concatStringsSep " " ( - (optional (config.extraPackages != [ ]) - ''--prefix PATH : "${makeBinPath config.extraPackages}"'') - ++ - (optional (config.wrapRc) - ''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'') - ); - - wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // { + customRC = + '' + vim.cmd([[ + ${neovimConfig.neovimRcContent} + ]]) + '' + + (optionalString (config.extraConfigLuaPre != "") '' + ${config.extraConfigLuaPre} + '') + + (optionalString (config.extraConfigVim != "") '' + vim.cmd([[ + ${config.extraConfigVim} + ]]) + '') + + (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") '' + ${config.extraConfigLua} + ${config.extraConfigLuaPost} + ''); + + extraWrapperArgs = builtins.concatStringsSep " " ( + (optional (config.extraPackages != []) + ''--prefix PATH : "${makeBinPath config.extraPackages}"'') + ++ (optional (config.wrapRc) + ''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'') + ); + + wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig + // { wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs; wrapRc = false; }); - in - { - finalPackage = wrappedNeovim; - initContent = customRC; - }; + in { + finalPackage = wrappedNeovim; + initContent = customRC; + }; } diff --git a/modules/plugins.nix b/modules/plugins.nix index 59d0271cf2..73ac600366 100644 --- a/modules/plugins.nix +++ b/modules/plugins.nix @@ -1,5 +1,4 @@ -{ ... }: -{ +{...}: { imports = [ ../plugins/default.nix ]; diff --git a/modules/warnings.nix b/modules/warnings.nix index 2790518776..d9d1d6e57f 100644 --- a/modules/warnings.nix +++ b/modules/warnings.nix @@ -1,7 +1,5 @@ -{ lib, ... }: -with lib; - -{ +{lib, ...}: +with lib; { options = { warnings = mkOption { type = types.listOf types.str; diff --git a/plugins/bufferlines/barbar.nix b/plugins/bufferlines/barbar.nix index 14c7150112..dfcb3cf54a 100644 --- a/plugins/bufferlines/barbar.nix +++ b/plugins/bufferlines/barbar.nix @@ -1,10 +1,13 @@ -{ lib, pkgs, config, ... }: -with lib; -let - cfg = config.plugins.barbar; - helpers = import ../helpers.nix { inherit lib; }; -in { + lib, + pkgs, + config, + ... +}: +with lib; let + cfg = config.plugins.barbar; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.barbar = { enable = mkEnableOption "barbar.nvim"; @@ -65,24 +68,25 @@ in highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers"; - icons = { - enable = helpers.defaultNullOpts.mkNullable - (with types; (either bool (enum [ "numbers" "both" ]))) + enable = + helpers.defaultNullOpts.mkNullable + (with types; (either bool (enum ["numbers" "both"]))) "true" '' - Enable/disable icons if set to 'numbers', will show buffer index in the tabline if set to - 'both', will show buffer index and icons in the tabline + Enable/disable icons if set to 'numbers', will show buffer index in the tabline if set to + 'both', will show buffer index and icons in the tabline ''; - customColors = helpers.defaultNullOpts.mkNullable + customColors = + helpers.defaultNullOpts.mkNullable (types.either types.bool types.str) "false" '' - If set, the icon color will follow its corresponding buffer - highlight group. By default, the Buffer*Icon group is linked to the - Buffer* group (see Highlighting below). Otherwise, it will take its - default value as defined by devicons. + If set, the icon color will follow its corresponding buffer + highlight group. By default, the Buffer*Icon group is linked to the + Buffer* group (see Highlighting below). Otherwise, it will take its + default value as defined by devicons. ''; separatorActive = helpers.defaultNullOpts.mkStr "▎" "Icon for the active tab separator"; @@ -122,7 +126,6 @@ in But only a static string is accepted here. ''; - # Keybinds concept: # keys = { # previousBuffer = mkBindDef "normal" "Previous buffer" { action = ":BufferPrevious"; silent = true; } ""; @@ -182,16 +185,16 @@ in tabpages = cfg.tabpages; }; in - mkIf cfg.enable { - extraPlugins = with pkgs.vimPlugins; [ - cfg.package - nvim-web-devicons - ]; - - extraConfigLua = '' - require('bufferline').setup(${helpers.toLuaObject setupOptions}) - ''; + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [ + cfg.package + nvim-web-devicons + ]; - # maps = genMaps cfg.keys; - }; + extraConfigLua = '' + require('bufferline').setup(${helpers.toLuaObject setupOptions}) + ''; + + # maps = genMaps cfg.keys; + }; } diff --git a/plugins/bufferlines/bufferline.nix b/plugins/bufferlines/bufferline.nix index 8b92e97a05..03f9cab944 100644 --- a/plugins/bufferlines/bufferline.nix +++ b/plugins/bufferlines/bufferline.nix @@ -1,12 +1,16 @@ -{ config, pkgs, lib, ... }@args: -with lib; -let +{ + config, + pkgs, + lib, + ... +} @ args: +with lib; let cfg = config.plugins.bufferline; optionWarnings = import ../../lib/option-warnings.nix args; helpers = import ../helpers.nix args; highlight = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { guifg = mkOption { type = types.nullOr types.str; @@ -20,14 +24,13 @@ let }; }; })); - default = { }; + default = {}; }; -in -{ +in { imports = [ (optionWarnings.mkDeprecatedOption { - option = [ "plugins" "bufferline" "indicatorIcon" ]; - alternative = [ "plugins" "bufferline" "indicator" "icon" ]; + option = ["plugins" "bufferline" "indicatorIcon"]; + alternative = ["plugins" "bufferline" "indicator" "icon"]; }) ]; @@ -111,7 +114,7 @@ in default = null; }; diagnostics = mkOption { - type = types.nullOr (types.enum [ false "nvim_lsp" "coc" ]); + type = types.nullOr (types.enum [false "nvim_lsp" "coc"]); default = null; }; diagnosticsUpdateInInsert = mkOption { @@ -147,7 +150,7 @@ in default = null; }; separatorStyle = mkOption { - type = types.nullOr (types.enum [ "slant" "thick" "thin" ]); + type = types.nullOr (types.enum ["slant" "thick" "thin"]); default = null; }; enforceRegularTabs = mkOption { @@ -159,27 +162,27 @@ in default = null; }; sortBy = mkOption { - type = types.nullOr (types.enum [ "id" "extension" "relative_directory" "directory" "tabs" ]); + type = types.nullOr (types.enum ["id" "extension" "relative_directory" "directory" "tabs"]); default = null; }; indicator = mkOption { - default = { }; - type = types.nullOr (types.submodule ({ ... }: { + default = {}; + type = types.nullOr (types.submodule ({...}: { options = { icon = mkOption { type = types.nullOr types.str; default = null; }; style = mkOption { - type = types.nullOr (types.enum [ "icon" "underline" "none" ]); + type = types.nullOr (types.enum ["icon" "underline" "none"]); default = null; }; }; })); }; highlights = mkOption { - default = { }; - type = types.nullOr (types.submodule ({ ... }: { + default = {}; + type = types.nullOr (types.submodule ({...}: { options = { fill = highlight; background = highlight; @@ -246,16 +249,16 @@ in extraOptions = mkOption { type = types.attrs; - default = { }; + default = {}; description = "Extra options, will override others if defined"; }; }; }; - config = - let - setupOptions = { - options = { + config = let + setupOptions = { + options = + { numbers = cfg.numbers; close_command = cfg.closeCommand; right_mouse_command = cfg.rightMouseCommand; @@ -264,10 +267,13 @@ in # deprecated, but might still work indicator_icon = cfg.indicatorIcon; indicator = - if cfg.indicator != null then with cfg.indicator; { - icon = icon; - style = style; - } else null; + if cfg.indicator != null + then + with cfg.indicator; { + icon = icon; + style = style; + } + else null; buffer_close_icon = cfg.bufferCloseIcon; modified_icon = cfg.modifiedIcon; close_icon = cfg.closeIcon; @@ -290,70 +296,74 @@ in enforce_regular_tabs = cfg.enforceRegularTabs; always_show_bufferline = cfg.alwaysShowBufferline; sort_by = cfg.sortBy; - } // cfg.extraOptions; - highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; { - fill = fill; - background = background; - - tab = tab; - tab_selected = tabSelected; - tab_close = tabClose; - close_button = closeButton; - close_button_visible = closeButtonVisible; - close_button_selected = closeButtonSelected; - - buffer_visible = bufferVisible; - buffer_selected = bufferSelected; - - diagnostic = diagnostic; - diagnostic_visible = diagnosticVisible; - diagnostic_selected = diagnosticSelected; - - info = info; - info_visible = infoVisible; - info_selected = infoSelected; - - info_diagnostic = infoDiagnostic; - info_diagnostic_visible = infoDiagnosticVisible; - info_diagnostic_selected = infoDiagnosticSelected; - - warning = warning; - warning_visible = warningVisible; - warning_selected = warningSelected; - - warning_diagnostic = warningDiagnostic; - warning_diagnostic_visible = warningDiagnosticVisible; - warning_diagnostic_selected = warningDiagnosticSelected; - - error = error; - error_visible = errorVisible; - error_selected = errorSelected; - - error_dagnostic = errorDiagnostic; - error_diagnostic_visible = errorDiagnosticVisible; - error_diagnostic_selected = errorDiagnosticSelected; - - modified = modified; - modified_visible = modifiedVisible; - modified_selected = modifiedSelected; - - duplicate = duplicate; - duplicate_visible = duplicateVisible; - duplicate_selected = duplicateSelected; - - separator = separator; - separator_visible = separatorVisible; - separator_selected = separatorSelected; - - indicator_selected = indicatorSelected; - - pick = pick; - pick_visible = pickVisible; - pick_selected = pickSelected; - - }; - }; - in + } + // cfg.extraOptions; + highlights = + if builtins.isNull cfg.highlights + then null + else + with cfg.highlights; { + fill = fill; + background = background; + + tab = tab; + tab_selected = tabSelected; + tab_close = tabClose; + close_button = closeButton; + close_button_visible = closeButtonVisible; + close_button_selected = closeButtonSelected; + + buffer_visible = bufferVisible; + buffer_selected = bufferSelected; + + diagnostic = diagnostic; + diagnostic_visible = diagnosticVisible; + diagnostic_selected = diagnosticSelected; + + info = info; + info_visible = infoVisible; + info_selected = infoSelected; + + info_diagnostic = infoDiagnostic; + info_diagnostic_visible = infoDiagnosticVisible; + info_diagnostic_selected = infoDiagnosticSelected; + + warning = warning; + warning_visible = warningVisible; + warning_selected = warningSelected; + + warning_diagnostic = warningDiagnostic; + warning_diagnostic_visible = warningDiagnosticVisible; + warning_diagnostic_selected = warningDiagnosticSelected; + + error = error; + error_visible = errorVisible; + error_selected = errorSelected; + + error_dagnostic = errorDiagnostic; + error_diagnostic_visible = errorDiagnosticVisible; + error_diagnostic_selected = errorDiagnosticSelected; + + modified = modified; + modified_visible = modifiedVisible; + modified_selected = modifiedSelected; + + duplicate = duplicate; + duplicate_visible = duplicateVisible; + duplicate_selected = duplicateSelected; + + separator = separator; + separator_visible = separatorVisible; + separator_selected = separatorSelected; + + indicator_selected = indicatorSelected; + + pick = pick; + pick_visible = pickVisible; + pick_selected = pickSelected; + }; + }; + in mkIf cfg.enable { extraPlugins = with pkgs.vimPlugins; [ cfg.package diff --git a/plugins/colorschemes/base16.nix b/plugins/colorschemes/base16.nix index 1a61c4d516..a8a8fb8330 100644 --- a/plugins/colorschemes/base16.nix +++ b/plugins/colorschemes/base16.nix @@ -1,11 +1,14 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.colorschemes.base16; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; themes = import ./base16-list.nix; -in -{ +in { options = { colorschemes.base16 = { enable = mkEnableOption "base16"; @@ -34,7 +37,7 @@ in config = mkIf cfg.enable { colorscheme = "base16-${cfg.colorscheme}"; - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; plugins.airline.theme = mkIf (cfg.setUpBar) "base16"; plugins.lightline.colorscheme = null; diff --git a/plugins/colorschemes/gruvbox.nix b/plugins/colorschemes/gruvbox.nix index dcc3b590de..94a351d306 100644 --- a/plugins/colorschemes/gruvbox.nix +++ b/plugins/colorschemes/gruvbox.nix @@ -1,11 +1,14 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.colorschemes.gruvbox; - helpers = import ../helpers.nix { inherit lib; }; - colors = types.enum [ "bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4" ]; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.colorschemes.gruvbox; + helpers = import ../helpers.nix {inherit lib;}; + colors = types.enum ["bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4"]; +in { options = { colorschemes.gruvbox = { enable = mkEnableOption "gruvbox"; @@ -18,13 +21,13 @@ in undercurl = mkEnableOption "undercurled text"; contrastDark = mkOption { - type = types.nullOr (types.enum [ "soft" "medium" "hard" ]); + type = types.nullOr (types.enum ["soft" "medium" "hard"]); default = null; description = "Contrast for the dark mode"; }; contrastLight = mkOption { - type = types.nullOr (types.enum [ "soft" "medium" "hard" ]); + type = types.nullOr (types.enum ["soft" "medium" "hard"]); default = null; description = "Contrast for the light mode"; }; @@ -110,13 +113,12 @@ in transparentBg = mkEnableOption "transparent background"; trueColor = mkEnableOption "true color support"; - }; }; config = mkIf cfg.enable { colorscheme = "gruvbox"; - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { gruvbox_bold = mkIf (!cfg.bold) 0; diff --git a/plugins/colorschemes/nord.nix b/plugins/colorschemes/nord.nix index cc464f722c..1163db1220 100644 --- a/plugins/colorschemes/nord.nix +++ b/plugins/colorschemes/nord.nix @@ -1,29 +1,37 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.colorschemes.nord; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.colorschemes.nord; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { colorschemes.nord = { enable = mkEnableOption "nord"; package = helpers.mkPackageOption "nord.vim" pkgs.vimPlugins.nord-nvim; - contrast = mkEnableOption + contrast = + mkEnableOption "Make sidebars and popup menus like nvim-tree and telescope have a different background"; - borders = mkEnableOption + borders = + mkEnableOption "Enable the border between verticaly split windows visable"; - disable_background = mkEnableOption + disable_background = + mkEnableOption "Disable the setting of background color so that NeoVim can use your terminal background"; - cursorline_transparent = mkEnableOption + cursorline_transparent = + mkEnableOption "Set the cursorline transparent/visible"; - enable_sidebar_background = mkEnableOption + enable_sidebar_background = + mkEnableOption "Re-enables the background of the sidebar if you disabled the background of everything"; italic = mkOption { @@ -36,7 +44,7 @@ in config = mkIf cfg.enable { colorscheme = "nord"; - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { nord_contrast = mkIf cfg.contrast 1; diff --git a/plugins/colorschemes/one.nix b/plugins/colorschemes/one.nix index d4432570aa..02f41770e6 100644 --- a/plugins/colorschemes/one.nix +++ b/plugins/colorschemes/one.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.colorschemes.one; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.colorschemes.one; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { colorschemes.one = { enable = mkEnableOption "vim-one"; @@ -15,7 +18,7 @@ in config = mkIf cfg.enable { colorscheme = "one"; - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; options = { termguicolors = true; diff --git a/plugins/colorschemes/onedark.nix b/plugins/colorschemes/onedark.nix index 802d0feaaf..4ac675b112 100644 --- a/plugins/colorschemes/onedark.nix +++ b/plugins/colorschemes/onedark.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.colorschemes.onedark; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.colorschemes.onedark; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { colorschemes.onedark = { enable = mkEnableOption "onedark"; @@ -15,7 +18,7 @@ in config = mkIf cfg.enable { colorscheme = "onedark"; - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; options = { termguicolors = true; diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix index 268b49c42a..f061878eea 100644 --- a/plugins/colorschemes/tokyonight.nix +++ b/plugins/colorschemes/tokyonight.nix @@ -1,76 +1,72 @@ -{ pkgs -, config -, lib -, ... -}@args: +{ + pkgs, + config, + lib, + ... +} @ args: with lib; let cfg = config.colorschemes.tokyonight; helpers = import ../helpers.nix args; -in -{ +in { options = { colorschemes.tokyonight = { enable = mkEnableOption "tokyonight"; package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim; - style = helpers.defaultNullOpts.mkEnumFirstDefault [ "storm" "night" "day" ] "Theme style"; + style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] "Theme style"; terminalColors = helpers.defaultNullOpts.mkBool true - "Configure the colors used when opening a :terminal in Neovim"; + "Configure the colors used when opening a :terminal in Neovim"; transparent = helpers.defaultNullOpts.mkBool false "disable setting the background color"; - styles = - let - mkBackgroundStyle = name: - helpers.defaultNullOpts.mkEnumFirstDefault [ "dark" "transparent" "normal" ] - "Background style for ${name}"; - in - { - comments = - helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}" - "Define comments highlight properties"; - keywords = - helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}" - "Define keywords highlight properties"; - functions = - helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" - "Define functions highlight properties"; - variables = - helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" - "Define variables highlight properties"; - sidebars = mkBackgroundStyle "sidebars"; - floats = mkBackgroundStyle "floats"; - }; + styles = let + mkBackgroundStyle = name: + helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"] + "Background style for ${name}"; + in { + comments = + helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}" + "Define comments highlight properties"; + keywords = + helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}" + "Define keywords highlight properties"; + functions = + helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" + "Define functions highlight properties"; + variables = + helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" + "Define variables highlight properties"; + sidebars = mkBackgroundStyle "sidebars"; + floats = mkBackgroundStyle "floats"; + }; sidebars = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["qf" "help"]'' - "Set a darker background on sidebar-like windows"; + "Set a darker background on sidebar-like windows"; dayBrightness = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3" - "Adjusts the brightness of the colors of the **Day** style"; + "Adjusts the brightness of the colors of the **Day** style"; hideInactiveStatusline = helpers.defaultNullOpts.mkBool false - "Enabling this option will hide inactive statuslines and replace them with a thin border"; + "Enabling this option will hide inactive statuslines and replace them with a thin border"; dimInactive = helpers.defaultNullOpts.mkBool false "dims inactive windows"; lualineBold = helpers.defaultNullOpts.mkBool false - "When true, section headers in the lualine theme will be bold"; + "When true, section headers in the lualine theme will be bold"; }; }; config = mkIf cfg.enable { colorscheme = "tokyonight"; - extraPlugins = [ cfg.package ]; - options = { termguicolors = true; }; - extraConfigLuaPre = - let - setupOptions = with cfg; { - inherit (cfg) style transparent styles sidebars; - terminal_colors = terminalColors; - hide_inactive_statusline = hideInactiveStatusline; - dim_inactive = dimInactive; - lualine_bold = lualineBold; - day_brightness = dayBrightness; - }; - in - '' - require("tokyonight").setup(${helpers.toLuaObject setupOptions}) - ''; + extraPlugins = [cfg.package]; + options = {termguicolors = true;}; + extraConfigLuaPre = let + setupOptions = with cfg; { + inherit (cfg) style transparent styles sidebars; + terminal_colors = terminalColors; + hide_inactive_statusline = hideInactiveStatusline; + dim_inactive = dimInactive; + lualine_bold = lualineBold; + day_brightness = dayBrightness; + }; + in '' + require("tokyonight").setup(${helpers.toLuaObject setupOptions}) + ''; }; } diff --git a/plugins/completion/copilot.nix b/plugins/completion/copilot.nix index 84c6c27fbb..e8efc20f6b 100644 --- a/plugins/completion/copilot.nix +++ b/plugins/completion/copilot.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.copilot; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.copilot; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.copilot = { enable = mkEnableOption "copilot"; @@ -12,11 +15,11 @@ in filetypes = mkOption { type = types.attrsOf types.bool; description = "A dictionary mapping file types to their enabled status"; - default = { }; - example = literalExpression ''{ - "*": false, - python: true - }''; + default = {}; + example = literalExpression '' { + "*": false, + python: true + }''; }; proxy = mkOption { type = types.nullOr types.str; @@ -27,12 +30,17 @@ in }; }; - config = - mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - globals = { + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; + globals = + { copilot_node_command = "${pkgs.nodejs-16_x}/bin/node"; copilot_filetypes = cfg.filetypes; - } // (if cfg.proxy != null then { copilot_proxy = cfg.proxy; } else { }); - }; + } + // ( + if cfg.proxy != null + then {copilot_proxy = cfg.proxy;} + else {} + ); + }; } diff --git a/plugins/completion/coq.nix b/plugins/completion/coq.nix index c0af25b5e8..9a3614586a 100644 --- a/plugins/completion/coq.nix +++ b/plugins/completion/coq.nix @@ -1,12 +1,14 @@ -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.plugins.coq-nvim; - helpers = import ../helpers.nix { inherit lib; }; - plugins = import ../plugin-defs.nix { inherit pkgs; }; - -in { + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.plugins.coq-nvim; + helpers = import ../helpers.nix {inherit lib;}; + plugins = import ../plugin-defs.nix {inherit pkgs;}; +in { options = { plugins.coq-nvim = { enable = mkEnableOption "coq-nvim"; @@ -16,7 +18,7 @@ in installArtifacts = mkEnableOption "Install coq-artifacts"; autoStart = mkOption { - type = with types; nullOr (oneOf [ bool (enum [ "shut-up" ]) ]); + type = with types; nullOr (oneOf [bool (enum ["shut-up"])]); default = null; description = "Auto-start or shut up"; }; @@ -28,23 +30,24 @@ in }; }; }; - config = - let - settings = { - auto_start = cfg.autoStart; - "keymap.recommended" = cfg.recommendedKeymaps; - }; - in + config = let + settings = { + auto_start = cfg.autoStart; + "keymap.recommended" = cfg.recommendedKeymaps; + }; + in mkIf cfg.enable { - extraPlugins = [ - cfg.package - ] ++ optional cfg.installArtifacts plugins.coq-artifacts; + extraPlugins = + [ + cfg.package + ] + ++ optional cfg.installArtifacts plugins.coq-artifacts; plugins.lsp = { preConfig = '' vim.g.coq_settings = ${helpers.toLuaObject settings} local coq = require 'coq' ''; - setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ]; + setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')]; }; }; } diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index e03293c079..deead798a0 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -1,23 +1,26 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.lspkind; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.lspkind; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.lspkind = { enable = mkEnableOption "lspkind.nvim"; package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim; mode = mkOption { - type = with types; nullOr (enum [ "text" "text_symbol" "symbol_text" "symbol" ]); + type = with types; nullOr (enum ["text" "text_symbol" "symbol_text" "symbol"]); default = null; description = "Defines how annotations are shown"; }; preset = mkOption { - type = with types; nullOr (enum [ "default" "codicons" ]); + type = with types; nullOr (enum ["default" "codicons"]); default = null; description = "Default symbol map"; }; @@ -61,34 +64,41 @@ in }; }; - config = - let - doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable; - options = { + config = let + doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable; + options = + { mode = cfg.mode; preset = cfg.preset; symbol_map = cfg.symbolMap; - } // (if doCmp then { - maxwidth = cfg.cmp.maxWidth; - ellipsis_char = cfg.cmp.ellipsisChar; - menu = cfg.cmp.menu; - } else { }); - in + } + // ( + if doCmp + then { + maxwidth = cfg.cmp.maxWidth; + ellipsis_char = cfg.cmp.ellipsisChar; + menu = cfg.cmp.menu; + } + else {} + ); + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = optionalString (!doCmp) '' require('lspkind').init(${helpers.toLuaObject options}) ''; plugins.nvim-cmp.formatting.format = - if cfg.cmp.after != null then '' + if cfg.cmp.after != null + then '' function(entry, vim_item) local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) return (${cfg.cmp.after})(entry, vim_after, kind) end - '' else '' + '' + else '' require('lspkind').cmp_format(${helpers.toLuaObject options}) ''; }; diff --git a/plugins/completion/nvim-cmp/cmp-helpers.nix b/plugins/completion/nvim-cmp/cmp-helpers.nix index 72cc4075c3..8d76b8ae7a 100644 --- a/plugins/completion/nvim-cmp/cmp-helpers.nix +++ b/plugins/completion/nvim-cmp/cmp-helpers.nix @@ -1,54 +1,64 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../../helpers.nix { inherit lib; }; -in with helpers; with lib; { - mkCmpSourcePlugin = { name, extraPlugins ? [], useDefaultPackage ? true, ... }: mkPlugin attrs { - inherit name; - extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); - description = "Enable ${name}"; - }; + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../../helpers.nix {inherit lib;}; +in + with helpers; + with lib; { + mkCmpSourcePlugin = { + name, + extraPlugins ? [], + useDefaultPackage ? true, + ... + }: + mkPlugin attrs { + inherit name; + extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); + description = "Enable ${name}"; + }; - pluginAndSourceNames = { - "luasnip" = "cmp_luasnip"; - "snippy" = "cmp-snippy"; - "ultisnips" = "cmp-nvim-ultisnips"; - "vsnip" = "cmp-vsnip"; - "buffer" = "cmp-buffer"; - "calc" = "cmp-calc"; - "dictionary" = "cmp-dictionary"; - "digraphs" = "cmp-digraphs"; - "omni" = "cmp-omni"; - "spell" = "cmp-spell"; - "nvim_lsp" = "cmp-nvim-lsp"; - "nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol"; - "nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help"; - "vim_lsp" = "cmp-vim-lsp"; - "path" = "cmp-path"; - "git" = "cmp-git"; - "conventionalcommits" = "cmp-conventionalcommits"; - "cmdline" = "cmp-cmdline"; - "cmp-cmdline-history" = "cmp-cmdline-history"; - "fuzzy_buffer" = "cmp-fuzzy-buffer"; - "fuzzy_path" = "cmp-fuzzy-path"; - "rg" = "cmp-rg"; - "fish" = "cmp-fish"; - "tmux" = "cmp-tmux"; - "zsh" = "cmp-zsh"; - "crates" = "crates-nvim"; - "npm" = "cmp-npm"; - "cmp-clippy" = "cmp-clippy"; - "cmp_tabnine" = "cmp-tabnine"; - "copilot" = "cmp-copilot"; - "dap" = "cmp-dap"; - "emoji" = "cmp-emoji"; - "greek" = "cmp-greek"; - "latex_symbols" = "cmp-latex-symbols"; - "look" = "cmp-look"; - "nvim_lua" = "cmp-nvim-lua"; - "pandoc_references" = "cmp-pandoc-references"; - "cmp_pandoc" = "cmp-pandoc-nvim"; - "treesitter" = "cmp-treesitter"; - "vimwiki-tags" = "cmp-vimwiki-tags"; - }; -} + pluginAndSourceNames = { + "luasnip" = "cmp_luasnip"; + "snippy" = "cmp-snippy"; + "ultisnips" = "cmp-nvim-ultisnips"; + "vsnip" = "cmp-vsnip"; + "buffer" = "cmp-buffer"; + "calc" = "cmp-calc"; + "dictionary" = "cmp-dictionary"; + "digraphs" = "cmp-digraphs"; + "omni" = "cmp-omni"; + "spell" = "cmp-spell"; + "nvim_lsp" = "cmp-nvim-lsp"; + "nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol"; + "nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help"; + "vim_lsp" = "cmp-vim-lsp"; + "path" = "cmp-path"; + "git" = "cmp-git"; + "conventionalcommits" = "cmp-conventionalcommits"; + "cmdline" = "cmp-cmdline"; + "cmp-cmdline-history" = "cmp-cmdline-history"; + "fuzzy_buffer" = "cmp-fuzzy-buffer"; + "fuzzy_path" = "cmp-fuzzy-path"; + "rg" = "cmp-rg"; + "fish" = "cmp-fish"; + "tmux" = "cmp-tmux"; + "zsh" = "cmp-zsh"; + "crates" = "crates-nvim"; + "npm" = "cmp-npm"; + "cmp-clippy" = "cmp-clippy"; + "cmp_tabnine" = "cmp-tabnine"; + "copilot" = "cmp-copilot"; + "dap" = "cmp-dap"; + "emoji" = "cmp-emoji"; + "greek" = "cmp-greek"; + "latex_symbols" = "cmp-latex-symbols"; + "look" = "cmp-look"; + "nvim_lua" = "cmp-nvim-lua"; + "pandoc_references" = "cmp-pandoc-references"; + "cmp_pandoc" = "cmp-pandoc-nvim"; + "treesitter" = "cmp-treesitter"; + "vimwiki-tags" = "cmp-vimwiki-tags"; + }; + } diff --git a/plugins/completion/nvim-cmp/default.nix b/plugins/completion/nvim-cmp/default.nix index 8812a62e4a..7c362c16ae 100644 --- a/plugins/completion/nvim-cmp/default.nix +++ b/plugins/completion/nvim-cmp/default.nix @@ -1,19 +1,20 @@ -{ pkgs, config, lib, ... }@args: -with lib; -let +{ + pkgs, + config, + lib, + ... +} @ args: +with lib; let cfg = config.plugins.nvim-cmp; - helpers = import ../../helpers.nix { inherit lib; }; + helpers = import ../../helpers.nix {inherit lib;}; mkNullOrOption = helpers.mkNullOrOption; cmpLib = import ./cmp-helpers.nix args; # functionName should be a string # parameters should be a list of strings - wrapWithFunction = functionName: parameters: - let - parameterString = strings.concatStringsSep "," parameters; - in - ''${functionName}(${parameterString})''; -in -{ + wrapWithFunction = functionName: parameters: let + parameterString = strings.concatStringsSep "," parameters; + in ''${functionName}(${parameterString})''; +in { options.plugins.nvim-cmp = { enable = mkEnableOption "nvim-cmp"; @@ -21,7 +22,7 @@ in performance = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { debounce = mkOption { type = types.nullOr types.int; @@ -36,14 +37,14 @@ in }; preselect = mkOption { - type = types.nullOr (types.enum [ "Item" "None" ]); + type = types.nullOr (types.enum ["Item" "None"]); default = null; example = ''"Item"''; }; snippet = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { expand = mkOption { type = types.nullOr types.str; @@ -61,7 +62,7 @@ in }; mappingPresets = mkOption { - default = [ ]; + default = []; type = types.listOf (types.enum [ "insert" "cmdline" @@ -75,7 +76,7 @@ in mapping = mkOption { default = null; - type = types.nullOr (types.attrsOf (types.either types.str (types.submodule ({ ... }: { + type = types.nullOr (types.attrsOf (types.either types.str (types.submodule ({...}: { options = { action = mkOption { type = types.nonEmptyStr; @@ -116,7 +117,7 @@ in completion = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { keyword_length = mkOption { default = null; @@ -145,7 +146,7 @@ in confirmation = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { get_commit_characters = mkOption { default = null; @@ -158,7 +159,7 @@ in formatting = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { fields = mkOption { default = null; @@ -176,7 +177,7 @@ in matching = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { disallow_fuzzy_matching = mkOption { default = null; @@ -196,7 +197,7 @@ in sorting = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { priority_weight = mkOption { default = null; @@ -218,54 +219,53 @@ in ''; }; - sources = - let - source_config = types.submodule ({ ... }: { - options = { - name = mkOption { - type = types.str; - description = "The name of the source."; - example = ''"buffer"''; - }; + sources = let + source_config = types.submodule ({...}: { + options = { + name = mkOption { + type = types.str; + description = "The name of the source."; + example = ''"buffer"''; + }; - option = mkOption { - default = null; - type = with types; nullOr (attrsOf anything); - description = "If direct lua code is needed use helpers.mkRaw"; - }; + option = mkOption { + default = null; + type = with types; nullOr (attrsOf anything); + description = "If direct lua code is needed use helpers.mkRaw"; + }; - keyword_length = mkOption { - default = null; - type = types.nullOr types.int; - }; + keyword_length = mkOption { + default = null; + type = types.nullOr types.int; + }; - keyword_pattern = mkOption { - default = null; - type = types.nullOr types.int; - }; + keyword_pattern = mkOption { + default = null; + type = types.nullOr types.int; + }; - trigger_characters = mkOption { - default = null; - type = with types; nullOr (listOf str); - }; + trigger_characters = mkOption { + default = null; + type = with types; nullOr (listOf str); + }; - priority = mkOption { - default = null; - type = types.nullOr types.int; - }; + priority = mkOption { + default = null; + type = types.nullOr types.int; + }; - max_item_count = mkOption { - default = null; - type = types.nullOr types.int; - }; + max_item_count = mkOption { + default = null; + type = types.nullOr types.int; + }; - group_index = mkOption { - default = null; - type = types.nullOr types.int; - }; + group_index = mkOption { + default = null; + type = types.nullOr types.int; }; - }); - in + }; + }); + in mkOption { default = null; type = with types; nullOr (either (listOf source_config) (listOf (listOf source_config))); @@ -286,7 +286,7 @@ in view = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { entries = mkOption { default = null; @@ -296,20 +296,19 @@ in })); }; - window = - let - # Reusable options - border = with types; mkNullOrOption (either str (listOf str)) null; - winhighlight = mkNullOrOption types.str null; - zindex = mkNullOrOption types.int null; - in + window = let + # Reusable options + border = with types; mkNullOrOption (either str (listOf str)) null; + winhighlight = mkNullOrOption types.str null; + zindex = mkNullOrOption types.int null; + in mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { completion = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { inherit border winhighlight zindex; col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor"; @@ -320,7 +319,7 @@ in documentation = mkOption { default = null; - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { inherit border winhighlight zindex; max_width = mkNullOrOption types.int "Window's max width"; @@ -336,68 +335,99 @@ in experimental = mkNullOrOption types.attrs "Experimental features"; }; - config = - let - options = { - enabled = cfg.enable; - performance = cfg.performance; - preselect = if (isNull cfg.preselect) then null else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}"; - - # Not very readable sorry - # If null then null - # If an attribute is a string, just treat it as lua code for that mapping - # If an attribute is a module, create a mapping with cmp.mapping() using the action as the first input and the modes as the second. - mapping = - let - mappings = - if (isNull cfg.mapping) then null - else - mapAttrs - (bind: mapping: helpers.mkRaw (if isString mapping then mapping - else "cmp.mapping(${mapping.action}${optionalString (mapping.modes != null && length mapping.modes >= 1) ("," + (helpers.toLuaObject mapping.modes))})")) - cfg.mapping; - luaMappings = (helpers.toLuaObject mappings); - wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets; - in - helpers.mkRaw wrapped; - - snippet = { - expand = if (isNull cfg.snippet || isNull cfg.snippet.expand) then null else helpers.mkRaw cfg.snippet.expand; - }; + config = let + options = { + enabled = cfg.enable; + performance = cfg.performance; + preselect = + if (isNull cfg.preselect) + then null + else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}"; + + # Not very readable sorry + # If null then null + # If an attribute is a string, just treat it as lua code for that mapping + # If an attribute is a module, create a mapping with cmp.mapping() using the action as the first input and the modes as the second. + mapping = let + mappings = + if (isNull cfg.mapping) + then null + else + mapAttrs + (bind: mapping: + helpers.mkRaw ( + if isString mapping + then mapping + else "cmp.mapping(${mapping.action}${optionalString (mapping.modes != null && length mapping.modes >= 1) ("," + (helpers.toLuaObject mapping.modes))})" + )) + cfg.mapping; + luaMappings = helpers.toLuaObject mappings; + wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets; + in + helpers.mkRaw wrapped; - completion = if (isNull cfg.completion) then null else { + snippet = { + expand = + if (isNull cfg.snippet || isNull cfg.snippet.expand) + then null + else helpers.mkRaw cfg.snippet.expand; + }; + + completion = + if (isNull cfg.completion) + then null + else { keyword_length = cfg.completion.keyword_length; keyword_pattern = cfg.completion.keyword_pattern; - autocomplete = if (isNull cfg.completion.autocomplete) then null else mkRaw cfg.completion.autocomplete; + autocomplete = + if (isNull cfg.completion.autocomplete) + then null + else mkRaw cfg.completion.autocomplete; completeopt = cfg.completion.completeopt; }; - confirmation = if (isNull cfg.confirmation) then null else { + confirmation = + if (isNull cfg.confirmation) + then null + else { get_commit_characters = - if (isString cfg.confirmation.get_commit_characters) then helpers.mkRaw cfg.confirmation.get_commit_characters + if (isString cfg.confirmation.get_commit_characters) + then helpers.mkRaw cfg.confirmation.get_commit_characters else cfg.confirmation.get_commit_characters; }; - formatting = if (isNull cfg.formatting) then null else { + formatting = + if (isNull cfg.formatting) + then null + else { fields = cfg.formatting.fields; - format = if (isNull cfg.formatting.format) then null else helpers.mkRaw cfg.formatting.format; + format = + if (isNull cfg.formatting.format) + then null + else helpers.mkRaw cfg.formatting.format; }; - matching = cfg.matching; + matching = cfg.matching; - sorting = if (isNull cfg.sorting) then null else { + sorting = + if (isNull cfg.sorting) + then null + else { priority_weight = cfg.sorting.priority_weight; - comparators = if (isNull cfg.sorting.comparators) then null else helpers.mkRaw cfg.sorting.comparators; + comparators = + if (isNull cfg.sorting.comparators) + then null + else helpers.mkRaw cfg.sorting.comparators; }; - sources = cfg.sources; - view = cfg.view; - window = cfg.window; - experimental = cfg.experimental; - }; - in + sources = cfg.sources; + view = cfg.view; + window = cfg.window; + experimental = cfg.experimental; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = helpers.wrapDo '' local cmp = require('cmp') @@ -406,21 +436,23 @@ in # If auto_enable_sources is set to true, figure out which are provided by the user # and enable the corresponding plugins. - plugins = - let - flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources; - # Take only the names from the sources provided by the user - found_sources = lists.unique (lists.map (source: source.name) flattened_sources); - # A list of known source names - known_source_names = attrNames cmpLib.pluginAndSourceNames; - - attrs_enabled = listToAttrs (map - (name: { - name = cmpLib.pluginAndSourceNames.${name}; - value.enable = mkIf (elem name found_sources) true; - }) - known_source_names); - in + plugins = let + flattened_sources = + if (isNull cfg.sources) + then [] + else flatten cfg.sources; + # Take only the names from the sources provided by the user + found_sources = lists.unique (lists.map (source: source.name) flattened_sources); + # A list of known source names + known_source_names = attrNames cmpLib.pluginAndSourceNames; + + attrs_enabled = listToAttrs (map + (name: { + name = cmpLib.pluginAndSourceNames.${name}; + value.enable = mkIf (elem name found_sources) true; + }) + known_source_names); + in mkIf cfg.auto_enable_sources attrs_enabled; }; } diff --git a/plugins/completion/nvim-cmp/sources/default.nix b/plugins/completion/nvim-cmp/sources/default.nix index 21b8af5537..b230b2e9f6 100644 --- a/plugins/completion/nvim-cmp/sources/default.nix +++ b/plugins/completion/nvim-cmp/sources/default.nix @@ -1,12 +1,16 @@ -{ lib, pkgs, ... }@attrs: -with lib; -let +{ + lib, + pkgs, + ... +} @ attrs: +with lib; let cmpLib = import ../cmp-helpers.nix attrs; cmpSourcesPluginNames = lib.attrValues cmpLib.pluginAndSourceNames; - pluginModules = lists.map (name: cmpLib.mkCmpSourcePlugin { inherit name; }) cmpSourcesPluginNames; -in -{ + pluginModules = lists.map (name: cmpLib.mkCmpSourcePlugin {inherit name;}) cmpSourcesPluginNames; +in { # For extra cmp plugins - imports = [ - ] ++ pluginModules; + imports = + [ + ] + ++ pluginModules; } diff --git a/plugins/git/fugitive.nix b/plugins/git/fugitive.nix index d3baeb0262..d16310166e 100644 --- a/plugins/git/fugitive.nix +++ b/plugins/git/fugitive.nix @@ -1,13 +1,18 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "fugitive"; - description = "Enable vim-fugitive"; - package = pkgs.vimPlugins.vim-fugitive; - extraPackages = [ pkgs.git ]; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "fugitive"; + description = "Enable vim-fugitive"; + package = pkgs.vimPlugins.vim-fugitive; + extraPackages = [pkgs.git]; - # In typical tpope fashin, this plugin has no config options - options = {}; -} + # In typical tpope fashin, this plugin has no config options + options = {}; + } diff --git a/plugins/git/gitgutter.nix b/plugins/git/gitgutter.nix index 81d9ac79c3..e1ab620990 100644 --- a/plugins/git/gitgutter.nix +++ b/plugins/git/gitgutter.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.gitgutter; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.gitgutter; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.gitgutter = { enable = mkEnableOption "gitgutter"; @@ -54,14 +57,14 @@ in }; signs = mkOption { - type = - let - signOption = desc: mkOption { + type = let + signOption = desc: + mkOption { type = types.nullOr types.str; default = null; description = "Sign for ${desc}"; }; - in + in types.submodule { options = { added = signOption "added lines"; @@ -73,7 +76,7 @@ in modifiedRemoved = signOption "modified and removed lines"; }; }; - default = { }; + default = {}; description = "Custom signs for the sign column"; }; @@ -166,20 +169,25 @@ in }; }; - config = - let - grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ]; - grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep; - in + config = let + grepPackage = + if builtins.isAttrs cfg.grep + then [cfg.grep.package] + else []; + grepCommand = + if builtins.isAttrs cfg.grep + then cfg.grep.command + else cfg.grep; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; options = mkIf cfg.recommendedSettings { updatetime = 100; foldtext = "gitgutter#fold#foldtext"; }; - extraPackages = [ pkgs.git ] ++ grepPackage; + extraPackages = [pkgs.git] ++ grepPackage; globals = { gitgutter_max_signs = mkIf (!isNull cfg.maxSigns) cfg.maxSigns; diff --git a/plugins/git/gitmessenger.nix b/plugins/git/gitmessenger.nix index ee9b6751a3..d254b988f1 100644 --- a/plugins/git/gitmessenger.nix +++ b/plugins/git/gitmessenger.nix @@ -1,12 +1,12 @@ -{ pkgs -, lib -, config -, ... +{ + pkgs, + lib, + config, + ... } @ args: with lib; let helpers = import ../helpers.nix args; -in -{ +in { options.plugins.gitmessenger = { enable = mkEnableOption "Enable the gitmessenger plugin"; @@ -16,7 +16,7 @@ in A popup window is no longer closed automatically when moving a cursor after the window is shown up. ''; - includeDiff = helpers.defaultNullOpts.mkEnumFirstDefault [ "none" "current" "all" ] '' + includeDiff = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "current" "all"] '' When this value is not set to "none", a popup window includes diff hunks of the commit at showing up. "current" includes diff hunks of only current file in the commit. "all" includes all diff hunks in the commit. @@ -26,10 +26,10 @@ in ''; gitCommand = helpers.defaultNullOpts.mkStr "git" - "git command to retrieve commit messages."; + "git command to retrieve commit messages."; noDefaultMappings = helpers.defaultNullOpts.mkBool false - "When this value is set, it does not define any key mappings"; + "When this value is set, it does not define any key mappings"; intoPopupAfterShow = helpers.defaultNullOpts.mkBool true '' When this value is set to v:false, running :GitMessenger or (git-messenger) again after showing a popup does not move the cursor in the window. @@ -91,12 +91,11 @@ in ''; }; - config = - let - cfg = config.plugins.gitmessenger; - in + config = let + cfg = config.plugins.gitmessenger; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { git_messenger_close_on_cursor_moved = cfg.closeOnCursorMoved; git_messenger_include_diff = cfg.includeDiff; diff --git a/plugins/git/gitsigns.nix b/plugins/git/gitsigns.nix index cff50d9be2..fa964d1528 100644 --- a/plugins/git/gitsigns.nix +++ b/plugins/git/gitsigns.nix @@ -1,26 +1,27 @@ -{ config -, lib -, pkgs -, ... +{ + config, + lib, + pkgs, + ... } @ args: with lib; let helpers = import ../helpers.nix args; signOptions = defaults: { hl = helpers.defaultNullOpts.mkStr defaults.hl - "Specifies the highlight group to use for the sign"; + "Specifies the highlight group to use for the sign"; text = helpers.defaultNullOpts.mkStr defaults.text - "Specifies the character to use for the sign"; + "Specifies the character to use for the sign"; numhl = helpers.defaultNullOpts.mkStr defaults.numhl - "Specifies the highlight group to use for the number column"; + "Specifies the highlight group to use for the number column"; linehl = helpers.defaultNullOpts.mkStr defaults.linehl - "Specifies the highlight group to use for the line"; + "Specifies the highlight group to use for the line"; showCount = helpers.defaultNullOpts.mkBool false - "showing count of hunk, e.g. number of deleted lines"; + "showing count of hunk, e.g. number of deleted lines"; }; signSetupOptions = values: { inherit (values) hl text numhl linehl; @@ -33,8 +34,7 @@ with lib; let description = "Lua function definition"; }; }; -in -{ +in { options.plugins.gitsigns = { enable = mkEnableOption "Enable gitsigns plugin"; package = helpers.mkPackageOption "gitsigns" pkgs.vimPlugins.gitsigns-nvim; @@ -76,19 +76,18 @@ in linehl = "GitSignsAddLn"; }; }; - worktrees = - let - worktreeModule = { - options = { - toplevel = mkOption { - type = types.str; - }; - gitdir = mkOption { - type = types.str; - }; + worktrees = let + worktreeModule = { + options = { + toplevel = mkOption { + type = types.str; + }; + gitdir = mkOption { + type = types.str; }; }; - in + }; + in mkOption { type = types.nullOr (types.listOf (types.submodule worktreeModule)); default = null; @@ -126,25 +125,25 @@ in watchGitDir = { enable = helpers.defaultNullOpts.mkBool true - "Whether the watcher is enabled"; + "Whether the watcher is enabled"; interval = helpers.defaultNullOpts.mkInt 1000 - "Interval the watcher waits between polls of the gitdir in milliseconds"; + "Interval the watcher waits between polls of the gitdir in milliseconds"; followFiles = helpers.defaultNullOpts.mkBool true - "If a file is moved with `git mv`, switch the buffer to the new location"; + "If a file is moved with `git mv`, switch the buffer to the new location"; }; signPriority = helpers.defaultNullOpts.mkInt 6 - "Priority to use for signs"; + "Priority to use for signs"; signcolumn = helpers.defaultNullOpts.mkBool true - '' - Enable/disable symbols in the sign column. + '' + Enable/disable symbols in the sign column. - When enabled the highlights defined in `signs.*.hl` and symbols defined - in `signs.*.text` are used. - ''; + When enabled the highlights defined in `signs.*.hl` and symbols defined + in `signs.*.text` are used. + ''; numhl = helpers.defaultNullOpts.mkBool false '' line number highlights. @@ -164,33 +163,32 @@ in Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`. ''; - diffOpts = - let - diffOptModule = { - options = { - algorithm = - helpers.defaultNullOpts.mkEnumFirstDefault [ "myers" "minimal" "patience" "histogram" ] - "Diff algorithm to use"; - internal = - helpers.defaultNullOpts.mkBool false - "Use Neovim's built in xdiff library for running diffs"; - indentHeuristic = - helpers.defaultNullOpts.mkBool false - "Use the indent heuristic for the internal diff library."; - vertical = - helpers.defaultNullOpts.mkBool true - "Start diff mode with vertical splits"; - linematch = mkOption { - type = types.nullOr types.int; - default = null; - description = '' - Enable second-stage diff on hunks to align lines. - Requires `internal=true`. - ''; - }; + diffOpts = let + diffOptModule = { + options = { + algorithm = + helpers.defaultNullOpts.mkEnumFirstDefault ["myers" "minimal" "patience" "histogram"] + "Diff algorithm to use"; + internal = + helpers.defaultNullOpts.mkBool false + "Use Neovim's built in xdiff library for running diffs"; + indentHeuristic = + helpers.defaultNullOpts.mkBool false + "Use the indent heuristic for the internal diff library."; + vertical = + helpers.defaultNullOpts.mkBool true + "Start diff mode with vertical splits"; + linematch = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + Enable second-stage diff on hunks to align lines. + Requires `internal=true`. + ''; }; }; - in + }; + in mkOption { type = types.nullOr (types.submodule diffOptModule); default = null; @@ -240,7 +238,7 @@ in '' "Function used to format `b:gitsigns_status`"; maxFileLength = helpers.defaultNullOpts.mkInt 40000 - "Max file length (in lines) to attach to"; + "Max file length (in lines) to attach to"; previewConfig = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) '' { @@ -256,34 +254,34 @@ in ''; attachToUntracked = helpers.defaultNullOpts.mkBool true - "Attach to untracked files."; + "Attach to untracked files."; updateDebounce = helpers.defaultNullOpts.mkInt 100 - "Debounce time for updates (in milliseconds)."; + "Debounce time for updates (in milliseconds)."; currentLineBlame = helpers.defaultNullOpts.mkBool false '' Adds an unobtrusive and customisable blame annotation at the end of the current line. ''; currentLineBlameOpts = { virtText = helpers.defaultNullOpts.mkBool true - "Whether to show a virtual text blame annotation"; + "Whether to show a virtual text blame annotation"; virtTextPos = - helpers.defaultNullOpts.mkEnumFirstDefault [ "eol" "overlay" "right_align" ] - "Blame annotation position"; + helpers.defaultNullOpts.mkEnumFirstDefault ["eol" "overlay" "right_align"] + "Blame annotation position"; delay = helpers.defaultNullOpts.mkInt 1000 - "Sets the delay (in milliseconds) before blame virtual text is displayed"; + "Sets the delay (in milliseconds) before blame virtual text is displayed"; ignoreWhitespace = helpers.defaultNullOpts.mkBool false - "Ignore whitespace when running blame"; + "Ignore whitespace when running blame"; virtTextPriority = helpers.defaultNullOpts.mkInt 100 - "Priority of virtual text"; + "Priority of virtual text"; }; currentLineBlameFormatter = { normal = helpers.defaultNullOpts.mkNullable (types.either types.str luaFunction) - ''" , - "'' '' + ''" , - "'' '' String or function used to format the virtual text of |gitsigns-config-current_line_blame|. @@ -292,7 +290,7 @@ in nonCommitted = helpers.defaultNullOpts.mkNullable (types.either types.str luaFunction) - ''" "'' '' + ''" "'' '' String or function used to format the virtual text of |gitsigns-config-current_line_blame| for lines that aren't committed. ''; @@ -316,89 +314,83 @@ in ''; }; - config = - let - cfg = config.plugins.gitsigns; - in + config = let + cfg = config.plugins.gitsigns; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - extraConfigLua = - let - luaFnOrStrToObj = val: - if val == null + extraPlugins = [cfg.package]; + extraConfigLua = let + luaFnOrStrToObj = val: + if val == null + then null + else if builtins.isString val + then val + else {__raw = val.function;}; + setupOptions = { + inherit (cfg) worktrees signcolumn numhl linehl trouble yadm; + signs = mapAttrs (_: signSetupOptions) cfg.signs; + on_attach = + if cfg.onAttach != null + then {__raw = cfg.onAttach.function;} + else null; + watch_gitdir = { + inherit (cfg.watchGitDir) enable interval; + follow_files = cfg.watchGitDir.followFiles; + }; + sign_priority = cfg.signPriority; + show_deleted = cfg.showDeleted; + diff_opts = + if cfg.diffOpts == null then null - else if builtins.isString val - then val - else { __raw = val.function; }; - setupOptions = { - inherit (cfg) worktrees signcolumn numhl linehl trouble yadm; - signs = mapAttrs (_: signSetupOptions) cfg.signs; - on_attach = - if cfg.onAttach != null - then { __raw = cfg.onAttach.function; } - else null; - watch_gitdir = { - inherit (cfg.watchGitDir) enable interval; - follow_files = cfg.watchGitDir.followFiles; + else { + inherit (cfg.diffOpts) algorithm internal vertical linematch; + indent_heuristic = cfg.diffOpts.indentHeuristic; }; - sign_priority = cfg.signPriority; - show_deleted = cfg.showDeleted; - diff_opts = - if cfg.diffOpts == null - then null - else { - inherit (cfg.diffOpts) algorithm internal vertical linematch; - indent_heuristic = cfg.diffOpts.indentHeuristic; - }; - count_chars = - let - isStrInt = s: (builtins.match "[0-9]+" s) != null; - in - if cfg.countChars != null - then { - __raw = - "{" - + (concatStringsSep "," ( - lib.mapAttrsToList - ( - name: value: - if isStrInt name - then "[${name}] = ${helpers.toLuaObject value}" - else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}" - ) - cfg.countChars - )) - + "}"; - } - else null; - status_formatter = - if cfg.statusFormatter != null - then { __raw = cfg.statusFormatter.function; } - else null; - max_file_length = cfg.maxFileLength; - preview_config = cfg.previewConfig; - attach_to_untracked = cfg.attachToUntracked; - update_debounce = cfg.updateDebounce; - current_line_blame = cfg.currentLineBlame; - current_line_blame_opts = - let - cfgCl = cfg.currentLineBlameOpts; - in - { - inherit (cfgCl) delay; - virt_text = cfgCl.virtText; - virt_text_pos = cfgCl.virtTextPos; - ignore_whitespace = cfgCl.ignoreWhitespace; - virt_text_priority = cfgCl.virtTextPriority; - }; - current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal; - current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted; - word_diff = cfg.wordDiff; - debug_mode = cfg.debugMode; + count_chars = let + isStrInt = s: (builtins.match "[0-9]+" s) != null; + in + if cfg.countChars != null + then { + __raw = + "{" + + (concatStringsSep "," ( + lib.mapAttrsToList + ( + name: value: + if isStrInt name + then "[${name}] = ${helpers.toLuaObject value}" + else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}" + ) + cfg.countChars + )) + + "}"; + } + else null; + status_formatter = + if cfg.statusFormatter != null + then {__raw = cfg.statusFormatter.function;} + else null; + max_file_length = cfg.maxFileLength; + preview_config = cfg.previewConfig; + attach_to_untracked = cfg.attachToUntracked; + update_debounce = cfg.updateDebounce; + current_line_blame = cfg.currentLineBlame; + current_line_blame_opts = let + cfgCl = cfg.currentLineBlameOpts; + in { + inherit (cfgCl) delay; + virt_text = cfgCl.virtText; + virt_text_pos = cfgCl.virtTextPos; + ignore_whitespace = cfgCl.ignoreWhitespace; + virt_text_priority = cfgCl.virtTextPriority; }; - in - '' - require('gitsigns').setup(${helpers.toLuaObject setupOptions}) - ''; + current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal; + current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted; + word_diff = cfg.wordDiff; + debug_mode = cfg.debugMode; + }; + in '' + require('gitsigns').setup(${helpers.toLuaObject setupOptions}) + ''; }; } diff --git a/plugins/git/neogit.nix b/plugins/git/neogit.nix index 3fcccc1388..c71a6b2235 100644 --- a/plugins/git/neogit.nix +++ b/plugins/git/neogit.nix @@ -1,8 +1,12 @@ -{ config, lib, pkgs, ... }: -with lib; -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let cfg = config.plugins.neogit; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; sectionDefaultsModule = types.submodule { options = { @@ -12,8 +16,7 @@ let }; }; }; -in -{ +in { options = { plugins.neogit = { enable = mkEnableOption "neogit"; @@ -72,7 +75,7 @@ in }; }; }; - default = { }; + default = {}; }; kind = mkOption { @@ -104,7 +107,7 @@ in }; }; }; - default = { }; + default = {}; }; integrations = mkOption { @@ -118,7 +121,7 @@ in }; }; }; - default = { }; + default = {}; }; sections = mkOption { @@ -162,7 +165,7 @@ in }; }; }; - default = { }; + default = {}; }; mappings = mkOption { @@ -198,14 +201,14 @@ in }; }; }; - default = { }; + default = {}; }; }; }; - config = - let - setupOptions = with cfg; helpers.toLuaObject { + config = let + setupOptions = with cfg; + helpers.toLuaObject { inherit kind integrations signs sections mappings; disable_signs = disableSigns; disable_hint = disableHint; @@ -216,14 +219,16 @@ in use_magit_keybindings = useMagitKeybindings; commit_popup = commitPopup; }; - in + in mkIf cfg.enable { - extraPlugins = with pkgs.vimPlugins; [ - cfg.package - plenary-nvim - ] ++ optional cfg.integrations.diffview diffview-nvim; - - extraPackages = [ pkgs.git ]; + extraPlugins = with pkgs.vimPlugins; + [ + cfg.package + plenary-nvim + ] + ++ optional cfg.integrations.diffview diffview-nvim; + + extraPackages = [pkgs.git]; extraConfigLua = '' require('neogit').setup(${setupOptions}) diff --git a/plugins/languages/clangd-extensions.nix b/plugins/languages/clangd-extensions.nix index 1eb9b33a38..12351b9a8f 100644 --- a/plugins/languages/clangd-extensions.nix +++ b/plugins/languages/clangd-extensions.nix @@ -17,7 +17,7 @@ in options.plugins.clangd-extensions = { enable = mkEnableOption "clangd_extensions, plugin implementing clangd LSP extensions"; - package = + package = helpers.mkPackageOption "clangd_extensions.nvim" pkgs.vimPlugins.clangd_extensions-nvim; enableOffsetEncodingWorkaround = mkEnableOption '' diff --git a/plugins/languages/ledger.nix b/plugins/languages/ledger.nix index 49a9dda73c..2c9e9bd6a7 100644 --- a/plugins/languages/ledger.nix +++ b/plugins/languages/ledger.nix @@ -1,33 +1,38 @@ -{ pkgs, lib, ... }@args: -with lib; with import ../helpers.nix { inherit lib; }; -mkPlugin args { - name = "ledger"; - description = "Enable ledger language features"; - package = pkgs.vimPlugins.vim-ledger; +{ + pkgs, + lib, + ... +} @ args: +with lib; +with import ../helpers.nix {inherit lib;}; + mkPlugin args { + name = "ledger"; + description = "Enable ledger language features"; + package = pkgs.vimPlugins.vim-ledger; - options = { - maxWidth = mkDefaultOpt { - global = "ledger_maxwidth"; - description = "Number of columns to display foldtext"; - type = types.int; - }; + options = { + maxWidth = mkDefaultOpt { + global = "ledger_maxwidth"; + description = "Number of columns to display foldtext"; + type = types.int; + }; - fillString = mkDefaultOpt { - global = "ledger_fillstring"; - description = "String used to fill the space between account name and amount in the foldtext"; - type = types.int; - }; + fillString = mkDefaultOpt { + global = "ledger_fillstring"; + description = "String used to fill the space between account name and amount in the foldtext"; + type = types.int; + }; - detailedFirst = mkDefaultOpt { - global = "ledger_detailed_first"; - description = "Account completion sorted by depth instead of alphabetically"; - type = types.bool; - }; + detailedFirst = mkDefaultOpt { + global = "ledger_detailed_first"; + description = "Account completion sorted by depth instead of alphabetically"; + type = types.bool; + }; - foldBlanks = mkDefaultOpt { - global = "ledger_fold_blanks"; - description = "Hide blank lines following a transaction on a fold"; - type = types.bool; + foldBlanks = mkDefaultOpt { + global = "ledger_fold_blanks"; + description = "Hide blank lines following a transaction on a fold"; + type = types.bool; + }; }; - }; -} + } diff --git a/plugins/languages/markdown-preview.nix b/plugins/languages/markdown-preview.nix index ec60bb67a5..b815fdb119 100644 --- a/plugins/languages/markdown-preview.nix +++ b/plugins/languages/markdown-preview.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.markdown-preview; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.markdown-preview; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.markdown-preview = { enable = mkEnableOption "markdown-preview"; @@ -54,7 +57,7 @@ in uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options"; maid = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "mermaid options"; disable_sync_scroll = helpers.defaultNullOpts.mkBool false "Disable sync scroll"; - sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum [ "middle" "top" "relative" ]) "middle" '' + sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum ["middle" "top" "relative"]) "middle" '' Scroll type: - "middle": The cursor position is always shown at the middle of the preview page. - "top": The vim top viewport is always shown at the top of the preview page. @@ -86,18 +89,17 @@ in Recognized filetypes. These filetypes will have MarkdownPreview... commands. ''; - theme = helpers.defaultNullOpts.mkNullable (types.enum [ "dark" "light" ]) "dark" '' + theme = helpers.defaultNullOpts.mkNullable (types.enum ["dark" "light"]) "dark" '' Default theme (dark or light). By default the theme is define according to the preferences of the system. ''; }; }; - config = - let - previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions; - in + config = let + previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { mkdp_auto_start = mkIf (!isNull cfg.autoStart) cfg.autoStart; @@ -109,7 +111,7 @@ in mkdp_browser = mkIf (!isNull cfg.browser) cfg.browser; mkdp_echo_preview_url = mkIf (!isNull cfg.echoPreviewUrl) cfg.echoPreviewUrl; mkdp_browserfunc = mkIf (!isNull cfg.browserFunc) cfg.browserFunc; - mkdp_preview_options = mkIf (cfg.previewOptions != { }) previewOptions; + mkdp_preview_options = mkIf (cfg.previewOptions != {}) previewOptions; mkdp_markdown_css = mkIf (!isNull cfg.markdownCss) cfg.markdownCss; mkdp_highlight_css = mkIf (!isNull cfg.highlightCss) cfg.highlightCss; mkdp_port = mkIf (!isNull cfg.port) cfg.port; diff --git a/plugins/languages/nix.nix b/plugins/languages/nix.nix index d314e33051..6ee166de03 100644 --- a/plugins/languages/nix.nix +++ b/plugins/languages/nix.nix @@ -1,12 +1,17 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "nix"; - description = "Enable nix"; - package = pkgs.vimPlugins.vim-nix; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "nix"; + description = "Enable nix"; + package = pkgs.vimPlugins.vim-nix; - # Possibly add option to disable Treesitter highlighting if this is installed - options = {}; -} + # Possibly add option to disable Treesitter highlighting if this is installed + options = {}; + } diff --git a/plugins/languages/plantuml-syntax.nix b/plugins/languages/plantuml-syntax.nix index 16695d7ad3..4cf32991e5 100644 --- a/plugins/languages/plantuml-syntax.nix +++ b/plugins/languages/plantuml-syntax.nix @@ -1,11 +1,11 @@ -{ pkgs -, lib -, config -, ... +{ + pkgs, + lib, + config, + ... }: -with lib; -let - helpers = import ../helpers.nix { inherit lib; }; +with lib; let + helpers = import ../helpers.nix {inherit lib;}; in { options.plugins.plantuml-syntax = { enable = mkEnableOption "plantuml syntax support"; @@ -24,12 +24,11 @@ in { }; }; - config = - let - cfg = config.plugins.plantuml-syntax; - in + config = let + cfg = config.plugins.plantuml-syntax; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { plantuml_set_makeprg = cfg.setMakeprg; diff --git a/plugins/languages/rust.nix b/plugins/languages/rust.nix index 1abd508daf..4e0a260bb3 100644 --- a/plugins/languages/rust.nix +++ b/plugins/languages/rust.nix @@ -1,233 +1,221 @@ -{ pkgs -, config -, lib -, ... +{ + pkgs, + config, + lib, + ... }: -with lib; -let - helpers = import ../helpers.nix { inherit lib; }; +with lib; let + helpers = import ../helpers.nix {inherit lib;}; in { - options.plugins.rust-tools = - let - mkNullableOptionWithDefault = - { type - , description - , default - , - }: - mkOption { - type = types.nullOr type; - default = null; - description = '' - ${description} - - default: `${default}` - ''; - }; - - mkNullableBoolDefault = default: description: - mkNullableOptionWithDefault { - inherit description; - type = types.bool; - default = toString default; - }; + options.plugins.rust-tools = let + mkNullableOptionWithDefault = { + type, + description, + default, + }: + mkOption { + type = types.nullOr type; + default = null; + description = '' + ${description} - mkNullableStrDefault = default: description: - mkNullableOptionWithDefault { - inherit description; - type = types.str; - default = ''"${default}"''; - }; + default: `${default}` + ''; + }; - mkNullableIntDefault = default: description: - mkNullableOptionWithDefault { - inherit description; - type = types.int; - default = toString default; - }; - in - { - enable = mkEnableOption "rust tools plugins"; - package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim; - serverPackage = mkOption { - type = types.package; - default = pkgs.rust-analyzer; - description = "Package to use for rust-analyzer"; + mkNullableBoolDefault = default: description: + mkNullableOptionWithDefault { + inherit description; + type = types.bool; + default = toString default; }; - executor = mkNullableOptionWithDefault { - type = types.enum [ "termopen" "quickfix" ]; - default = ''"termopen"''; - description = "how to execute terminal commands"; + mkNullableStrDefault = default: description: + mkNullableOptionWithDefault { + inherit description; + type = types.str; + default = ''"${default}"''; }; - onIntialized = mkOption { - type = types.nullOr types.str; - default = null; - description = '' - Callback to execute once rust-analyzer is done initializing the workspace - The callback receives one parameter indicating the `health` of the server: - "ok" | "warning" | "error" - ''; + mkNullableIntDefault = default: description: + mkNullableOptionWithDefault { + inherit description; + type = types.int; + default = toString default; }; + in { + enable = mkEnableOption "rust tools plugins"; + package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim; + serverPackage = mkOption { + type = types.package; + default = pkgs.rust-analyzer; + description = "Package to use for rust-analyzer"; + }; - reloadWorkspaceFromCargoToml = mkNullableBoolDefault true '' - Automatically call RustReloadWorkspace when writing to a Cargo.toml file. + executor = mkNullableOptionWithDefault { + type = types.enum ["termopen" "quickfix"]; + default = ''"termopen"''; + description = "how to execute terminal commands"; + }; + + onIntialized = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Callback to execute once rust-analyzer is done initializing the workspace + The callback receives one parameter indicating the `health` of the server: + "ok" | "warning" | "error" ''; + }; - inlayHints = { - auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)"; + reloadWorkspaceFromCargoToml = mkNullableBoolDefault true '' + Automatically call RustReloadWorkspace when writing to a Cargo.toml file. + ''; - onlyCurrentLine = mkNullableBoolDefault false "Only show for current line"; + inlayHints = { + auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)"; - showParameterHints = - mkNullableBoolDefault true - "whether to show parameter hints with the inlay hints or not"; + onlyCurrentLine = mkNullableBoolDefault false "Only show for current line"; - parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints"; - otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)"; + showParameterHints = + mkNullableBoolDefault true + "whether to show parameter hints with the inlay hints or not"; - maxLenAlign = - mkNullableBoolDefault false - "whether to align to the length of the longest line in the file"; + parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints"; + otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)"; - maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true"; + maxLenAlign = + mkNullableBoolDefault false + "whether to align to the length of the longest line in the file"; - rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not"; - rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true"; + maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true"; - highlight = mkNullableStrDefault "Comment" "The color of the hints"; - }; + rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not"; + rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true"; - hoverActions = { - border = mkOption { - type = types.nullOr types.anything; - default = null; - description = '' - the border that is used for the hover window. see vim.api.nvim_open_win() - ''; - }; - - maxWidth = mkOption { - type = types.nullOr types.int; - default = null; - description = "Maximal width of the hover window. Nil means no max."; - }; - maxHeight = mkOption { - type = types.nullOr types.int; - default = null; - description = "Maximal height of the hover window. Nil means no max."; - }; + highlight = mkNullableStrDefault "Comment" "The color of the hints"; + }; - autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused"; + hoverActions = { + border = mkOption { + type = types.nullOr types.anything; + default = null; + description = '' + the border that is used for the hover window. see vim.api.nvim_open_win() + ''; }; - crateGraph = { - backend = mkNullableStrDefault "x11" '' - Backend used for displaying the graph - see: https://graphviz.org/docs/outputs/ - ''; + maxWidth = mkOption { + type = types.nullOr types.int; + default = null; + description = "Maximal width of the hover window. Nil means no max."; + }; + maxHeight = mkOption { + type = types.nullOr types.int; + default = null; + description = "Maximal height of the hover window. Nil means no max."; + }; - output = mkOption { - type = types.nullOr types.str; - default = null; - description = "where to store the output, nil for no output stored"; - }; + autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused"; + }; - full = mkNullableBoolDefault true '' - true for all crates.io and external crates, false only the local crates - ''; + crateGraph = { + backend = mkNullableStrDefault "x11" '' + Backend used for displaying the graph + see: https://graphviz.org/docs/outputs/ + ''; - enabledGraphvizBackends = mkOption { - type = types.nullOr (types.listOf types.str); - default = null; - description = '' - List of backends found on: https://graphviz.org/docs/outputs/ - Is used for input validation and autocompletion - ''; - }; + output = mkOption { + type = types.nullOr types.str; + default = null; + description = "where to store the output, nil for no output stored"; }; - server = - { - standalone = mkNullableBoolDefault true '' - standalone file support - setting it to false may improve startup time - ''; - } - // (import ../nvim-lsp/rust-analyzer-config.nix lib); + full = mkNullableBoolDefault true '' + true for all crates.io and external crates, false only the local crates + ''; + + enabledGraphvizBackends = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + List of backends found on: https://graphviz.org/docs/outputs/ + Is used for input validation and autocompletion + ''; + }; }; - config = - let - cfg = config.plugins.rust-tools; - in + + server = + { + standalone = mkNullableBoolDefault true '' + standalone file support + setting it to false may improve startup time + ''; + } + // (import ../nvim-lsp/rust-analyzer-config.nix lib); + }; + config = let + cfg = config.plugins.rust-tools; + in mkIf cfg.enable { - extraPlugins = with pkgs.vimPlugins; [ nvim-lspconfig cfg.package ]; - extraPackages = [ cfg.serverPackage ]; - - plugins.lsp.postConfig = - let - setupOptions = { - tools = { - executor = - if cfg.executor != null - then { __raw = ''require("rust-tools.executors").${cfg.executor}''; } - else null; - - on_initialized = - if cfg.onIntialized != null - then { __raw = cfg.onIntialized; } - else null; - - reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml; - inlay_hints = - let - cfgIH = cfg.inlayHints; - in - { - auto = cfgIH.auto; - only_current_line = cfgIH.onlyCurrentLine; - show_parameter_hints = cfgIH.showParameterHints; - parameter_hints_prefix = cfgIH.parameterHintsPrefix; - other_hints_prefix = cfgIH.otherHintsPrefix; - max_len_align = cfgIH.maxLenAlign; - max_len_align_padding = cfgIH.maxLenAlignPadding; - right_align = cfgIH.rightAlign; - right_align_padding = cfgIH.rightAlignPadding; - highlight = cfgIH.highlight; - }; - - hover_actions = - let - cfgHA = cfg.hoverActions; - in - { - border = cfgHA.border; - max_width = cfgHA.maxWidth; - max_height = cfgHA.maxHeight; - auto_focus = cfgHA.autoFocus; - }; - - crate_graph = - let - cfgCG = cfg.crateGraph; - in - { - backend = cfgCG.backend; - output = cfgCG.output; - full = cfgCG.full; - enabled_graphviz_backends = cfgCG.enabledGraphvizBackends; - }; + extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package]; + extraPackages = [cfg.serverPackage]; + + plugins.lsp.postConfig = let + setupOptions = { + tools = { + executor = + if cfg.executor != null + then {__raw = ''require("rust-tools.executors").${cfg.executor}'';} + else null; + + on_initialized = + if cfg.onIntialized != null + then {__raw = cfg.onIntialized;} + else null; + + reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml; + inlay_hints = let + cfgIH = cfg.inlayHints; + in { + auto = cfgIH.auto; + only_current_line = cfgIH.onlyCurrentLine; + show_parameter_hints = cfgIH.showParameterHints; + parameter_hints_prefix = cfgIH.parameterHintsPrefix; + other_hints_prefix = cfgIH.otherHintsPrefix; + max_len_align = cfgIH.maxLenAlign; + max_len_align_padding = cfgIH.maxLenAlignPadding; + right_align = cfgIH.rightAlign; + right_align_padding = cfgIH.rightAlignPadding; + highlight = cfgIH.highlight; }; - server = { - standalone = cfg.server.standalone; - settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server; - on_attach = { __raw = "__lspOnAttach"; }; + + hover_actions = let + cfgHA = cfg.hoverActions; + in { + border = cfgHA.border; + max_width = cfgHA.maxWidth; + max_height = cfgHA.maxHeight; + auto_focus = cfgHA.autoFocus; + }; + + crate_graph = let + cfgCG = cfg.crateGraph; + in { + backend = cfgCG.backend; + output = cfgCG.output; + full = cfgCG.full; + enabled_graphviz_backends = cfgCG.enabledGraphvizBackends; }; }; - in - '' - require('rust-tools').setup(${helpers.toLuaObject setupOptions}) - ''; + server = { + standalone = cfg.server.standalone; + settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server; + on_attach = {__raw = "__lspOnAttach";}; + }; + }; + in '' + require('rust-tools').setup(${helpers.toLuaObject setupOptions}) + ''; }; } diff --git a/plugins/languages/tagbar.nix b/plugins/languages/tagbar.nix index 0b3f48e026..ffac2ea775 100644 --- a/plugins/languages/tagbar.nix +++ b/plugins/languages/tagbar.nix @@ -1,35 +1,32 @@ -{ pkgs -, lib -, config -, ... -}: -let +{ + pkgs, + lib, + config, + ... +}: let cfg = config.plugins.tagbar; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; in -with lib; -{ - options.plugins.tagbar = { - - enable = mkEnableOption "tagbar"; - - package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar; + with lib; { + options.plugins.tagbar = { + enable = mkEnableOption "tagbar"; - extraConfig = helpers.mkNullOrOption types.attrs '' - The configuration options for tagbar without the 'tagbar_' prefix. - Example: To set 'tagbar_show_tag_count' to 1, write - extraConfig = { - show_tag_count= true; - }; - ''; - }; + package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar; - config = mkIf cfg.enable { + extraConfig = helpers.mkNullOrOption types.attrs '' + The configuration options for tagbar without the 'tagbar_' prefix. + Example: To set 'tagbar_show_tag_count' to 1, write + extraConfig = { + show_tag_count= true; + }; + ''; + }; - extraPlugins = [ cfg.package ]; + config = mkIf cfg.enable { + extraPlugins = [cfg.package]; - extraPackages = [ pkgs.ctags ]; + extraPackages = [pkgs.ctags]; - globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig; - }; -} + globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig; + }; + } diff --git a/plugins/languages/treesitter-context.nix b/plugins/languages/treesitter-context.nix index 44d76db99e..dc8a42f2ba 100644 --- a/plugins/languages/treesitter-context.nix +++ b/plugins/languages/treesitter-context.nix @@ -1,11 +1,11 @@ -{ pkgs -, lib -, config -, ... +{ + pkgs, + lib, + config, + ... }: -with lib; -let - helpers = import ../helpers.nix { inherit lib; }; +with lib; let + helpers = import ../helpers.nix {inherit lib;}; in { options.plugins.treesitter-context = { enable = mkEnableOption "nvim-treesitter-context"; @@ -19,7 +19,7 @@ in { }; trimScope = mkOption { - type = types.enum [ "outer" "inner" ]; + type = types.enum ["outer" "inner"]; default = "outer"; description = "Which context lines to discard if `max_lines` is exceeded"; }; @@ -32,7 +32,7 @@ in { patterns = mkOption { type = types.attrsOf (types.listOf types.str); - default = { }; + default = {}; description = '' Patterns to use for context delimitation. The 'default' key matches all filetypes ''; @@ -40,17 +40,16 @@ in { exactPatterns = mkOption { type = types.attrsOf types.bool; - default = { }; + default = {}; description = "Treat the coresponding entry in patterns as an exact match"; }; }; - config = - let - cfg = config.plugins.treesitter-context; - in + config = let + cfg = config.plugins.treesitter-context; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; plugins.treesitter.moduleConfig.context = { max_lines = cfg.maxLines; diff --git a/plugins/languages/treesitter-refactor.nix b/plugins/languages/treesitter-refactor.nix index a490016dae..1ff04b6fa8 100644 --- a/plugins/languages/treesitter-refactor.nix +++ b/plugins/languages/treesitter-refactor.nix @@ -1,114 +1,110 @@ -{ pkgs -, config -, lib -, ... -}: -with lib; -let - helpers = import ../helpers.nix { inherit lib; }; -in { - options.plugins.treesitter-refactor = - let - disable = mkOption { - type = types.listOf types.str; - default = [ ]; - description = "List of languages to disable the module on"; + pkgs, + config, + lib, + ... +}: +with lib; let + helpers = import ../helpers.nix {inherit lib;}; +in { + options.plugins.treesitter-refactor = let + disable = mkOption { + type = types.listOf types.str; + default = []; + description = "List of languages to disable the module on"; + }; + in { + enable = + mkEnableOption + "treesitter-refactor (requires plugins.treesitter.enable to be true)"; + + package = helpers.mkPackageOption "treesitter-refactor" pkgs.vimPlugins.nvim-treesitter-refactor; + + highlightDefinitions = { + inherit disable; + enable = + mkEnableOption + "Highlights definition and usages of the current symbol under the cursor."; + clearOnCursorMove = mkOption { + type = types.bool; + default = true; + description = '' + Controls if highlights should be cleared when the cursor is moved. If your 'updatetime' + is around `100` you can set this to false to have a less laggy experience. + ''; }; - in - { + }; + highlightCurrentScope = { + inherit disable; + enable = mkEnableOption "highlights the block from the current scope where the cursor is."; + }; + smartRename = { + inherit disable; enable = mkEnableOption - "treesitter-refactor (requires plugins.treesitter.enable to be true)"; - - package = helpers.mkPackageOption "treesitter-refactor" pkgs.vimPlugins.nvim-treesitter-refactor; + "Renames the symbol under the cursor within the current scope (and current file)."; + keymaps = { + smartRename = mkOption { + type = types.nullOr types.str; + default = "grr"; + description = "rename symbol under the cursor"; + }; + }; + }; + navigation = { + inherit disable; + enable = mkEnableOption '' + Provides "go to definition" for the symbol under the cursor, + and lists the definitions from the current file. + ''; - highlightDefinitions = { - inherit disable; - enable = - mkEnableOption - "Highlights definition and usages of the current symbol under the cursor."; - clearOnCursorMove = mkOption { - type = types.bool; - default = true; + keymaps = { + gotoDefinition = mkOption { + type = types.nullOr types.str; + default = "gnd"; + description = "go to the definition of the symbol under the cursor"; + }; + gotoDefinitionLspFallback = mkOption { + type = types.nullOr types.str; + default = null; description = '' - Controls if highlights should be cleared when the cursor is moved. If your 'updatetime' - is around `100` you can set this to false to have a less laggy experience. + go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if + the symbol can not be resolved. You can use your own fallback function if create a + mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)`. ''; }; - }; - highlightCurrentScope = { - inherit disable; - enable = mkEnableOption "highlights the block from the current scope where the cursor is."; - }; - smartRename = { - inherit disable; - enable = - mkEnableOption - "Renames the symbol under the cursor within the current scope (and current file)."; - keymaps = { - smartRename = mkOption { - type = types.nullOr types.str; - default = "grr"; - description = "rename symbol under the cursor"; - }; + listDefinitons = mkOption { + type = types.nullOr types.str; + default = "gnD"; + description = "list all definitions from the current file"; }; - }; - navigation = { - inherit disable; - enable = mkEnableOption '' - Provides "go to definition" for the symbol under the cursor, - and lists the definitions from the current file. - ''; - - keymaps = { - gotoDefinition = mkOption { - type = types.nullOr types.str; - default = "gnd"; - description = "go to the definition of the symbol under the cursor"; - }; - gotoDefinitionLspFallback = mkOption { - type = types.nullOr types.str; - default = null; - description = '' - go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if - the symbol can not be resolved. You can use your own fallback function if create a - mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)`. - ''; - }; - listDefinitons = mkOption { - type = types.nullOr types.str; - default = "gnD"; - description = "list all definitions from the current file"; - }; - listDefinitonsToc = mkOption { - type = types.nullOr types.str; - default = "gO"; - description = '' - list all definitions from the current file like a table of contents (similar to the one - you see when pressing |gO| in help files). - ''; - }; - gotoNextUsage = mkOption { - type = types.nullOr types.str; - default = ""; - description = "go to next usage of identifier under the cursor"; - }; - gotoPreviousUsage = mkOption { - type = types.nullOr types.str; - default = ""; - description = "go to previous usage of identifier"; - }; + listDefinitonsToc = mkOption { + type = types.nullOr types.str; + default = "gO"; + description = '' + list all definitions from the current file like a table of contents (similar to the one + you see when pressing |gO| in help files). + ''; + }; + gotoNextUsage = mkOption { + type = types.nullOr types.str; + default = ""; + description = "go to next usage of identifier under the cursor"; + }; + gotoPreviousUsage = mkOption { + type = types.nullOr types.str; + default = ""; + description = "go to previous usage of identifier"; }; }; }; + }; - config = - let - cfg = config.plugins.treesitter-refactor; - in + config = let + cfg = config.plugins.treesitter-refactor; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; plugins.treesitter.moduleConfig.refactor = { highlight_definitions = { @@ -118,22 +114,20 @@ in highlight_current_scope = cfg.highlightCurrentScope; smart_rename = { inherit (cfg.smartRename) enable disable; - keymaps = { smart_rename = cfg.smartRename.keymaps.smartRename; }; + keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;}; }; navigation = { inherit (cfg.navigation) enable disable; - keymaps = - let - cfgK = cfg.navigation.keymaps; - in - { - goto_definition = cfgK.gotoDefinition; - goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback; - list_definitions = cfgK.listDefinitons; - list_definitions_toc = cfgK.listDefinitonsToc; - goto_next_usage = cfgK.gotoNextUsage; - goto_previous_usage = cfgK.gotoPreviousUsage; - }; + keymaps = let + cfgK = cfg.navigation.keymaps; + in { + goto_definition = cfgK.gotoDefinition; + goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback; + list_definitions = cfgK.listDefinitons; + list_definitions_toc = cfgK.listDefinitonsToc; + goto_next_usage = cfgK.gotoNextUsage; + goto_previous_usage = cfgK.gotoPreviousUsage; + }; }; }; }; diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 5771d65665..375abc780c 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -1,10 +1,13 @@ -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.plugins.treesitter; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.plugins.treesitter; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.treesitter = { enable = mkEnableOption "tree-sitter syntax highlighting"; @@ -22,7 +25,7 @@ in }; ensureInstalled = mkOption { - type = with types; oneOf [ (enum [ "all" ]) (listOf str) ]; + type = with types; oneOf [(enum ["all"]) (listOf str)]; default = "all"; description = "Either \"all\" or a list of languages"; }; @@ -32,8 +35,7 @@ in default = if cfg.nixGrammars then null - else "$XDG_DATA_HOME/nvim/treesitter" - ; + else "$XDG_DATA_HOME/nvim/treesitter"; description = '' Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled). This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you! @@ -42,38 +44,37 @@ in ignoreInstall = mkOption { type = types.listOf types.str; - default = [ ]; + default = []; description = "List of parsers to ignore installing (for \"all\")"; }; disabledLanguages = mkOption { type = types.listOf types.str; - default = [ ]; + default = []; description = "A list of languages to disable"; }; customCaptures = mkOption { type = types.attrsOf types.str; - default = { }; + default = {}; description = "Custom capture group highlighting"; }; - incrementalSelection = - let - keymap = default: mkOption { + incrementalSelection = let + keymap = default: + mkOption { type = types.str; inherit default; }; - in - { - enable = mkEnableOption "incremental selection based on the named nodes from the grammar"; - keymaps = { - initSelection = keymap "gnn"; - nodeIncremental = keymap "grn"; - scopeIncremental = keymap "grc"; - nodeDecremental = keymap "grm"; - }; + in { + enable = mkEnableOption "incremental selection based on the named nodes from the grammar"; + keymaps = { + initSelection = keymap "gnn"; + nodeIncremental = keymap "grn"; + scopeIncremental = keymap "grc"; + nodeDecremental = keymap "grm"; }; + }; indent = mkEnableOption "tree-sitter based indentation"; @@ -87,24 +88,31 @@ in moduleConfig = mkOption { type = types.attrsOf types.anything; - default = { }; + default = {}; description = "This is the configuration for extra modules. It should not be used directly"; }; }; }; - config = - let - tsOptions = { + config = let + tsOptions = + { highlight = { enable = cfg.enable; - disable = if (cfg.disabledLanguages != [ ]) then cfg.disabledLanguages else null; - - custom_captures = if (cfg.customCaptures != { }) then cfg.customCaptures else null; + disable = + if (cfg.disabledLanguages != []) + then cfg.disabledLanguages + else null; + + custom_captures = + if (cfg.customCaptures != {}) + then cfg.customCaptures + else null; }; incremental_selection = - if cfg.incrementalSelection.enable then { + if cfg.incrementalSelection.enable + then { enable = true; keymaps = { init_selection = cfg.incrementalSelection.keymaps.initSelection; @@ -112,29 +120,39 @@ in scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental; node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental; }; - } else null; + } + else null; indent = - if cfg.indent then { + if cfg.indent + then { enable = true; - } else null; + } + else null; - ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled; + ensure_installed = + if cfg.nixGrammars + then [] + else cfg.ensureInstalled; ignore_install = cfg.ignoreInstall; parser_install_dir = cfg.parserInstallDir; - } // cfg.moduleConfig; - in + } + // cfg.moduleConfig; + in mkIf cfg.enable { - extraConfigLua = (optionalString (cfg.parserInstallDir != null) '' - vim.opt.runtimepath:append("${cfg.parserInstallDir}") - '') + '' - require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) - ''; + extraConfigLua = + (optionalString (cfg.parserInstallDir != null) '' + vim.opt.runtimepath:append("${cfg.parserInstallDir}") + '') + + '' + require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) + ''; - extraPlugins = with pkgs; if cfg.nixGrammars then - [ (cfg.package.withPlugins (_: cfg.grammarPackages)) ] - else [ cfg.package ]; - extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; + extraPlugins = with pkgs; + if cfg.nixGrammars + then [(cfg.package.withPlugins (_: cfg.grammarPackages))] + else [cfg.package]; + extraPackages = [pkgs.tree-sitter pkgs.nodejs]; options = mkIf cfg.folding { foldmethod = "expr"; @@ -142,4 +160,3 @@ in }; }; } - diff --git a/plugins/languages/vimtex.nix b/plugins/languages/vimtex.nix index 169c305a7e..7387470b33 100644 --- a/plugins/languages/vimtex.nix +++ b/plugins/languages/vimtex.nix @@ -1,42 +1,40 @@ -{ pkgs -, lib -, config -, ... -}: -let +{ + pkgs, + lib, + config, + ... +}: let cfg = config.plugins.vimtex; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; in -with lib; -{ - options.plugins.vimtex = { - - enable = mkEnableOption "vimtex"; + with lib; { + options.plugins.vimtex = { + enable = mkEnableOption "vimtex"; - package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex; + package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex; - extraConfig = helpers.mkNullOrOption types.attrs '' - The configuration options for vimtex without the 'vimtex_' prefix. - Example: To set 'vimtex_compiler_enabled' to 1, write - extraConfig = { - compiler_enabled = true; - }; - ''; - }; + extraConfig = helpers.mkNullOrOption types.attrs '' + The configuration options for vimtex without the 'vimtex_' prefix. + Example: To set 'vimtex_compiler_enabled' to 1, write + extraConfig = { + compiler_enabled = true; + }; + ''; + }; - config = - let - globals = { - enabled = cfg.enable; - } // cfg.extraConfig; + config = let + globals = + { + enabled = cfg.enable; + } + // cfg.extraConfig; in - mkIf cfg.enable { - - extraPlugins = [ cfg.package ]; + mkIf cfg.enable { + extraPlugins = [cfg.package]; - # Usefull for inverse search - extraPackages = with pkgs; [ pstree xdotool ]; + # Usefull for inverse search + extraPackages = with pkgs; [pstree xdotool]; - globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals; - }; -} + globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals; + }; + } diff --git a/plugins/languages/zig.nix b/plugins/languages/zig.nix index 78958596cc..7c06565e61 100644 --- a/plugins/languages/zig.nix +++ b/plugins/languages/zig.nix @@ -1,18 +1,23 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "zig"; - description = "Enable zig"; - package = pkgs.vimPlugins.zig-vim; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "zig"; + description = "Enable zig"; + package = pkgs.vimPlugins.zig-vim; - # Possibly add option to disable Treesitter highlighting if this is installed - options = { - formatOnSave = mkDefaultOpt { - type = types.bool; - global = "zig_fmt_autosave"; - description = "Run zig fmt on save"; - }; - }; -} + # Possibly add option to disable Treesitter highlighting if this is installed + options = { + formatOnSave = mkDefaultOpt { + type = types.bool; + global = "zig_fmt_autosave"; + description = "Run zig fmt on save"; + }; + }; + } diff --git a/plugins/null-ls/default.nix b/plugins/null-ls/default.nix index e30e0fac60..e712fc3eeb 100644 --- a/plugins/null-ls/default.nix +++ b/plugins/null-ls/default.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.null-ls; - helpers = (import ../helpers.nix { inherit lib; }); -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.null-ls; + helpers = import ../helpers.nix {inherit lib;}; +in { imports = [ ./servers.nix ]; @@ -36,15 +39,14 @@ in # }; }; - config = - let - options = { - debug = cfg.debug; - sources = cfg.sourcesItems; - }; - in + config = let + options = { + debug = cfg.debug; + sources = cfg.sourcesItems; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' require("null-ls").setup(${helpers.toLuaObject options}) diff --git a/plugins/null-ls/helpers.nix b/plugins/null-ls/helpers.nix index 2f6c4fc7c2..c14611a4ca 100644 --- a/plugins/null-ls/helpers.nix +++ b/plugins/null-ls/helpers.nix @@ -1,30 +1,41 @@ -{ pkgs, config, lib, ... }: { - mkServer = - { name - , sourceType - , description ? "${name} source, for null-ls." - , package ? null - , extraPackages ? [ ] - , ... - }: - # returns a module - { pkgs, config, lib, ... }@args: - with lib; - let - helpers = import ../helpers.nix args; - cfg = config.plugins.null-ls.sources.${sourceType}.${name}; - # does this evaluate package? - packageOption = if package == null then { } else { + pkgs, + config, + lib, + ... +}: { + mkServer = { + name, + sourceType, + description ? "${name} source, for null-ls.", + package ? null, + extraPackages ? [], + ... + }: + # returns a module + { + pkgs, + config, + lib, + ... + } @ args: + with lib; let + helpers = import ../helpers.nix args; + cfg = config.plugins.null-ls.sources.${sourceType}.${name}; + # does this evaluate package? + packageOption = + if package == null + then {} + else { package = mkOption { type = types.package; default = package; description = "Package to use for ${name} by null-ls"; }; }; - in - { - options.plugins.null-ls.sources.${sourceType}.${name} = { + in { + options.plugins.null-ls.sources.${sourceType}.${name} = + { enable = mkEnableOption description; # TODO: withArgs can exist outside of the module in a generalized manner @@ -37,20 +48,22 @@ # '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\' # ''; }; - } // packageOption; + } + // packageOption; - config = mkIf cfg.enable { - # Does this evaluate package? - extraPackages = extraPackages ++ optional (package != null) cfg.package; + config = mkIf cfg.enable { + # Does this evaluate package? + extraPackages = extraPackages ++ optional (package != null) cfg.package; - # Add source to list of sources - plugins.null-ls.sourcesItems = - let - sourceItem = "${sourceType}.${name}"; - withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}"; - finalString = ''require("null-ls").builtins.${withArgs}''; - in - [ (helpers.mkRaw finalString) ]; - }; + # Add source to list of sources + plugins.null-ls.sourcesItems = let + sourceItem = "${sourceType}.${name}"; + withArgs = + if (isNull cfg.withArgs) + then sourceItem + else "${sourceItem}.with ${cfg.withArgs}"; + finalString = ''require("null-ls").builtins.${withArgs}''; + in [(helpers.mkRaw finalString)]; }; + }; } diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index 02892514ea..99836f63d2 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -1,14 +1,18 @@ -{ pkgs, config, lib, ... }@args: -let +{ + pkgs, + config, + lib, + ... +} @ args: let helpers = import ./helpers.nix args; serverData = { code_actions = { - gitsigns = { }; + gitsigns = {}; shellcheck = { package = pkgs.shellcheck; }; }; - completion = { }; + completion = {}; diagnostics = { flake8 = { package = pkgs.python3Packages.flake8; @@ -65,20 +69,20 @@ let # sourceType = "formatting"; # packages = [...]; # }] - serverDataFormatted = lib.mapAttrsToList - (sourceType: sourceSet: - lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet + serverDataFormatted = + lib.mapAttrsToList + ( + sourceType: sourceSet: + lib.mapAttrsToList (name: attrs: attrs // {inherit sourceType name;}) sourceSet ) serverData; dataFlattened = lib.flatten serverDataFormatted; -in -{ +in { imports = lib.lists.map (helpers.mkServer) dataFlattened; - config = - let - cfg = config.plugins.null-ls; - in + config = let + cfg = config.plugins.null-ls; + in lib.mkIf cfg.enable { plugins.gitsigns.enable = lib.mkIf (cfg.sources.code_actions.gitsigns.enable) true; }; diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 962325a56e..5e01cf302e 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -1,13 +1,17 @@ -{ pkgs, config, lib, ... }@args: -with lib; -let +{ + pkgs, + config, + lib, + ... +} @ args: +with lib; let helpers = import ./helpers.nix args; servers = [ { name = "astro"; description = "Enable astrols, for Astro"; package = pkgs.nodePackages."@astrojs/language-server"; - cmd = cfg: [ "${cfg.package}/bin/astro-ls" "--stdio" ]; + cmd = cfg: ["${cfg.package}/bin/astro-ls" "--stdio"]; } { name = "bashls"; @@ -23,7 +27,7 @@ let name = "cssls"; description = "Enable cssls, for CSS"; package = pkgs.nodePackages.vscode-langservers-extracted; - cmd = cfg: [ "${cfg.package}/bin/vscode-css-language-server" "--stdio" ]; + cmd = cfg: ["${cfg.package}/bin/vscode-css-language-server" "--stdio"]; } { name = "dartls"; @@ -70,7 +74,7 @@ let ''; }; renameFilesWithClasses = mkOption { - type = types.nullOr (types.enum [ "always" "prompt" ]); + type = types.nullOr (types.enum ["always" "prompt"]); default = null; description = '' When set to "always", will include edits to rename files when classes are renamed if the @@ -98,7 +102,7 @@ let ''; }; documentation = mkOption { - type = types.nullOr (types.enum [ "none" "summary" "full" ]); + type = types.nullOr (types.enum ["none" "summary" "full"]); default = null; description = '' The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other @@ -114,7 +118,7 @@ let ''; }; }; - settings = cfg: { dart = cfg; }; + settings = cfg: {dart = cfg;}; } { name = "denols"; @@ -125,13 +129,13 @@ let name = "eslint"; description = "Enable eslint"; package = pkgs.nodePackages.vscode-langservers-extracted; - cmd = cfg: [ "${cfg.package}/bin/vscode-eslint-language-server" "--stdio" ]; + cmd = cfg: ["${cfg.package}/bin/vscode-eslint-language-server" "--stdio"]; } { name = "elixirls"; description = "Enable elixirls"; package = pkgs.elixir_ls; - cmd = cfg: [ "${cfg.package}/bin/elixir-ls" ]; + cmd = cfg: ["${cfg.package}/bin/elixir-ls"]; } { name = "gdscript"; @@ -146,13 +150,13 @@ let name = "html"; description = "Enable html, for HTML"; package = pkgs.nodePackages.vscode-langservers-extracted; - cmd = cfg: [ "${cfg.package}/bin/vscode-html-language-server" "--stdio" ]; + cmd = cfg: ["${cfg.package}/bin/vscode-html-language-server" "--stdio"]; } { name = "jsonls"; description = "Enable jsonls, for JSON"; package = pkgs.nodePackages.vscode-langservers-extracted; - cmd = cfg: [ "${cfg.package}/bin/vscode-json-language-server" "--stdio" ]; + cmd = cfg: ["${cfg.package}/bin/vscode-json-language-server" "--stdio"]; } { name = "nil_ls"; @@ -170,7 +174,7 @@ let diagnostics = { ignored = mkOption { type = types.listOf types.str; - default = [ ]; + default = []; description = '' Ignored diagnostic kinds. The kind identifier is a snake_cased_string usually shown together @@ -179,7 +183,7 @@ let }; excludedFiles = mkOption { type = types.listOf types.str; - default = [ ]; + default = []; description = '' Files to exclude from showing diagnostics. Useful for generated files. It accepts an array of paths. Relative paths are joint to the workspace root. @@ -188,7 +192,7 @@ let }; }; }; - settings = cfg: { nil = { inherit (cfg) formatting diagnostics; }; }; + settings = cfg: {nil = {inherit (cfg) formatting diagnostics;};}; } { name = "pyright"; @@ -205,7 +209,7 @@ let serverName = "rust_analyzer"; settingsOptions = import ./rust-analyzer-config.nix lib; - settings = cfg: { rust-analyzer = cfg; }; + settings = cfg: {rust-analyzer = cfg;}; } { name = "sumneko-lua"; @@ -240,10 +244,9 @@ let name = "hls"; description = "Enable haskell language server"; package = pkgs.haskell-language-server; - cmd = cfg: [ "haskell-language-server-wrapper" ]; + cmd = cfg: ["haskell-language-server-wrapper"]; } ]; -in -{ +in { imports = lib.lists.map (helpers.mkLsp) servers; } diff --git a/plugins/nvim-lsp/default.nix b/plugins/nvim-lsp/default.nix index 8b50570c1a..66dcdb23ee 100644 --- a/plugins/nvim-lsp/default.nix +++ b/plugins/nvim-lsp/default.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.lsp; - helpers = (import ../helpers.nix { inherit lib; }); -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.lsp; + helpers = import ../helpers.nix {inherit lib;}; +in { imports = [ ./basic-servers.nix ]; @@ -14,24 +17,25 @@ in enable = mkEnableOption "neovim's built-in LSP"; enabledServers = mkOption { - type = with types; listOf (oneOf [ - str - (submodule { - options = { - name = mkOption { - type = str; - description = "The server's name"; - }; + type = with types; + listOf (oneOf [ + str + (submodule { + options = { + name = mkOption { + type = str; + description = "The server's name"; + }; - extraOptions = mkOption { - type = attrs; - description = "Extra options for the server"; + extraOptions = mkOption { + type = attrs; + description = "Extra options for the server"; + }; }; - }; - }) - ]); + }) + ]); description = "A list of enabled LSP servers. Don't use this directly."; - default = [ ]; + default = []; }; onAttach = mkOption { @@ -43,7 +47,7 @@ in setupWrappers = mkOption { type = with types; listOf (functionTo str); description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code."; - default = [ ]; + default = []; }; preConfig = mkOption { @@ -60,14 +64,14 @@ in }; }; - config = - let - runWrappers = wrappers: s: - if wrappers == [ ] then s - else (head wrappers) (runWrappers (tail wrappers) s); - in + config = let + runWrappers = wrappers: s: + if wrappers == [] + then s + else (head wrappers) (runWrappers (tail wrappers) s); + in mkIf cfg.enable { - extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ]; + extraPlugins = [pkgs.vimPlugins.nvim-lspconfig]; # Enable all LSP servers extraConfigLua = '' diff --git a/plugins/nvim-lsp/helpers.nix b/plugins/nvim-lsp/helpers.nix index 540369b78a..bd0333ff66 100644 --- a/plugins/nvim-lsp/helpers.nix +++ b/plugins/nvim-lsp/helpers.nix @@ -1,51 +1,65 @@ -{ pkgs, config, lib, ... }: - { - mkLsp = - { name - , description ? "Enable ${name}." - , serverName ? name - , package ? pkgs.${name} - , extraPackages ? { } - , cmd ? (cfg: null) - , settings ? (cfg: { }) - , settingsOptions ? { } - , ... - }: - # returns a module - { pkgs, config, lib, ... }: - with lib; - let - cfg = config.plugins.lsp.servers.${name}; + pkgs, + config, + lib, + ... +}: { + mkLsp = { + name, + description ? "Enable ${name}.", + serverName ? name, + package ? pkgs.${name}, + extraPackages ? {}, + cmd ? (cfg: null), + settings ? (cfg: {}), + settingsOptions ? {}, + ... + }: + # returns a module + { + pkgs, + config, + lib, + ... + }: + with lib; let + cfg = config.plugins.lsp.servers.${name}; - packageOption = - if package != null then { - package = mkOption { - default = package; - type = types.nullOr types.package; - }; - } else { }; - in - { - options = { - plugins.lsp.servers.${name} = { + packageOption = + if package != null + then { + package = mkOption { + default = package; + type = types.nullOr types.package; + }; + } + else {}; + in { + options = { + plugins.lsp.servers.${name} = + { enable = mkEnableOption description; settings = settingsOptions; - } // packageOption; - }; + } + // packageOption; + }; - config = mkIf cfg.enable - { - extraPackages = (optional (package != null) cfg.package) ++ - (mapAttrsToList (name: _: cfg."${name}Package") extraPackages); + config = + mkIf cfg.enable + { + extraPackages = + (optional (package != null) cfg.package) + ++ (mapAttrsToList (name: _: cfg."${name}Package") extraPackages); - plugins.lsp.enabledServers = [{ + plugins.lsp.enabledServers = [ + { name = serverName; extraOptions = { cmd = cmd cfg; settings = settings cfg.settings; }; - }]; - }; - }; + } + ]; + }; + }; } diff --git a/plugins/nvim-lsp/lsp-lines.nix b/plugins/nvim-lsp/lsp-lines.nix index 19ef383891..67c55b66e5 100644 --- a/plugins/nvim-lsp/lsp-lines.nix +++ b/plugins/nvim-lsp/lsp-lines.nix @@ -1,10 +1,13 @@ -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.plugins.lsp-lines; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.plugins.lsp-lines; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.lsp-lines = { enable = mkEnableOption "lsp_lines.nvim"; @@ -19,24 +22,25 @@ in }; }; - config = - let - diagnosticConfig = { - virtual_text = false; - virtual_lines = - if cfg.currentLine then { - only_current_line = true; - } else true; - }; - in + config = let + diagnosticConfig = { + virtual_text = false; + virtual_lines = + if cfg.currentLine + then { + only_current_line = true; + } + else true; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' do require("lsp_lines").setup() - vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig }) + vim.diagnostic.config(${helpers.toLuaObject diagnosticConfig}) end ''; }; diff --git a/plugins/nvim-lsp/lspsaga.nix b/plugins/nvim-lsp/lspsaga.nix index 4f786230e6..edd3dff344 100644 --- a/plugins/nvim-lsp/lspsaga.nix +++ b/plugins/nvim-lsp/lspsaga.nix @@ -1,10 +1,13 @@ -{ pkgs, lib, config, ... }: -with lib; -let - cfg = config.plugins.lspsaga; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + lib, + config, + ... +}: +with lib; let + cfg = config.plugins.lspsaga; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.lspsaga = { enable = mkEnableOption "lspsaga.nvim"; @@ -107,32 +110,31 @@ in description = "Maximum finder preview lines"; }; - keys = - let - defaultKeyOpt = desc: mkOption { + keys = let + defaultKeyOpt = desc: + mkOption { description = desc; type = types.nullOr types.str; default = null; }; - in - { - finderAction = { - open = defaultKeyOpt "Open from finder"; - vsplit = defaultKeyOpt "Vertical split in finder"; - split = defaultKeyOpt "Horizontal split in finder"; - quit = defaultKeyOpt "Quit finder"; - scrollDown = defaultKeyOpt "Scroll down finder"; - scrollUp = defaultKeyOpt "Scroll up finder"; - }; + in { + finderAction = { + open = defaultKeyOpt "Open from finder"; + vsplit = defaultKeyOpt "Vertical split in finder"; + split = defaultKeyOpt "Horizontal split in finder"; + quit = defaultKeyOpt "Quit finder"; + scrollDown = defaultKeyOpt "Scroll down finder"; + scrollUp = defaultKeyOpt "Scroll up finder"; + }; - codeAction = { - quit = defaultKeyOpt "Quit code actions menu"; - exec = defaultKeyOpt "Execute code action"; - }; + codeAction = { + quit = defaultKeyOpt "Quit code actions menu"; + exec = defaultKeyOpt "Execute code action"; }; + }; borderStyle = mkOption { - type = types.nullOr (types.enum [ "thin" "rounded" "thick" ]); + type = types.nullOr (types.enum ["thin" "rounded" "thick"]); default = null; description = "Border style"; }; @@ -145,71 +147,75 @@ in }; }; - config = - let - notDefault = default: opt: if (opt != default) then opt else null; - notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != { }) then opt else null; - notNull = opt: opt; - lspsagaConfig = { - use_saga_diagnostic_sign = notDefault true cfg.signs.use; - error_sign = notNull cfg.signs.error; - warn_sign = notNull cfg.signs.warning; - hint_sign = notNull cfg.signs.hint; - infor_sign = notNull cfg.signs.info; - - # TODO Fix this! - # error_header = notNull cfg.headers.error; - # warn_header = notNull cfg.headers.warning; - # hint_header = notNull cfg.headers.hint; - # infor_header = notNull cfg.headers.info; - - max_diag_msg_width = notNull cfg.maxDialogWidth; - - code_action_icon = notNull cfg.icons.codeAction; - finder_definition_icon = notNull cfg.icons.findDefinition; - finder_reference_icon = notNull cfg.icons.findReference; - definition_preview_icon = notNull cfg.icons.definitionPreview; - - max_finder_preview_lines = notNull cfg.maxFinderPreviewLines; - - rename_prompt_prefix = notNull cfg.renamePromptPrefix; - - border_style = - let - borderStyle = - if cfg.borderStyle == "thin" then 1 - else if cfg.borderStyle == "rounded" then 2 - else if cfg.borderStyle == "thick" then 3 - else null; - in - borderStyle; - - finder_action_keys = - let - keys = { - open = notNull cfg.keys.finderAction.open; - vsplit = notNull cfg.keys.finderAction.vsplit; - split = notNull cfg.keys.finderAction.split; - quit = notNull cfg.keys.finderAction.quit; - scroll_down = notNull cfg.keys.finderAction.scrollDown; - scroll_up = notNull cfg.keys.finderAction.scrollUp; - }; - in - notEmpty keys; - - code_action_keys = - let - keys = { - quit = notNull cfg.keys.codeAction.quit; - exec = notNull cfg.keys.codeAction.exec; - }; - in - notEmpty keys; - }; - in - mkIf cfg.enable { + config = let + notDefault = default: opt: + if (opt != default) + then opt + else null; + notEmpty = opt: + if ((filterAttrs (_: v: v != null) opt) != {}) + then opt + else null; + notNull = opt: opt; + lspsagaConfig = { + use_saga_diagnostic_sign = notDefault true cfg.signs.use; + error_sign = notNull cfg.signs.error; + warn_sign = notNull cfg.signs.warning; + hint_sign = notNull cfg.signs.hint; + infor_sign = notNull cfg.signs.info; + + # TODO Fix this! + # error_header = notNull cfg.headers.error; + # warn_header = notNull cfg.headers.warning; + # hint_header = notNull cfg.headers.hint; + # infor_header = notNull cfg.headers.info; + + max_diag_msg_width = notNull cfg.maxDialogWidth; + + code_action_icon = notNull cfg.icons.codeAction; + finder_definition_icon = notNull cfg.icons.findDefinition; + finder_reference_icon = notNull cfg.icons.findReference; + definition_preview_icon = notNull cfg.icons.definitionPreview; + + max_finder_preview_lines = notNull cfg.maxFinderPreviewLines; + + rename_prompt_prefix = notNull cfg.renamePromptPrefix; + + border_style = let + borderStyle = + if cfg.borderStyle == "thin" + then 1 + else if cfg.borderStyle == "rounded" + then 2 + else if cfg.borderStyle == "thick" + then 3 + else null; + in + borderStyle; + + finder_action_keys = let + keys = { + open = notNull cfg.keys.finderAction.open; + vsplit = notNull cfg.keys.finderAction.vsplit; + split = notNull cfg.keys.finderAction.split; + quit = notNull cfg.keys.finderAction.quit; + scroll_down = notNull cfg.keys.finderAction.scrollDown; + scroll_up = notNull cfg.keys.finderAction.scrollUp; + }; + in + notEmpty keys; - extraPlugins = [ cfg.package ]; + code_action_keys = let + keys = { + quit = notNull cfg.keys.codeAction.quit; + exec = notNull cfg.keys.codeAction.exec; + }; + in + notEmpty keys; + }; + in + mkIf cfg.enable { + extraPlugins = [cfg.package]; extraConfigLua = '' local saga = require 'lspsaga' diff --git a/plugins/nvim-lsp/nvim-lightbulb.nix b/plugins/nvim-lsp/nvim-lightbulb.nix index 2426b840d1..c64a4d3936 100644 --- a/plugins/nvim-lsp/nvim-lightbulb.nix +++ b/plugins/nvim-lsp/nvim-lightbulb.nix @@ -1,70 +1,69 @@ -{ pkgs -, lib -, config -, ... -}: -let - helpers = import ../helpers.nix { inherit lib; }; +{ + pkgs, + lib, + config, + ... +}: let + helpers = import ../helpers.nix {inherit lib;}; in -with lib; { - options.plugins.nvim-lightbulb = { - enable = mkEnableOption "nvim-lightbulb, showing available code actions"; + with lib; { + options.plugins.nvim-lightbulb = { + enable = mkEnableOption "nvim-lightbulb, showing available code actions"; - package = helpers.mkPackageOption "nvim-lightbulb" pkgs.vimPlugins.nvim-lightbulb; + package = helpers.mkPackageOption "nvim-lightbulb" pkgs.vimPlugins.nvim-lightbulb; - ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' - LSP client names to ignore - ''; + ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' + LSP client names to ignore + ''; - sign = { - enabled = helpers.defaultNullOpts.mkBool true ""; - priority = helpers.defaultNullOpts.mkInt 10 ""; - }; + sign = { + enabled = helpers.defaultNullOpts.mkBool true ""; + priority = helpers.defaultNullOpts.mkInt 10 ""; + }; - float = { - enabled = helpers.defaultNullOpts.mkBool false ""; + float = { + enabled = helpers.defaultNullOpts.mkBool false ""; - text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float"; + text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float"; - winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" '' - Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information) - ''; - }; + winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" '' + Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information) + ''; + }; - virtualText = { - enabled = helpers.defaultNullOpts.mkBool false ""; + virtualText = { + enabled = helpers.defaultNullOpts.mkBool false ""; - text = helpers.defaultNullOpts.mkStr "💡" "Text to show at virtual text"; + text = helpers.defaultNullOpts.mkStr "💡" "Text to show at virtual text"; - hlMode = helpers.defaultNullOpts.mkStr "replace" '' - highlight mode to use for virtual text (replace, combine, blend), see - :help nvim_buf_set_extmark() for reference - ''; - }; + hlMode = helpers.defaultNullOpts.mkStr "replace" '' + highlight mode to use for virtual text (replace, combine, blend), see + :help nvim_buf_set_extmark() for reference + ''; + }; - statusText = { - enabled = helpers.defaultNullOpts.mkBool false ""; + statusText = { + enabled = helpers.defaultNullOpts.mkBool false ""; - text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available"; + text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available"; - textUnavailable = helpers.defaultNullOpts.mkStr "" '' - Text to provide when no actions are available - ''; - }; + textUnavailable = helpers.defaultNullOpts.mkStr "" '' + Text to provide when no actions are available + ''; + }; - autocmd = { - enabled = helpers.defaultNullOpts.mkBool false ""; + autocmd = { + enabled = helpers.defaultNullOpts.mkBool false ""; - pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' ""; + pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' ""; - events = - helpers.defaultNullOpts.mkNullable (types.listOf types.str) + events = + helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["CursorHold" "CursorHoldI"]'' ""; + }; }; - }; - config = - let + config = let cfg = config.plugins.nvim-lightbulb; setupOptions = { inherit (cfg) ignore sign autocmd; @@ -82,10 +81,10 @@ with lib; { }; }; in - mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - extraConfigLua = '' - require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions}) - ''; - }; -} + mkIf cfg.enable { + extraPlugins = [cfg.package]; + extraConfigLua = '' + require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions}) + ''; + }; + } diff --git a/plugins/nvim-lsp/rust-analyzer-config.nix b/plugins/nvim-lsp/rust-analyzer-config.nix index 3bf0ee9cc2..4479e73717 100644 --- a/plugins/nvim-lsp/rust-analyzer-config.nix +++ b/plugins/nvim-lsp/rust-analyzer-config.nix @@ -1,8 +1,9 @@ # THIS FILE IS AUTOGENERATED DO NOT EDIT -lib: with lib; { +lib: +with lib; { "assist" = { "expressionFillDefault" = mkOption { - type = types.nullOr (types.enum [ "todo" "default" ]); + type = types.nullOr (types.enum ["todo" "default"]); default = null; description = '' Placeholder expression to use for missing expressions in assists. @@ -105,7 +106,7 @@ lib: with lib; { }; }; "features" = mkOption { - type = types.nullOr (types.oneOf [ (types.enum [ "all" ]) (types.listOf (types.str)) ]); + type = types.nullOr (types.oneOf [(types.enum ["all"]) (types.listOf (types.str))]); default = null; description = '' List of features to activate. @@ -217,7 +218,7 @@ lib: with lib; { ''; }; "features" = mkOption { - type = types.nullOr (types.nullOr (types.oneOf [ (types.enum [ "all" ]) (types.listOf (types.str)) ])); + type = types.nullOr (types.nullOr (types.oneOf [(types.enum ["all"]) (types.listOf (types.str))])); default = null; description = '' List of features to activate. Defaults to @@ -320,7 +321,7 @@ lib: with lib; { }; "callable" = { "snippets" = mkOption { - type = types.nullOr (types.enum [ "fill_arguments" "add_parentheses" "none" ]); + type = types.nullOr (types.enum ["fill_arguments" "add_parentheses" "none"]); default = null; description = '' Whether to add parenthesis and argument snippets when completing function. @@ -508,7 +509,7 @@ lib: with lib; { ''; }; "watcher" = mkOption { - type = types.nullOr (types.enum [ "client" "server" ]); + type = types.nullOr (types.enum ["client" "server"]); default = null; description = '' Controls file watching implementation. @@ -727,7 +728,7 @@ lib: with lib; { ''; }; "group" = mkOption { - type = types.nullOr (types.enum [ "preserve" "crate" "module" "item" ]); + type = types.nullOr (types.enum ["preserve" "crate" "module" "item"]); default = null; description = '' How imports should be grouped into use statements. @@ -768,7 +769,7 @@ lib: with lib; { }; }; "prefix" = mkOption { - type = types.nullOr (types.enum [ "plain" "self" "crate" ]); + type = types.nullOr (types.enum ["plain" "self" "crate"]); default = null; description = '' The path structure for newly inserted paths to use. @@ -838,7 +839,7 @@ lib: with lib; { }; "closureReturnTypeHints" = { "enable" = mkOption { - type = types.nullOr (types.enum [ "always" "never" "with_block" ]); + type = types.nullOr (types.enum ["always" "never" "with_block"]); default = null; description = '' Whether to show inlay type hints for return types of closures. @@ -852,7 +853,7 @@ lib: with lib; { }; "lifetimeElisionHints" = { "enable" = mkOption { - type = types.nullOr (types.enum [ "always" "never" "skip_trivial" ]); + type = types.nullOr (types.enum ["always" "never" "skip_trivial"]); default = null; description = '' Whether to show inlay type hints for elided lifetimes in function signatures. @@ -905,7 +906,7 @@ lib: with lib; { }; "reborrowHints" = { "enable" = mkOption { - type = types.nullOr (types.enum [ "always" "never" "mutable" ]); + type = types.nullOr (types.enum ["always" "never" "mutable"]); default = null; description = '' Whether to show inlay type hints for compiler inserted reborrows. @@ -1154,7 +1155,7 @@ lib: with lib; { }; }; "linkedProjects" = mkOption { - type = types.nullOr (types.listOf (types.oneOf [ (types.str) (types.attrsOf types.anything) ])); + type = types.nullOr (types.listOf (types.oneOf [(types.str) (types.attrsOf types.anything)])); default = null; description = '' Disable project auto-discovery in favor of explicitly specified set @@ -1471,7 +1472,7 @@ lib: with lib; { }; "signatureInfo" = { "detail" = mkOption { - type = types.nullOr (types.enum [ "full" "parameters" ]); + type = types.nullOr (types.enum ["full" "parameters"]); default = null; description = '' Show full signature of the callable. Only shows parameters if disabled. @@ -1517,7 +1518,7 @@ lib: with lib; { "symbol" = { "search" = { "kind" = mkOption { - type = types.nullOr (types.enum [ "only_types" "all_symbols" ]); + type = types.nullOr (types.enum ["only_types" "all_symbols"]); default = null; description = '' Workspace symbol search kind. @@ -1543,7 +1544,7 @@ lib: with lib; { ''; }; "scope" = mkOption { - type = types.nullOr (types.enum [ "workspace" "workspace_and_dependencies" ]); + type = types.nullOr (types.enum ["workspace" "workspace_and_dependencies"]); default = null; description = '' Workspace symbol search scope. diff --git a/plugins/nvim-lsp/trouble.nix b/plugins/nvim-lsp/trouble.nix index f323f606a3..91cdc3c4a7 100644 --- a/plugins/nvim-lsp/trouble.nix +++ b/plugins/nvim-lsp/trouble.nix @@ -1,26 +1,30 @@ -{ config, pkgs, lib, ... }: -let +{ + config, + pkgs, + lib, + ... +}: let cfg = config.plugins.trouble; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; in -with lib; -# with helpers; -{ - options.plugins.trouble = { - enable = mkEnableOption "trouble.nvim"; + with lib; + # with helpers; + { + options.plugins.trouble = { + enable = mkEnableOption "trouble.nvim"; - package = helpers.mkPackageOption "trouble-nvim" pkgs.vimPlugins.trouble-nvim; + package = helpers.mkPackageOption "trouble-nvim" pkgs.vimPlugins.trouble-nvim; - position = helpers.mkNullOrOption (types.enum [ "top" "left" "right" "bottom" ]) "Position of the list"; - height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom"; - width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right"; - icons = helpers.mkNullOrOption types.bool "Use devicons for filenames"; - }; + position = helpers.mkNullOrOption (types.enum ["top" "left" "right" "bottom"]) "Position of the list"; + height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom"; + width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right"; + icons = helpers.mkNullOrOption types.bool "Use devicons for filenames"; + }; - config = mkIf cfg.enable { - extraPlugins = with pkgs.vimPlugins; [ - cfg.package - nvim-web-devicons - ]; - }; -} + config = mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [ + cfg.package + nvim-web-devicons + ]; + }; + } diff --git a/plugins/plugin-defs.nix b/plugins/plugin-defs.nix index 52064873a2..6fbfa4e19a 100644 --- a/plugins/plugin-defs.nix +++ b/plugins/plugin-defs.nix @@ -1,8 +1,7 @@ # This is for plugins not in nixpkgs # e.g. intellitab.nvim # Ideally, in the future, this would all be specified as a flake input! -{ pkgs, ... }: -{ +{pkgs, ...}: { intellitab-nvim = pkgs.vimUtils.buildVimPlugin rec { pname = "intellitab-nvim"; version = "a6c1a505865f6131866d609c52440306e9914b16"; @@ -47,7 +46,7 @@ sha256 = "sha256-/m4Paw6AvDzTMWWCWpPnrdI4gsjIDSJPvGCMV7ufbEA="; }; - propagatedBuildInputs = [ pkgs.python3Packages.pynvim ]; + propagatedBuildInputs = [pkgs.python3Packages.pynvim]; }) (ps.buildPythonPackage rec { pname = "std2"; @@ -96,30 +95,29 @@ sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4="; }; - - - passthru.python3Dependencies = ps: with ps; [ - pynvim - jupyter-client - ueberzug - pillow - cairosvg - plotly - ipykernel - pyperclip - (ps.buildPythonPackage rec { - pname = "pnglatex"; - version = "1.1"; - src = fetchPypi { - inherit pname version; - hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M="; - }; - doCheck = false; - meta = with lib; { - homepage = "https://github.com/MaT1g3R/pnglatex"; - description = "a small program that converts LaTeX snippets to png"; - }; - }) - ]; + passthru.python3Dependencies = ps: + with ps; [ + pynvim + jupyter-client + ueberzug + pillow + cairosvg + plotly + ipykernel + pyperclip + (ps.buildPythonPackage rec { + pname = "pnglatex"; + version = "1.1"; + src = fetchPypi { + inherit pname version; + hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M="; + }; + doCheck = false; + meta = with lib; { + homepage = "https://github.com/MaT1g3R/pnglatex"; + description = "a small program that converts LaTeX snippets to png"; + }; + }) + ]; }; } diff --git a/plugins/pluginmanagers/packer.nix b/plugins/pluginmanagers/packer.nix index 7f05955a94..c132f6d0a6 100644 --- a/plugins/pluginmanagers/packer.nix +++ b/plugins/pluginmanagers/packer.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.packer; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.packer; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.packer = { enable = mkEnableOption "packer.nvim"; @@ -13,67 +16,79 @@ in type = types.listOf (types.oneOf [ types.str (with types; let - mkOpt = type: desc: mkOption { - type = nullOr type; - default = null; - description = desc; - }; + mkOpt = type: desc: + mkOption { + type = nullOr type; + default = null; + description = desc; + }; function = attrsOf str; in - types.submodule { - options = { - name = mkOption { - type = str; - description = "Name of the plugin to install"; - }; + types.submodule { + options = { + name = mkOption { + type = str; + description = "Name of the plugin to install"; + }; - disable = mkOpt bool "Mark plugin as inactive"; - as = mkOpt bool "Specifies an alias under which to install the plugin"; - installer = mkOpt function "A custom installer"; - updater = mkOpt function "A custom updater"; - after = mkOpt (oneOf [ str (listOf any) ]) "Plugins to load after this plugin"; - rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath"; - opt = mkOpt str "Marks a plugin as optional"; - branch = mkOpt str "Git branch to use"; - tag = mkOpt str "Git tag to use"; - commit = mkOpt str "Git commit to use"; - lock = mkOpt bool "Skip this plugin in updates"; - run = mkOpt (oneOf [ str function ]) "Post-install hook"; - requires = mkOpt (oneOf [ str (listOf any) ]) "Plugin dependencies"; - rocks = mkOpt (oneOf [ str (listOf any) ]) "Luarocks dependencies"; - config = mkOpt (oneOf [ str function ]) "Code to run after this plugin is loaded"; - setup = mkOpt (oneOf [ str function ]) "Code to be run before this plugin is loaded"; - cmd = mkOpt (oneOf [ str (listOf str) ]) "Commands which load this plugin"; - ft = mkOpt (oneOf [ str (listOf str) ]) "Filetypes which load this plugin"; - keys = mkOpt (oneOf [ str (listOf str) ]) "Keymaps which load this plugin"; - event = mkOpt (oneOf [ str (listOf str) ]) "Autocommand events which load this plugin"; - fn = mkOpt (oneOf [ str (listOf str) ]) "Functions which load this plugin"; - cond = mkOpt (oneOf [ str function (listOf (oneOf [ str function ])) ]) "Conditional test to load this plugin"; - module = mkOpt (oneOf [ str (listOf str) ]) "Patterns of module names which load this plugin"; - }; - }) + disable = mkOpt bool "Mark plugin as inactive"; + as = mkOpt bool "Specifies an alias under which to install the plugin"; + installer = mkOpt function "A custom installer"; + updater = mkOpt function "A custom updater"; + after = mkOpt (oneOf [str (listOf any)]) "Plugins to load after this plugin"; + rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath"; + opt = mkOpt str "Marks a plugin as optional"; + branch = mkOpt str "Git branch to use"; + tag = mkOpt str "Git tag to use"; + commit = mkOpt str "Git commit to use"; + lock = mkOpt bool "Skip this plugin in updates"; + run = mkOpt (oneOf [str function]) "Post-install hook"; + requires = mkOpt (oneOf [str (listOf any)]) "Plugin dependencies"; + rocks = mkOpt (oneOf [str (listOf any)]) "Luarocks dependencies"; + config = mkOpt (oneOf [str function]) "Code to run after this plugin is loaded"; + setup = mkOpt (oneOf [str function]) "Code to be run before this plugin is loaded"; + cmd = mkOpt (oneOf [str (listOf str)]) "Commands which load this plugin"; + ft = mkOpt (oneOf [str (listOf str)]) "Filetypes which load this plugin"; + keys = mkOpt (oneOf [str (listOf str)]) "Keymaps which load this plugin"; + event = mkOpt (oneOf [str (listOf str)]) "Autocommand events which load this plugin"; + fn = mkOpt (oneOf [str (listOf str)]) "Functions which load this plugin"; + cond = mkOpt (oneOf [str function (listOf (oneOf [str function]))]) "Conditional test to load this plugin"; + module = mkOpt (oneOf [str (listOf str)]) "Patterns of module names which load this plugin"; + }; + }) ]); - default = [ ]; + default = []; description = "List of plugins"; }; }; }; config = mkIf cfg.enable { - extraPlugins = [ (pkgs.vimPlugins.packer-nvim.overrideAttrs (_: { pname = "packer.nvim"; })) ]; - extraPackages = [ pkgs.git ]; + extraPlugins = [(pkgs.vimPlugins.packer-nvim.overrideAttrs (_: {pname = "packer.nvim";}))]; + extraPackages = [pkgs.git]; - extraConfigLua = - let - plugins = map - (plugin: - if isAttrs plugin then - mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin - else plugin) - cfg.plugins; - packedPlugins = if length plugins == 1 then head plugins else plugins; - in - mkIf (cfg.plugins != [ ]) '' + extraConfigLua = let + plugins = + map + (plugin: + if isAttrs plugin + then + mapAttrs' (k: v: { + name = + if k == "name" + then "@" + else k; + value = v; + }) + plugin + else plugin) + cfg.plugins; + packedPlugins = + if length plugins == 1 + then head plugins + else plugins; + in + mkIf (cfg.plugins != []) '' require('packer').startup(function() use ${helpers.toLuaObject packedPlugins} end) diff --git a/plugins/snippets/luasnip/default.nix b/plugins/snippets/luasnip/default.nix index 24e278d2fe..605b403407 100644 --- a/plugins/snippets/luasnip/default.nix +++ b/plugins/snippets/luasnip/default.nix @@ -1,17 +1,20 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.luasnip; - helpers = import ../../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.luasnip; + helpers = import ../../helpers.nix {inherit lib;}; +in { options.plugins.luasnip = { enable = mkEnableOption "Enable luasnip"; package = helpers.mkPackageOption "luasnip" pkgs.vimPlugins.luasnip; fromVscode = mkOption { - default = [ ]; + default = []; example = '' [ {} @@ -38,18 +41,19 @@ in # TODO: add option to also include the default runtimepath paths = mkOption { default = null; - type = with types; nullOr (oneOf - [ - str - path - helpers.rawType - (listOf (oneOf - [ - str - path - helpers.rawType - ])) - ]); + type = with types; + nullOr (oneOf + [ + str + path + helpers.rawType + (listOf (oneOf + [ + str + path + helpers.rawType + ])) + ]); }; exclude = mkOption { @@ -75,21 +79,18 @@ in # TODO: add support for lua }; - config = - let - - fromVscodeLoaders = lists.map - (loader: - let - options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader; - in - '' - require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options}) - '') - cfg.fromVscode; - in + config = let + fromVscodeLoaders = + lists.map + (loader: let + options = attrsets.getAttrs ["paths" "exclude" "include"] loader; + in '' + require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options}) + '') + cfg.fromVscode; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = concatStringsSep "\n" fromVscodeLoaders; }; } diff --git a/plugins/statuslines/airline.nix b/plugins/statuslines/airline.nix index 6ff4ff8713..9ece4162ec 100644 --- a/plugins/statuslines/airline.nix +++ b/plugins/statuslines/airline.nix @@ -1,17 +1,20 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.plugins.airline; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; - sectionType = with types; nullOr (oneOf [ str (listOf str) ]); + sectionType = with types; nullOr (oneOf [str (listOf str)]); sectionOption = mkOption { default = null; type = sectionType; description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*."; }; -in -{ +in { options = { plugins.airline = { enable = mkEnableOption "airline"; @@ -33,16 +36,17 @@ in sections = mkOption { description = "Statusbar sections"; default = null; - type = with types; nullOr (submodule { - options = { - a = sectionOption; - b = sectionOption; - c = sectionOption; - x = sectionOption; - y = sectionOption; - z = sectionOption; - }; - }); + type = with types; + nullOr (submodule { + options = { + a = sectionOption; + b = sectionOption; + c = sectionOption; + x = sectionOption; + y = sectionOption; + z = sectionOption; + }; + }); }; powerline = mkOption { @@ -59,21 +63,24 @@ in }; }; - config = - let - sections = { }; - in + config = let + sections = {}; + in mkIf cfg.enable { - extraPlugins = with pkgs.vimPlugins; [ - cfg.package - ] ++ optional (!isNull cfg.theme) vim-airline-themes; - globals = { - airline.extensions = cfg.extensions; + extraPlugins = with pkgs.vimPlugins; + [ + cfg.package + ] + ++ optional (!isNull cfg.theme) vim-airline-themes; + globals = + { + airline.extensions = cfg.extensions; - airline_statusline_ontop = mkIf cfg.onTop 1; - airline_powerline_fonts = mkIf (cfg.powerline) 1; + airline_statusline_ontop = mkIf cfg.onTop 1; + airline_powerline_fonts = mkIf (cfg.powerline) 1; - airline_theme = mkIf (!isNull cfg.theme) cfg.theme; - } // sections; + airline_theme = mkIf (!isNull cfg.theme) cfg.theme; + } + // sections; }; } diff --git a/plugins/statuslines/lightline.nix b/plugins/statuslines/lightline.nix index 290e5abc75..5a96a9db12 100644 --- a/plugins/statuslines/lightline.nix +++ b/plugins/statuslines/lightline.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.lightline; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.lightline; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.lightline = { enable = mkEnableOption "lightline"; @@ -51,23 +54,21 @@ in active = mkOption { default = null; type = types.nullOr (types.submodule { - options = - let - listType = with types; nullOr (listOf (listOf str)); - in - { - left = mkOption { - type = listType; - description = "List of components that will show up on the left side of the bar"; - default = null; - }; + options = let + listType = with types; nullOr (listOf (listOf str)); + in { + left = mkOption { + type = listType; + description = "List of components that will show up on the left side of the bar"; + default = null; + }; - right = mkOption { - type = listType; - description = "List of components that will show up on the right side of the bar"; - default = null; - }; + right = mkOption { + type = listType; + description = "List of components that will show up on the right side of the bar"; + default = null; }; + }; }); }; @@ -79,14 +80,13 @@ in }; }; - config = - let - configAttrs = filterAttrs (_: v: v != null) { - inherit (cfg) colorscheme active component componentFunction modeMap; - }; - in + config = let + configAttrs = filterAttrs (_: v: v != null) { + inherit (cfg) colorscheme active component componentFunction modeMap; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - globals.lightline = mkIf (configAttrs != { }) configAttrs; + extraPlugins = [cfg.package]; + globals.lightline = mkIf (configAttrs != {}) configAttrs; }; } diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 016c34fb73..d4703d02da 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -1,8 +1,12 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.plugins.lualine; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; separators = mkOption { type = types.nullOr (types.submodule { options = { @@ -32,7 +36,7 @@ let default = defaultName; }; icons_enabled = mkOption { - type = types.enum [ "True" "False" ]; + type = types.enum ["True" "False"]; default = "True"; description = "displays icons in alongside component"; }; @@ -44,7 +48,7 @@ let separator = separators; extraConfig = mkOption { type = types.attrs; - default = { }; + default = {}; description = "extra options for the component"; }; }; @@ -52,8 +56,7 @@ let ])); default = null; }; -in -{ +in { options = { plugins.lualine = { enable = mkEnableOption "lualine"; @@ -79,12 +82,11 @@ in alwaysDivideMiddle = mkOption { type = types.nullOr types.bool; default = null; - description = - "When true, left_sections (a,b,c) can't take over entire statusline"; + description = "When true, left_sections (a,b,c) can't take over entire statusline"; }; sections = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { lualine_a = component_options "mode"; lualine_b = component_options "branch"; @@ -100,7 +102,7 @@ in }; tabline = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { lualine_a = component_options ""; lualine_b = component_options ""; @@ -121,34 +123,45 @@ in }; }; }; - config = - let - processComponent = x: (if isAttrs x then processTableComponent else id) x; - processTableComponent = { name, icons_enabled, icon, separator, extraConfig }: mergeAttrs - { - "@" = name; - inherit icons_enabled icon separator; - } - extraConfig; - processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections; - setupOptions = { - options = { - theme = cfg.theme; - section_separators = cfg.sectionSeparators; - component_separators = cfg.componentSeparators; - disabled_filetypes = cfg.disabledFiletypes; - always_divide_middle = cfg.alwaysDivideMiddle; - }; - - sections = mapNullable processSections cfg.sections; - tabline = mapNullable processSections cfg.tabline; - extensions = cfg.extensions; + config = let + processComponent = x: + ( + if isAttrs x + then processTableComponent + else id + ) + x; + processTableComponent = { + name, + icons_enabled, + icon, + separator, + extraConfig, + }: + mergeAttrs + { + "@" = name; + inherit icons_enabled icon separator; + } + extraConfig; + processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections; + setupOptions = { + options = { + theme = cfg.theme; + section_separators = cfg.sectionSeparators; + component_separators = cfg.componentSeparators; + disabled_filetypes = cfg.disabledFiletypes; + always_divide_middle = cfg.alwaysDivideMiddle; }; - in + + sections = mapNullable processSections cfg.sections; + tabline = mapNullable processSections cfg.tabline; + extensions = cfg.extensions; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - extraPackages = [ pkgs.git ]; - extraConfigLua = - ''require("lualine").setup(${helpers.toLuaObject setupOptions})''; + extraPlugins = [cfg.package]; + extraPackages = [pkgs.git]; + extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})''; }; } diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index 335959a84a..d4609ca608 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -1,14 +1,13 @@ -{ pkgs -, config -, lib -, ... +{ + pkgs, + config, + lib, + ... }: -with lib; -let +with lib; let cfg = config.plugins.telescope; - helpers = import ../helpers.nix { inherit lib; }; -in -{ + helpers = import ../helpers.nix {inherit lib;}; +in { imports = [ ./frecency.nix ./fzf-native.nix @@ -33,13 +32,13 @@ in enabledExtensions = mkOption { type = types.listOf types.str; description = "A list of enabled extensions. Don't use this directly"; - default = [ ]; + default = []; }; extensionConfig = mkOption { type = types.attrsOf types.anything; description = "Configuration for the extensions. Don't use this directly"; - default = { }; + default = {}; }; defaults = mkOption { @@ -50,13 +49,13 @@ in extraOptions = mkOption { type = types.attrs; - default = { }; + default = {}; description = "An attribute set, that lets you set extra options or override options set by nixvim"; }; }; config = mkIf cfg.enable { - extraPackages = [ pkgs.bat ]; + extraPackages = [pkgs.bat]; extraPlugins = with pkgs.vimPlugins; [ cfg.package @@ -68,23 +67,23 @@ in let $BAT_THEME = '${cfg.highlightTheme}' ''; - extraConfigLua = - let - options = { + extraConfigLua = let + options = + { extensions = cfg.extensionConfig; defaults = cfg.defaults; - } // cfg.extraOptions; - in - '' - do - local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} + } + // cfg.extraOptions; + in '' + do + local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} - require('telescope').setup(${helpers.toLuaObject options}) + require('telescope').setup(${helpers.toLuaObject options}) - for i, extension in ipairs(__telescopeExtensions) do - require('telescope').load_extension(extension) - end + for i, extension in ipairs(__telescopeExtensions) do + require('telescope').load_extension(extension) end - ''; + end + ''; }; } diff --git a/plugins/telescope/frecency.nix b/plugins/telescope/frecency.nix index ba3a29e8c0..62cb616666 100644 --- a/plugins/telescope/frecency.nix +++ b/plugins/telescope/frecency.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.telescope.extensions.frecency; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.telescope.extensions.frecency; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.telescope.extensions.frecency = { enable = mkEnableOption "frecency"; @@ -47,26 +50,25 @@ in }; }; - config = - let - configuration = { - db_root = cfg.dbRoot; - default_workspace = cfg.defaultWorkspace; - ignore_patterns = cfg.ignorePatterns; - show_scores = cfg.showScores; - workspaces = cfg.workspaces; - show_unindexed = cfg.showUnindexed; - devicons_disabled = cfg.deviconsDisabled; - }; - in + config = let + configuration = { + db_root = cfg.dbRoot; + default_workspace = cfg.defaultWorkspace; + ignore_patterns = cfg.ignorePatterns; + show_scores = cfg.showScores; + workspaces = cfg.workspaces; + show_unindexed = cfg.showUnindexed; + devicons_disabled = cfg.deviconsDisabled; + }; + in mkIf cfg.enable { - extraPackages = [ pkgs.sqlite ]; + extraPackages = [pkgs.sqlite]; extraPlugins = with pkgs.vimPlugins; [ cfg.package sqlite-lua ]; - plugins.telescope.enabledExtensions = [ "frecency" ]; + plugins.telescope.enabledExtensions = ["frecency"]; plugins.telescope.extensionConfig."frecency" = configuration; }; } diff --git a/plugins/telescope/fzf-native.nix b/plugins/telescope/fzf-native.nix index dd70801b70..c14010401b 100644 --- a/plugins/telescope/fzf-native.nix +++ b/plugins/telescope/fzf-native.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.telescope.extensions.fzf-native; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.telescope.extensions.fzf-native; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.telescope.extensions.fzf-native = { enable = mkEnableOption "Enable fzf-native"; @@ -26,7 +29,7 @@ in default = null; }; caseMode = mkOption { - type = types.nullOr (types.enum [ "smart_case" "ignore_case" "respect_case" ]); + type = types.nullOr (types.enum ["smart_case" "ignore_case" "respect_case"]); default = null; }; }; @@ -38,10 +41,11 @@ in override_file_sorter = cfg.overrideFileSorter; case_mode = cfg.caseMode; }; - in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + in + mkIf cfg.enable { + extraPlugins = [cfg.package]; - plugins.telescope.enabledExtensions = [ "fzf" ]; - plugins.telescope.extensionConfig."fzf" = configuration; - }; + plugins.telescope.enabledExtensions = ["fzf"]; + plugins.telescope.extensionConfig."fzf" = configuration; + }; } diff --git a/plugins/telescope/fzy-native.nix b/plugins/telescope/fzy-native.nix index dc172189d9..4235ad79c4 100644 --- a/plugins/telescope/fzy-native.nix +++ b/plugins/telescope/fzy-native.nix @@ -1,9 +1,12 @@ -{ pkgs, config, lib, ...}: -with lib; -let - cfg = config.plugins.telescope.extensions.fzy-native; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.telescope.extensions.fzy-native; +in { options.plugins.telescope.extensions.fzy-native = { enable = mkEnableOption "Enable fzy-native"; @@ -24,10 +27,11 @@ in override_generic_sorter = cfg.overrideGenericSorter; override_file_sorter = cfg.overrideFileSorter; }; - in mkIf cfg.enable { - extraPlugins = [ pkgs.vimPlugins.telescope-fzy-native-nvim ]; + in + mkIf cfg.enable { + extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim]; - plugins.telescope.enabledExtensions = [ "fzy_native" ]; - plugins.telescope.extensionConfig."fzy_native" = configuration; - }; + plugins.telescope.enabledExtensions = ["fzy_native"]; + plugins.telescope.extensionConfig."fzy_native" = configuration; + }; } diff --git a/plugins/telescope/media-files.nix b/plugins/telescope/media-files.nix index 20d812ace8..77b16963f2 100644 --- a/plugins/telescope/media-files.nix +++ b/plugins/telescope/media-files.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.telescope.extensions.media_files; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.telescope.extensions.media_files; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.telescope.extensions.media_files = { enable = mkEnableOption "Enable media_files extension for telescope"; @@ -23,7 +26,7 @@ in }; config = mkIf cfg.enable { - plugins.telescope.enabledExtensions = [ "media_files" ]; + plugins.telescope.enabledExtensions = ["media_files"]; extraPlugins = with pkgs.vimPlugins; [ popup-nvim diff --git a/plugins/telescope/project-nvim.nix b/plugins/telescope/project-nvim.nix index e8d7d834b9..b19de997f1 100644 --- a/plugins/telescope/project-nvim.nix +++ b/plugins/telescope/project-nvim.nix @@ -1,15 +1,17 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.telescope.extensions.project-nvim; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.telescope.extensions.project-nvim; +in { options.plugins.telescope.extensions.project-nvim = { enable = mkEnableOption "project-nvim telescope extension"; - }; config = mkIf cfg.enable { - plugins.telescope.enabledExtensions = [ "projects" ]; + plugins.telescope.enabledExtensions = ["projects"]; }; } diff --git a/plugins/utils/comment-nvim.nix b/plugins/utils/comment-nvim.nix index 471f0c7bf6..04a235c11f 100644 --- a/plugins/utils/comment-nvim.nix +++ b/plugins/utils/comment-nvim.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.comment-nvim; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.comment-nvim; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.comment-nvim = { enable = mkEnableOption "Enable comment-nvim"; @@ -27,7 +30,7 @@ in default = null; }; toggler = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { line = mkOption { type = types.str; @@ -45,7 +48,7 @@ in default = null; }; opleader = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { line = mkOption { type = types.str; @@ -63,7 +66,7 @@ in default = null; }; mappings = mkOption { - type = types.nullOr (types.submodule ({ ... }: { + type = types.nullOr (types.submodule ({...}: { options = { basic = mkOption { type = types.bool; @@ -88,20 +91,18 @@ in }; }; - config = - let - setupOptions = { - padding = cfg.padding; - sticky = cfg.sticky; - ignore = cfg.ignore; - toggler = cfg.toggler; - opleader = cfg.opleader; - mappings = cfg.mappings; - }; - in + config = let + setupOptions = { + padding = cfg.padding; + sticky = cfg.sticky; + ignore = cfg.ignore; + toggler = cfg.toggler; + opleader = cfg.opleader; + mappings = cfg.mappings; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; - extraConfigLua = - ''require("Comment").setup${helpers.toLuaObject setupOptions}''; + extraPlugins = [cfg.package]; + extraConfigLua = ''require("Comment").setup${helpers.toLuaObject setupOptions}''; }; } diff --git a/plugins/utils/commentary.nix b/plugins/utils/commentary.nix index 885d81f251..8c1475c52f 100644 --- a/plugins/utils/commentary.nix +++ b/plugins/utils/commentary.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.commentary; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.commentary; + helpers = import ../helpers.nix {inherit lib;}; +in { # TODO Add support for aditional filetypes. This requires autocommands! options = { @@ -16,6 +19,6 @@ in }; config = mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; }; } diff --git a/plugins/utils/dashboard.nix b/plugins/utils/dashboard.nix index e47ec62e24..50bfdaa34e 100644 --- a/plugins/utils/dashboard.nix +++ b/plugins/utils/dashboard.nix @@ -1,11 +1,14 @@ -{ config, lib, pkgs, ... }: -with lib; -let +{ + config, + lib, + pkgs, + ... +}: +with lib; let cfg = config.plugins.dashboard; - helpers = import ../helpers.nix { inherit lib; }; -in -{ + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.dashboard = { enable = mkEnableOption "dashboard"; @@ -90,7 +93,7 @@ in }; }; }; - default = { }; + default = {}; }; hideStatusline = mkOption { @@ -107,34 +110,32 @@ in }; }; - config = - let - options = { - custom_header = cfg.header; - custom_footer = cfg.footer; - custom_center = cfg.center; + config = let + options = { + custom_header = cfg.header; + custom_footer = cfg.footer; + custom_center = cfg.center; - preview_file_path = cfg.preview.file; - preview_file_height = cfg.preview.height; - preview_file_width = cfg.preview.width; - preview_command = cfg.preview.command; + preview_file_path = cfg.preview.file; + preview_file_height = cfg.preview.height; + preview_file_width = cfg.preview.width; + preview_command = cfg.preview.command; - hide_statusline = cfg.hideStatusline; - hide_tabline = cfg.hideTabline; + hide_statusline = cfg.hideStatusline; + hide_tabline = cfg.hideTabline; - session_directory = cfg.sessionDirectory; - }; + session_directory = cfg.sessionDirectory; + }; - filteredOptions = filterAttrs (_: v: !isNull v) options; - in + filteredOptions = filterAttrs (_: v: !isNull v) options; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' local dashboard = require("dashboard") - ${toString (mapAttrsToList (n: v: - "dashboard.${n} = ${helpers.toLuaObject v}\n") - filteredOptions)} + ${toString (mapAttrsToList (n: v: "dashboard.${n} = ${helpers.toLuaObject v}\n") + filteredOptions)} ''; }; } diff --git a/plugins/utils/easyescape.nix b/plugins/utils/easyescape.nix index 990727dee9..7a8a6b0d59 100644 --- a/plugins/utils/easyescape.nix +++ b/plugins/utils/easyescape.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.easyescape; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.easyescape; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.easyescape = { enable = mkEnableOption "Enable easyescape"; diff --git a/plugins/utils/emmet.nix b/plugins/utils/emmet.nix index 6664bc667b..00a1bd4f6d 100644 --- a/plugins/utils/emmet.nix +++ b/plugins/utils/emmet.nix @@ -1,34 +1,39 @@ -{ lib, pkgs, ... }@attrs: -with lib; -let - helpers = import ../helpers.nix { inherit lib; }; +{ + lib, + pkgs, + ... +} @ attrs: +with lib; let + helpers = import ../helpers.nix {inherit lib;}; eitherAttrsStrInt = with types; let strInt = either str int; - in either strInt (attrsOf (either strInt (attrsOf strInt))); -in with helpers; -mkPlugin attrs { - name = "emmet"; - description = "Enable emmet"; - package = pkgs.vimPlugins.emmet-vim; + in + either strInt (attrsOf (either strInt (attrsOf strInt))); +in + with helpers; + mkPlugin attrs { + name = "emmet"; + description = "Enable emmet"; + package = pkgs.vimPlugins.emmet-vim; - options = { - mode = mkDefaultOpt { - type = types.enum [ "i" "n" "v" "a" ]; - global = "user_emmet_mode"; - description = "Mode where emmet will enable"; - }; + options = { + mode = mkDefaultOpt { + type = types.enum ["i" "n" "v" "a"]; + global = "user_emmet_mode"; + description = "Mode where emmet will enable"; + }; - leader = mkDefaultOpt { - type = types.str; - global = "user_emmet_leader_key"; - description = "Set leader key"; - }; + leader = mkDefaultOpt { + type = types.str; + global = "user_emmet_leader_key"; + description = "Set leader key"; + }; - settings = mkDefaultOpt { - type = types.attrsOf (types.attrsOf eitherAttrsStrInt); - global = "user_emmet_settings"; - description = "Emmet settings"; - }; - }; -} + settings = mkDefaultOpt { + type = types.attrsOf (types.attrsOf eitherAttrsStrInt); + global = "user_emmet_settings"; + description = "Emmet settings"; + }; + }; + } diff --git a/plugins/utils/endwise.nix b/plugins/utils/endwise.nix index e584629da8..9f81021979 100644 --- a/plugins/utils/endwise.nix +++ b/plugins/utils/endwise.nix @@ -1,12 +1,17 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "endwise"; - description = "Enable vim-endwise"; - package = pkgs.vimPlugins.vim-endwise; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "endwise"; + description = "Enable vim-endwise"; + package = pkgs.vimPlugins.vim-endwise; - # Yes it's really not configurable - options = {}; -} + # Yes it's really not configurable + options = {}; + } diff --git a/plugins/utils/floaterm.nix b/plugins/utils/floaterm.nix index 3a098676ae..787e2c6ece 100644 --- a/plugins/utils/floaterm.nix +++ b/plugins/utils/floaterm.nix @@ -1,10 +1,13 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.floaterm; - helpers = import ../helpers.nix { inherit lib; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.floaterm; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.floaterm = { enable = mkEnableOption "floaterm"; @@ -21,7 +24,7 @@ in default = null; }; winType = mkOption { - type = types.nullOr (types.enum [ "float" "split" "vsplit" ]); + type = types.nullOr (types.enum ["float" "split" "vsplit"]); default = null; }; winWidth = mkOption { @@ -45,17 +48,17 @@ in default = null; }; opener = mkOption { - type = types.nullOr (types.enum [ "edit" "split" "vsplit" "tabe" "drop" ]); + type = types.nullOr (types.enum ["edit" "split" "vsplit" "tabe" "drop"]); description = "Command used for opening a file in the outside nvim from within :terminal"; default = null; }; autoClose = mkOption { - type = types.nullOr (types.enum [ 0 1 2 ]); + type = types.nullOr (types.enum [0 1 2]); description = "Whether to close floaterm window once the job gets finished."; default = null; }; autoHide = mkOption { - type = types.nullOr (types.enum [ 0 1 2 ]); + type = types.nullOr (types.enum [0 1 2]); description = "Whether to hide previous floaterm before switching to or opening another one."; default = null; }; diff --git a/plugins/utils/goyo.nix b/plugins/utils/goyo.nix index ac23ab2360..49432586ca 100644 --- a/plugins/utils/goyo.nix +++ b/plugins/utils/goyo.nix @@ -1,29 +1,34 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "goyo"; - description = "Enable goyo.vim"; - package = pkgs.vimPlugins.goyo-vim; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "goyo"; + description = "Enable goyo.vim"; + package = pkgs.vimPlugins.goyo-vim; - options = { - width = mkDefaultOpt { - description = "Width"; - global = "goyo_width"; - type = types.int; - }; + options = { + width = mkDefaultOpt { + description = "Width"; + global = "goyo_width"; + type = types.int; + }; - height = mkDefaultOpt { - description = "Height"; - global = "goyo_height"; - type = types.int; - }; + height = mkDefaultOpt { + description = "Height"; + global = "goyo_height"; + type = types.int; + }; - showLineNumbers = mkDefaultOpt { - description = "Show line numbers when in Goyo mode"; - global = "goyo_linenr"; - type = types.bool; - }; - }; -} + showLineNumbers = mkDefaultOpt { + description = "Show line numbers when in Goyo mode"; + global = "goyo_linenr"; + type = types.bool; + }; + }; + } diff --git a/plugins/utils/harpoon.nix b/plugins/utils/harpoon.nix index 974414d02e..e201c67739 100644 --- a/plugins/utils/harpoon.nix +++ b/plugins/utils/harpoon.nix @@ -1,8 +1,12 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.plugins.harpoon; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; projectConfigModule = types.submodule { options = { @@ -15,8 +19,7 @@ let ''; }; }; -in -{ +in { options.plugins.harpoon = { enable = mkEnableOption "harpoon"; @@ -47,7 +50,7 @@ in ''; projects = mkOption { - default = { }; + default = {}; description = '' Predefined projetcs. The keys of this attrs should be the path to the project. $HOME is working. @@ -73,50 +76,48 @@ in Menu window height ''; - borderChars = helpers.defaultNullOpts.mkNullable (types.listOf types.str) + borderChars = + helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[ \"─\" \"│\" \"─\" \"│\" \"╭\" \"╮\" \"╯\" \"╰\" ]" - "Border characters" - ; + "Border characters"; }; - }; - config = - let - projects = builtins.mapAttrs - ( - name: value: { - term.cmds = value.termCommands; - mark.marks = map (mark: { filename = mark; }) value.marks; - } - ) - cfg.projects; - - options = { - global_settings = { - save_on_toggle = cfg.saveOnToggle; - save_on_change = cfg.saveOnChange; - enter_on_sendcmd = cfg.enterOnSendcmd; - tmux_autoclose_windows = cfg.tmuxAutocloseWindows; - excluded_filetypes = cfg.excludedFiletypes; - mark_branch = cfg.markBranch; - }; + config = let + projects = + builtins.mapAttrs + ( + name: value: { + term.cmds = value.termCommands; + mark.marks = map (mark: {filename = mark;}) value.marks; + } + ) + cfg.projects; + + options = { + global_settings = { + save_on_toggle = cfg.saveOnToggle; + save_on_change = cfg.saveOnChange; + enter_on_sendcmd = cfg.enterOnSendcmd; + tmux_autoclose_windows = cfg.tmuxAutocloseWindows; + excluded_filetypes = cfg.excludedFiletypes; + mark_branch = cfg.markBranch; + }; - projects = projects; + projects = projects; - menu = { - width = cfg.menu.width; - height = cfg.menu.height; - borderchars = cfg.menu.borderChars; - }; + menu = { + width = cfg.menu.width; + height = cfg.menu.height; + borderchars = cfg.menu.borderChars; }; - in + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' require('harpoon').setup(${helpers.toLuaObject options}) ''; }; } - diff --git a/plugins/utils/indent-blankline.nix b/plugins/utils/indent-blankline.nix index 89298b2d35..fb0360ddbc 100644 --- a/plugins/utils/indent-blankline.nix +++ b/plugins/utils/indent-blankline.nix @@ -1,12 +1,12 @@ -{ lib -, pkgs -, config -, ... +{ + lib, + pkgs, + config, + ... } @ args: with lib; let helpers = import ../helpers.nix args; -in -{ +in { options.plugins.indent-blankline = { enable = mkEnableOption "indent-blankline.nvim"; @@ -62,7 +62,7 @@ in useTreesitter = helpers.defaultNullOpts.mkBool false - "Use treesitter to calculate indentation when possible."; + "Use treesitter to calculate indentation when possible."; indentLevel = helpers.defaultNullOpts.mkInt 10 "Specifies the maximum indent level to display."; @@ -107,14 +107,14 @@ in filetypeExclude = helpers.defaultNullOpts.mkNullable (types.listOf types.str) - ''["lspinfo" "packer" "checkhealth" "help" "man" ""]'' '' + ''["lspinfo" "packer" "checkhealth" "help" "man" ""]'' '' Specifies a list of |filetype| values for which this plugin is not enabled. Ignored if the value is an empty list. ''; buftypeExclude = helpers.defaultNullOpts.mkNullable (types.listOf types.str) - ''["terminal" "nofile" "quickfix" "prompt"]'' '' + ''["terminal" "nofile" "quickfix" "prompt"]'' '' Specifies a list of |buftype| values for which this plugin is not enabled. Ignored if the value is an empty list. ''; @@ -197,7 +197,7 @@ in contextStartPriority = helpers.defaultNullOpts.mkInt 10000 - "Specifies the |extmarks| priority for the context start."; + "Specifies the |extmarks| priority for the context start."; contextPatterns = helpers.defaultNullOpts.mkNullable (types.listOf types.str) '' [ @@ -248,12 +248,11 @@ in helpers.defaultNullOpts.mkBool false "Turns deprecation warning messages off."; }; - config = - let - cfg = config.plugins.indent-blankline; - in + config = let + cfg = config.plugins.indent-blankline; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { indent_blankline_char = cfg.char; diff --git a/plugins/utils/intellitab.nix b/plugins/utils/intellitab.nix index 669f1315a0..b26dba47b3 100644 --- a/plugins/utils/intellitab.nix +++ b/plugins/utils/intellitab.nix @@ -1,11 +1,14 @@ -{ config, pkgs, lib, ... }: -with lib; -let - cfg = config.plugins.intellitab; - helpers = import ../helpers.nix { inherit lib; }; - defs = import ../plugin-defs.nix { inherit pkgs; }; -in { + config, + pkgs, + lib, + ... +}: +with lib; let + cfg = config.plugins.intellitab; + helpers = import ../helpers.nix {inherit lib;}; + defs = import ../plugin-defs.nix {inherit pkgs;}; +in { options = { plugins.intellitab = { enable = mkEnableOption "intellitab.nvim"; @@ -15,7 +18,7 @@ in }; config = mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; maps.insert."" = "lua require([[intellitab]]).indent()"; plugins.treesitter = { diff --git a/plugins/utils/magma-nvim.nix b/plugins/utils/magma-nvim.nix index 190a3c5f1f..3c58691e60 100644 --- a/plugins/utils/magma-nvim.nix +++ b/plugins/utils/magma-nvim.nix @@ -1,24 +1,27 @@ -{ pkgs, lib, config, ... }: -with lib; -let +{ + pkgs, + lib, + config, + ... +}: +with lib; let cfg = config.plugins.magma-nvim; - plugins = import ../plugin-defs.nix { inherit pkgs; }; + plugins = import ../plugin-defs.nix {inherit pkgs;}; package = pkgs.fetchFromGitHub { - owner = "dccsillag"; - repo = "magma-nvim"; - rev = version; - sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4="; - }; + owner = "dccsillag"; + repo = "magma-nvim"; + rev = version; + sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4="; + }; in { options = { plugins.magma-nvim = { enable = mkEnableOption "Enable magma-nvim?"; image_provider = mkOption { - type = types.enum [ "none" "ueberzug" "kitty" ]; + type = types.enum ["none" "ueberzug" "kitty"]; default = "none"; example = "ueberzug"; - description = - " This configures how to display images. The following options are available: + description = " This configures how to display images. The following options are available: none -- don't show imagesmagma_image_provider. ueberzug -- use Ueberzug to display images. kitty -- use the Kitty protocol to display images."; @@ -27,8 +30,7 @@ in { type = types.bool; default = true; example = false; - description = - " If this is true, then whenever you have an active cell its output window will be automatically shown. + description = " If this is true, then whenever you have an active cell its output window will be automatically shown. If this is false, then the output window will only be automatically shown when you've just evaluated the code. So, if you take your cursor out of the cell, and then come back, the output window won't be opened (but the cell will be highlighted). This means that there will be nothing covering your code. You can then open the output window at will using :MagmaShowOutput."; }; @@ -36,60 +38,54 @@ in { type = types.bool; default = true; example = false; - description = - " If this is true, then text output in the output window will be wrapped (akin to set wrap)."; + description = " If this is true, then text output in the output window will be wrapped (akin to set wrap)."; }; output_window_borders = mkOption { type = types.bool; default = true; example = false; - description = - " If this is true, then the output window will have rounded borders. If it is false, it will have no borders."; + description = " If this is true, then the output window will have rounded borders. If it is false, it will have no borders."; }; cell_highlight_group = mkOption { type = types.str; default = "CursorLine"; # example = ""; - description = - " The highlight group to be used for highlighting cells."; + description = " The highlight group to be used for highlighting cells."; }; save_path = mkOption { type = types.nullOr types.str; default = null; - description = - "Where to save/load with :MagmaSave and :MagmaLoad (with no parameters). + description = "Where to save/load with :MagmaSave and :MagmaLoad (with no parameters). The generated file is placed in this directory, with the filename itself being the buffer's name, with % replaced by %% and / replaced by %, and postfixed with the extension .json."; }; show_mimetype_debug = mkOption { type = types.bool; default = false; example = true; - description = - " If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it. + description = " If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it. This is meant for debugging and adding new mimetypes."; }; package = mkOption { type = types.nullOr types.package; default = null; - example = - "package = pkgs.fetchFromGitHub { + example = "package = pkgs.fetchFromGitHub { owner = \"WhiteBlackGoose\"; repo = \"magma-nvim-goose\"; rev = version; sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} "; - - }; - }; }; config = mkIf cfg.enable { - extraPlugins = [ ( - if cfg.package != null then plugins.magma-nvim.override {src = cfg.package;} else plugins.magma-nvim - )]; - + extraPlugins = [ + ( + if cfg.package != null + then plugins.magma-nvim.override {src = cfg.package;} + else plugins.magma-nvim + ) + ]; globals = { magma_image_provider = @@ -99,13 +95,11 @@ in { magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output; magma_output_window_borders = mkIf (!cfg.output_window_borders) cfg.output_window_borders; - magma_highlight_group = mkIf (cfg.cell_highlight_group != "CursorLine") + magma_highlight_group = + mkIf (cfg.cell_highlight_group != "CursorLine") cfg.cell_highlight_group; magma_show_mimetype_debug = mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug; - }; }; - } - diff --git a/plugins/utils/mark-radar.nix b/plugins/utils/mark-radar.nix index 9c1404a2ef..9dbbf0dfec 100644 --- a/plugins/utils/mark-radar.nix +++ b/plugins/utils/mark-radar.nix @@ -1,12 +1,14 @@ -{ pkgs, config, lib, ... }: - -with lib; -let - cfg = config.plugins.mark-radar; - helpers = import ../helpers.nix { inherit lib; }; - defs = import ../plugin-defs.nix { inherit pkgs; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.mark-radar; + helpers = import ../helpers.nix {inherit lib;}; + defs = import ../plugin-defs.nix {inherit pkgs;}; +in { options.plugins.mark-radar = { enable = mkEnableOption "mark-radar"; @@ -33,16 +35,15 @@ in }; }; - config = - let - opts = helpers.toLuaObject { - inherit (cfg) highlight_group background_highlight_group; - set_default_mappings = cfg.set_default_keybinds; - background_highlight = cfg.highlight_background; - }; - in + config = let + opts = helpers.toLuaObject { + inherit (cfg) highlight_group background_highlight_group; + set_default_mappings = cfg.set_default_keybinds; + background_highlight = cfg.highlight_background; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' require("mark-radar").setup(${opts}) diff --git a/plugins/utils/notify.nix b/plugins/utils/notify.nix index 73e7cc6415..7483f72f23 100644 --- a/plugins/utils/notify.nix +++ b/plugins/utils/notify.nix @@ -1,21 +1,24 @@ -{ pkgs, config, lib, ... }: -with lib; -let +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.plugins.notify; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; icon = mkOption { type = types.nullOr types.str; default = null; }; -in -{ +in { options.plugins.notify = { enable = mkEnableOption "notify"; package = helpers.mkPackageOption "notify" pkgs.vimPlugins.nvim-notify; stages = mkOption { - type = types.nullOr (types.enum [ "fade_in_slide_out" "fade" "slide" "static" ]); + type = types.nullOr (types.enum ["fade_in_slide_out" "fade" "slide" "static"]); description = "Animation style"; default = null; }; @@ -45,28 +48,27 @@ in }; }); description = "Icons for the different levels"; - default = { }; + default = {}; }; }; - config = - let - setupOptions = with cfg; { - stages = stages; - timeout = timeout; - background_color = backgroundColor; - minimum_width = minimumWidth; - icons = with icons; { - ERROR = error; - WARN = warn; - INFO = info; - DEBUG = debug; - TRACE = trace; - }; + config = let + setupOptions = with cfg; { + stages = stages; + timeout = timeout; + background_color = backgroundColor; + minimum_width = minimumWidth; + icons = with icons; { + ERROR = error; + WARN = warn; + INFO = info; + DEBUG = debug; + TRACE = trace; }; - in + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' vim.notify = require('notify'); require('notify').setup(${helpers.toLuaObject setupOptions}) diff --git a/plugins/utils/nvim-autopairs.nix b/plugins/utils/nvim-autopairs.nix index c392c57d6e..46752b98d5 100644 --- a/plugins/utils/nvim-autopairs.nix +++ b/plugins/utils/nvim-autopairs.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.nvim-autopairs; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.nvim-autopairs; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.nvim-autopairs = { enable = mkEnableOption "nvim-autopairs"; @@ -41,18 +44,17 @@ in }; }; - config = - let - options = { - pairs_map = cfg.pairs; - disable_filetype = cfg.disabledFiletypes; - break_line_filetype = cfg.breakLineFiletypes; - html_break_line_filetype = cfg.htmlFiletypes; - ignored_next_char = cfg.ignoredNextChar; - }; - in + config = let + options = { + pairs_map = cfg.pairs; + disable_filetype = cfg.disabledFiletypes; + break_line_filetype = cfg.breakLineFiletypes; + html_break_line_filetype = cfg.htmlFiletypes; + ignored_next_char = cfg.ignoredNextChar; + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' require('nvim-autopairs').setup(${helpers.toLuaObject options}) diff --git a/plugins/utils/nvim-colorizer.nix b/plugins/utils/nvim-colorizer.nix index 56e5d01239..51f9164566 100644 --- a/plugins/utils/nvim-colorizer.nix +++ b/plugins/utils/nvim-colorizer.nix @@ -1,9 +1,12 @@ -{ pkgs, config, lib, ... }: -with lib; -let - +{ + pkgs, + config, + lib, + ... +}: +with lib; let cfg = config.plugins.nvim-colorizer; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; colorizer-options = { RGB = mkOption { @@ -53,7 +56,7 @@ let }; mode = mkOption { description = "Set the display mode"; - type = types.nullOr (types.enum [ "foreground" "background" "virtualtext" ]); + type = types.nullOr (types.enum ["foreground" "background" "virtualtext"]); default = null; }; tailwind = mkOption { @@ -61,7 +64,7 @@ let type = types.nullOr ( types.oneOf [ types.bool - (types.enum [ "normal" "lsp" "both" ]) + (types.enum ["normal" "lsp" "both"]) ] ); default = null; @@ -84,12 +87,9 @@ let default = null; }; }; - -in -{ +in { options = { plugins.nvim-colorizer = { - enable = mkEnableOption "nvim-colorizer"; package = helpers.mkPackageOption "nvim-colorizer" pkgs.vimPlugins.nvim-colorizer-lua; @@ -100,11 +100,13 @@ in types.listOf (types.oneOf [ types.str (types.submodule { - options = { - language = mkOption { - type = types.str; - }; - } // colorizer-options; + options = + { + language = mkOption { + type = types.str; + }; + } + // colorizer-options; }) ]) ); @@ -128,24 +130,26 @@ in }; config = mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = let - - filetypes = if (cfg.fileTypes != null) - then ( - let - list = map ( - v: if builtins.isAttrs v - then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v [ "language" ]) - else "'${v}'" - ) cfg.fileTypes; - in "{" + (concatStringsSep "," list) + "}" - ) - else - "nil" - ; - + filetypes = + if (cfg.fileTypes != null) + then + ( + let + list = + map ( + v: + if builtins.isAttrs v + then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v ["language"]) + else "'${v}'" + ) + cfg.fileTypes; + in + "{" + (concatStringsSep "," list) + "}" + ) + else "nil"; in '' require("colorizer").setup({ filetypes = ${filetypes}, diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix index bbf0001934..0fc51fc806 100644 --- a/plugins/utils/nvim-tree.nix +++ b/plugins/utils/nvim-tree.nix @@ -1,27 +1,30 @@ -{ pkgs, config, lib, ... }@args: -with lib; -let +{ + pkgs, + config, + lib, + ... +} @ args: +with lib; let cfg = config.plugins.nvim-tree; - helpers = import ../helpers.nix { inherit lib; }; + helpers = import ../helpers.nix {inherit lib;}; optionWarnings = import ../../lib/option-warnings.nix args; - basePluginPath = [ "plugins" "nvim-tree" ]; -in -{ + basePluginPath = ["plugins" "nvim-tree"]; +in { imports = [ (optionWarnings.mkRenamedOption { - option = basePluginPath ++ [ "updateCwd" ]; - newOption = basePluginPath ++ [ "syncRootWithCwd" ]; + option = basePluginPath ++ ["updateCwd"]; + newOption = basePluginPath ++ ["syncRootWithCwd"]; }) (optionWarnings.mkRenamedOption { - option = basePluginPath ++ [ "updateFocusedFile" "updateCwd" ]; - newOption = basePluginPath ++ [ "updateFocusedFile" "updateRoot" ]; + option = basePluginPath ++ ["updateFocusedFile" "updateCwd"]; + newOption = basePluginPath ++ ["updateFocusedFile" "updateRoot"]; }) (optionWarnings.mkDeprecatedOption { - option = basePluginPath ++ [ "openOnSetup" ]; + option = basePluginPath ++ ["openOnSetup"]; alternative = []; }) (optionWarnings.mkDeprecatedOption { - option = basePluginPath ++ [ "ignoreFtOnSetup" ]; + option = basePluginPath ++ ["ignoreFtOnSetup"]; alternative = []; }) ]; @@ -102,20 +105,19 @@ in description = "Enable diagnostics"; }; - icons = - let - diagnosticOption = desc: mkOption { + icons = let + diagnosticOption = desc: + mkOption { type = types.nullOr types.str; default = null; description = desc; }; - in - { - hint = diagnosticOption "Hints"; - info = diagnosticOption "Info"; - warning = diagnosticOption "Warning"; - error = diagnosticOption "Error"; - }; + in { + hint = diagnosticOption "Hints"; + info = diagnosticOption "Info"; + warning = diagnosticOption "Warning"; + error = diagnosticOption "Error"; + }; }; updateFocusedFile = { @@ -233,50 +235,49 @@ in }; }; - config = - let - options = { - disable_netrw = cfg.disableNetrw; - hijack_netrw = cfg.hijackNetrw; - open_on_setup = cfg.openOnSetup; - ignore_ft_on_setup = cfg.ignoreFtOnSetup; - open_on_tab = cfg.openOnTab; - hijack_cursor = cfg.hijackCursor; - sync_root_with_cwd = cfg.syncRootWithCwd; - respect_buf_cwd = cfg.respectBufCwd; - update_to_buf_dir = { - enable = cfg.updateToBufDir.enable; - auto_open = cfg.updateToBufDir.autoOpen; - }; - diagnostics = cfg.diagnostics; - update_focused_file = { - enable = cfg.updateFocusedFile.enable; - update_root = cfg.updateFocusedFile.updateRoot; - ignore_list = cfg.updateFocusedFile.ignoreList; - }; - system_open = cfg.systemOpen; - filters = cfg.filters; - git = cfg.git; - view = { - width = cfg.view.width; - height = cfg.view.height; - hide_root_folder = cfg.view.hideRootFolder; - side = cfg.view.side; - auto_resize = cfg.view.autoResize; - mappings = { - custom_only = cfg.view.mappings.customOnly; - list = cfg.view.mappings.list; - }; - number = cfg.view.number; - relativenumber = cfg.view.relativenumber; - signcolumn = cfg.view.signcolumn; - }; - trash = { - cmd = cfg.trash.cmd; - require_confirm = cfg.trash.requireConfirm; + config = let + options = { + disable_netrw = cfg.disableNetrw; + hijack_netrw = cfg.hijackNetrw; + open_on_setup = cfg.openOnSetup; + ignore_ft_on_setup = cfg.ignoreFtOnSetup; + open_on_tab = cfg.openOnTab; + hijack_cursor = cfg.hijackCursor; + sync_root_with_cwd = cfg.syncRootWithCwd; + respect_buf_cwd = cfg.respectBufCwd; + update_to_buf_dir = { + enable = cfg.updateToBufDir.enable; + auto_open = cfg.updateToBufDir.autoOpen; + }; + diagnostics = cfg.diagnostics; + update_focused_file = { + enable = cfg.updateFocusedFile.enable; + update_root = cfg.updateFocusedFile.updateRoot; + ignore_list = cfg.updateFocusedFile.ignoreList; + }; + system_open = cfg.systemOpen; + filters = cfg.filters; + git = cfg.git; + view = { + width = cfg.view.width; + height = cfg.view.height; + hide_root_folder = cfg.view.hideRootFolder; + side = cfg.view.side; + auto_resize = cfg.view.autoResize; + mappings = { + custom_only = cfg.view.mappings.customOnly; + list = cfg.view.mappings.list; }; + number = cfg.view.number; + relativenumber = cfg.view.relativenumber; + signcolumn = cfg.view.signcolumn; + }; + trash = { + cmd = cfg.trash.cmd; + require_confirm = cfg.trash.requireConfirm; }; - in + }; + in mkIf cfg.enable { extraPlugins = with pkgs.vimPlugins; [ cfg.package @@ -294,6 +295,6 @@ in extraConfigLua = '' require('nvim-tree').setup(${helpers.toLuaObject options}) ''; - extraPackages = [ pkgs.git ]; + extraPackages = [pkgs.git]; }; } diff --git a/plugins/utils/project-nvim.nix b/plugins/utils/project-nvim.nix index d3d9e7597e..b19574f2f3 100644 --- a/plugins/utils/project-nvim.nix +++ b/plugins/utils/project-nvim.nix @@ -1,65 +1,69 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.project-nvim; - helpers = import ../helpers.nix { inherit lib pkgs; }; -in { - options.plugins.project-nvim = helpers.extraOptionsOptions // { - enable = mkEnableOption "project.nvim"; + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.project-nvim; + helpers = import ../helpers.nix {inherit lib pkgs;}; +in { + options.plugins.project-nvim = + helpers.extraOptionsOptions + // { + enable = mkEnableOption "project.nvim"; - package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim; + package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim; - manualMode = mkOption { - type = types.nullOr types.bool; - default = null; - }; + manualMode = mkOption { + type = types.nullOr types.bool; + default = null; + }; - detectionMethods = mkOption { - type = types.nullOr (types.listOf types.str); - default = null; - }; + detectionMethods = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; - patterns = mkOption { - type = types.nullOr (types.listOf types.str); - default = null; - }; + patterns = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; - ignoreLsp = mkOption { - type = types.nullOr (types.listOf types.str); - default = null; - }; + ignoreLsp = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; - excludeDirs = mkOption { - type = types.nullOr (types.listOf types.str); - default = null; - }; + excludeDirs = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; - showHidden = mkOption { - type = types.nullOr types.bool; - default = null; - }; + showHidden = mkOption { + type = types.nullOr types.bool; + default = null; + }; - silentChdir = mkOption { - type = types.nullOr types.bool; - default = null; - }; + silentChdir = mkOption { + type = types.nullOr types.bool; + default = null; + }; - scopeChdir = mkOption { - type = types.nullOr (types.enum [ "global" "tab" "win" ]); - default = null; - }; + scopeChdir = mkOption { + type = types.nullOr (types.enum ["global" "tab" "win"]); + default = null; + }; - dataPath = mkOption { - type = types.nullOr (types.either types.str helpers.rawType); - default = null; + dataPath = mkOption { + type = types.nullOr (types.either types.str helpers.rawType); + default = null; + }; }; - }; - - config = - let - options = { + config = let + options = + { manual_mode = cfg.manualMode; detection_methods = cfg.detectionMethods; patterns = cfg.patterns; @@ -69,10 +73,11 @@ in silent_chdir = cfg.silentChdir; scope_schdir = cfg.scopeChdir; data_path = cfg.dataPath; - } // cfg.extraOptions; - in + } + // cfg.extraOptions; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; extraConfigLua = '' require('project_nvim').setup(${helpers.toLuaObject options}) diff --git a/plugins/utils/specs.nix b/plugins/utils/specs.nix index cd42b8dc31..907abe622d 100644 --- a/plugins/utils/specs.nix +++ b/plugins/utils/specs.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.specs; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.specs; + helpers = import ../helpers.nix {inherit lib;}; +in { options.plugins.specs = { enable = mkEnableOption "specs-nvim"; @@ -73,15 +76,16 @@ in }; }; }; - default = { builtin = "linear_fader"; }; + default = {builtin = "linear_fader";}; }; resizer = mkOption { type = types.submodule { options = { builtin = mkOption { - type = types.nullOr - (types.enum [ "shrink_resizer" "slide_resizer" "empty_resizer" ]); + type = + types.nullOr + (types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]); default = "shrink_resizer"; }; @@ -98,48 +102,53 @@ in }; }; }; - default = { builtin = "shrink_resizer"; }; + default = {builtin = "shrink_resizer";}; }; ignored_filetypes = mkOption { type = with types; listOf string; - default = [ ]; + default = []; }; ignored_buffertypes = mkOption { type = with types; listOf string; - default = [ "nofile" ]; + default = ["nofile"]; }; - }; - config = - let - setup = helpers.toLuaObject { - inherit (cfg) show_jumps min_jump; - ignore_filetypes = attrsets.listToAttrs - (lib.lists.map (x: attrsets.nameValuePair x true) - cfg.ignored_filetypes); - ignore_buftypes = attrsets.listToAttrs - (lib.lists.map (x: attrsets.nameValuePair x true) - cfg.ignored_buffertypes); - popup = { - inherit (cfg) blend width; - winhl = if (!isNull cfg.color) then "SpecsPopColor" else "PMenu"; - delay_ms = cfg.delay; - inc_ms = cfg.increment; - fader = helpers.mkRaw (if cfg.fader.builtin == null then - cfg.fader.custom - else - ''require("specs").${cfg.fader.builtin}''); - resizer = helpers.mkRaw (if cfg.resizer.builtin == null then - cfg.resizer.custom - else - ''require("specs").${cfg.resizer.builtin}''); - }; + config = let + setup = helpers.toLuaObject { + inherit (cfg) show_jumps min_jump; + ignore_filetypes = + attrsets.listToAttrs + (lib.lists.map (x: attrsets.nameValuePair x true) + cfg.ignored_filetypes); + ignore_buftypes = + attrsets.listToAttrs + (lib.lists.map (x: attrsets.nameValuePair x true) + cfg.ignored_buffertypes); + popup = { + inherit (cfg) blend width; + winhl = + if (!isNull cfg.color) + then "SpecsPopColor" + else "PMenu"; + delay_ms = cfg.delay; + inc_ms = cfg.increment; + fader = helpers.mkRaw ( + if cfg.fader.builtin == null + then cfg.fader.custom + else ''require("specs").${cfg.fader.builtin}'' + ); + resizer = helpers.mkRaw ( + if cfg.resizer.builtin == null + then cfg.resizer.custom + else ''require("specs").${cfg.resizer.builtin}'' + ); }; - in + }; + in mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color; diff --git a/plugins/utils/startify.nix b/plugins/utils/startify.nix index cac64076ad..de7ec5a410 100644 --- a/plugins/utils/startify.nix +++ b/plugins/utils/startify.nix @@ -1,220 +1,233 @@ -{ pkgs, lib, ... }@args: -let - helpers = import ../helpers.nix { inherit lib; }; -in with lib; with helpers; -mkPlugin args { - name = "startify"; - description = "Enable startify"; - package = pkgs.vimPlugins.vim-startify; - - options = { - sessionDir = mkDefaultOpt { - description = "Directory to save/load session"; - global = "startify_session_dir"; - type = types.str; - }; - - lists = mkDefaultOpt { - description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; - global = "startify_lists"; - type = types.listOf (types.oneOf [(types.submodule { - options = { - type = mkOption { - type = types.str; - description = "The type of the list"; - }; - # TODO the header should be a literal lua string! - header = mkOption { - type = types.nullOr (types.listOf types.str); - description = "Optional header. It's a list of strings"; - default = null; - }; - indices = mkOption { - type = types.nullOr (types.listOf types.str); - description = "Optional indices for the current list"; - default = null; - }; - }; - }) types.str]); - - value = val: let - list = map (v: if builtins.isAttrs v then toLuaObject v else v) val; - in "{" + (concatStringsSep "," list) + "}"; - }; - - bookmarks = mkDefaultOpt { - description = "A list of files or directories to bookmark."; - global = "startify_bookmarks"; - type = with types; listOf (oneOf [str (attrsOf str)]); - }; - - commands = mkDefaultOpt { - description = "A list of commands to execute on selection"; - global = "startify_commands"; - type = with types; listOf (oneOf [ str (listOf str) attrs ]); - }; - - filesNumber = mkDefaultOpt { - description = "The number of files to list"; - global = "startify_files_number"; - type = types.int; - }; - - updateOldFiles = mkDefaultOpt { - description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date"; - global = "startify_update_oldfiles"; - type = types.bool; - }; - - sessionAutoload = mkDefaultOpt { - description = "Load Session.vim"; - global = "startify_session_autoload"; - type = types.bool; - }; - - sessionBeforeSave = mkDefaultOpt { - description = "Commands to be executed before saving a session"; - global = "startify_session_before_save"; - type = types.listOf types.str; - }; - - sessionPersistence = mkDefaultOpt { - description = "Automatically update sessions"; - global = "startify_session_persistence"; - type = types.bool; - }; - - sessionDeleteBuffers = mkDefaultOpt { - description = "Delete all buffers when loading or closing a session"; - global = "startify_session_delete_buffers"; - type = types.bool; - }; - - changeToDir = mkDefaultOpt { - description = "When opening a file or bookmark, change to its directory"; - global = "startify_change_to_dir"; - type = types.bool; - }; - - changeToVcsRoot = mkDefaultOpt { - description = "When opening a file or bookmark, change to the root directory of the VCS"; - global = "startify_change_to_vcs_root"; - type = types.bool; - }; - - changeCmd = mkDefaultOpt { - description = "The default command for switching directories"; - global = "startify_change_cmd"; - type = types.enum [ "cd" "lcd" "tcd" ]; - }; - - skipList = mkDefaultOpt { - description = "A list of regexes that is used to filter recently used files"; - global = "startify_skiplist"; - type = types.listOf types.str; - }; - - useUnicode = mkDefaultOpt { - description = "Use unicode box drawing characters for the fortune header"; - global = "startify_fortune_use_unicode"; - type = types.bool; - }; - - paddingLeft = mkDefaultOpt { - description = "Number of spaces used for left padding"; - global = "startify_padding_left"; - type = types.int; - }; - - skipListServer = mkDefaultOpt { - description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list"; - global = "startify_skiplist_server"; - type = types.listOf types.str; - }; - - enableSpecial = mkDefaultOpt { - description = "Show <empty buffer> and <quit>"; - global = "startify_enable_special"; - type = types.bool; - }; - - enableUnsafe = mkDefaultOpt { - description = "Improves start time but reduces accuracy of the file list"; - global = "startify_enable_unsafe"; - type = types.bool; - }; - - sessionRemoveLines = mkDefaultOpt { - description = "Lines matching any of the patterns in this list will be removed from the session file"; - global = "startify_session_remove_lines"; - type = types.listOf types.str; - }; - - sessionSaveVars = mkDefaultOpt { - description = "List of variables for Startify to save into the session file"; - global = "startify_session_savevars"; - type = types.listOf types.str; - }; - - sessionSaveCmds = mkDefaultOpt { - description = "List of cmdline commands to run when loading the session"; - global = "startify_session_savecmds"; - type = types.listOf types.str; - }; - - sessionNumber = mkDefaultOpt { - description = "Maximum number of sessions to display"; - global = "startify_session_number"; - type = types.listOf types.str; - }; - - sessionSort = mkDefaultOpt { - description = "Sort sessions by modification time rather than alphabetically"; - global = "startify_session_sort"; - type = types.bool; - }; - - customIndices = mkDefaultOpt { - description = "Use this list as indices instead of increasing numbers"; - global = "startify_custom_indices"; - type = types.listOf types.str; - }; - - customHeader = mkDefaultOpt { - description = "Define your own header"; - global = "startify_custom_header"; - type = types.oneOf [ types.str (types.listOf types.str) ]; - }; - - customQuotes = mkDefaultOpt { - description = "Own quotes for the cowsay header"; - global = "startify_custom_header_quotes"; - # TODO this should also support funcrefs! - type = types.listOf (types.listOf types.str); - }; - - customFooter = mkDefaultOpt { - description = "Custom footer"; - global = "startify_custom_footer"; - type = types.str; - }; - - disableAtVimEnter = mkDefaultOpt { - description = "Don't run Startify at Vim startup"; - global = "startify_disable_at_vimenter"; - type = types.bool; - }; - - relativePath = mkDefaultOpt { - description = "If the file is in or below the current working directory, use a relative path"; - global = "startify_relative_path"; - type = types.bool; - }; - - useEnv = mkDefaultOpt { - description = "Show environment variables in path, if their name is shorter than their value"; - global = "startify_use_env"; - type = types.bool; - }; - }; -} +{ + pkgs, + lib, + ... +} @ args: let + helpers = import ../helpers.nix {inherit lib;}; +in + with lib; + with helpers; + mkPlugin args { + name = "startify"; + description = "Enable startify"; + package = pkgs.vimPlugins.vim-startify; + + options = { + sessionDir = mkDefaultOpt { + description = "Directory to save/load session"; + global = "startify_session_dir"; + type = types.str; + }; + + lists = mkDefaultOpt { + description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; + global = "startify_lists"; + type = types.listOf (types.oneOf [ + (types.submodule { + options = { + type = mkOption { + type = types.str; + description = "The type of the list"; + }; + # TODO the header should be a literal lua string! + header = mkOption { + type = types.nullOr (types.listOf types.str); + description = "Optional header. It's a list of strings"; + default = null; + }; + indices = mkOption { + type = types.nullOr (types.listOf types.str); + description = "Optional indices for the current list"; + default = null; + }; + }; + }) + types.str + ]); + + value = val: let + list = map (v: + if builtins.isAttrs v + then toLuaObject v + else v) + val; + in + "{" + (concatStringsSep "," list) + "}"; + }; + + bookmarks = mkDefaultOpt { + description = "A list of files or directories to bookmark."; + global = "startify_bookmarks"; + type = with types; listOf (oneOf [str (attrsOf str)]); + }; + + commands = mkDefaultOpt { + description = "A list of commands to execute on selection"; + global = "startify_commands"; + type = with types; listOf (oneOf [str (listOf str) attrs]); + }; + + filesNumber = mkDefaultOpt { + description = "The number of files to list"; + global = "startify_files_number"; + type = types.int; + }; + + updateOldFiles = mkDefaultOpt { + description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date"; + global = "startify_update_oldfiles"; + type = types.bool; + }; + + sessionAutoload = mkDefaultOpt { + description = "Load Session.vim"; + global = "startify_session_autoload"; + type = types.bool; + }; + + sessionBeforeSave = mkDefaultOpt { + description = "Commands to be executed before saving a session"; + global = "startify_session_before_save"; + type = types.listOf types.str; + }; + + sessionPersistence = mkDefaultOpt { + description = "Automatically update sessions"; + global = "startify_session_persistence"; + type = types.bool; + }; + + sessionDeleteBuffers = mkDefaultOpt { + description = "Delete all buffers when loading or closing a session"; + global = "startify_session_delete_buffers"; + type = types.bool; + }; + + changeToDir = mkDefaultOpt { + description = "When opening a file or bookmark, change to its directory"; + global = "startify_change_to_dir"; + type = types.bool; + }; + + changeToVcsRoot = mkDefaultOpt { + description = "When opening a file or bookmark, change to the root directory of the VCS"; + global = "startify_change_to_vcs_root"; + type = types.bool; + }; + + changeCmd = mkDefaultOpt { + description = "The default command for switching directories"; + global = "startify_change_cmd"; + type = types.enum ["cd" "lcd" "tcd"]; + }; + + skipList = mkDefaultOpt { + description = "A list of regexes that is used to filter recently used files"; + global = "startify_skiplist"; + type = types.listOf types.str; + }; + + useUnicode = mkDefaultOpt { + description = "Use unicode box drawing characters for the fortune header"; + global = "startify_fortune_use_unicode"; + type = types.bool; + }; + + paddingLeft = mkDefaultOpt { + description = "Number of spaces used for left padding"; + global = "startify_padding_left"; + type = types.int; + }; + + skipListServer = mkDefaultOpt { + description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list"; + global = "startify_skiplist_server"; + type = types.listOf types.str; + }; + + enableSpecial = mkDefaultOpt { + description = "Show <empty buffer> and <quit>"; + global = "startify_enable_special"; + type = types.bool; + }; + + enableUnsafe = mkDefaultOpt { + description = "Improves start time but reduces accuracy of the file list"; + global = "startify_enable_unsafe"; + type = types.bool; + }; + + sessionRemoveLines = mkDefaultOpt { + description = "Lines matching any of the patterns in this list will be removed from the session file"; + global = "startify_session_remove_lines"; + type = types.listOf types.str; + }; + + sessionSaveVars = mkDefaultOpt { + description = "List of variables for Startify to save into the session file"; + global = "startify_session_savevars"; + type = types.listOf types.str; + }; + + sessionSaveCmds = mkDefaultOpt { + description = "List of cmdline commands to run when loading the session"; + global = "startify_session_savecmds"; + type = types.listOf types.str; + }; + + sessionNumber = mkDefaultOpt { + description = "Maximum number of sessions to display"; + global = "startify_session_number"; + type = types.listOf types.str; + }; + + sessionSort = mkDefaultOpt { + description = "Sort sessions by modification time rather than alphabetically"; + global = "startify_session_sort"; + type = types.bool; + }; + + customIndices = mkDefaultOpt { + description = "Use this list as indices instead of increasing numbers"; + global = "startify_custom_indices"; + type = types.listOf types.str; + }; + + customHeader = mkDefaultOpt { + description = "Define your own header"; + global = "startify_custom_header"; + type = types.oneOf [types.str (types.listOf types.str)]; + }; + + customQuotes = mkDefaultOpt { + description = "Own quotes for the cowsay header"; + global = "startify_custom_header_quotes"; + # TODO this should also support funcrefs! + type = types.listOf (types.listOf types.str); + }; + + customFooter = mkDefaultOpt { + description = "Custom footer"; + global = "startify_custom_footer"; + type = types.str; + }; + + disableAtVimEnter = mkDefaultOpt { + description = "Don't run Startify at Vim startup"; + global = "startify_disable_at_vimenter"; + type = types.bool; + }; + + relativePath = mkDefaultOpt { + description = "If the file is in or below the current working directory, use a relative path"; + global = "startify_relative_path"; + type = types.bool; + }; + + useEnv = mkDefaultOpt { + description = "Show environment variables in path, if their name is shorter than their value"; + global = "startify_use_env"; + type = types.bool; + }; + }; + } diff --git a/plugins/utils/surround.nix b/plugins/utils/surround.nix index 2580c8bcd1..4be33bfee3 100644 --- a/plugins/utils/surround.nix +++ b/plugins/utils/surround.nix @@ -1,11 +1,16 @@ -{ lib, pkgs, ... }@attrs: -let - helpers = import ../helpers.nix { inherit lib; }; -in with helpers; with lib; -mkPlugin attrs { - name = "surround"; - description = "Enable surround.vim"; - package = pkgs.vimPlugins.surround; +{ + lib, + pkgs, + ... +} @ attrs: let + helpers = import ../helpers.nix {inherit lib;}; +in + with helpers; + with lib; + mkPlugin attrs { + name = "surround"; + description = "Enable surround.vim"; + package = pkgs.vimPlugins.surround; - options = {}; -} + options = {}; + } diff --git a/plugins/utils/undotree.nix b/plugins/utils/undotree.nix index 223b5a5fbb..eac38bd6f0 100644 --- a/plugins/utils/undotree.nix +++ b/plugins/utils/undotree.nix @@ -1,10 +1,13 @@ -{ pkgs, config, lib, ... }: -with lib; -let - cfg = config.plugins.undotree; - helpers = import ../helpers.nix { inherit lib; }; -in { + pkgs, + config, + lib, + ... +}: +with lib; let + cfg = config.plugins.undotree; + helpers = import ../helpers.nix {inherit lib;}; +in { options = { plugins.undotree = { enable = mkEnableOption "Enable undotree"; @@ -110,7 +113,7 @@ in }; config = mkIf cfg.enable { - extraPlugins = [ cfg.package ]; + extraPlugins = [cfg.package]; globals = { undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout; diff --git a/tests/flake.nix b/tests/flake.nix index 59ba77fe3c..49800b54dd 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -14,299 +14,305 @@ inputs.nixpkgs.follows = "nixpkgs-stable"; }; - outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, build-ts, gleam, ... }: + outputs = { + self, + nixvim, + nixvim-stable, + nixpkgs, + flake-utils, + nixpkgs-stable, + build-ts, + gleam, + ... + }: (flake-utils.lib.eachDefaultSystem - (system: - let - pkgs = import nixpkgs { inherit system; }; - pkgs-stable = import nixpkgs-stable { inherit system; }; - build = nixvim.legacyPackages.${system}.makeNixvim; - build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim; - in - rec { - # A plain nixvim configuration - packages = { - plain = build { }; - - # Should print "Hello!" when starting up - hello = build { - extraConfigLua = "print(\"Hello!\")"; - }; - - simple-plugin = build { - extraPlugins = [ pkgs.vimPlugins.vim-surround ]; - }; + (system: let + pkgs = import nixpkgs {inherit system;}; + pkgs-stable = import nixpkgs-stable {inherit system;}; + build = nixvim.legacyPackages.${system}.makeNixvim; + build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim; + in rec { + # A plain nixvim configuration + packages = { + plain = build {}; + + # Should print "Hello!" when starting up + hello = build { + extraConfigLua = "print(\"Hello!\")"; + }; - gruvbox = build { - extraPlugins = [ pkgs.vimPlugins.gruvbox ]; - colorscheme = "gruvbox"; - }; + simple-plugin = build { + extraPlugins = [pkgs.vimPlugins.vim-surround]; + }; - gruvbox-module = build { - colorschemes.gruvbox.enable = true; - }; + gruvbox = build { + extraPlugins = [pkgs.vimPlugins.gruvbox]; + colorscheme = "gruvbox"; + }; - treesitter = build { - plugins.treesitter.enable = true; - }; + gruvbox-module = build { + colorschemes.gruvbox.enable = true; + }; - treesitter-nonix = build { - plugins.treesitter = { - enable = true; - nixGrammars = false; - }; - }; - elixir-ls = build { - plugins.lsp.enable = true; - plugins.lsp.servers.elixirls.enable = true; - }; + treesitter = build { + plugins.treesitter.enable = true; + }; - lsp-lines = build-stable { - plugins.lsp-lines.enable = true; + treesitter-nonix = build { + plugins.treesitter = { + enable = true; + nixGrammars = false; }; + }; + elixir-ls = build { + plugins.lsp.enable = true; + plugins.lsp.servers.elixirls.enable = true; + }; - trouble = build { - plugins.lsp = { - enable = true; - servers.clangd.enable = true; - }; + lsp-lines = build-stable { + plugins.lsp-lines.enable = true; + }; - plugins.trouble.enable = true; + trouble = build { + plugins.lsp = { + enable = true; + servers.clangd.enable = true; }; - beautysh = build { - plugins.null-ls = { - enable = true; - sources.formatting.beautysh.enable = true; - }; - }; + plugins.trouble.enable = true; + }; - keymaps = build { - maps.normal."," = "echo \"test\""; + beautysh = build { + plugins.null-ls = { + enable = true; + sources.formatting.beautysh.enable = true; }; + }; - issue-40 = build-stable { - plugins = { - nix.enable = true; - nvim-autopairs.enable = true; - - lualine = { - enable = true; + keymaps = build { + maps.normal."," = "echo \"test\""; + }; - sectionSeparators = { - left = ""; - right = ""; - }; + issue-40 = build-stable { + plugins = { + nix.enable = true; + nvim-autopairs.enable = true; - componentSeparators = { - left = ""; - right = ""; - }; + lualine = { + enable = true; - theme = "auto"; + sectionSeparators = { + left = ""; + right = ""; }; - goyo = { - enable = true; - showLineNumbers = false; + componentSeparators = { + left = ""; + right = ""; }; - lsp = { - enable = true; - servers = { - rust-analyzer.enable = true; - rnix-lsp.enable = true; - }; - }; + theme = "auto"; + }; + goyo = { + enable = true; + showLineNumbers = false; }; - options = { - # Indentation - autoindent = true; - tabstop = 4; - shiftwidth = 4; - expandtab = true; - backspace = "indent,eol,start"; - - # Text - showmatch = true; - mouse = "a"; - number = true; - relativenumber = false; - ttyfast = true; - clipboard = "unnamedplus"; - - # Colors - background = "dark"; - termguicolors = true; + lsp = { + enable = true; + servers = { + rust-analyzer.enable = true; + rnix-lsp.enable = true; + }; }; }; - issue-65 = build { - colorschemes.gruvbox = { + options = { + # Indentation + autoindent = true; + tabstop = 4; + shiftwidth = 4; + expandtab = true; + backspace = "indent,eol,start"; + + # Text + showmatch = true; + mouse = "a"; + number = true; + relativenumber = false; + ttyfast = true; + clipboard = "unnamedplus"; + + # Colors + background = "dark"; + termguicolors = true; + }; + }; + + issue-65 = build { + colorschemes.gruvbox = { + enable = true; + contrastLight = "hard"; + contrastDark = "hard"; + }; + + options = { + number = true; + shiftwidth = 2; + tabstop = 2; + guifont = "FiraCode\ Nerd\ Font\ Mono:h14"; + }; + + plugins = { + lsp = { enable = true; - contrastLight = "hard"; - contrastDark = "hard"; + servers.rnix-lsp.enable = true; + servers.rust-analyzer.enable = true; + servers.jsonls.enable = true; }; - options = { - number = true; - shiftwidth = 2; - tabstop = 2; - guifont = "FiraCode\ Nerd\ Font\ Mono:h14"; + nvim-tree = { + enable = true; + openOnSetup = true; + openOnTab = true; }; - plugins = { - lsp = { - enable = true; - servers.rnix-lsp.enable = true; - servers.rust-analyzer.enable = true; - servers.jsonls.enable = true; - }; - - nvim-tree = { - enable = true; - openOnSetup = true; - openOnTab = true; - }; + telescope = { + enable = true; + }; - telescope = { - enable = true; + nvim-cmp = { + formatting = { + format = '' + require("lspkind").cmp_format({ + mode="symbol", + maxwidth = 50, + ellipsis_char = "..." + }) + ''; }; - nvim-cmp = { - formatting = { - format = '' - require("lspkind").cmp_format({ - mode="symbol", - maxwidth = 50, - ellipsis_char = "..." - }) - ''; - }; - - auto_enable_sources = true; - snippet = { - expand = '' - function(args) - require("luasnip").lsp_expand(args.body) - end - ''; - }; - enable = true; - sources = [ - { name = "nvim_lsp"; } - { - name = "luasnip"; - option = { - show_autosnippets = true; - }; - } - { name = "path"; } - { name = "buffer"; } - ]; - + auto_enable_sources = true; + snippet = { + expand = '' + function(args) + require("luasnip").lsp_expand(args.body) + end + ''; }; - barbar.enable = true; + enable = true; + sources = [ + {name = "nvim_lsp";} + { + name = "luasnip"; + option = { + show_autosnippets = true; + }; + } + {name = "path";} + {name = "buffer";} + ]; }; + barbar.enable = true; + }; - globals.mapleader = " "; - extraPlugins = with pkgs.vimPlugins; [ - which-key-nvim - # leap-nvim - vim-flutter - plenary-nvim - fidget-nvim - luasnip - lspkind-nvim - ]; + globals.mapleader = " "; + extraPlugins = with pkgs.vimPlugins; [ + which-key-nvim + # leap-nvim + vim-flutter + plenary-nvim + fidget-nvim + luasnip + lspkind-nvim + ]; - # extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua); - }; + # extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua); + }; - issue-71 = build { - maps.normal."hb" = "lua require('gitsigns').blame_line{full=true}"; - }; + issue-71 = build { + maps.normal."hb" = "lua require('gitsigns').blame_line{full=true}"; + }; - lspkind = build { - plugins = { - lsp = { - enable = true; - servers.clangd.enable = true; - }; - nvim-cmp.enable = true; - lspkind.enable = true; + lspkind = build { + plugins = { + lsp = { + enable = true; + servers.clangd.enable = true; }; + nvim-cmp.enable = true; + lspkind.enable = true; }; + }; - highlight = build { - options.termguicolors = true; - highlight = { - Normal.fg = "#ff0000"; - }; + highlight = build { + options.termguicolors = true; + highlight = { + Normal.fg = "#ff0000"; }; + }; - autoCmd = build { - autoCmd = [ - { - event = [ "BufEnter" "BufWinEnter" ]; - pattern = [ "*.c" "*.h" ]; - command = "echo 'Entering a C or C++ file'"; - } - { - event = "InsertEnter"; - command = "norm zz"; - } - ]; - }; + autoCmd = build { + autoCmd = [ + { + event = ["BufEnter" "BufWinEnter"]; + pattern = ["*.c" "*.h"]; + command = "echo 'Entering a C or C++ file'"; + } + { + event = "InsertEnter"; + command = "norm zz"; + } + ]; + }; - ts-custom = build { - plugins.treesitter = { - enable = true; - nixGrammars = true; - grammarPackages = [ - (build-ts.lib.buildGrammar pkgs { - language = "gleam"; - version = "0.25.0"; - source = gleam; - }) - ]; - }; + ts-custom = build { + plugins.treesitter = { + enable = true; + nixGrammars = true; + grammarPackages = [ + (build-ts.lib.buildGrammar pkgs { + language = "gleam"; + version = "0.25.0"; + source = gleam; + }) + ]; }; }; - })) // { + }; + })) + // { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ({ pkgs, ... }: { + ({pkgs, ...}: { environment.systemPackages = [ - (nixvim.build pkgs { colorschemes.gruvbox.enable = true; }) + (nixvim.build pkgs {colorschemes.gruvbox.enable = true;}) ]; }) ]; }; nixosConfigurations.container = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = - [ - ({ pkgs, ... }: { - boot.isContainer = true; + modules = [ + ({pkgs, ...}: { + boot.isContainer = true; - # Let 'nixos-version --json' know about the Git revision - # of this flake. - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + # Let 'nixos-version --json' know about the Git revision + # of this flake. + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - imports = [ - nixvim.nixosModules.x86_64-linux.nixvim - ]; + imports = [ + nixvim.nixosModules.x86_64-linux.nixvim + ]; - programs.nixvim = { - enable = true; - colorschemes.gruvbox.enable = true; - }; - }) - ]; + programs.nixvim = { + enable = true; + colorschemes.gruvbox.enable = true; + }; + }) + ]; }; }; } diff --git a/wrappers/_shared.nix b/wrappers/_shared.nix index 43c5ae6c19..5d5086bb23 100644 --- a/wrappers/_shared.nix +++ b/wrappers/_shared.nix @@ -1,9 +1,10 @@ -{ lib, pkgs, ... }: - -let - inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; -in { + lib, + pkgs, + ... +}: let + inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; +in { helpers = mkOption { type = mkOptionType { name = "helpers"; @@ -11,6 +12,6 @@ in check = builtins.isAttrs; }; description = "Use this option to access the helpers"; - default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + default = import ../plugins/helpers.nix {inherit (pkgs) lib;}; }; } diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix index 0267a40b35..d2be007ff2 100644 --- a/wrappers/darwin.nix +++ b/wrappers/darwin.nix @@ -1,25 +1,29 @@ -modules: -{ pkgs, config, lib, ... }@args: - -let +modules: { + pkgs, + config, + lib, + ... +} @ args: let inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; shared = import ./_shared.nix args; cfg = config.programs.nixvim; -in -{ +in { options = { programs.nixvim = mkOption { - type = types.submodule ((modules pkgs) ++ [{ - options.enable = mkEnableOption "nixvim"; - config.wrapRc = mkForce true; - }]); + type = types.submodule ((modules pkgs) + ++ [ + { + options.enable = mkEnableOption "nixvim"; + config.wrapRc = mkForce true; + } + ]); }; nixvim.helpers = shared.helpers; }; config = mkIf cfg.enable mkMerge [ { - environment.systemPackages = [ cfg.finalPackage ]; + environment.systemPackages = [cfg.finalPackage]; } { warnings = cfg.warnings; diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 971c255a8e..1f8032d8d2 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -1,30 +1,35 @@ -modules: -{ pkgs, config, lib, ... }@args: - -let +modules: { + pkgs, + config, + lib, + ... +} @ args: let inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; shared = import ./_shared.nix args; cfg = config.programs.nixvim; -in -{ +in { options = { programs.nixvim = mkOption { - type = types.submodule ((modules pkgs) ++ [{ - options.enable = mkEnableOption "nixvim"; - }]); + type = types.submodule ((modules pkgs) + ++ [ + { + options.enable = mkEnableOption "nixvim"; + } + ]); }; nixvim.helpers = shared.helpers; }; - config = mkIf cfg.enable + config = + mkIf cfg.enable (mkMerge [ - { home.packages = [ cfg.finalPackage ]; } + {home.packages = [cfg.finalPackage];} (mkIf (!cfg.wrapRc) { xdg.configFile."nvim/init.lua".text = cfg.initContent; }) - ({ + { warnings = cfg.warnings; assertions = cfg.assertions; - }) + } ]); } diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index 66eadbcb93..41c7df21f2 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -1,31 +1,36 @@ -modules: -{ pkgs, config, lib, ... }@args: - -let +modules: { + pkgs, + config, + lib, + ... +} @ args: let inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; shared = import ./_shared.nix args; cfg = config.programs.nixvim; -in -{ +in { options = { programs.nixvim = mkOption { - type = types.submodule ((modules pkgs) ++ [{ - options.enable = mkEnableOption "nixvim"; - }]); + type = types.submodule ((modules pkgs) + ++ [ + { + options.enable = mkEnableOption "nixvim"; + } + ]); }; nixvim.helpers = shared.helpers; }; - config = mkIf cfg.enable + config = + mkIf cfg.enable (mkMerge [ - { environment.systemPackages = [ cfg.finalPackage ]; } + {environment.systemPackages = [cfg.finalPackage];} (mkIf (!cfg.wrapRc) { environment.etc."nvim/sysinit.lua".text = cfg.initContent; environment.variables."VIM" = "/etc/nvim"; }) - ({ + { warnings = cfg.warnings; assertions = cfg.assertions; - }) + } ]); } diff --git a/wrappers/standalone.nix b/wrappers/standalone.nix index 20fb966773..3d0fb86dcc 100644 --- a/wrappers/standalone.nix +++ b/wrappers/standalone.nix @@ -1,13 +1,13 @@ -default_pkgs: modules: {pkgs ? default_pkgs, module}: - -let - +default_pkgs: modules: { + pkgs ? default_pkgs, + module, +}: let inherit (pkgs) lib; - wrap = { wrapRc = true; }; + wrap = {wrapRc = true;}; eval = lib.evalModules { - modules = (modules pkgs) ++ [ module wrap ]; + modules = (modules pkgs) ++ [module wrap]; }; - -in eval.config.finalPackage +in + eval.config.finalPackage