From e40d7a2a56382937db96f2755f075429beb6dde1 Mon Sep 17 00:00:00 2001 From: raf Date: Thu, 19 Sep 2024 19:07:25 +0000 Subject: [PATCH 1/7] neovim/basic: add undofile options (#367) `vim.undoFile.enable` and `vim.undoFile.path` can be used to manipulate whether undofile will be enabled, and the location if it is enabled. --- modules/neovim/init/basic.nix | 204 +++++++++++++++++++--------------- 1 file changed, 116 insertions(+), 88 deletions(-) diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index 07bb70d..2114dcb 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -3,11 +3,13 @@ lib, ... }: let - inherit (lib.options) mkOption literalExpression; + inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; inherit (lib.strings) optionalString; - inherit (lib.types) enum bool str int; + inherit (lib.types) enum bool str int either; + inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.types) luaInline; cfg = config.vim; in { @@ -158,112 +160,138 @@ in { default = "sensitive"; description = "Set the case sensitivity of search"; }; + + undoFile = { + enable = mkEnableOption "undofile for persistent undo behaviour"; + path = mkOption { + type = either str luaInline; + default = mkLuaInline "vim.fn.stdpath('state') .. '/undo'"; + defaultText = literalMD '' + ```nix + mkLuaInline "vim.fn.stdpath('state') .. '/undo'" + ``` + ''; + example = literalMD '' + ```nix + mkLuaInline "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'" + ``` + ''; + description = "Path to the directory in which undo history will be stored"; + }; + }; }; - config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] '' - -- Settings that are set for everything - vim.o.encoding = "utf-8" - vim.o.hidden = true - vim.opt.shortmess:append("c") - vim.o.expandtab = true - vim.o.mouse = ${toLuaObject cfg.mouseSupport} - vim.o.tabstop = ${toLuaObject cfg.tabWidth} - vim.o.shiftwidth = ${toLuaObject cfg.tabWidth} - vim.o.softtabstop = ${toLuaObject cfg.tabWidth} - vim.o.cmdheight = ${toLuaObject cfg.cmdHeight} - vim.o.updatetime = ${toLuaObject cfg.updateTime} - vim.o.tm = ${toLuaObject cfg.mapTimeout} - vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt} - vim.o.scrolloff = ${toLuaObject cfg.scrollOffset} - vim.g.mapleader = ${toLuaObject cfg.leaderKey} - vim.g.maplocalleader = ${toLuaObject cfg.leaderKey} + config = { + vim.luaConfigRC.basic = entryAfter ["globalsScript"] '' + -- Settings that are set for everything + vim.o.encoding = "utf-8" + vim.o.hidden = true + vim.opt.shortmess:append("c") + vim.o.expandtab = true + vim.o.mouse = ${toLuaObject cfg.mouseSupport} + vim.o.tabstop = ${toLuaObject cfg.tabWidth} + vim.o.shiftwidth = ${toLuaObject cfg.tabWidth} + vim.o.softtabstop = ${toLuaObject cfg.tabWidth} + vim.o.cmdheight = ${toLuaObject cfg.cmdHeight} + vim.o.updatetime = ${toLuaObject cfg.updateTime} + vim.o.tm = ${toLuaObject cfg.mapTimeout} + vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt} + vim.o.scrolloff = ${toLuaObject cfg.scrollOffset} + vim.g.mapleader = ${toLuaObject cfg.leaderKey} + vim.g.maplocalleader = ${toLuaObject cfg.leaderKey} - ${optionalString cfg.splitBelow '' - vim.o.splitbelow = true - ''} + ${optionalString cfg.undoFile.enable '' + vim.o.undofile = true + vim.o.undodir = ${toLuaObject cfg.undoFile.path} + ''} - ${optionalString cfg.splitRight '' - vim.o.splitright = true - ''} + ${optionalString cfg.splitBelow '' + vim.o.splitbelow = true + ''} - ${optionalString cfg.showSignColumn '' - vim.o.signcolumn = "yes" - ''} + ${optionalString cfg.splitRight '' + vim.o.splitright = true + ''} - ${optionalString cfg.autoIndent '' - vim.o.autoindent = true - ''} + ${optionalString cfg.showSignColumn '' + vim.o.signcolumn = "yes" + ''} - ${optionalString cfg.preventJunkFiles '' - vim.o.swapfile = false - vim.o.backup = false - vim.o.writebackup = false - ''} + ${optionalString cfg.autoIndent '' + vim.o.autoindent = true + ''} - ${optionalString (cfg.bell == "none") '' - vim.o.errorbells = false - vim.o.visualbell = false - ''} + ${optionalString cfg.preventJunkFiles '' + vim.o.swapfile = false + vim.o.backup = false + vim.o.writebackup = false + ''} - ${optionalString (cfg.bell == "on") '' - vim.o.visualbell = false - ''} + ${optionalString (cfg.bell == "none") '' + vim.o.errorbells = false + vim.o.visualbell = false + ''} - ${optionalString (cfg.bell == "visual") '' - vim.o.errorbells = false - ''} + ${optionalString (cfg.bell == "on") '' + vim.o.visualbell = false + ''} - ${optionalString (cfg.lineNumberMode == "relative") '' - vim.o.relativenumber = true - ''} + ${optionalString (cfg.bell == "visual") '' + vim.o.errorbells = false + ''} - ${optionalString (cfg.lineNumberMode == "number") '' - vim.o.number = true - ''} + ${optionalString (cfg.lineNumberMode == "relative") '' + vim.o.relativenumber = true + ''} - ${optionalString (cfg.lineNumberMode == "relNumber") '' - vim.o.number = true - vim.o.relativenumber = true - ''} + ${optionalString (cfg.lineNumberMode == "number") '' + vim.o.number = true + ''} - ${optionalString cfg.useSystemClipboard '' - vim.opt.clipboard:append("unnamedplus") - ''} + ${optionalString (cfg.lineNumberMode == "relNumber") '' + vim.o.number = true + vim.o.relativenumber = true + ''} - ${optionalString cfg.syntaxHighlighting '' - vim.cmd("syntax on") - ''} + ${optionalString cfg.useSystemClipboard '' + vim.opt.clipboard:append("unnamedplus") + ''} - ${optionalString (!cfg.wordWrap) '' - vim.o.wrap = false - ''} + ${optionalString cfg.syntaxHighlighting '' + vim.cmd("syntax on") + ''} - ${optionalString cfg.hideSearchHighlight '' - vim.o.hlsearch = false - vim.o.incsearch = true - ''} + ${optionalString (!cfg.wordWrap) '' + vim.o.wrap = false + ''} - ${optionalString cfg.colourTerm '' - vim.o.termguicolors = true - ''} + ${optionalString cfg.hideSearchHighlight '' + vim.o.hlsearch = false + vim.o.incsearch = true + ''} - ${optionalString (!cfg.enableEditorconfig) '' - vim.g.editorconfig = false - ''} + ${optionalString cfg.colourTerm '' + vim.o.termguicolors = true + ''} - ${optionalString (cfg.searchCase == "ignore") '' - vim.o.smartcase = false - vim.o.ignorecase = true - ''} + ${optionalString (!cfg.enableEditorconfig) '' + vim.g.editorconfig = false + ''} - ${optionalString (cfg.searchCase == "smart") '' - vim.o.smartcase = true - vim.o.ignorecase = true - ''} + ${optionalString (cfg.searchCase == "ignore") '' + vim.o.smartcase = false + vim.o.ignorecase = true + ''} - ${optionalString (cfg.searchCase == "sensitive") '' - vim.o.smartcase = false - vim.o.ignorecase = false - ''} - ''; + ${optionalString (cfg.searchCase == "smart") '' + vim.o.smartcase = true + vim.o.ignorecase = true + ''} + + ${optionalString (cfg.searchCase == "sensitive") '' + vim.o.smartcase = false + vim.o.ignorecase = false + ''} + ''; + }; } From 99ace503adaae13e50ddf3f4d2813fdb43be25ca Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Fri, 20 Sep 2024 17:51:11 +0200 Subject: [PATCH 2/7] fastaction: add module (#376) * plugins/lsp: add code-actions module; add fastaction.nvim * deprecate nvimCodeActionMenu * fastaction-nvim: move range_code_action to visual maps * fastaction: move to vim.ui, remove mappings, enable register_ui_select by default * fastaction: add missing documentation * fastaction: support vim.ui.borders * treewide: clean up nvim-code-action-menu remnants * docs: add missing section ids --------- Co-authored-by: NotAShelf --- configuration.nix | 2 +- docs/release-notes/rl-0.7.md | 16 ++++++++ flake.lock | 34 ++++++++--------- flake.nix | 4 +- flake/modules/home-manager.nix | 1 - flake/modules/nixos.nix | 1 - modules/extra/deprecations.nix | 7 ++++ modules/plugins/lsp/default.nix | 1 - modules/plugins/lsp/lspsaga/config.nix | 2 +- .../lsp/nvim-code-action-menu/config.nix | 38 ------------------- .../nvim-code-action-menu.nix | 20 ---------- modules/plugins/ui/borders/borders.nix | 2 +- modules/plugins/ui/default.nix | 1 + modules/plugins/ui/fastaction/config.nix | 24 ++++++++++++ .../fastaction}/default.nix | 2 +- .../plugins/ui/fastaction/fastaction-nvim.nix | 9 +++++ modules/plugins/visuals/config.nix | 2 - 17 files changed, 80 insertions(+), 86 deletions(-) delete mode 100644 modules/plugins/lsp/nvim-code-action-menu/config.nix delete mode 100644 modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix create mode 100644 modules/plugins/ui/fastaction/config.nix rename modules/plugins/{lsp/nvim-code-action-menu => ui/fastaction}/default.nix (55%) create mode 100644 modules/plugins/ui/fastaction/fastaction-nvim.nix diff --git a/configuration.nix b/configuration.nix index b0c613b..7479012 100644 --- a/configuration.nix +++ b/configuration.nix @@ -17,7 +17,6 @@ isMaximal: { lspkind.enable = false; lightbulb.enable = true; lspsaga.enable = false; - nvimCodeActionMenu.enable = isMaximal; trouble.enable = true; lspSignature.enable = true; lsplines.enable = isMaximal; @@ -204,6 +203,7 @@ isMaximal: { go = ["90" "130"]; }; }; + fastaction.enable = true; }; assistant = { diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ce5d8bd..cf250e0 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -4,6 +4,8 @@ Release notes for release 0.7 ## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7} +### `vim.configRC` removed {#sec-vim-configrc-removed} + In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the top-level DAG, and thereby making the entire configuration Lua based. This change introduces a few breaking changes: @@ -24,6 +26,17 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and brings unnecessary performance overhead while working with different configuration formats. +### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation} + +The nvim-code-action-menu plugin has been archived and broken for a long time, +so it's being replaced with a young, but better alternative called +fastaction.nvim. Simply remove everything set under +`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. + +Note that we are looking to add more alternatives in the future like +dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for +everyone. + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -103,6 +116,9 @@ configuration formats. yourself by adding `vim.opt.listchars:append({ eol = '' })` to your lua configuration +- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the + breaking changes section above for more details + [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() - Make Neovim's configuration file entirely Lua based. This comes with a few diff --git a/flake.lock b/flake.lock index 574e222..a39bf46 100644 --- a/flake.lock +++ b/flake.lock @@ -571,6 +571,22 @@ "type": "github" } }, + "plugin-fastaction-nvim": { + "flake": false, + "locked": { + "lastModified": 1721396662, + "narHash": "sha256-L7na78FsE+QHlEwxMpiwQcoOPhtmrknvdTZfzUoDANI=", + "owner": "Chaitanyabsprip", + "repo": "fastaction.nvim", + "rev": "2384dea7ba81d2709d0bee0e4bc7a8831ff13a9d", + "type": "github" + }, + "original": { + "owner": "Chaitanyabsprip", + "repo": "fastaction.nvim", + "type": "github" + } + }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1052,22 +1068,6 @@ "type": "github" } }, - "plugin-nvim-code-action-menu": { - "flake": false, - "locked": { - "lastModified": 1702287297, - "narHash": "sha256-pY+aP9iBuJhvDZzVEsOHZmnfaq3vUP7TfKEEQrj+Mo8=", - "owner": "weilbith", - "repo": "nvim-code-action-menu", - "rev": "8c7672a4b04d3cc4edd2c484d05b660a9cb34a1b", - "type": "github" - }, - "original": { - "owner": "weilbith", - "repo": "nvim-code-action-menu", - "type": "github" - } - }, "plugin-nvim-colorizer-lua": { "flake": false, "locked": { @@ -1855,6 +1855,7 @@ "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", "plugin-elixir-tools": "plugin-elixir-tools", + "plugin-fastaction-nvim": "plugin-fastaction-nvim", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", @@ -1885,7 +1886,6 @@ "plugin-nvim-autopairs": "plugin-nvim-autopairs", "plugin-nvim-bufferline-lua": "plugin-nvim-bufferline-lua", "plugin-nvim-cmp": "plugin-nvim-cmp", - "plugin-nvim-code-action-menu": "plugin-nvim-code-action-menu", "plugin-nvim-colorizer-lua": "plugin-nvim-colorizer-lua", "plugin-nvim-cursorline": "plugin-nvim-cursorline", "plugin-nvim-dap": "plugin-nvim-dap", diff --git a/flake.nix b/flake.nix index c00e9b8..0684972 100644 --- a/flake.nix +++ b/flake.nix @@ -133,8 +133,8 @@ flake = false; }; - plugin-nvim-code-action-menu = { - url = "github:weilbith/nvim-code-action-menu"; + plugin-fastaction-nvim = { + url = "github:Chaitanyabsprip/fastaction.nvim"; flake = false; }; diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index 66a3552..77b8448 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -67,7 +67,6 @@ in { formatOnSave = true; lightbulb.enable = true; lspsaga.enable = false; - nvimCodeActionMenu.enable = true; trouble.enable = true; lspSignature.enable = true; rust.enable = false; diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index e1e81f1..022b3d9 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -67,7 +67,6 @@ in { formatOnSave = true; lightbulb.enable = true; lspsaga.enable = false; - nvimCodeActionMenu.enable = true; trouble.enable = true; lspSignature.enable = true; rust.enable = false; diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index cb06380..388913a 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -7,5 +7,12 @@ in { Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If you depended on this functionality, please open an issue. '') + + # 2024-07-20 + (mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' + nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be + available under `vim.ui.fastaction` as a replacement. Simply remove everything under + `vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. + '') ]; } diff --git a/modules/plugins/lsp/default.nix b/modules/plugins/lsp/default.nix index f8408aa..a5d5163 100644 --- a/modules/plugins/lsp/default.nix +++ b/modules/plugins/lsp/default.nix @@ -10,7 +10,6 @@ # lsp plugins ./lspsaga - ./nvim-code-action-menu ./trouble ./lsp-signature ./lightbulb diff --git a/modules/plugins/lsp/lspsaga/config.nix b/modules/plugins/lsp/lspsaga/config.nix index 71c9025..6605087 100644 --- a/modules/plugins/lsp/lspsaga/config.nix +++ b/modules/plugins/lsp/lspsaga/config.nix @@ -36,7 +36,7 @@ in { (mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')") (mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')") - (mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action")) + (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action") (mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help")) ]; }; diff --git a/modules/plugins/lsp/nvim-code-action-menu/config.nix b/modules/plugins/lsp/nvim-code-action-menu/config.nix deleted file mode 100644 index 145cb60..0000000 --- a/modules/plugins/lsp/nvim-code-action-menu/config.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings pushDownDefault; - inherit (lib.nvim.lua) toLuaObject; - - cfg = config.vim.lsp; - - self = import ./nvim-code-action-menu.nix {inherit lib;}; - mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings; - mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions; -in { - config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) { - vim = { - startPlugins = ["nvim-code-action-menu"]; - - maps.normal = mkSetBinding mappings.open ":CodeActionMenu"; - - binds.whichKey.register = pushDownDefault { - "c" = "+CodeAction"; - }; - - pluginRC.code-action-menu = entryAnywhere '' - -- border configuration - vim.g.code_action_menu_window_border = ${toLuaObject config.vim.ui.borders.plugins.code-action-menu.style} - - -- show individual sections of the code action menu - ${lib.optionalString cfg.nvimCodeActionMenu.show.details "vim.g.code_action_menu_show_details = true"} - ${lib.optionalString cfg.nvimCodeActionMenu.show.diff "vim.g.code_action_menu_show_diff = true"} - ${lib.optionalString cfg.nvimCodeActionMenu.show.actionKind "vim.g.code_action_menu_show_action_kind = true"} - ''; - }; - }; -} diff --git a/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix b/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix deleted file mode 100644 index c303f7c..0000000 --- a/modules/plugins/lsp/nvim-code-action-menu/nvim-code-action-menu.nix +++ /dev/null @@ -1,20 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; - inherit (lib.nvim.binds) mkMappingOption; -in { - options.vim.lsp = { - nvimCodeActionMenu = { - enable = mkEnableOption "nvim code action menu"; - - show = { - details = mkEnableOption "Show details" // {default = true;}; - diff = mkEnableOption "Show diff" // {default = true;}; - actionKind = mkEnableOption "Show action kind" // {default = true;}; - }; - - mappings = { - open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "ca"; - }; - }; - }; -} diff --git a/modules/plugins/ui/borders/borders.nix b/modules/plugins/ui/borders/borders.nix index 9951591..cf19d38 100644 --- a/modules/plugins/ui/borders/borders.nix +++ b/modules/plugins/ui/borders/borders.nix @@ -43,7 +43,7 @@ in { lspsaga = mkPluginStyleOption "lspsaga"; nvim-cmp = mkPluginStyleOption "nvim-cmp"; lsp-signature = mkPluginStyleOption "lsp-signature"; - code-action-menu = mkPluginStyleOption "code-actions-menu"; + fastaction = mkPluginStyleOption "fastaction"; }; }; } diff --git a/modules/plugins/ui/default.nix b/modules/plugins/ui/default.nix index 262cdbb..3407660 100644 --- a/modules/plugins/ui/default.nix +++ b/modules/plugins/ui/default.nix @@ -8,5 +8,6 @@ ./illuminate ./breadcrumbs ./borders + ./fastaction ]; } diff --git a/modules/plugins/ui/fastaction/config.nix b/modules/plugins/ui/fastaction/config.nix new file mode 100644 index 0000000..79c3e25 --- /dev/null +++ b/modules/plugins/ui/fastaction/config.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf mkDefault; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.ui.fastaction; + borderCfg = config.vim.ui.borders.plugins.fastaction; +in { + config = mkIf cfg.enable { + vim = { + ui.fastaction.setupOpts = { + register_ui_select = mkDefault true; + popup.border = mkIf borderCfg.enable borderCfg.style; + }; + + startPlugins = ["fastaction-nvim"]; + pluginRC.fastaction = entryAnywhere "require('fastaction').setup(${toLuaObject cfg.setupOpts})"; + }; + }; +} diff --git a/modules/plugins/lsp/nvim-code-action-menu/default.nix b/modules/plugins/ui/fastaction/default.nix similarity index 55% rename from modules/plugins/lsp/nvim-code-action-menu/default.nix rename to modules/plugins/ui/fastaction/default.nix index f94dd22..ef5c2bc 100644 --- a/modules/plugins/lsp/nvim-code-action-menu/default.nix +++ b/modules/plugins/ui/fastaction/default.nix @@ -1,6 +1,6 @@ { imports = [ - ./nvim-code-action-menu.nix + ./fastaction-nvim.nix ./config.nix ]; } diff --git a/modules/plugins/ui/fastaction/fastaction-nvim.nix b/modules/plugins/ui/fastaction/fastaction-nvim.nix new file mode 100644 index 0000000..52ac59a --- /dev/null +++ b/modules/plugins/ui/fastaction/fastaction-nvim.nix @@ -0,0 +1,9 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.ui.fastaction = { + enable = mkEnableOption "overriding vim.ui.select with fastaction.nvim"; + setupOpts = mkPluginSetupOption "fastaction" {}; + }; +} diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 1dfc661..1457ff3 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -45,8 +45,6 @@ in { 'noice', 'NvimTree', 'alpha', - 'code-action-menu-menu', - 'code-action-menu-warning-message', 'notify', 'Navbuddy' }, From 57be605ed411c1de4a9fa0b1951aa31f56fbde18 Mon Sep 17 00:00:00 2001 From: Gerg-L <88247690+Gerg-L@users.noreply.github.com> Date: Sun, 22 Sep 2024 19:52:10 +0000 Subject: [PATCH 3/7] lib.neovimConfiguration: deprecated extraModules and configuration (#377) * lib.neovimConfiguration: deprecated extraModules and configuration * docs: various fixes --- .github/workflows/manual.yml | 37 +++-- docs/default.nix | 268 ++++++++++++++++------------------- docs/html-open-tool.nix | 23 ++- docs/manual.nix | 35 ++--- flake/packages.nix | 1 + lib/configuration.nix | 18 --- lib/default.nix | 2 +- modules/default.nix | 27 +++- modules/modules.nix | 129 ++++++++--------- 9 files changed, 257 insertions(+), 283 deletions(-) delete mode 100644 lib/configuration.nix diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index 34c11ff..23381e4 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -1,4 +1,5 @@ name: "Build and deploy documentation" + on: workflow_dispatch: push: @@ -7,6 +8,7 @@ on: paths: # build the manuals only when docs directory is updated - docs/** + - modules/** # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: @@ -20,23 +22,34 @@ concurrency: cancel-in-progress: true jobs: + check_date: + runs-on: ubuntu-latest + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + steps: + - uses: actions/checkout@v4.1.7 + - name: print latest_commit + run: echo ${{ github.sha }} + + - id: should_run + continue-on-error: true + name: check latest commit is less than a day + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" + publish: + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false' }} runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main + - uses: actions/checkout@v4.1.7 + - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Build - run: | - nix build '.#docs' + - run: | + nix build .#docs cp -r result/share/doc/nvf public - - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 + - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public diff --git a/docs/default.nix b/docs/default.nix index b48daf5..4a9d2f8 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -2,131 +2,135 @@ inputs, pkgs, lib, - manpageUrls ? pkgs.path + "/doc/manpage-urls.json", - ... }: let - inherit (lib.modules) mkForce evalModules; - inherit (lib.strings) hasPrefix removePrefix; - inherit (lib.attrsets) isAttrs mapAttrs optionalAttrs recursiveUpdate isDerivation; - inherit (builtins) fromJSON readFile; + inherit ((lib.importJSON ../release.json)) release; - # release data - release-config = fromJSON (readFile ../release.json); - revision = release-config.release; - - # From home-manager: - # - # Recursively replace each derivation in the given attribute set - # with the same derivation but with the `outPath` attribute set to - # the string `"\${pkgs.attribute.path}"`. This allows the - # documentation to refer to derivations through their values without - # establishing an actual dependency on the derivation output. - # - # This is not perfect, but it seems to cover a vast majority of use - # cases. - # - # Caveat: even if the package is reached by a different means, the - # path above will be shown and not e.g. - # `${config.services.foo.package}`. - scrubDerivations = prefixPath: attrs: let - scrubDerivation = name: value: let - pkgAttrName = prefixPath + "." + name; - in - if isAttrs value - then - scrubDerivations pkgAttrName value - // optionalAttrs (isDerivation value) { - outPath = "\${${pkgAttrName}}"; - } - else value; - in - mapAttrs scrubDerivation attrs; - - # Make sure the used package is scrubbed to avoid actually - # instantiating derivations. - scrubbedPkgsModule = { - imports = [ - { - _module.args = { - pkgs = mkForce (scrubDerivations "pkgs" pkgs); - pkgs_i686 = mkForce {}; - }; - } - ]; - }; - - # Specify the path to the module entrypoint - nvimPath = toString ./..; - buildOptionsDocs = args @ { - modules, - includeModuleSystemOptions ? true, - warningsAreErrors ? true, - ... - }: let - inherit ((evalModules {inherit modules;})) options; - - # Declaration of the Github site URL. - # Takes a user, repo, and subpath, and returns a declaration site - # as a string. - githubDeclaration = user: repo: subpath: let - urlRef = "github.com"; - branch = "main"; - in { - url = "https://${urlRef}/${user}/${repo}/blob/${branch}/${subpath}"; - name = "<${repo}/${subpath}>"; - }; - in - pkgs.buildPackages.nixosOptionsDoc ({ - inherit warningsAreErrors; - - options = - if includeModuleSystemOptions - then options - else builtins.removeAttrs options ["_module"]; - - transformOptions = opt: - recursiveUpdate opt { - # Clean up declaration sites to not refer to the nvf - # source tree. - declarations = map (decl: - if hasPrefix nvimPath (toString decl) - then - githubDeclaration "notashelf" "nvf" - (removePrefix "/" (removePrefix nvimPath (toString decl))) - else if decl == "lib/modules.nix" - then - # TODO: handle this in a better way (may require upstream - # changes to nixpkgs) - githubDeclaration "NixOS" "nixpkgs" decl - else decl) - opt.declarations; - }; - } - // builtins.removeAttrs args ["modules" "includeModuleSystemOptions"]); - - nvimModuleDocs = buildOptionsDocs { + nvimModuleDocs = pkgs.nixosOptionsDoc { variablelistId = "nvf-options"; + warningsAreErrors = true; - modules = - import ../modules/modules.nix { - inherit lib pkgs; - check = false; - } - ++ [scrubbedPkgsModule]; + inherit + ( + (lib.evalModules { + modules = + import ../modules/modules.nix { + inherit lib pkgs; + } + ++ [ + ( + let + # From nixpkgs: + # + # Recursively replace each derivation in the given attribute set + # with the same derivation but with the `outPath` attribute set to + # the string `"\${pkgs.attribute.path}"`. This allows the + # documentation to refer to derivations through their values without + # establishing an actual dependency on the derivation output. + # + # This is not perfect, but it seems to cover a vast majority of use + # cases. + # + # Caveat: even if the package is reached by a different means, the + # path above will be shown and not e.g. + # `${config.services.foo.package}`. + scrubDerivations = namePrefix: pkgSet: + builtins.mapAttrs ( + name: value: let + wholeName = "${namePrefix}.${name}"; + in + if builtins.isAttrs value + then + scrubDerivations wholeName value + // lib.optionalAttrs (lib.isDerivation value) { + inherit (value) drvPath; + outPath = "\${${wholeName}}"; + } + else value + ) + pkgSet; + in { + _module = { + check = false; + args.pkgs = lib.mkForce (scrubDerivations "pkgs" pkgs); + }; + } + ) + ]; + }) + ) + options + ; + + transformOptions = opt: + opt + // { + declarations = + map ( + decl: + if lib.hasPrefix (toString ../.) (toString decl) + then + lib.pipe decl [ + toString + (lib.removePrefix (toString ../.)) + (lib.removePrefix "/") + (x: { + url = "https://github.com/NotAShelf/nvf/blob/main/${decl}"; + name = ""; + }) + ] + else if decl == "lib/modules.nix" + then { + url = "https://github.com/NixOS/nixpkgs/blob/master/${decl}"; + name = ""; + } + else decl + ) + opt.declarations; + }; }; + # Generate the HTML manual pages + html = pkgs.callPackage ./manual.nix { + inherit release; + inherit (nvimModuleDocs) optionsJSON; + }; +in { + inherit (inputs) nmd; + + # TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream + # `nixosOptionsDoc` is more customizable. + options.json = + pkgs.runCommand "options.json" + { + meta.description = "List of nvf options in JSON format"; + } + '' + mkdir -p $out/{share/doc,nix-support} + cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf + substitute \ + ${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \ + $out/nix-support/hydra-build-products \ + --replace \ + '${nvimModuleDocs.optionsJSON}/share/doc/nixos' \ + "$out/share/doc/nvf" + ''; + # Generate the `man home-configuration.nix` package - nvf-configuration-manual = - pkgs.runCommand "nvf-reference-manpage" { - nativeBuildInputs = [pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs]; + manPages = + pkgs.runCommand "nvf-reference-manpage" + { + nativeBuildInputs = [ + pkgs.buildPackages.installShellFiles + pkgs.nixos-render-docs + ]; allowedReferences = ["out"]; - } '' + } + '' # Generate manpages. - mkdir -p $out/share/man/man5 - mkdir -p $out/share/man/man1 + mkdir -p $out/share/man/{man5,man1} nixos-render-docs -j $NIX_BUILD_CORES options manpage \ - --revision ${revision} \ + --revision ${release} \ --header ${./man/header.5} \ --footer ${./man/footer.5} \ ${nvimModuleDocs.optionsJSON}/share/doc/nixos/options.json \ @@ -135,38 +139,8 @@ cp ${./man/nvf.1} $out/share/man/man1/nvf.1 ''; - # Generate the HTML manual pages - nvf-manual = pkgs.callPackage ./manual.nix { - inherit revision manpageUrls; - outputPath = "share/doc/nvf"; - options = { - nvf = nvimModuleDocs.optionsJSON; - }; + manual = { + inherit html; + htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {inherit html;}; }; - - html = nvf-manual; - htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {} {inherit html;}; -in { - inherit (inputs) nmd; - - options = { - # TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream - # `nixosOptionsDoc` is more customizable. - json = - pkgs.runCommand "options.json" { - meta.description = "List of nvf options in JSON format"; - } '' - mkdir -p $out/{share/doc,nix-support} - cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf - substitute \ - ${nvimModuleDocs.optionsJSON}/nix-support/hydra-build-products \ - $out/nix-support/hydra-build-products \ - --replace \ - '${nvimModuleDocs.optionsJSON}/share/doc/nixos' \ - "$out/share/doc/nvf" - ''; - }; - - manPages = nvf-configuration-manual; - manual = {inherit html htmlOpenTool;}; } diff --git a/docs/html-open-tool.nix b/docs/html-open-tool.nix index 756feba..d430d24 100644 --- a/docs/html-open-tool.nix +++ b/docs/html-open-tool.nix @@ -2,13 +2,9 @@ writeShellScriptBin, makeDesktopItem, symlinkJoin, -}: { html, - pathName ? "nvf", - projectName ? pathName, - name ? "${pathName}-help", }: let - helpScript = writeShellScriptBin name '' + helpScript = writeShellScriptBin "nvf-help" '' set -euo pipefail if [[ ! -v BROWSER || -z $BROWSER ]]; then @@ -24,20 +20,23 @@ echo "$0: unable to start a web browser; please set \$BROWSER" exit 1 else - exec "$BROWSER" "${html}/share/doc/${pathName}/index.xhtml" + exec "$BROWSER" "${html}/share/doc/nvf/index.xhtml" fi ''; desktopItem = makeDesktopItem { - name = "${pathName}-manual"; - desktopName = "${projectName} Manual"; - genericName = "View ${projectName} documentation in a web browser"; + name = "nvf-manual"; + desktopName = "nvf Manual"; + genericName = "View nvf documentation in a web browser"; icon = "nix-snowflake"; - exec = "${helpScript}/bin/${name}"; + exec = "${helpScript}/bin/nvf-help"; categories = ["System"]; }; in symlinkJoin { - inherit name; - paths = [helpScript desktopItem]; + name = "nvf-help"; + paths = [ + helpScript + desktopItem + ]; } diff --git a/docs/manual.nix b/docs/manual.nix index 14e8ae2..f5b23d0 100644 --- a/docs/manual.nix +++ b/docs/manual.nix @@ -4,11 +4,10 @@ # build inputs nixos-render-docs, documentation-highlighter, + path, # nrd configuration - manpageUrls, - revision, - options, - outputPath ? "share/doc/nvf", + release, + optionsJSON, }: stdenvNoCC.mkDerivation { name = "nvf-manual"; @@ -20,9 +19,11 @@ stdenvNoCC.mkDerivation { nativeBuildInputs = [nixos-render-docs]; buildPhase = '' - mkdir -p out/{highlightjs,media} + dest="$out/share/doc/nvf" + mkdir -p "$(dirname "$dest")" + mkdir -p $dest/{highlightjs,media} - cp -vt out/highlightjs \ + cp -vt $dest/highlightjs \ ${documentation-highlighter}/highlight.pack.js \ ${documentation-highlighter}/LICENSE \ ${documentation-highlighter}/mono-blue.css \ @@ -31,38 +32,32 @@ stdenvNoCC.mkDerivation { substituteInPlace ./options.md \ --subst-var-by \ OPTIONS_JSON \ - ${options.nvf}/share/doc/nixos/options.json + ${optionsJSON}/share/doc/nixos/options.json substituteInPlace ./manual.md \ --subst-var-by \ NVF_VERSION \ - ${revision} + ${release} # copy stylesheet - cp ${./static/style.css} out/style.css + cp ${./static/style.css} "$dest/style.css" # copy release notes cp -vr ${./release-notes} release-notes # generate manual from nixos-render-docs manual html \ - --manpage-urls ${manpageUrls} \ - --revision ${lib.trivial.revisionWithDefault revision} \ + --manpage-urls ${path + "/doc/manpage-urls.json"} \ + --revision ${lib.trivial.revisionWithDefault release} \ --stylesheet style.css \ --script highlightjs/highlight.pack.js \ --script highlightjs/loader.js \ --toc-depth 2 \ --section-toc-depth 1 \ manual.md \ - out/index.xhtml - ''; + "$dest/index.xhtml" - installPhase = '' - dest="$out/${outputPath}" - mkdir -p "$(dirname "$dest")" - mv out "$dest" - - mkdir -p $out/nix-support/ - echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products + mkdir -p $out/nix-support/ + echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products ''; } diff --git a/flake/packages.nix b/flake/packages.nix index f8ad3c2..84514a2 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -8,6 +8,7 @@ docs = import ../docs {inherit pkgs inputs lib;}; in { packages = { + inherit (docs.manual) htmlOpenTool; # Documentation docs = docs.manual.html; docs-html = docs.manual.html; diff --git a/lib/configuration.nix b/lib/configuration.nix deleted file mode 100644 index 1f3c59a..0000000 --- a/lib/configuration.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - inputs, - lib, -}: let - modulesWithInputs = import ../modules inputs; -in - { - modules ? [], - pkgs, - check ? true, - extraSpecialArgs ? {}, - extraModules ? [], - ... - }: - modulesWithInputs { - inherit pkgs lib check extraSpecialArgs extraModules; - configuration.imports = modules; - } diff --git a/lib/default.nix b/lib/default.nix index 2e4b7f8..a418cff 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -11,5 +11,5 @@ languages = import ./languages.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; - neovimConfiguration = import ./configuration.nix {inherit inputs lib;}; + neovimConfiguration = import ../modules {inherit inputs lib;}; } diff --git a/modules/default.nix b/modules/default.nix index 1ae3b03..6a95080 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,10 +1,13 @@ -inputs: { - configuration, - pkgs, +{ + inputs, lib, - check ? true, +}: { + pkgs, extraSpecialArgs ? {}, + modules ? [], + # deprecated extraModules ? [], + configuration ? {}, }: let inherit (pkgs) vimPlugins; inherit (lib.strings) isString toString; @@ -13,13 +16,25 @@ inputs: { # import modules.nix with `check`, `pkgs` and `lib` as arguments # check can be disabled while calling this file is called # to avoid checking in all modules - nvimModules = import ./modules.nix {inherit pkgs check lib;}; + nvimModules = import ./modules.nix {inherit pkgs lib;}; # evaluate the extended library with the modules # optionally with any additional modules passed by the user module = lib.evalModules { specialArgs = extraSpecialArgs // {modulesPath = toString ./.;}; - modules = concatLists [[configuration] nvimModules extraModules]; + modules = concatLists [ + nvimModules + modules + (lib.optional (configuration != {}) (lib.warn '' + nvf: passing 'configuration' to lib.neovimConfiguration is deprecated. + '' + configuration)) + + (lib.optionals (extraModules != []) (lib.warn '' + nvf: passing 'extraModules' to lib.neovimConfiguration is deprecated, use 'modules' instead. + '' + extraModules)) + ]; }; # alias to the internal configuration diff --git a/modules/modules.nix b/modules/modules.nix index a00cea6..195652d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -1,77 +1,72 @@ { - check ? true, pkgs, lib, }: let inherit (lib.modules) mkDefault; inherit (lib.lists) concatLists; + allModules = let + # The core neovim modules. + # Contains configuration for core neovim features + # such as spellchecking, mappings, and the init script (init.vim). + neovim = map (p: "${./neovim}/${p}") [ + "init" + "mappings" + ]; - # The core neovim modules. - # Contains configuration for core neovim features - # such as spellchecking, mappings, and the init script (init.vim). - neovim = map (p: ./neovim + "/${p}") [ - "init" - "mappings" - ]; + # Individual plugin modules, separated by the type of plugin. + # While adding a new type, you must make sure your type is + # included in the list below. + plugins = map (p: "${./plugins}/${p}") [ + "assistant" + "autopairs" + "comments" + "completion" + "dashboard" + "debugger" + "filetree" + "git" + "languages" + "lsp" + "minimap" + "notes" + "projects" + "rich-presence" + "session" + "snippets" + # "spellcheck" # FIXME: see neovim/init/spellcheck.nix + "statusline" + "tabline" + "terminal" + "theme" + "treesitter" + "ui" + "utility" + "visuals" + ]; - # Individual plugin modules, separated by the type of plugin. - # While adding a new type, you must make sure your type is - # included in the list below. - plugins = map (p: ./plugins + "/${p}") [ - "assistant" - "autopairs" - "comments" - "completion" - "dashboard" - "debugger" - "filetree" - "git" - "languages" - "lsp" - "minimap" - "notes" - "projects" - "rich-presence" - "session" - "snippets" - # "spellcheck" # FIXME: see neovim/init/spellcheck.nix - "statusline" - "tabline" - "terminal" - "theme" - "treesitter" - "ui" - "utility" - "visuals" - ]; + # The neovim wrapper, used to build a wrapped neovim package + # using the configuration passed in `neovim` and `plugins` modules. + wrapper = map (p: "${./wrapper}/${p}") [ + "build" + "rc" + "warnings" + ]; - # The neovim wrapper, used to build a wrapped neovim package - # using the configuration passed in `neovim` and `plugins` modules. - wrapper = map (p: ./wrapper + "/${p}") [ - "build" - "rc" - "warnings" - ]; - - # Extra modules, such as deprecation warnings - # or renames in one place. - extra = map (p: ./extra + "/${p}") [ - "deprecations.nix" - ]; - - allModules = concatLists [neovim plugins wrapper extra]; - - pkgsModule = {config, ...}: { - config = { - _module = { - inherit check; - args = { - baseModules = allModules; - pkgsPath = mkDefault pkgs.path; - pkgs = mkDefault pkgs; - }; - }; - }; - }; + # Extra modules, such as deprecation warnings + # or renames in one place. + extra = map (p: "${./extra}/${p}") [ + "deprecations.nix" + ]; + in + concatLists [neovim plugins wrapper extra]; in - allModules ++ [pkgsModule] + allModules + ++ [ + { + _module.args = { + baseModules = allModules; + pkgsPath = mkDefault pkgs.path; + pkgs = mkDefault pkgs; + }; + } + ] From a85ac83182fe4507cc2ed1a4ff408c4022a61bce Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 24 Sep 2024 06:05:47 +0300 Subject: [PATCH 4/7] flake: minor cleanup - Get rid of Zig input (nixpkgs one is alright.) - Minor typo fixes --- flake.lock | 70 +----------------------------------------------------- flake.nix | 7 ++---- 2 files changed, 3 insertions(+), 74 deletions(-) diff --git a/flake.lock b/flake.lock index a39bf46..780614b 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -52,21 +36,6 @@ "type": "github" } }, - "flake-utils_2": { - "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "mnw": { "locked": { "lastModified": 1726188505, @@ -171,22 +140,6 @@ "type": "github" } }, - "nixpkgs_3": { - "locked": { - "lastModified": 1702350026, - "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "9463103069725474698139ab10f17a9d125da859", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nmd": { "flake": false, "locked": { @@ -1933,8 +1886,7 @@ "plugin-vim-vsnip": "plugin-vim-vsnip", "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", - "systems": "systems_2", - "zig": "zig" + "systems": "systems_2" } }, "rust-overlay": { @@ -2006,26 +1958,6 @@ "repo": "flake-utils", "type": "github" } - }, - "zig": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1716725305, - "narHash": "sha256-LIz08gALt2wlutGXAEhNroEoIuPV5ePQB8LI4WzXcy8=", - "owner": "mitchellh", - "repo": "zig-overlay", - "rev": "93b02a697561ecd438cfa5779727b5a1c300cb4c", - "type": "github" - }, - "original": { - "owner": "mitchellh", - "repo": "zig-overlay", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0684972..c4996fc 100644 --- a/flake.nix +++ b/flake.nix @@ -90,10 +90,7 @@ flake = false; }; - # TODO: get zig from the zig overlay instead of nixpkgs - zig.url = "github:mitchellh/zig-overlay"; - - # Langauge server (use master instead of nixpkgs) + # Language servers (use master instead of nixpkgs) rnix-lsp.url = "github:nix-community/rnix-lsp"; nil = { url = "github:oxalica/nil"; @@ -159,7 +156,7 @@ flake = false; }; - # language support + # Language support plugin-sqls-nvim = { url = "github:nanotee/sqls.nvim"; flake = false; From 27b3524508075bcede63de961b974e04734d5974 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 24 Sep 2024 06:07:44 +0300 Subject: [PATCH 5/7] flake: bump nixpkgs --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 780614b..6b4b715 100644 --- a/flake.lock +++ b/flake.lock @@ -98,11 +98,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1726142289, - "narHash": "sha256-Jks8O42La+nm5AMTSq/PvM5O+fUAhIy0Ce1QYqLkyZ4=", + "lastModified": 1726871744, + "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "280db3decab4cbeb22a4599bd472229ab74d25e1", + "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2", "type": "github" }, "original": { From 842b45b969c8280e474f0bb55b93ab0e32e47033 Mon Sep 17 00:00:00 2001 From: raf Date: Tue, 24 Sep 2024 03:20:56 +0000 Subject: [PATCH 6/7] languages/ts: update lspconfig; rename tsserver to ts_ls (#379) Silence lspconfig, Microsoft naming convention is speaking. --- flake.lock | 6 ++-- modules/plugins/languages/ts.nix | 47 ++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 6b4b715..377c084 100644 --- a/flake.lock +++ b/flake.lock @@ -1136,11 +1136,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1716498901, - "narHash": "sha256-PMMqPDnq4Q8gWeKQ2WPE+pOf1R1G61wJ+bAWkHpQlzE=", + "lastModified": 1727085470, + "narHash": "sha256-IPpUZEMIL7+4mmqQLy9JeT0cW15/SH3Hx8kyksVcqC0=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "b972e7154bc94ab4ecdbb38c8edbccac36f83996", + "rev": "dd329912c8d446240584a2dbcd3802af3a19105a", "type": "github" }, "original": { diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index dd1bde6..e6e718e 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -17,12 +17,12 @@ cfg = config.vim.languages.ts; - defaultServer = "tsserver"; + defaultServer = "ts_ls"; servers = { - tsserver = { + ts_ls = { package = pkgs.typescript-language-server; lspConfig = '' - lspconfig.tsserver.setup { + lspconfig.ts_ls.setup { capabilities = capabilities; on_attach = attach_keymaps, cmd = ${ @@ -49,6 +49,24 @@ } ''; }; + + # Here for backwards compatibility. Still consider tsserver a valid + # configuration in the enum, but assert if it's set to *properly* + # redirect the user to the correct server. + tsserver = { + package = pkgs.typescript-language-server; + lspConfig = '' + lspconfig.ts_ls.setup { + capabilities = capabilities; + on_attach = attach_keymaps, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}'' + } + } + ''; + }; }; # TODO: specify packages @@ -65,6 +83,7 @@ ) ''; }; + prettierd = { package = pkgs.prettierd; nullConfig = '' @@ -94,6 +113,7 @@ }; }; in { + _file = ./ts.nix; options.vim.languages.ts = { enable = mkEnableOption "Typescript/Javascript language support"; @@ -190,11 +210,32 @@ in { }; }) + # Extensions (mkIf cfg.extensions."ts-error-translator".enable { vim.startPlugins = ["ts-error-translator"]; vim.pluginRC.ts-error-translator = entryAnywhere '' require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) ''; }) + + # Warn the user if they have set the default server name to tsserver to match upstream (us) + # The name "tsserver" has been deprecated in lspconfig, and now should be called ts_ls. This + # is a purely cosmetic change, but emits a warning if not accounted for. + { + assertions = [ + { + assertion = cfg.lsp.enable -> cfg.lsp.server != "tsserver"; + message = '' + As of a recent lspconfig update, he `tsserver` configuration has been renamed + to `ts_ls` to match upstream behaviour of `lspconfig`, and the name `tsserver` + is no longer considered valid by nvf. Please set `vim.languages.ts.lsp.server` + to `"ts_ls"` instead of to `${cfg.lsp.server}` + + Please see for more details + about this change. + ''; + } + ]; + } ]); } From 316f25a0f62696b289ad4b944789beaae7fa9415 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 24 Sep 2024 06:27:06 +0300 Subject: [PATCH 7/7] docs: minor formatting changes Gerg I swear to god... --- docs/default.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/default.nix b/docs/default.nix index 4a9d2f8..cce02b1 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -100,11 +100,9 @@ in { # TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream # `nixosOptionsDoc` is more customizable. options.json = - pkgs.runCommand "options.json" - { + pkgs.runCommand "options.json" { meta.description = "List of nvf options in JSON format"; - } - '' + } '' mkdir -p $out/{share/doc,nix-support} cp -a ${nvimModuleDocs.optionsJSON}/share/doc/nixos $out/share/doc/nvf substitute \ @@ -117,15 +115,13 @@ in { # Generate the `man home-configuration.nix` package manPages = - pkgs.runCommand "nvf-reference-manpage" - { + pkgs.runCommand "nvf-reference-manpage" { nativeBuildInputs = [ pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs ]; allowedReferences = ["out"]; - } - '' + } '' # Generate manpages. mkdir -p $out/share/man/{man5,man1}