From f7be7364620a357aded1f46d66a9b86035d8f771 Mon Sep 17 00:00:00 2001 From: LightQuantum Date: Mon, 31 Oct 2022 18:32:59 +0800 Subject: [PATCH 01/61] treesitter: allow specifying custom parser install dir (#60) --- plugins/languages/treesitter.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 73bfd223..3dffdff6 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -21,6 +21,12 @@ in description = "Either \"all\" or a list of languages"; }; + parserInstallDir = mkOption { + type = types.nullOr types.str; + default = null; + description = "Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled)"; + }; + ignoreInstall = mkOption { type = types.listOf types.str; default = [ ]; @@ -90,11 +96,14 @@ in ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled; ignore_install = cfg.ignoreInstall; + parser_install_dir = cfg.parserInstallDir; }; in mkIf cfg.enable { extraConfigLua = '' require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) + '' + optionalString (cfg.parserInstallDir != null) '' + vim.opt.runtimepath:append("${cfg.parserInstallDir}") ''; extraPlugins = with pkgs; if cfg.nixGrammars then From 1fa86d169984f229acc1a69d1454f38cd4b22e9f Mon Sep 17 00:00:00 2001 From: LightQuantum Date: Mon, 7 Nov 2022 23:12:40 +0800 Subject: [PATCH 02/61] helpers: expose to config.nixvim.helpers (#59) --- wrappers/hm.nix | 18 ++++++++++++++---- wrappers/nixos.nix | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 5a547b97..8d32e200 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -2,18 +2,28 @@ modules: { pkgs, config, lib, ... }: let - inherit (lib) mkEnableOption mkOption mkIf mkMerge types; + inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; cfg = config.programs.nixvim; -in { +in +{ options = { - programs.nixvim = lib.mkOption { + programs.nixvim = mkOption { type = types.submodule ((modules pkgs) ++ [{ options.enable = mkEnableOption "nixvim"; }]); }; + nixvim.helpers = mkOption { + type = mkOptionType { + name = "helpers"; + description = "Helpers that can be used when writing nixvim configs"; + check = builtins.isAttrs; + }; + description = "Use this option to access the helpers"; + default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + }; }; - config = mkIf cfg.enable + config = mkIf cfg.enable (mkMerge [ { home.packages = [ cfg.finalPackage ]; } (mkIf (!cfg.wrapRc) { diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index a82bc056..0c6a807a 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -2,18 +2,28 @@ modules: { pkgs, config, lib, ... }: let - inherit (lib) mkEnableOption mkOption mkMerge mkIf types; + inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; cfg = config.programs.nixvim; -in { +in +{ options = { - programs.nixvim = lib.mkOption { + programs.nixvim = mkOption { type = types.submodule ((modules pkgs) ++ [{ options.enable = mkEnableOption "nixvim"; }]); }; + nixvim.helpers = mkOption { + type = mkOptionType { + name = "helpers"; + description = "Helpers that can be used when writing nixvim configs"; + check = builtins.isAttrs; + }; + description = "Use this option to access the helpers"; + default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + }; }; - config = mkIf cfg.enable + config = mkIf cfg.enable (mkMerge [ { environment.systemPackages = [ cfg.finalPackage ]; } (mkIf (!cfg.wrapRc) { From 3849a1de9a28ed5434e864b8f2815c905a8d28ad Mon Sep 17 00:00:00 2001 From: dfangx Date: Mon, 7 Nov 2022 10:59:10 -0500 Subject: [PATCH 03/61] Use init.lua instead of init.vim (#64) * Use init.lua instead of init.vim * fix standalone generation Co-authored-by: cyrusng Co-authored-by: Pedro Alves --- modules/output.nix | 26 ++++++++++++++++---------- tests/flake.lock | 12 ++++++------ wrappers/hm.nix | 2 +- wrappers/nixos.nix | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/modules/output.nix b/modules/output.nix index 40e2369e..3d7708e6 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -79,7 +79,7 @@ in initContent = mkOption { type = types.str; - description = "The content of the init.vim file"; + description = "The content of the init.lua file"; readOnly = true; visible = false; }; @@ -89,15 +89,16 @@ in let customRC = (optionalString (config.extraConfigLuaPre != "") '' - lua < Date: Mon, 7 Nov 2022 17:10:18 +0100 Subject: [PATCH 04/61] nvim-tree: added new option (#54) --- plugins/utils/nvim-tree.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix index 697dec06..60161544 100644 --- a/plugins/utils/nvim-tree.nix +++ b/plugins/utils/nvim-tree.nix @@ -48,11 +48,17 @@ in description = "Hijack cursor"; }; + # TODO: change this to it's new definition sync_root_with_cwd updateCwd = mkOption { type = types.nullOr types.bool; default = null; }; + respectBufCwd = mkOption { + type = types.nullOr types.bool; + default = null; + }; + updateToBufDir = { enable = mkOption { type = types.nullOr types.bool; @@ -94,6 +100,7 @@ in default = null; }; + # TODO: change this to it's new definition update_root updateCwd = mkOption { type = types.nullOr types.bool; default = null; @@ -214,6 +221,7 @@ in open_on_tab = cfg.openOnTab; hijack_cursor = cfg.hijackCursor; update_cwd = cfg.updateCwd; + respect_buf_cwd = cfg.respectBufCwd; update_to_buf_dir = { enable = cfg.updateToBufDir.enable; auto_open = cfg.updateToBufDir.autoOpen; From 1a89cd2107cc66345267ea43d8b0a8a6ca71d7a0 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 8 Nov 2022 11:19:38 +0000 Subject: [PATCH 05/61] (hopefully) fix #65 --- modules/output.nix | 34 +++++++++++-------- tests/flake.lock | 12 +++---- tests/flake.nix | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 20 deletions(-) diff --git a/modules/output.nix b/modules/output.nix index 3d7708e6..cce4aa38 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -87,19 +87,6 @@ in config = let - customRC = - (optionalString (config.extraConfigLuaPre != "") '' - ${config.extraConfigLuaPre} - '') + - (optionalString (config.extraConfigVim != "") '' - vim.cmd([[ - ${config.extraConfigVim} - ]]) - '') + - (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") '' - ${config.extraConfigLua} - ${config.extraConfigLuaPost} - ''); defaultPlugin = { plugin = null; @@ -121,6 +108,25 @@ in { 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}"'') @@ -136,6 +142,6 @@ in in { finalPackage = wrappedNeovim; - initContent = neovimConfig.neovimRcContent; + initContent = customRC; }; } diff --git a/tests/flake.lock b/tests/flake.lock index d8bc57a1..b4d67168 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -97,12 +97,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-p/xU46Ew3l56jrG0A+yeRLrOCxRMfAu3JBVvMP0bFUQ=", - "path": "/nix/store/h0ngn8s4pvbwifcc7b0waxmhrgkf5d62-source", + "narHash": "sha256-7vhOkX4qovJR5Vm44lk6c81w3DkuGcQTRxGEnRJI8ro=", + "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", "type": "path" }, "original": { - "path": "/nix/store/h0ngn8s4pvbwifcc7b0waxmhrgkf5d62-source", + "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", "type": "path" } }, @@ -116,12 +116,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-p/xU46Ew3l56jrG0A+yeRLrOCxRMfAu3JBVvMP0bFUQ=", - "path": "/nix/store/h0ngn8s4pvbwifcc7b0waxmhrgkf5d62-source", + "narHash": "sha256-7vhOkX4qovJR5Vm44lk6c81w3DkuGcQTRxGEnRJI8ro=", + "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", "type": "path" }, "original": { - "path": "/nix/store/h0ngn8s4pvbwifcc7b0waxmhrgkf5d62-source", + "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", "type": "path" } }, diff --git a/tests/flake.nix b/tests/flake.nix index 1b083b37..d611baa1 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -118,6 +118,88 @@ 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; + 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; + }; + + 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"; } + ]; + + }; + barbar.enable = true; + }; + + 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); + }; }; })) // { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { From cba9cca52b3676d21b5eb5c050208447af4b7cbb Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Tue, 8 Nov 2022 20:59:26 +0100 Subject: [PATCH 06/61] luasnip: init plugin (#56) * luasnip: init plugin Also added support for paths in `toLuaObject` * luasnip: more flexible types * luasnip: changed options to be more flexible * luasnip: added example * luasnip: added package option --- plugins/default.nix | 2 + plugins/helpers.nix | 2 + plugins/snippets/luasnip/default.nix | 98 ++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 plugins/snippets/luasnip/default.nix diff --git a/plugins/default.nix b/plugins/default.nix index e784ca97..d3e02ee3 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -32,6 +32,8 @@ ./pluginmanagers/packer.nix + ./snippets/luasnip + ./statuslines/airline.nix ./statuslines/lightline.nix ./statuslines/lualine.nix diff --git a/plugins/helpers.nix b/plugins/helpers.nix index 35c3398b..62d3c577 100644 --- a/plugins/helpers.nix +++ b/plugins/helpers.nix @@ -23,6 +23,8 @@ rec { else if builtins.isString args then # This should be enough! escapeShellArg args + else if builtins.isPath args then + escapeShellArg args else if builtins.isBool args then "${ boolToString args }" else if builtins.isFloat args then diff --git a/plugins/snippets/luasnip/default.nix b/plugins/snippets/luasnip/default.nix new file mode 100644 index 00000000..66fcae81 --- /dev/null +++ b/plugins/snippets/luasnip/default.nix @@ -0,0 +1,98 @@ +{ pkgs, config, lib, ... }: +with lib; +let + cfg = config.plugins.luasnip; + helpers = import ../../helpers.nix { lib = lib; }; +in +{ + options.plugins.luasnip = { + enable = mkEnableOption "Enable luasnip"; + + package = mkOption { + default = pkgs.vimPlugins.luasnip; + type = types.package; + }; + + fromVscode = mkOption { + default = [ ]; + example = '' + [ + {} + { + paths = ./path/to/snippets; + } + ] + # generates: + # + # require("luasnip.loaders.from_vscode").lazy_load({}) + # require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}}) + # + ''; + type = types.listOf (types.submodule { + options = { + lazyLoad = mkOption { + type = types.bool; + default = true; + description = '' + Whether or not to lazy load the snippets + ''; + }; + + # 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 + ])) + ]); + }; + + exclude = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + List of languages to exclude, by default is empty. + ''; + }; + + include = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + List of languages to include, by default is not set. + ''; + }; + }; + }); + }; + + # TODO: add support for snipmate + # 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 + mkIf cfg.enable { + extraPlugins = [ cfg.package ]; + extraConfigLua = concatStringsSep "\n" fromVscodeLoaders; + }; +} From c320be04c82914933fe94f64282e646d97d342d4 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 8 Nov 2022 20:02:17 +0000 Subject: [PATCH 07/61] remove obsolete test.sh --- test.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 test.sh diff --git a/test.sh b/test.sh deleted file mode 100755 index bb66d707..00000000 --- a/test.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env sh -# Creates a container and then runs the resulting neovim executable with the configuration -set -e - -sudo nixos-container destroy nvim-test -sudo nixos-container create nvim-test --flake . - -.tmp/sw/bin/nvim -u .tmp/etc/xdg/nvim/sysinit.vim $@ From 4cb8fc4febd4f28366918b7cdda1eaf09c069baa Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 18:22:45 +0000 Subject: [PATCH 08/61] lspkind: init plugin --- flake.lock | 12 +++--- plugins/completion/lspkind.nix | 71 ++++++++++++++++++++++++++++++++++ plugins/default.nix | 1 + tests/flake.lock | 48 +++++++++++------------ tests/flake.nix | 31 ++++++++++----- 5 files changed, 123 insertions(+), 40 deletions(-) create mode 100644 plugins/completion/lspkind.nix diff --git a/flake.lock b/flake.lock index 73627e2d..cc4141f4 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -32,11 +32,11 @@ "nmdSrc": { "flake": false, "locked": { - "lastModified": 1654807200, - "narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=", + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", "owner": "rycee", "repo": "nmd", - "rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", "type": "gitlab" }, "original": { diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix new file mode 100644 index 00000000..4a5337b4 --- /dev/null +++ b/plugins/completion/lspkind.nix @@ -0,0 +1,71 @@ +{ config, pkgs, lib, helpers, ... }: +with lib; +let + cfg = config.plugins.lspkind; +in +{ + options.plugins.lspkind = { + enable = mkEnableOption "lspkind.nvim"; + mode = mkOption { + 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" ]); + default = null; + description = "Default symbol map"; + }; + + symbolMap = mkOption { + type = with types; nullOr (attrsOf str); + default = null; + description = "Override preset symbols"; + }; + + cmp = { + enable = mkOption { + type = types.bool; + default = true; + description = "Integrate with nvim-cmp"; + }; + + maxWidth = mkOption { + type = with types; nullOr int; + default = null; + description = "Maximum number of characters to show in the popup"; + }; + + ellipsisChar = mkOption { + type = with types; nullOr str; + default = null; + description = "Character to show when the popup exceeds maxwidth"; + }; + }; + }; + + 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; + } else { }); + in + mkIf cfg.enable { + extraPlugins = [ pkgs.vimPlugins.lspkind-nvim ]; + + extraConfigLua = optionalString (!doCmp) '' + require('lspkind').init(${helpers.toLuaObject options}) + ''; + + plugins.nvim-cmp.formatting.format = '' + require('lspkind').cmp_format(${helpers.toLuaObject options}) + ''; + }; +} diff --git a/plugins/default.nix b/plugins/default.nix index d3e02ee3..e1ba054b 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -14,6 +14,7 @@ ./completion/copilot.nix ./completion/nvim-cmp ./completion/nvim-cmp/sources + ./completion/lspkind.nix ./git/fugitive.nix ./git/gitgutter.nix diff --git a/tests/flake.lock b/tests/flake.lock index b4d67168..032d8e6b 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "flake-utils_2": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -32,11 +32,11 @@ }, "flake-utils_3": { "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -61,11 +61,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1665066044, - "narHash": "sha256-mkO0LMHVunMFRWLcJhHT0fBf2v6RlH3vg7EVpfSIAFc=", + "lastModified": 1668016843, + "narHash": "sha256-ioBuF+IAhmJO7s4ewEij1LkMxJvCCNCKXxMto/DU02I=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ed9b904c5eba055a6d6f5c1ccb89ba8f0a056dc6", + "rev": "fa842715565307b7e05cdb187b08c05f16ed08f1", "type": "github" }, "original": { @@ -97,12 +97,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-7vhOkX4qovJR5Vm44lk6c81w3DkuGcQTRxGEnRJI8ro=", - "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", + "narHash": "sha256-2xKbMFW3jSlyvl1ZKoe9sNe4h5k5Qk410Dom4TU3nls=", + "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", "type": "path" }, "original": { - "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", + "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", "type": "path" } }, @@ -116,23 +116,23 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-7vhOkX4qovJR5Vm44lk6c81w3DkuGcQTRxGEnRJI8ro=", - "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", + "narHash": "sha256-2xKbMFW3jSlyvl1ZKoe9sNe4h5k5Qk410Dom4TU3nls=", + "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", "type": "path" }, "original": { - "path": "/nix/store/iz74dsm3s96n1f07w6blgw4bf9n2rl5c-source", + "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", "type": "path" } }, "nmdSrc": { "flake": false, "locked": { - "lastModified": 1654807200, - "narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=", + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", "owner": "rycee", "repo": "nmd", - "rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", "type": "gitlab" }, "original": { @@ -144,11 +144,11 @@ "nmdSrc_2": { "flake": false, "locked": { - "lastModified": 1654807200, - "narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=", + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", "owner": "rycee", "repo": "nmd", - "rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", "type": "gitlab" }, "original": { diff --git a/tests/flake.nix b/tests/flake.nix index d611baa1..adff2976 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -154,21 +154,21 @@ nvim-cmp = { formatting = { format = '' - require("lspkind").cmp_format({ - mode="symbol", - maxwidth = 50, - ellipsis_char = "..." - }) - ''; + 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 - ''; + function(args) + require("luasnip").lsp_expand(args.body) + end + ''; }; enable = true; sources = [ @@ -200,6 +200,17 @@ # extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua); }; + + lspkind = build { + plugins = { + lsp = { + enable = true; + servers.clangd.enable = true; + }; + nvim-cmp.enable = true; + lspkind.enable = true; + }; + }; }; })) // { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { From 226c62dc9e35876ca6f5ae67385577ec5f3f29d7 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 18:35:52 +0000 Subject: [PATCH 09/61] lspkind: add menu --- plugins/completion/lspkind.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index 4a5337b4..dd383331 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -42,6 +42,12 @@ in default = null; description = "Character to show when the popup exceeds maxwidth"; }; + + menu = mkOption { + type = with types; nullOr (attrsOf str); + default = null; + description = "Show source names in the popup"; + }; }; }; @@ -55,6 +61,7 @@ in } // (if doCmp then { maxwidth = cfg.cmp.maxWidth; ellipsis_char = cfg.cmp.ellipsisChar; + menu = cfg.cmp.menu; } else { }); in mkIf cfg.enable { From 8d5967c1cb18a8c1c1fec02912a9f6ed7606e845 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 18:53:16 +0000 Subject: [PATCH 10/61] lspking: add function to run after --- plugins/completion/lspkind.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index dd383331..93053e9c 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -48,6 +48,12 @@ in default = null; description = "Show source names in the popup"; }; + + after = mkOption { + type = with types; nullOr types.str; + default = null; + description = "Function to run after calculating the formatting. function(entry, vim_item, kind)"; + }; }; }; @@ -71,8 +77,15 @@ in require('lspkind').init(${helpers.toLuaObject options}) ''; - plugins.nvim-cmp.formatting.format = '' - require('lspkind').cmp_format(${helpers.toLuaObject options}) - ''; + plugins.nvim-cmp.formatting.format = + if cfg.cmp.after != null then '' + function(entry, vim_item) + local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) + + return ${cmp.cfg.after}(entry, vim_after, kind) + end + '' else '' + require('lspkind').cmp_format(${helpers.toLuaObject options}) + ''; }; } From 52e605166b490d96148d44f76f795a2a67945710 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 18:56:48 +0000 Subject: [PATCH 11/61] lspkind: fix bug --- plugins/completion/lspkind.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index 93053e9c..d7f9e402 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -82,7 +82,7 @@ in function(entry, vim_item) local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) - return ${cmp.cfg.after}(entry, vim_after, kind) + return ${cfg.cmp.after}(entry, vim_after, kind) end '' else '' require('lspkind').cmp_format(${helpers.toLuaObject options}) From faf0a946b4c2b3108f42234d86ab121d4a4e7d7d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 10 Nov 2022 19:05:44 +0000 Subject: [PATCH 12/61] lspkind: fix bug --- plugins/completion/lspkind.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index d7f9e402..7ed148e1 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -82,7 +82,7 @@ in function(entry, vim_item) local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) - return ${cfg.cmp.after}(entry, vim_after, kind) + return (${cfg.cmp.after})(entry, vim_after, kind) end '' else '' require('lspkind').cmp_format(${helpers.toLuaObject options}) From bd5c46202eeb31a6084e2aca58062da9bb33e555 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 11 Nov 2022 02:15:23 +0000 Subject: [PATCH 13/61] nixvim: support highlight groups --- modules/highlights.nix | 30 ++++++++++++++++++++++++++++++ tests/flake.lock | 12 ++++++------ tests/flake.nix | 7 +++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 modules/highlights.nix diff --git a/modules/highlights.nix b/modules/highlights.nix new file mode 100644 index 00000000..7ba9297a --- /dev/null +++ b/modules/highlights.nix @@ -0,0 +1,30 @@ +{ config, lib, helpers, ... }: +with lib; +{ + options = { + highlight = mkOption { + type = types.attrsOf types.anything; + default = { }; + description = "Define highlight groups"; + example = '' + highlight = { + Comment.fg = '#ff0000'; + }; + ''; + }; + }; + + config = mkIf (config.highlight != { }) { + extraConfigLuaPost = '' + -- 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 + -- }} + ''; + }; +} diff --git a/tests/flake.lock b/tests/flake.lock index 032d8e6b..67900918 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -97,12 +97,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-2xKbMFW3jSlyvl1ZKoe9sNe4h5k5Qk410Dom4TU3nls=", - "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", + "narHash": "sha256-3m9eDTuaK9RS8HpctJwSu1wnyx5/CILSGppr+6OjTPw=", + "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", "type": "path" }, "original": { - "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", + "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", "type": "path" } }, @@ -116,12 +116,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-2xKbMFW3jSlyvl1ZKoe9sNe4h5k5Qk410Dom4TU3nls=", - "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", + "narHash": "sha256-3m9eDTuaK9RS8HpctJwSu1wnyx5/CILSGppr+6OjTPw=", + "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", "type": "path" }, "original": { - "path": "/nix/store/89k711hq8f8j87h2kadz5kivkcpxjv58-source", + "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", "type": "path" } }, diff --git a/tests/flake.nix b/tests/flake.nix index adff2976..3305bbab 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -211,6 +211,13 @@ lspkind.enable = true; }; }; + + highlight = build { + options.termguicolors = true; + highlight = { + Normal.fg = "#ff0000"; + }; + }; }; })) // { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { From 7992526721462dc734f8c5d914fbb06381ad9ce3 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 13 Nov 2022 14:13:00 +0000 Subject: [PATCH 14/61] nvim-cmp: add extra window options --- plugins/completion/nvim-cmp/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/completion/nvim-cmp/default.nix b/plugins/completion/nvim-cmp/default.nix index b9c3bf43..4d93f3b2 100644 --- a/plugins/completion/nvim-cmp/default.nix +++ b/plugins/completion/nvim-cmp/default.nix @@ -299,6 +299,8 @@ in border = with types; mkNullOrOption (either str (listOf str)) null; winhighlight = mkNullOrOption types.str null; zindex = mkNullOrOption types.int null; + colOffset = mkNullOrOption types.int null; + sidePadding = mkNullOrOption types.int null; in mkOption { default = null; @@ -308,7 +310,7 @@ in default = null; type = types.nullOr (types.submodule ({ ... }: { options = { - inherit border winhighlight zindex; + inherit border winhighlight zindex colOffset sidePadding; }; })); }; @@ -387,7 +389,13 @@ in sources = cfg.sources; view = cfg.view; - window = cfg.window; + window = if (isNull cfg.window) then null else { + border = cfg.window.border; + winhighlight = cfg.window.winhighlight; + zindex = cfg.window.zindex; + col_offset = cfg.window.colOffset; + side_padding = cfg.window.sidePadding; + }; experimental = cfg.experimental; }; in From e2ffc64e68019e4450f9aa8b6c63938374afb768 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 13 Nov 2022 14:14:33 +0000 Subject: [PATCH 15/61] nvim-cmp: fix window options --- plugins/completion/nvim-cmp/default.nix | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/completion/nvim-cmp/default.nix b/plugins/completion/nvim-cmp/default.nix index 4d93f3b2..ff06ef69 100644 --- a/plugins/completion/nvim-cmp/default.nix +++ b/plugins/completion/nvim-cmp/default.nix @@ -299,8 +299,8 @@ in border = with types; mkNullOrOption (either str (listOf str)) null; winhighlight = mkNullOrOption types.str null; zindex = mkNullOrOption types.int null; - colOffset = mkNullOrOption types.int null; - sidePadding = mkNullOrOption types.int null; + col_offset = mkNullOrOption types.int null; + side_padding = mkNullOrOption types.int null; in mkOption { default = null; @@ -310,7 +310,7 @@ in default = null; type = types.nullOr (types.submodule ({ ... }: { options = { - inherit border winhighlight zindex colOffset sidePadding; + inherit border winhighlight zindex col_offset side_padding; }; })); }; @@ -389,13 +389,7 @@ in sources = cfg.sources; view = cfg.view; - window = if (isNull cfg.window) then null else { - border = cfg.window.border; - winhighlight = cfg.window.winhighlight; - zindex = cfg.window.zindex; - col_offset = cfg.window.colOffset; - side_padding = cfg.window.sidePadding; - }; + window = cfg.window; experimental = cfg.experimental; }; in From ac6deb4e957fd5cec450596c3221998e47fd6560 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 13 Nov 2022 14:29:15 +0000 Subject: [PATCH 16/61] nvim-cmp: refactor window options --- plugins/completion/nvim-cmp/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/completion/nvim-cmp/default.nix b/plugins/completion/nvim-cmp/default.nix index ff06ef69..c8351cf4 100644 --- a/plugins/completion/nvim-cmp/default.nix +++ b/plugins/completion/nvim-cmp/default.nix @@ -299,8 +299,6 @@ in border = with types; mkNullOrOption (either str (listOf str)) null; winhighlight = mkNullOrOption types.str null; zindex = mkNullOrOption types.int null; - col_offset = mkNullOrOption types.int null; - side_padding = mkNullOrOption types.int null; in mkOption { default = null; @@ -310,7 +308,9 @@ in default = null; type = types.nullOr (types.submodule ({ ... }: { options = { - inherit border winhighlight zindex col_offset side_padding; + inherit border winhighlight zindex; + col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor"; + side_padding = mkNullOrOption types.int "The amount of padding to add on the completion window's sides"; }; })); }; From fb22debb36bb9c25ac89a890e352e5d2e61715be Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 13 Nov 2022 15:20:23 +0000 Subject: [PATCH 17/61] null-ls: add black formatter --- plugins/null-ls/servers.nix | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index b554077f..476dde26 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -2,11 +2,12 @@ let helpers = import ./helpers.nix args; serverData = { - code_actions = { - }; - completion = { - }; + code_actions = { }; + completion = { }; diagnostics = { + flake8 = { + packages = [ pkgs.python3Packages.flake8 ]; + }; }; formatting = { phpcbf = { @@ -21,8 +22,8 @@ let prettier = { packages = [ pkgs.nodePackages.prettier ]; }; - flake8 = { - packages = [ pkgs.python3Packages.flake8 ]; + black = { + packages = [ pkgs.python3Packages.black ]; }; }; }; @@ -32,9 +33,11 @@ let # sourceType = "formatting"; # packages = [...]; # }] - serverDataFormatted = lib.mapAttrsToList (sourceType: sourceSet: - lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet - ) serverData; + serverDataFormatted = lib.mapAttrsToList + (sourceType: sourceSet: + lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet + ) + serverData; dataFlattened = lib.flatten serverDataFormatted; in { From 4f08c8a4bfb8b32da0350d1f4de1c667ffcd5ec0 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 15 Nov 2022 10:14:43 +0000 Subject: [PATCH 18/61] trouble.nvim: init --- plugins/default.nix | 1 + plugins/nvim-lsp/trouble.nix | 23 +++++++++++++++++++++++ tests/flake.lock | 12 ++++++------ tests/flake.nix | 9 +++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 plugins/nvim-lsp/trouble.nix diff --git a/plugins/default.nix b/plugins/default.nix index e1ba054b..34434ea0 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -30,6 +30,7 @@ ./nvim-lsp ./nvim-lsp/lspsaga.nix ./nvim-lsp/lsp-lines.nix + ./nvim-lsp/trouble.nix ./pluginmanagers/packer.nix diff --git a/plugins/nvim-lsp/trouble.nix b/plugins/nvim-lsp/trouble.nix new file mode 100644 index 00000000..ccb0fd9d --- /dev/null +++ b/plugins/nvim-lsp/trouble.nix @@ -0,0 +1,23 @@ +{ config, pkgs, lib, helpers, ... }: +let + cfg = config.plugins.trouble; +in +with lib; +# with helpers; +{ + options.plugins.trouble = { + enable = mkEnableOption "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"; + }; + + config = mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [ + trouble-nvim + nvim-web-devicons + ]; + }; +} diff --git a/tests/flake.lock b/tests/flake.lock index 67900918..eef046ea 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -97,12 +97,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-3m9eDTuaK9RS8HpctJwSu1wnyx5/CILSGppr+6OjTPw=", - "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", + "narHash": "sha256-b5FuoFQsTCgKsVTQS13qmFnMmVotIQWtcjPu+WT6ubo=", + "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", "type": "path" }, "original": { - "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", + "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", "type": "path" } }, @@ -116,12 +116,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-3m9eDTuaK9RS8HpctJwSu1wnyx5/CILSGppr+6OjTPw=", - "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", + "narHash": "sha256-b5FuoFQsTCgKsVTQS13qmFnMmVotIQWtcjPu+WT6ubo=", + "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", "type": "path" }, "original": { - "path": "/nix/store/pp50jx20wrkbrkv3mxkwzckciy8xcqy2-source", + "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", "type": "path" } }, diff --git a/tests/flake.nix b/tests/flake.nix index 3305bbab..8f4eabf7 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -61,6 +61,15 @@ plugins.lsp-lines.enable = true; }; + trouble = build { + plugins.lsp = { + enable = true; + servers.clangd.enable = true; + }; + + plugins.trouble.enable = true; + }; + issue-40 = build-stable { plugins = { nix.enable = true; From 4c36cdc2e762bc71e659df464795e5e025349385 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 15 Nov 2022 11:36:42 +0000 Subject: [PATCH 19/61] null-ls: add beautysh and shellcheck --- flake.nix | 4 + plugins/null-ls/servers.nix | 8 +- tests/flake.lock | 144 ++++++++++++++++++++++++++++++++++-- tests/flake.nix | 7 ++ 4 files changed, 156 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 4b1aef0d..a2698286 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,9 @@ inputs.nmdSrc.url = "gitlab:rycee/nmd"; inputs.nmdSrc.flake = false; + inputs.beautysh.url = "github:lovesegfault/beautysh"; + inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs"; + outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs: with nixpkgs.lib; with builtins; @@ -22,6 +25,7 @@ pkgs = mkForce pkgs; inherit (pkgs) lib; helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; }; + inputs = inputs; }; }; }) diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index 476dde26..b5cfb213 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -1,4 +1,4 @@ -{ pkgs, config, lib, ... }@args: +{ pkgs, config, lib, inputs, ... }@args: let helpers = import ./helpers.nix args; serverData = { @@ -8,6 +8,9 @@ let flake8 = { packages = [ pkgs.python3Packages.flake8 ]; }; + shellcheck = { + packages = [ pkgs.shellcheck ]; + }; }; formatting = { phpcbf = { @@ -25,6 +28,9 @@ let black = { packages = [ pkgs.python3Packages.black ]; }; + beautysh = { + packages = [ inputs.beautysh.packages.${pkgs.system}.beautysh-python38 ]; + }; }; }; # Format the servers to be an array of attrs like the following example diff --git a/tests/flake.lock b/tests/flake.lock index eef046ea..b6272a30 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -1,5 +1,51 @@ { "nodes": { + "beautysh": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "utils": "utils" + }, + "locked": { + "lastModified": 1667262410, + "narHash": "sha256-yqqvPvazG/Ci3WpIfPb+o+i2cNuyAYYY19lwJGCmUao=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "a1fdaff999db2dfc5032914630f5052360f4b432", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, + "beautysh_2": { + "inputs": { + "nixpkgs": [ + "nixvim-stable", + "nixpkgs" + ], + "poetry2nix": "poetry2nix_2", + "utils": "utils_2" + }, + "locked": { + "lastModified": 1667262410, + "narHash": "sha256-yqqvPvazG/Ci3WpIfPb+o+i2cNuyAYYY19lwJGCmUao=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "a1fdaff999db2dfc5032914630f5052360f4b432", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -91,23 +137,25 @@ }, "nixvim": { "inputs": { + "beautysh": "beautysh", "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs_2", "nmdSrc": "nmdSrc" }, "locked": { "lastModified": 0, - "narHash": "sha256-b5FuoFQsTCgKsVTQS13qmFnMmVotIQWtcjPu+WT6ubo=", - "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", + "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", + "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", "type": "path" }, "original": { - "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", + "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", "type": "path" } }, "nixvim-stable": { "inputs": { + "beautysh": "beautysh_2", "flake-utils": "flake-utils_3", "nixpkgs": [ "nixpkgs-stable" @@ -116,12 +164,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-b5FuoFQsTCgKsVTQS13qmFnMmVotIQWtcjPu+WT6ubo=", - "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", + "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", + "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", "type": "path" }, "original": { - "path": "/nix/store/m90wvnc3d4rci36q0r0j7d2i1sk35cgy-source", + "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", "type": "path" } }, @@ -157,6 +205,60 @@ "type": "gitlab" } }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "nixvim", + "beautysh", + "utils" + ], + "nixpkgs": [ + "nixvim", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "poetry2nix_2": { + "inputs": { + "flake-utils": [ + "nixvim-stable", + "beautysh", + "utils" + ], + "nixpkgs": [ + "nixvim-stable", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", @@ -165,6 +267,36 @@ "nixvim": "nixvim", "nixvim-stable": "nixvim-stable" } + }, + "utils": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/tests/flake.nix b/tests/flake.nix index 8f4eabf7..803be217 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -70,6 +70,13 @@ plugins.trouble.enable = true; }; + beautysh = build { + plugins.null-ls = { + enable = true; + sources.formatting.beautysh.enable = true; + }; + }; + issue-40 = build-stable { plugins = { nix.enable = true; From a601a75d0cae8229f1416506bd172e4e4aef3ce7 Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Wed, 16 Nov 2022 13:37:35 +0100 Subject: [PATCH 20/61] nvim-lsp: added denols (#68) --- plugins/nvim-lsp/basic-servers.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 5a85a4e5..fa9a4fd6 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -12,6 +12,11 @@ let description = "Enable cssls, for CSS"; packages = [ pkgs.nodePackages.vscode-langservers-extracted ]; } + { + name = "denols"; + description = "Enable denols, for Deno"; + packages = [ pkgs.deno ]; + } { name = "eslint"; description = "Enable eslint"; From f9cfb250e9043a8dd30a8f1d5696b9227aca8e2d Mon Sep 17 00:00:00 2001 From: *Kim Zick Date: Sun, 27 Nov 2022 16:53:49 -0500 Subject: [PATCH 21/61] helpers: fix toLuaObject string escapes (#72) --- plugins/helpers.nix | 4 ++-- tests/flake.nix | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/helpers.nix b/plugins/helpers.nix index 62d3c577..32eba33c 100644 --- a/plugins/helpers.nix +++ b/plugins/helpers.nix @@ -22,9 +22,9 @@ rec { "{" + concatMapStringsSep "," toLuaObject args + "}" else if builtins.isString args then # This should be enough! - escapeShellArg args + builtins.toJSON args else if builtins.isPath args then - escapeShellArg args + builtins.toJSON (toString args) else if builtins.isBool args then "${ boolToString args }" else if builtins.isFloat args then diff --git a/tests/flake.nix b/tests/flake.nix index 803be217..8fc73a7d 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -217,6 +217,10 @@ # extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua); }; + issue-71 = build { + maps.normal."hb" = "lua require('gitsigns').blame_line{full=true}"; + }; + lspkind = build { plugins = { lsp = { From 867809451164b0080cb57b646914360761dbfbe7 Mon Sep 17 00:00:00 2001 From: *Kim Zick Date: Sun, 27 Nov 2022 16:55:34 -0500 Subject: [PATCH 22/61] specs: add color option (#76) --- plugins/utils/specs.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/utils/specs.nix b/plugins/utils/specs.nix index 5edd292d..9ebd3cb6 100644 --- a/plugins/utils/specs.nix +++ b/plugins/utils/specs.nix @@ -35,6 +35,11 @@ in default = 10; }; + color = mkOption { + type = types.nullOr types.str; + default = null; + }; + width = mkOption { type = types.int; default = 10; @@ -117,6 +122,7 @@ in 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 @@ -133,6 +139,8 @@ in mkIf cfg.enable { extraPlugins = [ pkgs.vimPlugins.specs-nvim ]; + highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color; + extraConfigLua = '' require('specs').setup(${setup}) ''; From bc045bd50a0bbb6d5b08965e9c7e375652975c8d Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Wed, 30 Nov 2022 18:04:24 +0100 Subject: [PATCH 23/61] vuels: using non deprecated version (#77) --- plugins/nvim-lsp/basic-servers.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index fa9a4fd6..ef1881a2 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -72,7 +72,7 @@ let { name = "vuels"; description = "Enable vuels, for Vue"; - packages = [ pkgs.nodePackages.vue-language-server ]; + packages = [ pkgs.nodePackages.vls ]; } { name = "zls"; From 36bc31ed5cb4b7d5d3b48ea2ac93cf6bee8d16dc Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:05:35 +0000 Subject: [PATCH 24/61] lsp: add haskell language server --- plugins/languages/treesitter.nix | 8 ++- plugins/nvim-lsp/basic-servers.nix | 7 ++- tests/flake.lock | 88 ++++++++++++++++++++++++++---- tests/flake.nix | 20 ++++++- 4 files changed, 109 insertions(+), 14 deletions(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 3dffdff6..be4ed3ce 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -66,6 +66,12 @@ in folding = mkEnableOption "Enable tree-sitter based folding"; }; + + grammarPackages = mkOption { + type = with types; listOf package; + default = pkgs.tree-sitter.allGrammars; + description = "Grammar packages to install"; + }; }; config = @@ -107,7 +113,7 @@ in ''; extraPlugins = with pkgs; if cfg.nixGrammars then - [ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ] + [ (vimPlugins.nvim-treesitter.withPlugins (_: cfg.grammarPackages)) ] else [ vimPlugins.nvim-treesitter ]; extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index ef1881a2..25e59bdc 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -26,7 +26,7 @@ let name = "elixirls"; description = "Enable elixirls"; packages = [ ]; - cmd = ["${pkgs.elixir_ls}/bin/elixir-ls"]; + cmd = [ "${pkgs.elixir_ls}/bin/elixir-ls" ]; } { name = "gdscript"; @@ -78,6 +78,11 @@ let name = "zls"; description = "Enable zls, for Zig."; } + { + name = "hls"; + description = "Enable haskell language server"; + packages = [ pkgs.haskell-language-server ]; + } ]; in { diff --git a/tests/flake.lock b/tests/flake.lock index b6272a30..a1a8df89 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -46,6 +46,25 @@ "type": "github" } }, + "build-ts": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1669771646, + "narHash": "sha256-IfH9zCq0+QpAB8D1ClhISfWcR59mSDsi91/2NW0RWfs=", + "owner": "pta2002", + "repo": "build-ts-grammar.nix", + "rev": "bba8a5b14a4632f25411dbf0fb01de69e999ce82", + "type": "github" + }, + "original": { + "owner": "pta2002", + "repo": "build-ts-grammar.nix", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -91,6 +110,37 @@ "type": "github" } }, + "flake-utils_4": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gleam": { + "flake": false, + "locked": { + "lastModified": 1669665314, + "narHash": "sha256-aeho84P91cH13j7uLJwyD/zj8O/peROrpfa41HA/FGo=", + "owner": "gleam-lang", + "repo": "tree-sitter-gleam", + "rev": "97611918f79643ade377a156f3e4192cd50dc3e6", + "type": "github" + }, + "original": { + "owner": "gleam-lang", + "repo": "tree-sitter-gleam", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1663491030, @@ -135,28 +185,42 @@ "type": "indirect" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1663491030, + "narHash": "sha256-MVsfBhE9US5DvLtBAaTRjwYdv1tLO8xjahM8qLXTgTo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "767542707d394ff15ac1981e903e005ba69528b5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nixvim": { "inputs": { "beautysh": "beautysh", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3", "nmdSrc": "nmdSrc" }, "locked": { "lastModified": 0, - "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" }, "original": { - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" } }, "nixvim-stable": { "inputs": { "beautysh": "beautysh_2", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs-stable" ], @@ -164,12 +228,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" }, "original": { - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" } }, @@ -261,8 +325,10 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "build-ts": "build-ts", + "flake-utils": "flake-utils_2", + "gleam": "gleam", + "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable", "nixvim": "nixvim", "nixvim-stable": "nixvim-stable" diff --git a/tests/flake.nix b/tests/flake.nix index 8fc73a7d..735e6910 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -4,13 +4,17 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixvim.url = "./.."; + inputs.build-ts.url = "github:pta2002/build-ts-grammar.nix"; + inputs.gleam.url = "github:gleam-lang/tree-sitter-gleam"; + inputs.gleam.flake = false; + inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.05"; inputs.nixvim-stable = { url = "./.."; inputs.nixpkgs.follows = "nixpkgs-stable"; }; - outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, ... }: + outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, build-ts, gleam, ... }: (flake-utils.lib.eachDefaultSystem (system: let @@ -238,6 +242,20 @@ Normal.fg = "#ff0000"; }; }; + + 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 { From 6537e9aa1f1b540773cdcdf534924b988ff1216a Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:07:08 +0000 Subject: [PATCH 25/61] treesitter: custom grammars --- plugins/languages/treesitter.nix | 10 +++++----- tests/flake.lock | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index be4ed3ce..e96a68af 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -65,12 +65,12 @@ in indent = mkEnableOption "Enable tree-sitter based indentation"; folding = mkEnableOption "Enable tree-sitter based folding"; - }; - grammarPackages = mkOption { - type = with types; listOf package; - default = pkgs.tree-sitter.allGrammars; - description = "Grammar packages to install"; + grammarPackages = mkOption { + type = with types; listOf package; + default = pkgs.tree-sitter.allGrammars; + description = "Grammar packages to install"; + }; }; }; diff --git a/tests/flake.lock b/tests/flake.lock index a1a8df89..7fc1ef8c 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -157,11 +157,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1668016843, - "narHash": "sha256-ioBuF+IAhmJO7s4ewEij1LkMxJvCCNCKXxMto/DU02I=", + "lastModified": 1669546925, + "narHash": "sha256-Gvtk9agz88tBgqmCdHl5U7gYttTkiuEd8/Rq1Im0pTg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fa842715565307b7e05cdb187b08c05f16ed08f1", + "rev": "fecf05d4861f3985e8dee73f08bc82668ef75125", "type": "github" }, "original": { @@ -208,12 +208,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", - "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", + "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", + "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", "type": "path" }, "original": { - "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", + "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", "type": "path" } }, @@ -228,12 +228,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", - "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", + "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", + "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", "type": "path" }, "original": { - "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", + "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", "type": "path" } }, From 5242d9333ec9cdfbc3ebe1c016f3c826ad12b029 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:15:46 +0000 Subject: [PATCH 26/61] nvim-lsp: fix hls --- plugins/nvim-lsp/basic-servers.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 25e59bdc..9d5e8a31 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -81,7 +81,8 @@ let { name = "hls"; description = "Enable haskell language server"; - packages = [ pkgs.haskell-language-server ]; + packages = [ ]; + cmd = [ "${pkgs.haskell-language-server}/bin/haskell-language-serve-wrapper" ]; } ]; in From 398c96ffe09ee971a3e0be7a03c57e0d95779f49 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:18:23 +0000 Subject: [PATCH 27/61] nvim-lsp: fix typo in hls config I'm an idiot that can't type :') --- plugins/nvim-lsp/basic-servers.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 9d5e8a31..df95ad31 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -82,7 +82,7 @@ let name = "hls"; description = "Enable haskell language server"; packages = [ ]; - cmd = [ "${pkgs.haskell-language-server}/bin/haskell-language-serve-wrapper" ]; + cmd = [ "${pkgs.haskell-language-server}/bin/haskell-language-server-wrapper" ]; } ]; in From 46c0128a3633970c57225f81e26eefc6b08669ff Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:22:15 +0000 Subject: [PATCH 28/61] nvim-lsp: fix hls again i hope it's the last time <.< --- plugins/nvim-lsp/basic-servers.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index df95ad31..add776c2 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -81,7 +81,7 @@ let { name = "hls"; description = "Enable haskell language server"; - packages = [ ]; + packages = [ pkgs.haskell-language-server ]; cmd = [ "${pkgs.haskell-language-server}/bin/haskell-language-server-wrapper" ]; } ]; From 8135cce2c7330132288db9b19c247effe33a6501 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:37:30 +0000 Subject: [PATCH 29/61] null-ls: add fourmolu --- plugins/null-ls/servers.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index b5cfb213..4188f8b9 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -31,6 +31,9 @@ let beautysh = { packages = [ inputs.beautysh.packages.${pkgs.system}.beautysh-python38 ]; }; + fourmolu = { + packages = [ pkgs.haskellPackages.fourmolu ]; + }; }; }; # Format the servers to be an array of attrs like the following example From 27bf782ed8794daa99a4f63334d8cb678808694d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 15:15:54 +0000 Subject: [PATCH 30/61] nvim-lsp: try again to fix haskell gaaaaa --- plugins/nvim-lsp/basic-servers.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index add776c2..96c23999 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -82,7 +82,7 @@ let name = "hls"; description = "Enable haskell language server"; packages = [ pkgs.haskell-language-server ]; - cmd = [ "${pkgs.haskell-language-server}/bin/haskell-language-server-wrapper" ]; + cmd = [ "haskell-language-server-wrapper" ]; } ]; in From 1bd5e97892acd1efe9b124d864e9a13b0da80029 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 19:55:54 +0000 Subject: [PATCH 31/61] README: direct people to GH Discussions --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f1305bd8..c5285e36 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ lightline plugin: When we do this, lightline will be set up to a sensible default, and will use gruvbox as the colorscheme, no extra configuration required! +## Support/Questions +If you have any question, please use the [discussions page](https://github.com/pta2002/nixvim/discussions/categories/q-a)! + ## Instalation ### Without flakes NixVim now ships with `flake-compat`, which makes it usable from any system. From 90b8a45092f6f2f4ea2f5d586364feb7defa1158 Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Thu, 1 Dec 2022 20:57:06 +0100 Subject: [PATCH 32/61] Added extra options (#62) * Added extraOptions helper * project-nvim: added extraOptions --- plugins/helpers.nix | 11 +++++++++++ plugins/utils/project-nvim.nix | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/helpers.nix b/plugins/helpers.nix index 32eba33c..ab6a9866 100644 --- a/plugins/helpers.nix +++ b/plugins/helpers.nix @@ -106,6 +106,17 @@ rec { inherit value global; }; + extraOptionsOptions = { + extraOptions = mkOption { + default = { }; + type = types.attrs; + description = '' + These attributes will be added to the table parameter for the setup function. + (Can override other attributes set by nixvim) + ''; + }; + }; + mkRaw = r: { __raw = r; }; wrapDo = string: '' diff --git a/plugins/utils/project-nvim.nix b/plugins/utils/project-nvim.nix index ff76926f..d81b7251 100644 --- a/plugins/utils/project-nvim.nix +++ b/plugins/utils/project-nvim.nix @@ -5,7 +5,7 @@ let helpers = import ../helpers.nix { inherit lib; }; in { - options.plugins.project-nvim = { + options.plugins.project-nvim = helpers.extraOptionsOptions // { enable = mkEnableOption "Enable project.nvim"; manualMode = mkOption { @@ -52,6 +52,7 @@ in type = types.nullOr (types.either types.str helpers.rawType); default = null; }; + }; config = @@ -66,7 +67,7 @@ in silent_chdir = cfg.silentChdir; scope_schdir = cfg.scopeChdir; data_path = cfg.dataPath; - }; + } // cfg.extraOptions; in mkIf cfg.enable { extraPlugins = [ pkgs.vimPlugins.project-nvim ]; From 4880459702314cf77d066ad1c1ac52d6bf61aed5 Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Thu, 1 Dec 2022 20:58:35 +0100 Subject: [PATCH 33/61] telescope: added extraOptions and defaults (#67) * telescope: added extraOptions and defualtConfig * Update default.nix Co-authored-by: Pedro Alves --- plugins/telescope/default.nix | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index dd3397c2..46d1ba3a 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -35,6 +35,18 @@ in description = "Configuration for the extensions. Don't use this directly"; default = { }; }; + + defaults = mkOption { + type = types.nullOr types.attrs; + default = null; + description = "Telescope default configuration"; + }; + + extraOptions = mkOption { + type = types.attrs; + default = { }; + description = "An attribute set, that lets you set extra options or override options set by nixvim"; + }; }; config = mkIf cfg.enable { @@ -50,13 +62,16 @@ in let $BAT_THEME = '${cfg.highlightTheme}' ''; - extraConfigLua = '' + extraConfigLua = let + options = { + extensions = cfg.extensionConfig; + defaults = cfg.defaults; + } // cfg.extraOptions; + in '' do local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} - require('telescope').setup{ - extensions = ${helpers.toLuaObject cfg.extensionConfig} - } + require('telescope').setup(${helpers.toLuaObject options}) for i, extension in ipairs(__telescopeExtensions) do require('telescope').load_extension(extension) From 78f5f36738af40cce4fd0cb23e10fec70fe1b3f2 Mon Sep 17 00:00:00 2001 From: *Kim Zick Date: Thu, 1 Dec 2022 18:15:21 -0500 Subject: [PATCH 34/61] fix: basic flake check should work now (#74) --- plugins/completion/lspkind.nix | 3 ++- plugins/nvim-lsp/trouble.nix | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/completion/lspkind.nix b/plugins/completion/lspkind.nix index 7ed148e1..6ee84f09 100644 --- a/plugins/completion/lspkind.nix +++ b/plugins/completion/lspkind.nix @@ -1,7 +1,8 @@ -{ config, pkgs, lib, helpers, ... }: +{ config, pkgs, lib, ... }: with lib; let cfg = config.plugins.lspkind; + helpers = import ../helpers.nix { inherit lib; }; in { options.plugins.lspkind = { diff --git a/plugins/nvim-lsp/trouble.nix b/plugins/nvim-lsp/trouble.nix index ccb0fd9d..c21f41bb 100644 --- a/plugins/nvim-lsp/trouble.nix +++ b/plugins/nvim-lsp/trouble.nix @@ -1,6 +1,7 @@ -{ config, pkgs, lib, helpers, ... }: +{ config, pkgs, lib, ... }: let cfg = config.plugins.trouble; + helpers = import ../helpers.nix { inherit lib; }; in with lib; # with helpers; From 472e10f069c57da281ef178b28423f7f6b2529c2 Mon Sep 17 00:00:00 2001 From: Syahdan <58659387+LittleQuartZ@users.noreply.github.com> Date: Mon, 5 Dec 2022 09:49:37 +0700 Subject: [PATCH 35/61] lsp: add bufnr to passed argument (#82) * lsp: add bufnr to passed argument * lsp: add docs for last commit --- plugins/nvim-lsp/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/nvim-lsp/default.nix b/plugins/nvim-lsp/default.nix index 8949510d..f2f74593 100644 --- a/plugins/nvim-lsp/default.nix +++ b/plugins/nvim-lsp/default.nix @@ -36,7 +36,7 @@ in onAttach = mkOption { type = types.lines; - description = "A lua function to be run when a new LSP buffer is attached. The argument `client` is provided."; + description = "A lua function to be run when a new LSP buffer is attached. The argument `client` and `bufnr` is provided."; default = ""; }; @@ -69,7 +69,7 @@ in do ${cfg.preConfig} local __lspServers = ${helpers.toLuaObject cfg.enabledServers} - local __lspOnAttach = function(client) + local __lspOnAttach = function(client, bufnr) ${cfg.onAttach} end From a7fbb812242d1223fcca8c0a270eb87a82f98f17 Mon Sep 17 00:00:00 2001 From: *Kim Zick Date: Thu, 8 Dec 2022 12:12:57 -0500 Subject: [PATCH 36/61] options: add viAlias and vimAlias (#75) --- modules/output.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/output.nix b/modules/output.nix index cce4aa38..516607b6 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -22,6 +22,22 @@ let in { options = { + viAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink vi to nvim binary. + ''; + }; + + vimAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink vim to nvim binary. + ''; + }; + package = mkOption { type = types.package; default = pkgs.neovim-unwrapped; @@ -97,6 +113,7 @@ in normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins; neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({ + inherit (config) viAlias vimAlias; # inherit customRC; plugins = normalizedPlugins; } From db8a2c0b97cbbfbdb43b0e6909f38f83d1600e4e Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 11 Dec 2022 19:39:45 +0000 Subject: [PATCH 37/61] lsp-lines: add currentLine option --- flake.lock | 63 ++++++++++++++++++++++++++++++++++ plugins/nvim-lsp/lsp-lines.nix | 18 ++++++++-- 2 files changed, 78 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index cc4141f4..96a9886f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "beautysh": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "utils": "utils" + }, + "locked": { + "lastModified": 1669854260, + "narHash": "sha256-Z8NAL3g4i5LAhxveNGJhrVDHxIBbUf1lVIy/Thr2RMU=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "d616eb8d9d05ee4fb33de9c5521d99c3f0695d52", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -45,12 +67,53 @@ "type": "gitlab" } }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "beautysh", + "utils" + ], + "nixpkgs": [ + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "root": { "inputs": { + "beautysh": "beautysh", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "nmdSrc": "nmdSrc" } + }, + "utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/plugins/nvim-lsp/lsp-lines.nix b/plugins/nvim-lsp/lsp-lines.nix index 54ece053..e415b469 100644 --- a/plugins/nvim-lsp/lsp-lines.nix +++ b/plugins/nvim-lsp/lsp-lines.nix @@ -8,10 +8,24 @@ in options = { plugins.lsp-lines = { enable = mkEnableOption "lsp_lines.nvim"; + currentLine = mkOption { + type = types.bool; + default = false; + description = "Show diagnostics only on current line"; + }; }; }; config = + let + diagnosticConfig = { + virtual_text = false; + virtual_lines = + if cfg.currentLine then { + only_current_line = true; + } else true; + }; + in mkIf cfg.enable { extraPlugins = [ pkgs.vimPlugins.lsp_lines-nvim ]; @@ -19,9 +33,7 @@ in do require("lsp_lines").setup() - vim.diagnostic.config({ - virtual_text = false - }) + vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig }) end ''; }; From de6519f713d651ab0d9ef2223822927e1d91d18b Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Thu, 15 Dec 2022 18:03:31 +0100 Subject: [PATCH 38/61] nvim-lsp/tailwindcss: init (#85) --- plugins/nvim-lsp/basic-servers.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 96c23999..3882d8d9 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -61,6 +61,11 @@ let description = "Enable rust-analyzer, for Rust."; serverName = "rust_analyzer"; } + { + name = "tailwindcss"; + description = "Enable tailwindcss language server, for tailwindcss"; + packages = [ pkgs.nodePackages."@tailwindcss/language-server" ]; + } { name = "tsserver"; description = "Enable tsserver for typescript"; From 470fd9c07eccd5df3dbd03b3a18b019f57e138a1 Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Thu, 15 Dec 2022 18:04:24 +0100 Subject: [PATCH 39/61] copilot: add package option (#84) --- plugins/completion/copilot.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/completion/copilot.nix b/plugins/completion/copilot.nix index 5fc628df..62002064 100644 --- a/plugins/completion/copilot.nix +++ b/plugins/completion/copilot.nix @@ -7,6 +7,11 @@ in options = { plugins.copilot = { enable = mkEnableOption "Enable copilot"; + package = mkOption { + type = types.package; + description = "The copilot plugin package to use"; + default = pkgs.vimPlugins.copilot-vim; + }; filetypes = mkOption { type = types.attrsOf types.bool; description = "A dictionary mapping file types to their enabled status"; @@ -27,7 +32,7 @@ in config = mkIf cfg.enable { - extraPlugins = [ pkgs.vimPlugins.copilot-vim ]; + extraPlugins = [ cfg.package ]; globals = { copilot_node_command = "${pkgs.nodejs-16_x}/bin/node"; copilot_filetypes = cfg.filetypes; From fdbba2238e5e7b400ff10eef5b8fc474d8059deb Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 19 Dec 2022 02:18:15 +0000 Subject: [PATCH 40/61] null-ls: add fnlfmt --- plugins/null-ls/servers.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index 4188f8b9..48575425 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -34,6 +34,9 @@ let fourmolu = { packages = [ pkgs.haskellPackages.fourmolu ]; }; + fnlfmt = { + packages = [ pkgs.fnlfmt ]; + }; }; }; # Format the servers to be an array of attrs like the following example From 5f67918bae3115e5d5ae17eeb9d414517762fc66 Mon Sep 17 00:00:00 2001 From: traxys Date: Sat, 24 Dec 2022 01:08:54 +0100 Subject: [PATCH 41/61] tokyonight: Fix configuration and align more with defaults (#87) The global variables don't work for applying configuration, we need to switch to using the 'setup' function. This also aligns the default option values in tokyonight upstream. --- plugins/colorschemes/tokyonight.nix | 108 ++++++++++++++++++---------- 1 file changed, 72 insertions(+), 36 deletions(-) diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix index 9264ee27..2054ef56 100644 --- a/plugins/colorschemes/tokyonight.nix +++ b/plugins/colorschemes/tokyonight.nix @@ -1,4 +1,4 @@ -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, helpers, ... }: with lib; let cfg = config.colorschemes.tokyonight; @@ -9,50 +9,86 @@ in colorschemes.tokyonight = { enable = mkEnableOption "Enable tokyonight"; style = mkOption { - type = types.nullOr style; - default = null; + type = style; + default = "storm"; description = "Theme style"; }; - terminalColors = mkEnableOption - "Configure the colors used when opening a :terminal in Neovim"; - italicComments = mkEnableOption "Make comments italic"; - italicKeywords = mkEnableOption "Make keywords italic"; - italicFunctions = mkEnableOption "Make functions italic"; - italicVariables = mkEnableOption "Make variables and identifiers italic"; + terminalColors = mkOption { + type = types.bool; + default = true; + description = "Configure the colors used when opening a :terminal in Neovim"; + }; transparent = mkEnableOption "Enable this to disable setting the background color"; - hideInactiveStatusline = mkEnableOption - "Enabling this option will hide inactive statuslines and replace them with a thin border"; - transparentSidebar = mkEnableOption - "Sidebar like windows like NvimTree get a transparent background"; - darkSidebar = mkEnableOption - "Sidebar like windows like NvimTree get a darker background"; - darkFloat = mkEnableOption - "Float windows like the lsp diagnostics windows get a darker background"; - lualineBold = mkEnableOption - "When true, section headers in the lualine theme will be bold"; + styles = + let + mkBackgroundStyle = name: mkOption { + type = types.enum [ "dark" "transparent" "normal" ]; + description = "Background style for ${name}"; + default = "dark"; + }; + in + { + comments = mkOption { + type = types.attrsOf types.anything; + description = "Define comments highlight properties"; + default = { italic = true; }; + }; + keywords = mkOption { + type = types.attrsOf types.anything; + description = "Define keywords highlight properties"; + default = { italic = true; }; + }; + functions = mkOption { + type = types.attrsOf types.anything; + description = "Define functions highlight properties"; + default = { }; + }; + variables = mkOption { + type = types.attrsOf types.anything; + description = "Define variables highlight properties"; + default = { }; + }; + sidebars = mkBackgroundStyle "sidebars"; + floats = mkBackgroundStyle "floats"; + }; + sidebars = mkOption { + type = types.listOf types.str; + default = [ "qf" "help" ]; + description = "Set a darker background on sidebar-like windows"; + example = ''["qf" "vista_kind" "terminal" "packer"]''; + }; + dayBrightness = mkOption { + type = types.numbers.between 0.0 1.0; + default = 0.3; + description = "Adjusts the brightness of the colors of the **Day** style"; + }; + hideInactiveStatusline = + mkEnableOption + "Enabling this option will hide inactive statuslines and replace them with a thin border"; + dimInactive = mkEnableOption "dims inactive windows"; + lualineBold = + mkEnableOption + "When true, section headers in the lualine theme will be bold"; }; }; config = mkIf cfg.enable { colorscheme = "tokyonight"; extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ]; options = { termguicolors = true; }; - globals = { - tokyonight_style = mkIf (!isNull cfg.style) cfg.style; - tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0; - - tokyonight_italic_comments = mkIf (!cfg.italicComments) 0; - tokyonight_italic_keywords = mkIf (!cfg.italicKeywords) 0; - tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1; - tokyonight_italic_variables = mkIf (cfg.italicVariables) 1; - - tokyonight_transparent = mkIf (cfg.transparent) 1; - tokyonight_hide_inactive_statusline = - mkIf (cfg.hideInactiveStatusline) 1; - tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1; - tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0; - tokyonight_dark_float = mkIf (!cfg.darkFloat) 0; - tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1; - }; + 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}) + ''; }; } From dd9ec124a25383f4ea9eb7d000de26a842fa13df Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 29 Dec 2022 17:34:47 +0000 Subject: [PATCH 42/61] docs: fix documentation generation --- .circleci/config.yml | 2 +- docs.nix | 35 ++++++ docs/default.nix | 48 -------- docs/man-nixvim.xml | 27 ----- docs/man-pages.xml | 11 -- docs/manual.xml | 23 ---- docs/plugins.md | 29 ----- docs/plugins/colorschemes/base16.md | 155 ------------------------ docs/plugins/colorschemes/gruvbox.md | 144 ---------------------- docs/plugins/colorschemes/one.md | 6 - docs/plugins/colorschemes/onedark.md | 6 - docs/plugins/colorschemes/tokyonight.md | 70 ----------- docs/plugins/git/fugitive.md | 0 docs/plugins/git/gitgutter.md | 0 docs/plugins/languages/ledger.md | 0 docs/plugins/languages/nix.md | 0 docs/plugins/languages/treesitter.md | 0 docs/plugins/languages/zig.md | 0 docs/plugins/nvim-lsp/clangd.md | 0 docs/plugins/nvim-lsp/default.md | 0 docs/plugins/nvim-lsp/lspsaga.md | 0 docs/plugins/nvim-lsp/rnix-lsp.md | 0 docs/plugins/nvim-lsp/rust-analyzer.md | 0 docs/plugins/pluginmanagers/packer.md | 0 docs/plugins/statuslines/airline.md | 0 docs/plugins/statuslines/lightline.md | 0 docs/plugins/utils/barbar.md | 0 docs/plugins/utils/commentary.md | 0 docs/plugins/utils/endwise.md | 0 docs/plugins/utils/goyo.md | 0 docs/plugins/utils/nvim-autopairs.md | 0 docs/plugins/utils/startify.md | 0 docs/plugins/utils/telescope.md | 0 docs/plugins/utils/undotree.md | 0 flake.lock | 19 +-- flake.nix | 14 +-- modules/highlights.nix | 5 +- modules/keymaps.nix | 4 +- modules/options.nix | 5 +- plugins/colorschemes/base16.nix | 1 + plugins/colorschemes/tokyonight.nix | 3 +- 41 files changed, 55 insertions(+), 552 deletions(-) create mode 100644 docs.nix delete mode 100644 docs/default.nix delete mode 100644 docs/man-nixvim.xml delete mode 100644 docs/man-pages.xml delete mode 100644 docs/manual.xml delete mode 100644 docs/plugins.md delete mode 100644 docs/plugins/colorschemes/base16.md delete mode 100644 docs/plugins/colorschemes/gruvbox.md delete mode 100644 docs/plugins/colorschemes/one.md delete mode 100644 docs/plugins/colorschemes/onedark.md delete mode 100644 docs/plugins/colorschemes/tokyonight.md delete mode 100644 docs/plugins/git/fugitive.md delete mode 100644 docs/plugins/git/gitgutter.md delete mode 100644 docs/plugins/languages/ledger.md delete mode 100644 docs/plugins/languages/nix.md delete mode 100644 docs/plugins/languages/treesitter.md delete mode 100644 docs/plugins/languages/zig.md delete mode 100644 docs/plugins/nvim-lsp/clangd.md delete mode 100644 docs/plugins/nvim-lsp/default.md delete mode 100644 docs/plugins/nvim-lsp/lspsaga.md delete mode 100644 docs/plugins/nvim-lsp/rnix-lsp.md delete mode 100644 docs/plugins/nvim-lsp/rust-analyzer.md delete mode 100644 docs/plugins/pluginmanagers/packer.md delete mode 100644 docs/plugins/statuslines/airline.md delete mode 100644 docs/plugins/statuslines/lightline.md delete mode 100644 docs/plugins/utils/barbar.md delete mode 100644 docs/plugins/utils/commentary.md delete mode 100644 docs/plugins/utils/endwise.md delete mode 100644 docs/plugins/utils/goyo.md delete mode 100644 docs/plugins/utils/nvim-autopairs.md delete mode 100644 docs/plugins/utils/startify.md delete mode 100644 docs/plugins/utils/telescope.md delete mode 100644 docs/plugins/utils/undotree.md diff --git a/.circleci/config.yml b/.circleci/config.yml index a5ff3b18..119e012c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,4 +56,4 @@ workflows: - build-docs filters: branches: - only: main \ No newline at end of file + only: main diff --git a/docs.nix b/docs.nix new file mode 100644 index 00000000..4c27d66c --- /dev/null +++ b/docs.nix @@ -0,0 +1,35 @@ +{ pkgs, lib, modules, ... }: +let + options = lib.evalModules { + modules = modules; + 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 + options = lib.filterAttrs (k: _: k != "_module") options.options; + warningsAreErrors = false; + }; + asciidoc = docs.optionsAsciiDoc; +in +pkgs.stdenv.mkDerivation { + name = "nixvim-docs"; + + src = asciidoc; + buildInputs = [ + pkgs.asciidoctor + ]; + + phases = [ "buildPhase" ]; + + buildPhase = '' + mkdir -p $out/share + 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/index.html + ''; +} diff --git a/docs/default.nix b/docs/default.nix deleted file mode 100644 index 5601e5f6..00000000 --- a/docs/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ pkgs ? import { } -, lib ? import -, nmdSrc -, nixvimModules ? [ ] -, ... -}: -let - nmd = import nmdSrc { inherit pkgs lib; }; - scrubbedPkgsModule = { - imports = [{ - _module.args = { - pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs); - pkgs_i686 = lib.mkForce { }; - }; - }]; - }; - buildModulesDocs = args: - nmd.buildModulesDocs ({ - moduleRootPaths = [ ./.. ]; - mkModuleUrl = path: - "https://github.com/pta2002/nixvim/blob/main/${path}#blob-path"; - channelName = "nixvim"; - } // args); - nixvimDocs = buildModulesDocs { - modules = [ - scrubbedPkgsModule - ] ++ nixvimModules; - docBook.id = "nixvim-options"; - }; - - docs = nmd.buildDocBookDocs { - pathName = ""; - modulesDocs = [ nixvimDocs ]; - documentsDirectory = ./.; - documentType = "book"; - chunkToc = '' - - - - - - - ''; - }; -in -# TODO: Parse this json or something, since docbook isn't working (and it's kind of terrible anyway) -nixvimDocs.json - diff --git a/docs/man-nixvim.xml b/docs/man-nixvim.xml deleted file mode 100644 index de162807..00000000 --- a/docs/man-nixvim.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - nixvim.nix - 5 - NixVim - - - - nixvim.nix - NixVim configuration specification - - - Description - - TODO - - - - Options - - You can use the following options in your nixvim config - - - - diff --git a/docs/man-pages.xml b/docs/man-pages.xml deleted file mode 100644 index 9d4c1ce8..00000000 --- a/docs/man-pages.xml +++ /dev/null @@ -1,11 +0,0 @@ - - NixVim Reference Pages - - NixVim contributors - 2021-2022NixVim contributors - - - - diff --git a/docs/manual.xml b/docs/manual.xml deleted file mode 100644 index 090643d3..00000000 --- a/docs/manual.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - NixVim Manual - - - Preface - - This manual is meant to serve as the ultimate reference for how to use and install NixVim. - - - If you have any issues, questions, or plugin suggestions please open an issue on the - NixVim GitHub - - - - Configuration Options - - - diff --git a/docs/plugins.md b/docs/plugins.md deleted file mode 100644 index 954ca512..00000000 --- a/docs/plugins.md +++ /dev/null @@ -1,29 +0,0 @@ -# List of plugins for NixVim - -## Colorschemes -### Gruvbox - -Just set `enable` to use the colorscheme. - -```nix -programs.nixvim.colorscheme.gruvbox.enable = true; -``` - -## Status lines -### Lightline -Lightline is a small and customizable status line for vim. It can be enabled -with `programs.nixvim.plugins.lightline.enable`, and it will try to use the -colorscheme set by the user. If you want to manually override this, set -`programs.nixvim.plugins.lightline.colorscheme` to the name of the colorscheme -to use. - -```nix -programs.nixvim.plugins.lightline = { - enable = true; # Enable this plugin - - # This can be set to null to reset. Defaults to global colorscheme - colorscheme = "wombat"; - - # ... -}; -``` diff --git a/docs/plugins/colorschemes/base16.md b/docs/plugins/colorschemes/base16.md deleted file mode 100644 index 04ce3441..00000000 --- a/docs/plugins/colorschemes/base16.md +++ /dev/null @@ -1,155 +0,0 @@ -# base16 -Base16 is a set of colorschemes, so it comes with several themes you can choose from: - - - 3024 - - apathy - - ashes - - atelier-cave-light - - atelier-cave - - atelier-dune-light - - atelier-dune - - atelier-estuary-light - - atelier-estuary - - atelier-forest-light - - atelier-forest - - atelier-heath-light - - atelier-heath - - atelier-lakeside-light - - atelier-lakeside - - atelier-plateau-light - - atelier-plateau - - atelier-savanna-light - - atelier-savanna - - atelier-seaside-light - - atelier-seaside - - atelier-sulphurpool-light - - atelier-sulphurpool - - atlas - - bespin - - black-metal-bathory - - black-metal-burzum - - black-metal-dark-funeral - - black-metal-gorgoroth - - black-metal-immortal - - black-metal-khold - - black-metal-marduk - - black-metal-mayhem - - black-metal-nile - - black-metal-venom - - black-metal - - brewer - - bright - - brogrammer - - brushtrees-dark - - brushtrees - - chalk - - circus - - classic-dark - - classic-light - - codeschool - - cupcake - - cupertino - - darktooth - - default-dark - - default-light - - dracula - - eighties - - embers - - flat - - fruit-soda - - github - - google-dark - - google-light - - grayscale-dark - - grayscale-light - - greenscreen - - gruvbox-dark-hard - - gruvbox-dark-medium - - gruvbox-dark-pale - - gruvbox-dark-soft - - gruvbox-light-hard - - gruvbox-light-medium - - gruvbox-light-soft - - harmonic-dark - - harmonic-light - - heetch-light - - heetch - - helios - - hopscotch - - horizon-dark - - ia-dark - - ia-light - - icy - - irblack - - isotope - - macintosh - - marrakesh - - material-darker - - material-lighter - - material-palenight - - material - - material-vivid - - materia - - mellow-purple - - mexico-light - - mocha - - monokai - - nord - - oceanicnext - - ocean - - onedark - - one-light - - outrun-dark - - papercolor-dark - - papercolor-light - - paraiso - - phd - - pico - - pop - - porple - - railscasts - - rebecca - - seti - - shapeshifter - - snazzy - - solarflare - - solarized-dark - - solarized-light - - spacemacs - - summerfruit-dark - - summerfruit-light - - synth-midnight-dark - - tomorrow-night-eighties - - tomorrow-night - - tomorrow - - tube - - twilight - - unikitty-dark - - unikitty-light - - woodland - - xcode-dusk - - zenburn - -More information can be found on the official base16 website, [here](http://chriskempson.com/projects/base16/). - -## Options - -### `colorschemes.base16.enable` -**Description**: Enables base16 - -**Type**: `bool` - -### `colorschemes.base16.useTruecolor` -**Description**: Whether to use truecolor for the colorschemes. If set to -false, you'll need to set up base16 in your shell. - -**Type**: `bool` - -**Default**: `true` - -### `colorschemes.base16.setUpBar` -**Description**: Whether to install the matching plugin for your statusbar. This does nothing as of yet, waiting for upstream support. - -**Type**: `bool` - -**Default**: `true` diff --git a/docs/plugins/colorschemes/gruvbox.md b/docs/plugins/colorschemes/gruvbox.md deleted file mode 100644 index b7e8880e..00000000 --- a/docs/plugins/colorschemes/gruvbox.md +++ /dev/null @@ -1,144 +0,0 @@ -# gruvbox -This plugin sets up the `gruvbox` colorscheme. - -## Options -### `colorschemes.gruvbox.enable` -**Description**: Enable gruvbox - -**Type**: `bool` - -### `colorschemes.gruvbox.italics` -**Description**: Enable italics - -**Type**: `bool` - -### `colorschemes.gruvbox.bold` -**Description**: Enable bold - -**Type**: `bool` - -### `colorschemes.gruvbox.underline` -**Description**: Enable underlined text - -**Type**: `bool` - -### `colorschemes.gruvbox.undercurl` -**Description**: Enable undercurled text - -**Type**: `bool` - -### `colorschemes.gruvbox.contrastDark` -**Description**: Contrast for the dark mode - -**Type**: `nullOr (enum [ "soft" "medium" "hard" ])` - -**Default**: `null` - -### `colorschemes.gruvbox.contrastLight` -**Type**: `nullOr (enum [ "soft" "medium" "hard" ])` - -**Default**: `null` - -**Description**: "Contrast for the light mode"; - -### `colorschemes.gruvbox.highlightSearchCursor` -**Type**: `nullOr colors` - -**Default**: `null` - -**Description**: "The cursor background while search is highlighted"; - -### `colorschemes.gruvbox.numberColumn` -**Description**: The number column background - -**Type**: `nullOr colors` - -**Default**: `null` - -### `colorschemes.gruvbox.signColumn` -**Description**: "The sign column background"; - -**Type**: `nullOr colors` - -**Default**: `null` - -### `colorschemes.gruvbox.colorColumn` -**Description**: "The color column background"; - -**Type**: `nullOr colors` - -**Default**: `null` - -### `colorschemes.gruvbox.vertSplitColor` -**Description**: "The vertical split background color"; - -**Type**: `nullOr colors` - -**Default**: `null` - -### `colorschemes.gruvbox.italicizeComments` -**Description**: "Italicize comments"; - -**Type**: `bool` - -**Default**: `true` - -### `colorschemes.gruvbox.italicizeStrings` -**Description**: "Italicize strings"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.invertSelection` -**Description**: "Invert the select text"; - -**Type**: `bool` - -**Default**: `true` - -### `colorschemes.gruvbox.invertSigns` -**Description**: "Invert GitGutter and Syntastic signs"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.invertIndentGuides` -**Description**: "Invert indent guides"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.invertTabline` -**Description**: "Invert tabline highlights"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.improvedStrings` -**Description**: "Improved strings"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.improvedWarnings` -**Description**: "Improved warnings"; - -**Type**: `bool` - -**Default**: `false` - -### `colorschemes.gruvbox.transparentBg` -**Description**: Transparent background - -**Type**: `bool` - -### `colorschemes.gruvbox.trueColor` -**Description**: Enable true color support - -**Type**: `bool` - diff --git a/docs/plugins/colorschemes/one.md b/docs/plugins/colorschemes/one.md deleted file mode 100644 index 2fa8db13..00000000 --- a/docs/plugins/colorschemes/one.md +++ /dev/null @@ -1,6 +0,0 @@ -# vim-one -## Options -### `colorschemes.one.enable` -**Description**: Enable vim-one - -**Type**: `bool` diff --git a/docs/plugins/colorschemes/onedark.md b/docs/plugins/colorschemes/onedark.md deleted file mode 100644 index 92621b25..00000000 --- a/docs/plugins/colorschemes/onedark.md +++ /dev/null @@ -1,6 +0,0 @@ -# onedark -## Options -### `colorschemes.onedark.enable` -**Description**: Enable onedark - -**Type**: `bool` diff --git a/docs/plugins/colorschemes/tokyonight.md b/docs/plugins/colorschemes/tokyonight.md deleted file mode 100644 index efb53b11..00000000 --- a/docs/plugins/colorschemes/tokyonight.md +++ /dev/null @@ -1,70 +0,0 @@ -# tokyonight -This plugin sets up the `tokyonight` colorscheme. - -## Options -### `colorschemes.tokyonight.enable` -**Description**: Enable tokyonight - -**Type***: `bool` - -### `colorschemes.tokyonight.style` -**Description**: Theme style - -**Type**: `nullOr (enum [ "storm" "night" "day" ])` - -**Default**: `null` - -### `colorschemes.tokyonight.terminalColors` -**Description**: Configure the colors used when opening a `:terminal` in Neovim - -**Type**: `bool` - -### `colorschemes.tokyonight.italicComments` -**Description**: Make comments italic - -**Type**: `bool` - -### `colorschemes.tokyonight.italicKeywords` -**Description**: Make keywords italic - -**Type**: `bool` - -### `colorschemes.tokyonight.italicFunctions` -**Description**: Make functions italic - -**Type**: `bool` - -### `colorschemes.tokyonight.italicVariables` -**Description**: Make variables and identifiers italic - -**Type**: `bool` - -### `colorschemes.tokyonight.transparent` -**Description**: Enable this to disable setting the background color - -**Type**: `bool` - -### `colorschemes.tokyonight.hideInactiveStatusline` -**Description**: Enabling this option will hide inactive statuslines and replace them with a thin border - -**Type**: `bool` - -### `colorschemes.tokyonight.transparentSidebar` -**Description**: Sidebar like windows like NvimTree get a transparent background - -**Type**: `bool` - -### `colorschemes.tokyonight.darkSidebar` -**Description**: Sidebar like windows like NvimTree get a darker background - -**Type**: `bool` - -### `colorschemes.tokyonight.darkFloat` -**Description**: Float windows like the lsp diagnostic windows get a darker background - -**Type**: `bool` - -### `colorschemes.tokyonight.lualineBold` -**Description**: When true, section headers in the lualine theme will be bold - -**Type**: `bool` diff --git a/docs/plugins/git/fugitive.md b/docs/plugins/git/fugitive.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/git/gitgutter.md b/docs/plugins/git/gitgutter.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/ledger.md b/docs/plugins/languages/ledger.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/nix.md b/docs/plugins/languages/nix.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/treesitter.md b/docs/plugins/languages/treesitter.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/zig.md b/docs/plugins/languages/zig.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/clangd.md b/docs/plugins/nvim-lsp/clangd.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/default.md b/docs/plugins/nvim-lsp/default.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/lspsaga.md b/docs/plugins/nvim-lsp/lspsaga.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/rnix-lsp.md b/docs/plugins/nvim-lsp/rnix-lsp.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/rust-analyzer.md b/docs/plugins/nvim-lsp/rust-analyzer.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/pluginmanagers/packer.md b/docs/plugins/pluginmanagers/packer.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/statuslines/airline.md b/docs/plugins/statuslines/airline.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/statuslines/lightline.md b/docs/plugins/statuslines/lightline.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/barbar.md b/docs/plugins/utils/barbar.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/commentary.md b/docs/plugins/utils/commentary.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/endwise.md b/docs/plugins/utils/endwise.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/goyo.md b/docs/plugins/utils/goyo.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/nvim-autopairs.md b/docs/plugins/utils/nvim-autopairs.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/startify.md b/docs/plugins/utils/startify.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/telescope.md b/docs/plugins/utils/telescope.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/undotree.md b/docs/plugins/utils/undotree.md deleted file mode 100644 index e69de29b..00000000 diff --git a/flake.lock b/flake.lock index 96a9886f..c4dfdf24 100644 --- a/flake.lock +++ b/flake.lock @@ -51,22 +51,6 @@ "type": "indirect" } }, - "nmdSrc": { - "flake": false, - "locked": { - "lastModified": 1666190571, - "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", - "owner": "rycee", - "repo": "nmd", - "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, "poetry2nix": { "inputs": { "flake-utils": [ @@ -96,8 +80,7 @@ "inputs": { "beautysh": "beautysh", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "nmdSrc": "nmdSrc" + "nixpkgs": "nixpkgs" } }, "utils": { diff --git a/flake.nix b/flake.nix index a2698286..1e48a65c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,13 +3,10 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nmdSrc.url = "gitlab:rycee/nmd"; - inputs.nmdSrc.flake = false; - inputs.beautysh.url = "github:lovesegfault/beautysh"; inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs"; - outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs: + outputs = { self, nixpkgs, flake-utils, ... }@inputs: with nixpkgs.lib; with builtins; let @@ -30,7 +27,7 @@ }; }) - ./plugins/default.nix + # ./plugins/default.nix ]; flakeOutput = @@ -40,11 +37,8 @@ pkgs = import nixpkgs { inherit system; }; in { - packages.docs = import ./docs { - pkgs = import nixpkgs { inherit system; }; - lib = nixpkgs.lib; - nixvimModules = nixvimModules; - inherit nmdSrc; + packages.docs = pkgs.callPackage (import ./docs.nix) { + modules = nixvimModules; }; legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs); diff --git a/modules/highlights.nix b/modules/highlights.nix index 7ba9297a..0f5fc1f0 100644 --- a/modules/highlights.nix +++ b/modules/highlights.nix @@ -1,4 +1,7 @@ -{ config, lib, helpers, ... }: +{ config, lib, ... }: +let + helpers = import ../plugins/helpers.nix { inherit lib; }; +in with lib; { options = { diff --git a/modules/keymaps.nix b/modules/keymaps.nix index b6426a9b..fa4787dc 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -1,6 +1,8 @@ -{ config, lib, helpers, ... }: +{ config, lib, ... }: with lib; let + helpers = import ../plugins/helpers.nix { inherit lib; }; + mapOption = types.oneOf [ types.str (types.submodule { diff --git a/modules/options.nix b/modules/options.nix index 76bceeb1..d3de54c0 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -1,5 +1,8 @@ -{ config, lib, helpers, ... }: +{ config, lib, ... }: with lib; +let + helpers = import ../plugins/helpers.nix { inherit lib; }; +in { options = { options = mkOption { diff --git a/plugins/colorschemes/base16.nix b/plugins/colorschemes/base16.nix index 218be191..34ae17a2 100644 --- a/plugins/colorschemes/base16.nix +++ b/plugins/colorschemes/base16.nix @@ -18,6 +18,7 @@ in colorscheme = mkOption { type = types.enum themes; description = "The base16 colorscheme to use"; + default = head themes; }; setUpBar = mkOption { diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix index 2054ef56..6d47bddd 100644 --- a/plugins/colorschemes/tokyonight.nix +++ b/plugins/colorschemes/tokyonight.nix @@ -1,8 +1,9 @@ -{ pkgs, config, lib, helpers, ... }: +{ pkgs, config, lib, ... }: with lib; let cfg = config.colorschemes.tokyonight; style = types.enum [ "storm" "night" "day" ]; + helpers = import ../helpers.nix { inherit lib; }; in { options = { From 498986d90ac76dda81173c171af3085da5ff6215 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 29 Dec 2022 17:36:54 +0000 Subject: [PATCH 43/61] docs: fix CI documentation generation --- docs.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs.nix b/docs.nix index 4c27d66c..fff79cd8 100644 --- a/docs.nix +++ b/docs.nix @@ -22,7 +22,7 @@ pkgs.stdenv.mkDerivation { phases = [ "buildPhase" ]; buildPhase = '' - mkdir -p $out/share + mkdir -p $out/share/doc cat < header.adoc = NixVim options This lists all the options available for NixVim. @@ -30,6 +30,6 @@ pkgs.stdenv.mkDerivation { EOF cat header.adoc $src > tmp.adoc - asciidoctor tmp.adoc -o $out/share/index.html + asciidoctor tmp.adoc -o $out/share/doc/index.html ''; } From 4dedb06cebed9e43de1bbda2197fb7a6989eef8f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 29 Dec 2022 17:40:39 +0000 Subject: [PATCH 44/61] readme: update to reflect documentation home --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5285e36..27ad1983 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,8 @@ Since everything is disabled by default, it will be as snappy as you want it to be. # Documentation -Documentation is very much a work-in-progress. It will become available on this -repository's Wiki. +Documentation is available on this project's GitHub Pages page: +[https://pta2002.github.io/nixvim](https://pta2002.github.io/nixvim) ## Plugins After you have installed NixVim, you will no doubt want to enable some plugins. From 660c9319e1b05c5066f21bef0fc8a88ae504d6b5 Mon Sep 17 00:00:00 2001 From: traxys Date: Thu, 29 Dec 2022 18:51:57 +0100 Subject: [PATCH 45/61] wrappers: Extend and document the `makeNixvim` function (#86) * wrappers: Allow to customize the nixpkgs used for nixvim This allows to pass overlays and other such modifications of nixpkgs. * wrappers: Allow to pass a custom module to nixvim This is useful to be able to take full advantage of the Nix module system, with `imports` and `options`. * README: Update the documentation on the standalone usage The following information were out of date or incomplete: - The `build` function has be changed to the `makeNixvim` function. - `makeNixvimWithModule` has been introduced in order to allow more customization. - Added a full example using nixvim in a standalone flake --- README.md | 56 ++++++++++++++++++++++++++++++++++++++--- flake.nix | 10 ++++++-- wrappers/standalone.nix | 4 +-- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 27ad1983..222078f5 100644 --- a/README.md +++ b/README.md @@ -80,23 +80,73 @@ you're not using it. ## Usage NixVim can be used in three ways: through the home-manager and NixOS modules, -and through the `build` function. To use the modules, just import the +and through the `makeNixvim` function. To use the modules, just import the `nixvim.homeManagerModules.${system}.nixvim` and `nixvim.nixosModules.${system}.nixvim` modules, depending on which system you're using. -If you want to use it standalone, you can use the `build` function: +If you want to use it standalone, you can use the `makeNixvim` function: ```nix { pkgs, nixvim, ... }: { environment.systemModules = [ - (nixvim.build pkgs { + (nixvim.legacyPackages."${system}".makeNixvim { colorschemes.gruvbox.enable = true; }) ]; } ``` +Alternatively if you want a minimal flake to allow building a custom neovim you +can use the following: + +```nix +{ + description = "A very basic flake"; + + inputs.nixvim.url = "github:pta2002/nixvim"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { + self, + nixpkgs, + nixvim, + flake-utils, + }: let + config = { + colorschemes.gruvbox.enable = true; + }; + in + flake-utils.lib.eachDefaultSystem (system: let + nixvim' = nixvim.legacyPackages."${system}"; + nvim = nixvim'.makeNixvim config; + in { + packages = { + inherit nvim; + default = nvim; + }; + }); +} +``` + +You can then run neovim using `nix run .# -- `. This can be useful to test +config changes easily. + +### Advanced Usage + +You may want more control over the nixvim modules like: + +- Splitting your configuration in multiple files +- Adding custom nix modules to enhance nixvim +- Change the nixpkgs used by nixvim + +In this case you can use the `makeNixvimWithModule` function. + +It takes a set with the following keys: +- `pkgs`: The nixpkgs to use (defaults to the nixpkgs pointed at by the nixvim flake) +- `module`: The nix module definition used to extend nixvim. + This is useful to pass additional module machinery like `options` or `imports`. + ## How does it work? When you build the module (probably using home-manager), it will install all your plugins and generate a lua config for NeoVim with all the options diff --git a/flake.nix b/flake.nix index 1e48a65c..11760619 100644 --- a/flake.nix +++ b/flake.nix @@ -40,8 +40,14 @@ packages.docs = pkgs.callPackage (import ./docs.nix) { modules = nixvimModules; }; - - legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs); + legacyPackages = rec { + makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules; + makeNixvim = configuration: makeNixvimWithModule { + module = { + config = configuration; + }; + }; + }; }); in flakeOutput // { diff --git a/wrappers/standalone.nix b/wrappers/standalone.nix index a21cd33b..20fb9667 100644 --- a/wrappers/standalone.nix +++ b/wrappers/standalone.nix @@ -1,4 +1,4 @@ -pkgs: modules: configuration: +default_pkgs: modules: {pkgs ? default_pkgs, module}: let @@ -7,7 +7,7 @@ let wrap = { wrapRc = true; }; eval = lib.evalModules { - modules = modules ++ [ { config = configuration; } wrap ]; + modules = (modules pkgs) ++ [ module wrap ]; }; in eval.config.finalPackage From de9a5913d2a8967612b55e37f0b42e2316d7b579 Mon Sep 17 00:00:00 2001 From: volkswagenfeature Date: Fri, 30 Dec 2022 10:02:59 -0500 Subject: [PATCH 46/61] magma-vnim: init * Added magma-nvim skeleton * Added magma-nvim options * formatting, suggestions Co-authored-by: tristan BetaBlue-NixOS-2022 --- plugins/default.nix | 1 + plugins/plugin-defs.nix | 40 ++++++++++++- plugins/utils/magma-nvim.nix | 111 +++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 plugins/utils/magma-nvim.nix diff --git a/plugins/default.nix b/plugins/default.nix index 34434ea0..ca984a64 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -60,5 +60,6 @@ ./utils/undotree.nix ./utils/dashboard.nix ./utils/emmet.nix + ./utils/magma-nvim.nix ]; } diff --git a/plugins/plugin-defs.nix b/plugins/plugin-defs.nix index d6e9cda3..52064873 100644 --- a/plugins/plugin-defs.nix +++ b/plugins/plugin-defs.nix @@ -53,7 +53,7 @@ pname = "std2"; version = "48bb39b69ed631ef64eed6123443484133fd20fc"; - doCheck = false; + doCheck = true; src = pkgs.fetchFromGitHub { owner = "ms-jpq"; @@ -84,4 +84,42 @@ sha256 = "sha256-AtkG2XRVZgvJzH2iLr7UT/U1+LXxenvNckdapnJV+8A="; }; }; + + magma-nvim = pkgs.vimUtils.buildVimPlugin rec { + pname = "magma-nvim"; + version = "94370733757d550594fe4a1d65643949d7485989"; + + src = pkgs.fetchFromGitHub { + owner = "WhiteBlackGoose"; + repo = "magma-nvim-goose"; + rev = version; + 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"; + }; + }) + ]; + }; } diff --git a/plugins/utils/magma-nvim.nix b/plugins/utils/magma-nvim.nix new file mode 100644 index 00000000..67fa1358 --- /dev/null +++ b/plugins/utils/magma-nvim.nix @@ -0,0 +1,111 @@ +{ pkgs, lib, config, ... }: +with lib; +let + cfg = config.plugins.magma-nvim; + plugins = import ../plugin-defs.nix { inherit pkgs; }; + package = pkgs.fetchFromGitHub { + 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" ]; + default = "none"; + example = "ueberzug"; + 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."; + }; + automatically_open_output = mkOption { + 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. + 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."; + }; + + wrap_output = mkOption { + 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)."; + }; + + 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."; + }; + + cell_highlight_group = mkOption { + type = types.str; + default = "CursorLine"; + # example = ""; + 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). + 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. + This is meant for debugging and adding new mimetypes."; + }; + package = mkOption { + type = types.nullOr types.package; + default = null; + 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 + )]; + + + globals = { + magma_image_provider = + mkIf (cfg.image_provider != "none") cfg.image_provider; + magma_automatically_open_output = + mkIf (!cfg.automatically_open_output) cfg.automatically_open_output; + 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") + cfg.cell_highlight_group; + magma_show_mimetype_debug = + mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug; + + }; + }; + +} + From 7807c51ccf438d3a76f8ae9d16bf21cf4a3b3a50 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 30 Dec 2022 21:12:07 +0100 Subject: [PATCH 47/61] nixvim: add nix-darwin wrapper --- README.md | 15 ++++++++------ flake.nix | 1 + tests/flake.lock | 50 ++++++++------------------------------------- wrappers/darwin.nix | 30 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 wrappers/darwin.nix diff --git a/README.md b/README.md index 222078f5..885ca31a 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,12 @@ let in { imports = [ + # For home-manager nixvim.homeManagerModules.nixvim - # Or, if you're not using home-manager: + # For NixOS nixvim.nixosModules.nixvim + # For nix-darwin + nixvim.nixDarwinModules.nixvim ]; programs.nixvim.enable = true; @@ -75,14 +78,14 @@ flakes, just add the nixvim input: ``` You can now access the module using `inputs.nixvim.homeManagerModules.nixvim`, -for a home-manager instalation, and `inputs.nixvim.nixosModules.nixvim`, if -you're not using it. +for a home-manager instalation, `inputs.nixvim.nixosModules.nixvim`, for NixOS, +and `inputs.nixvim.nixDarwinModules.nixvim` for nix-darwin. ## Usage -NixVim can be used in three ways: through the home-manager and NixOS modules, +NixVim can be used in four ways: through the home-manager, nix-darwin, and NixOS modules, and through the `makeNixvim` function. To use the modules, just import the -`nixvim.homeManagerModules.${system}.nixvim` and -`nixvim.nixosModules.${system}.nixvim` modules, depending on which system +`nixvim.homeManagerModules.nixvim`, `nixvim.nixDarwinModules.nixvim`, and +`nixvim.nixosModules.nixvim` modules, depending on which system you're using. If you want to use it standalone, you can use the `makeNixvim` function: diff --git a/flake.nix b/flake.nix index 11760619..ac6957c2 100644 --- a/flake.nix +++ b/flake.nix @@ -53,5 +53,6 @@ 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/tests/flake.lock b/tests/flake.lock index 7fc1ef8c..1a49f821 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -203,17 +203,16 @@ "inputs": { "beautysh": "beautysh", "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_3", - "nmdSrc": "nmdSrc" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 0, - "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" }, "original": { - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" } }, @@ -223,52 +222,19 @@ "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs-stable" - ], - "nmdSrc": "nmdSrc_2" + ] }, "locked": { "lastModified": 0, - "narHash": "sha256-x6+KGgpSlPfBvI8YG3hf3lN5FKhJdeLyXDmQdLk34cE=", - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" }, "original": { - "path": "/nix/store/l49ggcslcfsav82lgfb5dzw4a2qajfnp-source", + "path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source", "type": "path" } }, - "nmdSrc": { - "flake": false, - "locked": { - "lastModified": 1666190571, - "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", - "owner": "rycee", - "repo": "nmd", - "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, - "nmdSrc_2": { - "flake": false, - "locked": { - "lastModified": 1666190571, - "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", - "owner": "rycee", - "repo": "nmd", - "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", - "type": "gitlab" - }, - "original": { - "owner": "rycee", - "repo": "nmd", - "type": "gitlab" - } - }, "poetry2nix": { "inputs": { "flake-utils": [ diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix new file mode 100644 index 00000000..75365711 --- /dev/null +++ b/wrappers/darwin.nix @@ -0,0 +1,30 @@ +modules: +{ pkgs, config, lib, ... }: + +let + inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; + cfg = config.programs.nixvim; +in +{ + options = { + programs.nixvim = mkOption { + type = types.submodule ((modules pkgs) ++ [{ + options.enable = mkEnableOption "nixvim"; + config.wrapRc = mkForce true; + }]); + }; + nixvim.helpers = mkOption { + type = mkOptionType { + name = "helpers"; + description = "Helpers that can be used when writing nixvim configs"; + check = builtins.isAttrs; + }; + description = "Use this option to access the helpers"; + default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.finalPackage ]; + }; +} From 30fc8b4f43b261bb534c95aa3d814e9b3c1cd8f8 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 30 Dec 2022 21:21:59 +0100 Subject: [PATCH 48/61] gitsigns: init plugin (#99) --- plugins/default.nix | 1 + plugins/git/gitsigns.nix | 433 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 434 insertions(+) create mode 100644 plugins/git/gitsigns.nix diff --git a/plugins/default.nix b/plugins/default.nix index ca984a64..01c68e6d 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -18,6 +18,7 @@ ./git/fugitive.nix ./git/gitgutter.nix + ./git/gitsigns.nix ./git/neogit.nix ./languages/ledger.nix diff --git a/plugins/git/gitsigns.nix b/plugins/git/gitsigns.nix new file mode 100644 index 00000000..368c5f9f --- /dev/null +++ b/plugins/git/gitsigns.nix @@ -0,0 +1,433 @@ +{ + config, + lib, + pkgs, + helpers, + ... +}: +with lib; let + signOptions = defaults: + with types; { + hl = mkOption { + type = str; + description = "Specifies the highlight group to use for the sign"; + default = defaults.hl; + }; + text = mkOption { + type = str; + description = "Specifies the character to use for the sign"; + default = defaults.text; + }; + numhl = mkOption { + type = str; + description = "Specifies the highlight group to use for the number column"; + default = defaults.numhl; + }; + linehl = mkOption { + type = str; + description = "Specifies the highlight group to use for the line"; + default = defaults.linehl; + }; + showCount = mkEnableOption "Enable showing count of hunk, e.g. number of deleted lines"; + }; + signSetupOptions = values: { + inherit (values) hl text numhl linehl; + show_count = values.showCount; + }; + + luaFunction = types.submodule { + options.function = mkOption { + type = types.str; + description = "Lua function definition"; + }; + }; +in { + options.plugins.gitsigns = { + enable = mkEnableOption "Enable gitsigns plugin"; + signs = { + add = signOptions { + hl = "GitSignsAdd"; + text = "┃"; + numhl = "GitSignsAddNr"; + linehl = "GitSignsAddLn"; + }; + change = signOptions { + hl = "GitSignsChange"; + text = "┃"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + delete = signOptions { + hl = "GitSignsDelete"; + text = "▁"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + topdelete = signOptions { + hl = "GitSignsDelete"; + text = "▔"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + changedelete = signOptions { + hl = "GitSignsChange"; + text = "~"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + untracked = signOptions { + hl = "GitSignsAdd"; + text = "┆"; + numhl = "GitSignsAddNr"; + linehl = "GitSignsAddLn"; + }; + }; + worktrees = let + worktreeModule = { + options = { + toplevel = mkOption { + type = types.str; + }; + gitdir = mkOption { + type = types.str; + }; + }; + }; + in + mkOption { + type = types.nullOr (types.listOf (types.submodule worktreeModule)); + default = null; + description = '' + Detached working trees. + If normal attaching fails, then each entry in the table is attempted with the work tree + details set. + ''; + }; + onAttach = mkOption { + type = types.nullOr luaFunction; + default = null; + description = '' + Callback called when attaching to a buffer. Mainly used to setup keymaps + when `config.keymaps` is empty. The buffer number is passed as the first + argument. + + This callback can return `false` to prevent attaching to the buffer. + ''; + example = '' + \'\' + function(bufnr) + if vim.api.nvim_buf_get_name(bufnr):match() then + -- Don't attach to specific buffers whose name matches a pattern + return false + end + -- Setup keymaps + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', 'lua require"gitsigns".stage_hunk()', {}) + ... -- More keymaps + end + \'\' + ''; + }; + + watchGitDir = { + enable = mkOption { + type = types.bool; + default = true; + description = "Whether the watcher is enabled"; + }; + interval = mkOption { + type = types.int; + default = 1000; + description = "Interval the watcher waits between polls of the gitdir in milliseconds"; + }; + followFiles = mkOption { + type = types.bool; + default = true; + description = "If a file is moved with `git mv`, switch the buffer to the new location"; + }; + }; + signPriority = mkOption { + type = types.int; + default = 6; + description = "Priority to use for signs"; + }; + signcolumn = mkOption { + type = types.bool; + default = true; + description = '' + Enable/disable symbols in the sign column. + + When enabled the highlights defined in `signs.*.hl` and symbols defined + in `signs.*.text` are used. + ''; + }; + numhl = mkEnableOption '' + Enable/disable line number highlights. + + When enabled the highlights defined in `signs.*.numhl` are used. If + the highlight group does not exist, then it is automatically defined + and linked to the corresponding highlight group in `signs.*.hl`. + ''; + linehl = mkEnableOption '' + Enable/disable line highlights. + + When enabled the highlights defined in `signs.*.linehl` are used. If + the highlight group does not exist, then it is automatically defined + and linked to the corresponding highlight group in `signs.*.hl`. + ''; + showDeleted = mkEnableOption '' + Show the old version of hunks inline in the buffer (via virtual lines). + + Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`. + ''; + diffOpts = let + diffOptModule = { + options = { + algorithm = mkOption { + type = types.enum ["myers" "minimal" "patience" "histogram"]; + default = "myers"; + description = "Diff algorithm to use"; + }; + internal = mkOption { + type = types.bool; + default = false; + description = "Use Neovim's built in xdiff library for running diffs"; + }; + indentHeuristic = mkOption { + type = types.bool; + default = false; + description = "Use the indent heuristic for the internal diff library."; + }; + vertical = mkOption { + type = types.bool; + default = true; + description = "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 + mkOption { + type = types.nullOr (types.submodule diffOptModule); + default = null; + description = "Diff options. If set to null they are derived from the vim diffopt"; + }; + base = mkOption { + type = types.nullOr types.str; + default = null; + description = "The object/revision to diff against. Default to 'index'"; + }; + countChars = mkOption { + type = types.attrsOf types.str; + default = { + "1" = "1"; + "2" = "2"; + "3" = "3"; + "4" = "4"; + "5" = "5"; + "6" = "6"; + "7" = "7"; + "8" = "8"; + "9" = "9"; + "+" = ">"; + }; + description = '' + The count characters used when `signs.*.show_count` is enabled. The + `+` entry is used as a fallback. With the default, any count outside + of 1-9 uses the `>` character in the sign. + + Possible use cases for this field: + • to specify unicode characters for the counts instead of 1-9. + • to define characters to be used for counts greater than 9. + ''; + }; + statusFormatter = mkOption { + type = luaFunction; + default = { + function = '' + function(status) + local added, changed, removed = status.added, status.changed, status.removed + local status_txt = {} + if added and added > 0 then table.insert(status_txt, '+'..added ) end + if changed and changed > 0 then table.insert(status_txt, '~'..changed) end + if removed and removed > 0 then table.insert(status_txt, '-'..removed) end + return table.concat(status_txt, ' ') + end + ''; + }; + description = "Function used to format `b:gitsigns_status`"; + }; + maxFileLength = mkOption { + type = types.int; + default = 40000; + description = "Max file length (in lines) to attach to"; + }; + previewConfig = mkOption { + type = types.attrsOf types.anything; + default = { + border = "single"; + style = "minimal"; + relative = "cursor"; + row = 0; + col = 1; + }; + description = '' + Option overrides for the Gitsigns preview window. + Table is passed directly to `nvim_open_win`. + ''; + }; + attachToUntracked = mkOption { + type = types.bool; + default = true; + description = "Attach to untracked files."; + }; + updateDebounce = mkOption { + type = types.number; + default = 100; + description = "Debounce time for updates (in milliseconds)."; + }; + currentLineBlame = mkEnableOption '' + Adds an unobtrusive and customisable blame annotation at the end of the current line. + ''; + currentLineBlameOpts = { + virtText = mkOption { + type = types.bool; + default = true; + description = "Whether to show a virtual text blame annotation"; + }; + virtTextPos = mkOption { + type = types.enum ["eol" "overlay" "right_align"]; + default = "eol"; + description = "Blame annotation position"; + }; + delay = mkOption { + type = types.int; + default = 1000; + description = "Sets the delay (in milliseconds) before blame virtual text is displayed"; + }; + ignoreWhitespace = mkEnableOption "Ignore whitespace when running blame"; + virtTextPriority = mkOption { + type = types.int; + default = 100; + description = "Priority of virtual text"; + }; + }; + currentLineBlameFormatter = { + normal = mkOption { + type = types.either types.str luaFunction; + default = " , - "; + description = '' + String or function used to format the virtual text of + |gitsigns-config-current_line_blame|. + + See |gitsigns-config-current_line_blame_formatter| for more details. + ''; + }; + + nonCommitted = mkOption { + type = types.either types.str luaFunction; + default = " "; + description = '' + String or function used to format the virtual text of + |gitsigns-config-current_line_blame| for lines that aren't committed. + ''; + }; + }; + trouble = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + When using setqflist() or setloclist(), open Trouble instead of the quickfix/location list + window. + ''; + }; + yadm.enable = mkEnableOption "Enable YADM support"; + wordDiff = mkEnableOption '' + Highlight intra-line word differences in the buffer. + Requires `config.diff_opts.internal = true`. + ''; + debugMode = mkEnableOption '' + Enables debug logging and makes the following functions available: `dump_cache`, + `debug_messages`, `clear_debug`. + ''; + }; + + config = let + cfg = config.plugins.gitsigns; + in + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [ + gitsigns-nvim + ]; + extraConfigLua = let + luaFnOrStrToObj = val: + 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 { + inherit (cfg.diffOpts) algorithm internal vertical linematch; + indent_heuristic = cfg.diffOpts.indentHeuristic; + }; + count_chars = let + isStrInt = s: (builtins.match "[0-9]+" s) != null; + in { + __raw = + "{" + + (concatStringsSep "," ( + lib.mapAttrsToList ( + name: value: + if isStrInt name + then "[${name}] = ${helpers.toLuaObject value}" + else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}" + ) + cfg.countChars + )) + + "}"; + }; + status_formatter = {__raw = cfg.statusFormatter.function;}; + 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; + }; + in '' + require('gitsigns').setup(${helpers.toLuaObject setupOptions}) + ''; + }; +} From 125ed74a423429e5af6796334b68400c78ac26b7 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 30 Dec 2022 22:04:43 +0100 Subject: [PATCH 49/61] null-ls: Add gitsigns code action (#100) As this is not an external command but a plugin it adds the gitsigns plugin if enabled. --- plugins/null-ls/servers.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index 48575425..da44c114 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -2,7 +2,9 @@ let helpers = import ./helpers.nix args; serverData = { - code_actions = { }; + code_actions = { + gitsigns = { }; + }; completion = { }; diagnostics = { flake8 = { @@ -54,4 +56,11 @@ let in { imports = lib.lists.map (helpers.mkServer) dataFlattened; + + config = let + cfg = config.plugins.null-ls; + in + lib.mkIf cfg.enable { + plugins.gitsigns.enable = lib.mkIf (cfg.sources.code_actions.gitsigns.enable) true; + }; } From 1f723e8abd6286f1e489fa0c374ee1be95b0157c Mon Sep 17 00:00:00 2001 From: traxys Date: Thu, 5 Jan 2023 15:23:23 +0100 Subject: [PATCH 50/61] treesitter: add module for treesitter-refactor (#101) As treesitter-refactor is a treesitter module we need a way to pass extra configuration options to the treesitter setup. This is done through a `moduleConfig` attrset. This set should not be used outside nixvim. --- plugins/default.nix | 1 + plugins/languages/treesitter-refactor.nix | 128 ++++++++++++++++++++++ plugins/languages/treesitter.nix | 8 +- 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 plugins/languages/treesitter-refactor.nix diff --git a/plugins/default.nix b/plugins/default.nix index 01c68e6d..4ca0ac62 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -24,6 +24,7 @@ ./languages/ledger.nix ./languages/nix.nix ./languages/treesitter.nix + ./languages/treesitter-refactor.nix ./languages/zig.nix ./null-ls diff --git a/plugins/languages/treesitter-refactor.nix b/plugins/languages/treesitter-refactor.nix new file mode 100644 index 00000000..56b768a3 --- /dev/null +++ b/plugins/languages/treesitter-refactor.nix @@ -0,0 +1,128 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; { + 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 + "Enable treesitter-refactor (requires plugins.treesitter.enable to be true)"; + 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. + ''; + }; + }; + 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"; + }; + }; + }; + 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"; + }; + }; + }; + }; + + config = let + cfg = config.plugins.treesitter-refactor; + in + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-refactor]; + plugins.treesitter.moduleConfig.refactor = { + highlight_definitions = { + inherit (cfg.highlightDefinitions) enable disable; + clear_on_cursor_move = cfg.highlightDefinitions.clearOnCursorMove; + }; + highlight_current_scope = cfg.highlightCurrentScope; + smart_rename = { + inherit (cfg.smartRename) enable disable; + 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; + }; + }; + }; + }; +} diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index e96a68af..a76b44d8 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -71,6 +71,12 @@ in default = pkgs.tree-sitter.allGrammars; description = "Grammar packages to install"; }; + + moduleConfig = mkOption { + type = types.attrsOf types.anything; + default = {}; + description = "This is the configuration for extra modules. It should not be used directly"; + }; }; }; @@ -103,7 +109,7 @@ in ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled; ignore_install = cfg.ignoreInstall; parser_install_dir = cfg.parserInstallDir; - }; + } // cfg.moduleConfig; in mkIf cfg.enable { extraConfigLua = '' From 2f9c21ffc8f470336b671b3caf2b6231db8950c5 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 6 Jan 2023 12:31:54 +0100 Subject: [PATCH 51/61] treesitter: add tree-sitter context plugin (#103) --- plugins/default.nix | 1 + plugins/languages/treesitter-context.nix | 56 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 plugins/languages/treesitter-context.nix diff --git a/plugins/default.nix b/plugins/default.nix index 4ca0ac62..12080028 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -24,6 +24,7 @@ ./languages/ledger.nix ./languages/nix.nix ./languages/treesitter.nix + ./languages/treesitter-context.nix ./languages/treesitter-refactor.nix ./languages/zig.nix diff --git a/plugins/languages/treesitter-context.nix b/plugins/languages/treesitter-context.nix new file mode 100644 index 00000000..35e09ea9 --- /dev/null +++ b/plugins/languages/treesitter-context.nix @@ -0,0 +1,56 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; { + options.plugins.treesitter-context = { + enable = mkEnableOption "Enable nvim-treesitter-context"; + + maxLines = mkOption { + type = types.nullOr types.ints.positive; + default = null; + description = "How many lines the window should span. Null means no limit"; + }; + + trimScope = mkOption { + type = types.enum ["outer" "inner"]; + default = "outer"; + description = "Which context lines to discard if `max_lines` is exceeded"; + }; + + maxWindowHeight = mkOption { + type = types.nullOr types.ints.positive; + default = null; + description = "Minimum editor window height to enable context"; + }; + + patterns = mkOption { + type = types.attrsOf (types.listOf types.str); + default = {}; + description = '' + Patterns to use for context delimitation. The 'default' key matches all filetypes + ''; + }; + + exactPatterns = mkOption { + type = types.attrsOf types.bool; + default = {}; + description = "Treat the coresponding entry in patterns as an exact match"; + }; + }; + + config = let + cfg = config.plugins.treesitter-context; + in + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-context]; + + plugins.treesitter.moduleConfig.context = { + max_lines = cfg.maxLines; + trim_scope = cfg.trimScope; + min_window_height = cfg.maxWindowHeight; + }; + }; +} From 7713f5d4414e73616651f5df2c1a2de674c9faaf Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 6 Jan 2023 16:14:30 +0100 Subject: [PATCH 52/61] plantuml: init syntax plugin (#104) --- plugins/default.nix | 1 + plugins/languages/plantuml-syntax.nix | 33 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 plugins/languages/plantuml-syntax.nix diff --git a/plugins/default.nix b/plugins/default.nix index 12080028..551a8bd2 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -23,6 +23,7 @@ ./languages/ledger.nix ./languages/nix.nix + ./languages/plantuml-syntax.nix ./languages/treesitter.nix ./languages/treesitter-context.nix ./languages/treesitter-refactor.nix diff --git a/plugins/languages/plantuml-syntax.nix b/plugins/languages/plantuml-syntax.nix new file mode 100644 index 00000000..edfcab53 --- /dev/null +++ b/plugins/languages/plantuml-syntax.nix @@ -0,0 +1,33 @@ +{ + pkgs, + lib, + config, + ... +}: +with lib; { + options.plugins.plantuml-syntax = { + enable = mkEnableOption "Enable plantuml syntax support"; + setMakeprg = mkOption { + type = types.bool; + default = true; + description = "Set the makeprg to 'plantuml'"; + }; + executableScript = mkOption { + type = types.nullOr types.str; + default = null; + description = "Set the script to be called with makeprg, default to 'plantuml' in PATH"; + }; + }; + + config = let + cfg = config.plugins.plantuml-syntax; + in + mkIf cfg.enable { + extraPlugins = with pkgs.vimPlugins; [plantuml-syntax]; + + globals = { + plantuml_set_makeprg = cfg.setMakeprg; + plantuml_executable_script = cfg.executableScript; + }; + }; +} From 7827947ca9369e1b11bca76434bd093e5cceea86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:38:25 +0100 Subject: [PATCH 53/61] readme: fix typos (#106) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 885ca31a..9fd24d66 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ gruvbox as the colorscheme, no extra configuration required! ## Support/Questions If you have any question, please use the [discussions page](https://github.com/pta2002/nixvim/discussions/categories/q-a)! -## Instalation +## Installation ### Without flakes NixVim now ships with `flake-compat`, which makes it usable from any system. @@ -78,7 +78,7 @@ flakes, just add the nixvim input: ``` You can now access the module using `inputs.nixvim.homeManagerModules.nixvim`, -for a home-manager instalation, `inputs.nixvim.nixosModules.nixvim`, for NixOS, +for a home-manager installation, `inputs.nixvim.nixosModules.nixvim`, for NixOS, and `inputs.nixvim.nixDarwinModules.nixvim` for nix-darwin. ## Usage @@ -132,7 +132,7 @@ can use the following: } ``` -You can then run neovim using `nix run .# -- `. This can be useful to test +You can then run neovim using `nix run .# -- `. This can be useful to test config changes easily. ### Advanced Usage From 84006ea282b73a3ea0ac73bbdfc39449b1880467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:38:59 +0100 Subject: [PATCH 54/61] nvim-tree: typo in option updateFocusedFile (#107) --- plugins/utils/nvim-tree.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix index 60161544..351f49ba 100644 --- a/plugins/utils/nvim-tree.nix +++ b/plugins/utils/nvim-tree.nix @@ -227,7 +227,7 @@ in auto_open = cfg.updateToBufDir.autoOpen; }; diagnostics = cfg.diagnostics; - updateFocusedFile = { + update_focused_file = { enable = cfg.updateFocusedFile.enable; update_cwd = cfg.updateFocusedFile.updateCwd; ignore_list = cfg.updateFocusedFile.ignoreList; From f32627307ace7bd5fdaa5c5d76d82009f020c68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:41:47 +0100 Subject: [PATCH 55/61] nvim-lsp: add bashls language server (#108) --- example.nix | 2 +- plugins/nvim-lsp/basic-servers.nix | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/example.nix b/example.nix index 0fe208b1..20a89dc2 100644 --- a/example.nix +++ b/example.nix @@ -1,7 +1,7 @@ { pkgs, ... }: { programs.nixvim = { - # This just enables NixVim. + # This just enables NixVim. # If all you have is this, then there will be little visible difference # when compared to just installing NeoVim. enable = true; diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 3882d8d9..385173cc 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -2,6 +2,11 @@ let helpers = import ./helpers.nix args; servers = [ + { + name = "bashls"; + description = "Enable bashls, for bash."; + packages = [ pkgs.nodePackages.bash-language-server ]; + } { name = "clangd"; description = "Enable clangd LSP, for C/C++."; From 02f28c7b48b7ae6a7304b3d3bc649c25fb26817a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:42:22 +0100 Subject: [PATCH 56/61] nvim-lsp: add texlab language server (#110) --- plugins/nvim-lsp/basic-servers.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 385173cc..79965b16 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -71,6 +71,11 @@ let description = "Enable tailwindcss language server, for tailwindcss"; packages = [ pkgs.nodePackages."@tailwindcss/language-server" ]; } + { + name = "texlab"; + description = "Enable texlab language server, for LaTeX"; + packages = [ pkgs.texlab ]; + } { name = "tsserver"; description = "Enable tsserver for typescript"; From b1ba5f873e6a7a19891754836b7e439bd4fcc7c9 Mon Sep 17 00:00:00 2001 From: traxys Date: Tue, 10 Jan 2023 23:47:52 +0100 Subject: [PATCH 57/61] lsp: add support for several LSP clients (#111) * nvim-lsp: Allow to pass settings to clients Some clients (like rust-analyzer, nil_ls, ...) can take settings specified in the setup function. This commit adds two fields for the 'mkLsp' function to handle this: - extraOptions: define nix module options - settings: A function that takes the corresponding lsp module config and formats it as a settings object compatible with the server. * nvim-lsp: Add nil-ls (for Nix) * nvim-lsp: Add bashls (for Bash) * nvim-lsp: Add dartls, for dart Co-authored-by: Pedro Alves --- plugins/nvim-lsp/basic-servers.nix | 128 +++++++++++++++++++++++++++++ plugins/nvim-lsp/helpers.nix | 5 +- 2 files changed, 132 insertions(+), 1 deletion(-) diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index 79965b16..f0a1235c 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -1,4 +1,5 @@ { pkgs, config, lib, ... }@args: +with lib; let helpers = import ./helpers.nix args; servers = [ @@ -17,6 +18,97 @@ let description = "Enable cssls, for CSS"; packages = [ pkgs.nodePackages.vscode-langservers-extracted ]; } + { + name = "dartls"; + description = "Enable dart language-server, for dart"; + packages = [ pkgs.dart ]; + extraOptions = { + analysisExcludedFolders = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + An array of paths (absolute or relative to each workspace folder) that should be + excluded from analysis. + ''; + }; + enableSdkFormatter = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + When set to false, prevents registration (or unregisters) the SDK formatter. When set + to true or not supplied, will register/reregister the SDK formatter + ''; + }; + lineLength = mkOption { + type = types.nullOr types.int; + default = null; + description = '' + The number of characters the formatter should wrap code at. If unspecified, code will + be wrapped at 80 characters. + ''; + }; + completeFunctionCalls = mkOption { + type = types.nullOr types.bool; + default = true; + description = '' + When set to true, completes functions/methods with their required parameters. + ''; + }; + showTodos = mkOption { + type = types.nullOr types.bool; + default = true; + description = '' + Whether to generate diagnostics for TODO comments. If unspecified, diagnostics will not + be generated. + ''; + }; + renameFilesWithClasses = mkOption { + 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 + filename matches the class name (but in snake_form). When set to "prompt", a prompt will + be shown on each class rename asking to confirm the file rename. Otherwise, files will + not be renamed. Renames are performed using LSP's ResourceOperation edits - that means + the rename is simply included in the resulting WorkspaceEdit and must be handled by the + client. + ''; + }; + enableSnippets = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to include code snippets (such as class, stful, switch) in code completion. When + unspecified, snippets will be included. + ''; + }; + updateImportsOnRename = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to update imports and other directives when files are renamed. When unspecified, + imports will be updated if the client supports willRenameFiles requests + ''; + }; + documentation = mkOption { + 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 + similar requests. If not set, defaults to full + ''; + }; + includeDependenciesInWorkspaceSymbols = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol + results. If not set, defaults to true. + ''; + }; + }; + settings = cfg: { dart = cfg; }; + } { name = "denols"; description = "Enable denols, for Deno"; @@ -52,6 +144,42 @@ let description = "Enable jsonls, for JSON"; packages = [ pkgs.nodePackages.vscode-langservers-extracted ]; } + { + name = "nil_ls"; + description = "Enable nil, for Nix"; + packages = [ pkgs.nil ]; + extraOptions = { + formatting.command = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + description = '' + External formatter command (with arguments). + It should accepts file content in stdin and print the formatted code into stdout. + ''; + }; + diagnostics = { + ignored = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Ignored diagnostic kinds. + The kind identifier is a snake_cased_string usually shown together + with the diagnostic message. + ''; + }; + excludedFiles = mkOption { + type = types.listOf types.str; + 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. + Glob patterns are currently not supported. + ''; + }; + }; + }; + settings = cfg: { nil = { inherit (cfg) formatting diagnostics; }; }; + } { name = "pyright"; description = "Enable pyright, for Python."; diff --git a/plugins/nvim-lsp/helpers.nix b/plugins/nvim-lsp/helpers.nix index b2d9a395..77a10b00 100644 --- a/plugins/nvim-lsp/helpers.nix +++ b/plugins/nvim-lsp/helpers.nix @@ -7,6 +7,8 @@ , serverName ? name , packages ? [ pkgs.${name} ] , cmd ? null + , settings ? null + , extraOptions ? { } , ... }: # returns a module @@ -19,7 +21,7 @@ options = { plugins.lsp.servers.${name} = { enable = mkEnableOption description; - }; + } // extraOptions; }; config = mkIf cfg.enable { @@ -29,6 +31,7 @@ name = serverName; extraOptions = { inherit cmd; + settings = if settings != null then settings cfg else { }; }; }]; }; From 9aec0f9275f1a9d2076d5b97d69358da0bb1c5c9 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 11 Jan 2023 13:04:19 +0000 Subject: [PATCH 58/61] readme: add link to matrix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fd24d66..d1781ef1 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ When we do this, lightline will be set up to a sensible default, and will use gruvbox as the colorscheme, no extra configuration required! ## Support/Questions -If you have any question, please use the [discussions page](https://github.com/pta2002/nixvim/discussions/categories/q-a)! +If you have any question, please use the [discussions page](https://github.com/pta2002/nixvim/discussions/categories/q-a)! Alternatively, join the Matrix channel at [#nixvim:matrix.org](https://matrix.to/#/#nixvim:matrix.org)! ## Installation ### Without flakes From 5c6ba55f8a65fb238e2243faaf4b98df5e8b8be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:13:47 +0100 Subject: [PATCH 59/61] keymaps: switch to lua API vim.keymap.set (#115) * modules/keymaps: switch to lua API vim.keymap.set * add test for keymaps Co-authored-by: Pedro Alves --- modules/keymaps.nix | 3 +-- tests/flake.nix | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/keymaps.nix b/modules/keymaps.nix index fa4787dc..b75cf954 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -117,14 +117,13 @@ in (helpers.genMaps "c" config.maps.command); in { - # TODO: Use vim.keymap.set if on nvim >= 0.7 extraConfigLua = optionalString (mappings != [ ]) '' -- Set up keybinds {{{ do local __nixvim_binds = ${helpers.toLuaObject mappings} for i, map in ipairs(__nixvim_binds) do - vim.api.nvim_set_keymap(map.mode, map.key, map.action, map.config) + vim.keymap.set(map.mode, map.key, map.action, map.config) end end -- }}} diff --git a/tests/flake.nix b/tests/flake.nix index 735e6910..1a23bdee 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -81,6 +81,10 @@ }; }; + keymaps = build { + maps.normal."," = "echo \"test\""; + }; + issue-40 = build-stable { plugins = { nix.enable = true; From 20d47fb2832d9c5b0fb18ab1ee0e01564dc0365c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:17:43 +0100 Subject: [PATCH 60/61] treesitter: change default value for parserInstallDir (#117) * plugins/languages/treesitter: change default value for parserInstallDir * better document parserInstallDir Co-authored-by: Pedro Alves --- plugins/languages/treesitter.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index a76b44d8..da46b4dd 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -23,8 +23,15 @@ in parserInstallDir = mkOption { type = types.nullOr types.str; - default = null; - description = "Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled)"; + default = + if cfg.nixGrammars + then null + 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! + ''; }; ignoreInstall = mkOption { @@ -74,7 +81,7 @@ in moduleConfig = mkOption { type = types.attrsOf types.anything; - default = {}; + default = { }; description = "This is the configuration for extra modules. It should not be used directly"; }; }; From b9a4f0ca19201cbc2e6c583f3f3a269fe1a6314f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=A9tan=20Lepage?= <33058747+GaetanLepage@users.noreply.github.com> Date: Fri, 13 Jan 2023 11:48:24 +0100 Subject: [PATCH 61/61] plugins/languages/treesitter: fixed parsers installation when not using nixGrammars (#116) --- plugins/languages/treesitter.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index da46b4dd..8539af81 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -119,10 +119,10 @@ in } // cfg.moduleConfig; in mkIf cfg.enable { - extraConfigLua = '' - require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) - '' + optionalString (cfg.parserInstallDir != null) '' + 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