From fca55e1db19eccc37c7c286cff024ed5b6f27f2d Mon Sep 17 00:00:00 2001 From: Omar Abragh Date: Mon, 9 Dec 2024 06:45:08 +0100 Subject: [PATCH 01/25] lualine: fix builtin_themes list (#486) Co-authored-by: raf --- modules/plugins/statusline/lualine/lualine.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/plugins/statusline/lualine/lualine.nix b/modules/plugins/statusline/lualine/lualine.nix index 1f694eafa..6e95f03bf 100644 --- a/modules/plugins/statusline/lualine/lualine.nix +++ b/modules/plugins/statusline/lualine/lualine.nix @@ -13,41 +13,43 @@ builtin_themes = [ "auto" "16color" - "gruvbox" "ayu_dark" "ayu_light" "ayu_mirage" "ayu" + "base16" "codedark" "dracula" "everforest" "gruvbox" "gruvbox_dark" "gruvbox_light" - "gruvbox_material" + "gruvbox-material" "horizon" "iceberg_dark" "iceberg_light" "iceberg" "jellybeans" "material" - "modus_vivendi" + "modus-vivendi" "molokai" "moonfly" "nightfly" "nord" - "oceanicnext" + "OceanicNext" "onedark" "onelight" "palenight" "papercolor_dark" "papercolor_light" + "PaperColor" "powerline_dark" "powerline" + "pywal" "seoul256" "solarized_dark" "solarized_light" - "tomorrow" + "Tomorrow" "wombat" ]; in { From ed3be410c591c9bfaf28fcaec29c0ef47b7dbb09 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 09:28:18 +0300 Subject: [PATCH 02/25] meta: update release info (0.8) --- release.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.json b/release.json index 28c5eb7f9..a80b41ea3 100644 --- a/release.json +++ b/release.json @@ -1,4 +1,4 @@ { - "release": "v0.7", - "isReleaseBranch": true + "release": "v0.8", + "isReleaseBranch": false } From a36935236564323b3fa37d5be9056bc91e18c7f7 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 09:28:23 +0300 Subject: [PATCH 03/25] languages/typst: add `typst-preview.nvim` as an extension --- docs/release-notes/rl-0.8.md | 8 ++++ flake.lock | 17 ++++++++ flake.nix | 5 +++ modules/plugins/languages/typst.nix | 62 +++++++++++++++++++++++++++-- 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 docs/release-notes/rl-0.8.md diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md new file mode 100644 index 000000000..128ecd197 --- /dev/null +++ b/docs/release-notes/rl-0.8.md @@ -0,0 +1,8 @@ +# Release 0.8 {#sec-release-0.8} + +[NotAShelf](https://github.com/notashelf): + +[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim + +- Add [typst-preview.nvim] under + `languages.typst.extensions.typst-preview-nvim`. diff --git a/flake.lock b/flake.lock index e84beb3ae..d5532b4bc 100644 --- a/flake.lock +++ b/flake.lock @@ -1902,6 +1902,22 @@ "type": "github" } }, + "plugin-typst-preview-nvim": { + "flake": false, + "locked": { + "lastModified": 1733120663, + "narHash": "sha256-uYMZ2PONiiI3UDvCgNvyy4+jhzmUDbAyxX0phKxELXw=", + "owner": "chomosuke", + "repo": "typst-preview.nvim", + "rev": "0cb5f5627312f50ce089f785ec42b55a85f30ce7", + "type": "github" + }, + "original": { + "owner": "chomosuke", + "repo": "typst-preview.nvim", + "type": "github" + } + }, "plugin-vim-dirtytalk": { "flake": false, "locked": { @@ -2151,6 +2167,7 @@ "plugin-tokyonight": "plugin-tokyonight", "plugin-trouble": "plugin-trouble", "plugin-ts-error-translator": "plugin-ts-error-translator", + "plugin-typst-preview-nvim": "plugin-typst-preview-nvim", "plugin-vim-dirtytalk": "plugin-vim-dirtytalk", "plugin-vim-fugitive": "plugin-vim-fugitive", "plugin-vim-illuminate": "plugin-vim-illuminate", diff --git a/flake.nix b/flake.nix index e52f9416d..65c802f23 100644 --- a/flake.nix +++ b/flake.nix @@ -206,6 +206,11 @@ flake = false; }; + plugin-typst-preview-nvim = { + url = "github:chomosuke/typst-preview.nvim"; + flake = false; + }; + plugin-nvim-metals = { url = "github:scalameta/nvim-metals"; flake = false; diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix index fbb090e8d..24097e2c5 100644 --- a/modules/plugins/languages/typst.nix +++ b/modules/plugins/languages/typst.nix @@ -7,10 +7,13 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; - inherit (lib.types) enum either listOf package str; + inherit (lib.types) nullOr enum either attrsOf listOf package str; inherit (lib.attrsets) attrNames; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.generators) mkLuaInline; + inherit (lib.meta) getExe; + inherit (lib.nvim.lua) expToLua toLuaObject; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.typst; @@ -33,6 +36,7 @@ } ''; }; + tinymist = { package = pkgs.tinymist; lspConfig = '' @@ -120,6 +124,50 @@ in { default = formats.${cfg.format.type}.package; }; }; + + extensions = { + typst-preview-nvim = { + enable = + mkEnableOption '' + [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim + + Low latency typst preview for Neovim via [typst-preview.nvim] + '' + // {default = true;}; + + setupOpts = mkPluginSetupOption "typst-preview-nvim" { + open_cmd = mkOption { + type = nullOr str; + default = null; + example = "firefox %s -P typst-preview --class typst-preview"; + description = '' + Custom format string to open the output link provided with `%s` + ''; + }; + + dependencies_bin = mkOption { + type = attrsOf str; + default = { + "tinymist" = getExe servers.tinymist.package; + "websocat" = getExe pkgs.websocat; + }; + + description = '' + Provide the path to binaries for dependencies. Setting this + to a non-null value will skip the download of the binary by + the plugin. + ''; + }; + + extra_args = mkOption { + type = nullOr (listOf str); + default = null; + example = ["--input=ver=draft" "--ignore-system-fonts"]; + description = "A list of extra arguments (or `null`) to be passed to previewer"; + }; + }; + }; + }; }; config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { @@ -136,5 +184,13 @@ in { vim.lsp.lspconfig.enable = true; vim.lsp.lspconfig.sources.typst-lsp = servers.${cfg.lsp.server}.lspConfig; }) + + # Extensions + (mkIf cfg.extensions.typst-preview-nvim.enable { + vim.startPlugins = ["typst-preview-nvim"]; + vim.pluginRC.typst-preview-nvim = entryAnywhere '' + require("typst-preview").setup(${toLuaObject cfg.extensions.typst-preview-nvim.setupOpts}) + ''; + }) ]); } From 0c90a7b1c691893a139aa9db94ec0f6e6b78e2f5 Mon Sep 17 00:00:00 2001 From: raf Date: Mon, 9 Dec 2024 13:31:59 +0300 Subject: [PATCH 04/25] configuration: disable superfluous language modules in maximal (#491) --- configuration.nix | 60 +++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/configuration.nix b/configuration.nix index aadd1f83a..3802f758a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,3 +1,7 @@ +# This is the sample configuration for nvf, aiming to give you a feel of the default options +# while certain plugins are enabled. While it may act as one, this is not an overview of nvf's +# module options. To find a complete overview of nvf's options and examples, visit the manual. +# https://notashelf.github.io/nvf/options.html isMaximal: { config.vim = { viAlias = true; @@ -31,54 +35,60 @@ isMaximal: { }; }; + # This section does not include a comprehensive list of available language modules. + # To list all available language module options, please visit the nvf manual. languages = { enableLSP = true; enableFormat = true; enableTreesitter = true; enableExtraDiagnostics = true; - # Nim LSP is broken on Darwin and therefore - # should be disabled by default. Users may still enable - # `vim.languages.vim` to enable it, this does not restrict - # that. - # See: - nim.enable = false; - + # Languages that will be supported in default and maximal configurations. nix.enable = true; + markdown.enable = true; - # Assembly is not common, and the asm LSP is a major hit-or-miss - assembly.enable = false; - astro.enable = false; - markdown.enable = isMaximal; - html.enable = isMaximal; + # Languages that are enabled in the maximal configuration. + bash.enable = isMaximal; + clang.enable = isMaximal; css.enable = isMaximal; + html.enable = isMaximal; sql.enable = isMaximal; java.enable = isMaximal; kotlin.enable = isMaximal; ts.enable = isMaximal; - svelte.enable = isMaximal; go.enable = isMaximal; lua.enable = isMaximal; - elixir.enable = isMaximal; zig.enable = isMaximal; - ocaml.enable = isMaximal; python.enable = isMaximal; - dart.enable = isMaximal; - bash.enable = isMaximal; - gleam.enable = false; - r.enable = isMaximal; - tailwind.enable = isMaximal; typst.enable = isMaximal; - clang.enable = isMaximal; - scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; }; - csharp.enable = isMaximal; - julia.enable = isMaximal; - vala.enable = isMaximal; + + # Language modules that are not as common. + assembly.enable = false; + astro.enable = false; nu.enable = false; + csharp.enable = false; + julia.enable = false; + vala.enable = false; + scala.enable = false; + r.enable = false; + gleam.enable = false; + dart.enable = false; + ocaml.enable = false; + elixir.enable = false; + + tailwind.enable = false; + svelte.enable = false; + + # Nim LSP is broken on Darwin and therefore + # should be disabled by default. Users may still enable + # `vim.languages.vim` to enable it, this does not restrict + # that. + # See: + nim.enable = false; }; visuals = { From 37dc96575d3b9960df8b3abef16ede47832f9ba4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 10:27:01 +0300 Subject: [PATCH 05/25] docs: add search widget to options page --- .editorconfig | 2 +- docs/manual.nix | 4 +++- docs/static/script/search.js | 40 ++++++++++++++++++++++++++++++++++++ docs/static/style.scss | 18 ++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/static/script/search.js diff --git a/.editorconfig b/.editorconfig index 5f4be94ca..434562236 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,7 +14,7 @@ indent_style = space indent_size = 2 trim_trailing_whitespace = false -[*.{nix,yml,yaml}] +[*.{js,nix,yml,yaml}] indent_style = space indent_size = 2 tab_width = 2 diff --git a/docs/manual.nix b/docs/manual.nix index 113fb7896..4becdf2db 100644 --- a/docs/manual.nix +++ b/docs/manual.nix @@ -62,7 +62,8 @@ in # Copy anchor scripts to the script directory in document root. cp -vt "$dest"/script \ ${./static/script}/anchor-min.js \ - ${./static/script}/anchor-use.js + ${./static/script}/anchor-use.js \ + ${./static/script}/search.js substituteInPlace ./options.md \ --subst-var-by OPTIONS_JSON ./config-options.json @@ -100,6 +101,7 @@ in --script highlightjs/loader.js \ --script script/anchor-use.js \ --script script/anchor-min.js \ + --script script/search.js \ --toc-depth 2 \ --section-toc-depth 1 \ manual.md \ diff --git a/docs/static/script/search.js b/docs/static/script/search.js new file mode 100644 index 000000000..34ce28bd5 --- /dev/null +++ b/docs/static/script/search.js @@ -0,0 +1,40 @@ +document.addEventListener("DOMContentLoaded", () => { + if (!window.location.pathname.endsWith("options.html")) return; + + const searchBar = document.createDocumentFragment(); + const searchDiv = document.createElement("div"); + searchDiv.id = "search-bar"; + searchDiv.innerHTML = ` + +
+ `; + searchBar.appendChild(searchDiv); + document.body.prepend(searchDiv); + + const dtElements = Array.from(document.querySelectorAll("dt")); + const ddElements = Array.from(document.querySelectorAll("dd")); + const dtOptionIds = dtElements.map( + (dt) => dt.querySelector("a")?.id.toLowerCase() || "", + ); + + if (dtElements.length === 0 || ddElements.length === 0) { + console.warn("Something went wrong, page may be loaded incorrectly."); + return; + } + + let debounceTimeout; + document.getElementById("search-input").addEventListener("input", (event) => { + clearTimeout(debounceTimeout); + debounceTimeout = setTimeout(() => { + const query = event.target.value.toLowerCase(); + dtElements.forEach((dt, index) => { + const isMatch = dtOptionIds[index].includes(query); + + if (dt.classList.contains("hidden") !== !isMatch) { + dt.classList.toggle("hidden", !isMatch); + ddElements[index]?.classList.toggle("hidden", !isMatch); + } + }); + }, 200); + }); +}); diff --git a/docs/static/style.scss b/docs/static/style.scss index 718302f35..3b1487398 100644 --- a/docs/static/style.scss +++ b/docs/static/style.scss @@ -233,6 +233,24 @@ li { } } +#search-bar { + position: sticky; + top: 0; + background: white; + padding: 10px; + border-bottom: 1px solid #ccc; + z-index: 1000; +} +#search-input { + width: 100%; + padding: 8px; + border: 1px solid #ccc; + border-radius: 4px; +} +.hidden { + display: none; +} + div.titlepage { margin: 40px 0; From 48bcd5d695794cb693e3a82d55f6742b6010d6bc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 9 Dec 2024 17:57:27 +0300 Subject: [PATCH 06/25] visuals/indent-blankline: properly pass setupOpts to `mkPluginSetupOption` --- modules/plugins/visuals/indent-blankline/indent-blankline.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/plugins/visuals/indent-blankline/indent-blankline.nix b/modules/plugins/visuals/indent-blankline/indent-blankline.nix index ff9bccc77..1133b80b2 100644 --- a/modules/plugins/visuals/indent-blankline/indent-blankline.nix +++ b/modules/plugins/visuals/indent-blankline/indent-blankline.nix @@ -6,6 +6,7 @@ inherit (lib.modules) mkRenamedOptionModule; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) int bool str nullOr either listOf attrsOf; + inherit (lib.nvim.types) mkPluginSetupOption; cfg = config.vim.visuals; in { @@ -15,7 +16,7 @@ in { options.vim.visuals.indent-blankline = { enable = mkEnableOption "indentation guides [indent-blankline]"; - setupOpts = { + setupOpts = mkPluginSetupOption "indent-blankline" { debounce = mkOption { type = int; description = "Debounce time in milliseconds"; From 0a3855cdc277b3cb402a22850f943c31f9f8f700 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 12:46:50 +0300 Subject: [PATCH 07/25] docs: properly theme searchbar on prefers-dark --- docs/static/style.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/static/style.scss b/docs/static/style.scss index 3b1487398..1c0b57e52 100644 --- a/docs/static/style.scss +++ b/docs/static/style.scss @@ -240,13 +240,19 @@ li { padding: 10px; border-bottom: 1px solid #ccc; z-index: 1000; + @media (prefers-color-scheme: dark) { + background: $color-gray-900; + color: $color-gray-50; + } } + #search-input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; } + .hidden { display: none; } From 9fad42374f3f4cdaa67ec13483824896ba55f174 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Tue, 10 Dec 2024 11:34:18 +0100 Subject: [PATCH 08/25] docs: fix search bar style in dark mode --- docs/static/style.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/static/style.scss b/docs/static/style.scss index 1c0b57e52..d5f739e54 100644 --- a/docs/static/style.scss +++ b/docs/static/style.scss @@ -251,6 +251,8 @@ li { padding: 8px; border: 1px solid #ccc; border-radius: 4px; + background: inherit; + color: inherit; } .hidden { From 781385f991f26a36102fe289f0e44770ff581ec5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 17:15:23 +0300 Subject: [PATCH 09/25] docs: perform DOM manipulation in batches; preprocess data --- docs/static/script/search.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/static/script/search.js b/docs/static/script/search.js index 34ce28bd5..1537b235a 100644 --- a/docs/static/script/search.js +++ b/docs/static/script/search.js @@ -1,14 +1,12 @@ document.addEventListener("DOMContentLoaded", () => { if (!window.location.pathname.endsWith("options.html")) return; - const searchBar = document.createDocumentFragment(); const searchDiv = document.createElement("div"); searchDiv.id = "search-bar"; searchDiv.innerHTML = `
`; - searchBar.appendChild(searchDiv); document.body.prepend(searchDiv); const dtElements = Array.from(document.querySelectorAll("dt")); @@ -22,18 +20,27 @@ document.addEventListener("DOMContentLoaded", () => { return; } + const dtElementsData = dtElements.map((dt, index) => ({ + element: dt, + id: dtOptionIds[index], + ddElement: ddElements[index], + })); + let debounceTimeout; document.getElementById("search-input").addEventListener("input", (event) => { clearTimeout(debounceTimeout); debounceTimeout = setTimeout(() => { const query = event.target.value.toLowerCase(); - dtElements.forEach((dt, index) => { - const isMatch = dtOptionIds[index].includes(query); - if (dt.classList.contains("hidden") !== !isMatch) { - dt.classList.toggle("hidden", !isMatch); - ddElements[index]?.classList.toggle("hidden", !isMatch); - } + requestAnimationFrame(() => { + const fragment = document.createDocumentFragment(); + dtElementsData.forEach(({ element, id, ddElement }) => { + const isMatch = id.includes(query); + if (element.classList.contains("hidden") !== !isMatch) { + element.classList.toggle("hidden", !isMatch); + ddElement?.classList.toggle("hidden", !isMatch); + } + }); }); }, 200); }); From f8e185662017aa3a7a8f2a72b8170c9889ea8a38 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 23:10:05 +0300 Subject: [PATCH 10/25] docs: better performance in the resource widget ft. Keira and Michaili --- docs/static/script/search.js | 27 +++++++++++++++++++-------- docs/static/style.scss | 11 +++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/static/script/search.js b/docs/static/script/search.js index 1537b235a..e20c2314f 100644 --- a/docs/static/script/search.js +++ b/docs/static/script/search.js @@ -26,21 +26,32 @@ document.addEventListener("DOMContentLoaded", () => { ddElement: ddElements[index], })); + const hiddenClass = "hidden"; + const hiddenStyle = document.createElement("style"); + hiddenStyle.innerHTML = `.${hiddenClass} { display: none; }`; + document.head.appendChild(hiddenStyle); + let debounceTimeout; document.getElementById("search-input").addEventListener("input", (event) => { clearTimeout(debounceTimeout); debounceTimeout = setTimeout(() => { const query = event.target.value.toLowerCase(); + const matches = []; + const nonMatches = []; + + dtElementsData.forEach(({ element, id, ddElement }) => { + const isMatch = id.includes(query); + if (isMatch) { + matches.push(element, ddElement); + } else { + nonMatches.push(element, ddElement); + } + }); + requestAnimationFrame(() => { - const fragment = document.createDocumentFragment(); - dtElementsData.forEach(({ element, id, ddElement }) => { - const isMatch = id.includes(query); - if (element.classList.contains("hidden") !== !isMatch) { - element.classList.toggle("hidden", !isMatch); - ddElement?.classList.toggle("hidden", !isMatch); - } - }); + matches.forEach((el) => el?.classList.remove(hiddenClass)); + nonMatches.forEach((el) => el?.classList.add(hiddenClass)); }); }, 200); }); diff --git a/docs/static/style.scss b/docs/static/style.scss index d5f739e54..d6becd0cd 100644 --- a/docs/static/style.scss +++ b/docs/static/style.scss @@ -189,14 +189,16 @@ th { dt { margin: 1.2rem 0 0.8rem; + content-visibility: auto; + contain-intrinsic-size: auto 42px; } - dd { margin-left: 2rem; + content-visibility: auto; + contain-intrinsic-size: auto 500px; } -div.book { -} +div.book {} ul { @include margined; @@ -238,11 +240,12 @@ li { top: 0; background: white; padding: 10px; - border-bottom: 1px solid #ccc; + border-bottom: 1px solid $color-gray-200; z-index: 1000; @media (prefers-color-scheme: dark) { background: $color-gray-900; color: $color-gray-50; + border-bottom: 1px solid black; } } From cece170a41f794da8d630b6bb0adc15c6e28dc02 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 23:21:00 +0300 Subject: [PATCH 11/25] docs: mention lazy-loading capability in README --- .github/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index 029f2fc82..fdc878d6f 100644 --- a/.github/README.md +++ b/.github/README.md @@ -69,7 +69,7 @@ [Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm - **Simple**: One language to rule them all! Use Nix to configure everything, - with additional Lua Support + with optional Lua support for robust configurability! - **Reproducible**: Your configuration will behave the same _anywhere_. No surprises, promise! - **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No @@ -77,8 +77,9 @@ - Options to install [standalone], [NixOS module] or [Home-Manager module]. - **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully customizable through the Nix module system. -- Not comfortable with a full-nix config or want to bring your Lua config? You - can do just that, no unnecessary restrictions. + - Not comfortable with a full-nix config or want to bring your Lua config? You + can do just that, no unnecessary restrictions. + - Lazyloading? We got it! Lazyload both internal and external plugins at will. - **Well-documented**: Documentation is priority. You will _never_ face undocumented, obscure behaviour. - **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and From c3a4686fa18715ff373b0aedc34eb08a6a735e7c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 23:34:08 +0300 Subject: [PATCH 12/25] wrapper/rc: use `mkOption` in `enableLuaLoader` description `mkEnableOption` seems to be clobbering the markdown syntax. --- modules/wrapper/rc/options.nix | 38 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 4680190ad..ab5414197 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -12,22 +12,28 @@ cfg = config.vim; in { options.vim = { - enableLuaLoader = mkEnableOption '' - [{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable() - - the experimental Lua module loader to speed up the start up process - - If `true`, this will enable the experimental Lua module loader which: - - overrides loadfile - - adds the lua loader using the byte-compilation cache - - adds the libs loader - - removes the default Neovim loader - - ::: {.note} - This is disabled by default. Before setting this option, please - take a look at the [{option}`official documentation`]. - ::: - ''; + enableLuaLoader = mkOption { + type = bool; + default = false; + example = true; + description = '' + [{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable() + + the experimental Lua module loader to speed up the start up process + + If `true`, this will enable the experimental Lua module loader which: + - overrides loadfile + - adds the lua loader using the byte-compilation cache + - adds the libs loader + - removes the default Neovim loader + + ::: {.note} + The Lua module loader is *disabled* by default. Before setting this option, please + take a look at the [{option}`official documentation`]. This option may be enabled by + default in the future. + ::: + ''; + }; additionalRuntimePaths = mkOption { type = listOf (either path str); From 6567b463ee001d984a7ac9eaf3effe80a557f7b8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 23:37:32 +0300 Subject: [PATCH 13/25] docs: update release notes --- docs/release-notes/rl-0.8.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 128ecd197..52a9ae646 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -6,3 +6,5 @@ - Add [typst-preview.nvim] under `languages.typst.extensions.typst-preview-nvim`. + +- Add a search widget to the options page in the nvf manual. From 4daa9201668c40cb4892f884b02eb8d8d1325a9f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 10 Dec 2024 23:56:46 +0300 Subject: [PATCH 14/25] docs: mention non-flakes in FAQ --- .github/README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/README.md b/.github/README.md index fdc878d6f..5d10c73f4 100644 --- a/.github/README.md +++ b/.github/README.md @@ -168,19 +168,19 @@ fix. ## Frequently Asked Questions -[appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose +[issue template]: https://github.com/NotAShelf/nvf/issues/new/choose [list of branches]: https://github.com/NotAShelf/nvf/branches [list of open pull requests]: https://github.com/NotAShelf/nvf/pulls **Q**: What platforms are supported? -
**A**: nvf actively supports Linux and Darwin platforms using standalone -Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available -installation instructions. +
**A**: nvf actively supports **Linux and Darwin** platforms using +standalone Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] +for available installation instructions. **Q**: Can you add _X_?
**A**: Maybe! It is not one of our goals to support each and every Neovim plugin, however, I am always open to new modules and plugin setup additions to -**nvf**. Use the [appropriate issue template] and I will consider a module +**nvf**. Use the appropriate [issue template] and I will consider a module addition. As mentioned before, pull requests to add new features are also welcome. @@ -197,6 +197,13 @@ not noticed any activity on the main branch, consider taking a look at the _testing_ those release branches to get access to new features ahead of time and better prepare to breaking changes. +**Q**: Will you support non-flake installations? +
**A**: Quite possibly. **nvf** started as "neovim-flake", which does mean +it is and will remain flakes-first but we might consider non-flakes +compatibility. Though keep in mind that **nvf** under non-flake environments +would lose customizability of plugin inputs, which is one of our primary +features. + ## Credits ### Contributors From 73660af2e36e9881c6cf7d82600950785b4cd51d Mon Sep 17 00:00:00 2001 From: Omar Abragh Date: Tue, 10 Dec 2024 22:00:51 +0100 Subject: [PATCH 15/25] lightbulb: add setupOpts option (#492) Co-authored-by: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Co-authored-by: raf --- modules/plugins/lsp/lightbulb/config.nix | 3 ++- modules/plugins/lsp/lightbulb/lightbulb.nix | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/plugins/lsp/lightbulb/config.nix b/modules/plugins/lsp/lightbulb/config.nix index f44c2ddb7..f17b8ad9a 100644 --- a/modules/plugins/lsp/lightbulb/config.nix +++ b/modules/plugins/lsp/lightbulb/config.nix @@ -5,6 +5,7 @@ }: let inherit (lib.modules) mkIf; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.lsp; in { @@ -16,7 +17,7 @@ in { vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') -- Enable trouble diagnostics viewer - require'nvim-lightbulb'.setup() + require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts}) ''; }; }; diff --git a/modules/plugins/lsp/lightbulb/lightbulb.nix b/modules/plugins/lsp/lightbulb/lightbulb.nix index ef101a0e4..4341cac69 100644 --- a/modules/plugins/lsp/lightbulb/lightbulb.nix +++ b/modules/plugins/lsp/lightbulb/lightbulb.nix @@ -1,9 +1,11 @@ {lib, ...}: let inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.lsp = { lightbulb = { enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font"; + setupOpts = mkPluginSetupOption "nvim-lightbulb" {}; }; }; } From a0a57757a07941c5523e646f0a97176492704bd4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 12 Dec 2024 20:16:27 +0300 Subject: [PATCH 16/25] wrapper/rc: explicitly add `tabstop` & `shiftwidth` to `vim.options` Defaults are taken from Neovim's :help tags for those options to avoid intrusive/confusing behaviour. --- modules/wrapper/rc/options.nix | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index ab5414197..df3831ecd 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -126,16 +126,14 @@ in { example = {"some_variable" = 42;}; description = '' - An attribute set containing global variable values - for storing vim variables as early as possible. If - populated, this option will set vim variables in the - built luaConfigRC as the first item. + A freeform attribute set containing global variable values for setting vim + variables as early as possible. If populated, this option will set vim variables + in the built {option}`luaConfigRC` as the first item. ::: {.note} - `{foo = "bar";}` will set `vim.g.foo` to "bar", where - the type of `bar` in the resulting Lua value will be - inferred from the type of the value in the `{name = value;}` - pair passed to the option. + `{foo = "bar";}` will set `vim.g.foo` to "bar", where the type of `bar` in the + resulting Lua value will be inferred from the type of the value in the + `{name = value;}` pair passed to the option. ::: ''; }; @@ -212,21 +210,39 @@ in { default = true; description = "Enable word wrapping."; }; + + tabstop = mkOption { + type = int; + default = 8; # Neovim default + description = '' + Number of spaces that a `` in the file counts for. Also see + the {command}`:retab` command, and the {option}`softtabstop` option. + ''; + }; + + shiftwidth = mkOption { + type = int; + default = 8; # Neovim default + description = '' + Number of spaces to use for each step of (auto)indent. Used for + {option}`cindent`, `>>`, `<<`, etc. + + When zero the {option}`tabstop` value will be used. + ''; + }; }; }; example = {visualbell = true;}; description = '' - An attribute set containing vim options to be set - as early as possible. If populated, this option will - set vim options in the built luaConfigRC after `basic` - and before `pluginConfigs` DAG entries. + A freeform attribute set containing vim options to be set as early as possible. + If populated, this option will set vim options in the built {option}`luaConfigRC` + after `basic` and before `pluginConfigs` DAG entries. ::: {.note} - `{foo = "bar";}` will set `vim.o.foo` to "bar", where - the type of `bar` in the resulting Lua value will be - inferred from the type of the value in the`{name = value;}` - pair passed to the option. + `{foo = "bar";}` will set `vim.o.foo` to "bar", where the type of `bar` in the + resulting Lua value will be inferred from the type of the value in the + `{name = value;}` pair passed to the option. ::: ''; }; From 4f616283992803ba5b3d2dc833b03f947c1573c6 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 16 Dec 2024 01:16:56 +0300 Subject: [PATCH 17/25] preview/markdown-preview: convert `mkdp_filetypes` to correct format --- modules/plugins/utility/preview/markdown-preview/config.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/plugins/utility/preview/markdown-preview/config.nix b/modules/plugins/utility/preview/markdown-preview/config.nix index 8349d3fc6..50fec81a3 100644 --- a/modules/plugins/utility/preview/markdown-preview/config.nix +++ b/modules/plugins/utility/preview/markdown-preview/config.nix @@ -4,8 +4,8 @@ lib, ... }: let - inherit (lib.strings) concatMapStringsSep; inherit (lib.modules) mkIf; + cfg = config.vim.utility.preview.markdownPreview; in { config = mkIf cfg.enable { @@ -15,7 +15,7 @@ in { mkdp_auto_start = cfg.autoStart; mkdp_auto_close = cfg.autoClose; mkdp_refresh_slow = cfg.lazyRefresh; - mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)]; + mkdp_filetypes = cfg.filetypes; mkdp_command_for_global = cfg.alwaysAllowPreview; mkdp_open_to_the_world = cfg.broadcastServer; mkdp_open_ip = cfg.customIP; From e715463257abd42ec6726a10a5cb2177ebda0c00 Mon Sep 17 00:00:00 2001 From: Artur Manuel Date: Fri, 20 Dec 2024 03:50:38 +0000 Subject: [PATCH 18/25] plugins/languages: add haskell support (#499) * plugins/languages: add haskell support Closes #426 * fix docs --------- Co-authored-by: Artur Manuel Co-authored-by: raf --- configuration.nix | 1 + docs/release-notes/rl-0.8.md | 6 ++ flake.lock | 17 +++++ flake.nix | 5 ++ modules/plugins/languages/default.nix | 1 + modules/plugins/languages/haskell.nix | 104 ++++++++++++++++++++++++++ modules/plugins/languages/rust.nix | 4 +- 7 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 modules/plugins/languages/haskell.nix diff --git a/configuration.nix b/configuration.nix index 3802f758a..3be1d39b0 100644 --- a/configuration.nix +++ b/configuration.nix @@ -79,6 +79,7 @@ isMaximal: { dart.enable = false; ocaml.enable = false; elixir.enable = false; + haskell.enable = false; tailwind.enable = false; svelte.enable = false; diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 52a9ae646..36209ff72 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -8,3 +8,9 @@ `languages.typst.extensions.typst-preview-nvim`. - Add a search widget to the options page in the nvf manual. + +[amadaluzia](https://github.com/amadaluzia): + +[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim + +- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim] diff --git a/flake.lock b/flake.lock index d5532b4bc..dc9cd81af 100644 --- a/flake.lock +++ b/flake.lock @@ -684,6 +684,22 @@ "type": "github" } }, + "plugin-haskell-tools-nvim": { + "flake": false, + "locked": { + "lastModified": 1734222260, + "narHash": "sha256-gZVN9ADPO5wFOaf19FydCneb7aKTT9K1vcLoBURPEjk=", + "owner": "mrcjkb", + "repo": "haskell-tools.nvim", + "rev": "943b77b68a79d3991523ba4d373063c9355c6f55", + "type": "github" + }, + "original": { + "owner": "mrcjkb", + "repo": "haskell-tools.nvim", + "type": "github" + } + }, "plugin-highlight-undo": { "flake": false, "locked": { @@ -2091,6 +2107,7 @@ "plugin-gitsigns-nvim": "plugin-gitsigns-nvim", "plugin-glow-nvim": "plugin-glow-nvim", "plugin-gruvbox": "plugin-gruvbox", + "plugin-haskell-tools-nvim": "plugin-haskell-tools-nvim", "plugin-highlight-undo": "plugin-highlight-undo", "plugin-hop-nvim": "plugin-hop-nvim", "plugin-icon-picker-nvim": "plugin-icon-picker-nvim", diff --git a/flake.nix b/flake.nix index 65c802f23..161ba43fe 100644 --- a/flake.nix +++ b/flake.nix @@ -720,5 +720,10 @@ url = "github:otavioschwanck/new-file-template.nvim"; flake = false; }; + + plugin-haskell-tools-nvim = { + url = "github:mrcjkb/haskell-tools.nvim"; + flake = false; + }; }; } diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index a69d3e8d1..48945b38e 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -14,6 +14,7 @@ in { ./hcl.nix ./kotlin.nix ./html.nix + ./haskell.nix ./java.nix ./lua.nix ./markdown.nix diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix new file mode 100644 index 000000000..f8e17b750 --- /dev/null +++ b/modules/plugins/languages/haskell.nix @@ -0,0 +1,104 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (builtins) isList; + inherit (lib.types) either package listOf str; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.strings) optionalString; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) expToLua; + inherit (pkgs) haskellPackages; + + cfg = config.vim.languages.haskell; +in { + options.vim.languages.haskell = { + enable = mkEnableOption "Haskell support"; + + treesitter = { + enable = mkEnableOption "Treesitter support for Haskell" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "haskell"; + }; + + lsp = { + enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;}; + package = mkOption { + description = "Haskell LSP package or command to run the Haskell LSP"; + example = ''[ (lib.getExe pkgs.haskellPackages.haskell-language-server) "--debug" ]''; + default = haskellPackages.haskell-language-server; + type = either package (listOf str); + }; + }; + + dap = { + enable = mkEnableOption "DAP support for Haskell" // {default = config.vim.languages.enableDAP;}; + package = mkOption { + description = "Haskell DAP package or command to run the Haskell DAP"; + default = haskellPackages.haskell-debug-adapter; + type = either package (listOf str); + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter = { + enable = true; + grammars = [cfg.treesitter.package]; + }; + }) + + (mkIf (cfg.dap.enable || cfg.lsp.enable) { + vim = { + startPlugins = ["haskell-tools-nvim"]; + luaConfigRC.haskell-tools-nvim = + entryAfter + ["lsp-setup"] + '' + vim.g.haskell_tools = { + ${optionalString cfg.lsp.enable '' + -- LSP + tools = { + hover = { + enable = true, + }, + }, + hls = { + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper"}'' + }, + on_attach = function(client, bufnr, ht) + default_on_attach(client, bufnr, ht) + local opts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'cl', vim.lsp.codelens.run, opts) + vim.keymap.set('n', 'hs', ht.hoogle.hoogle_signature, opts) + vim.keymap.set('n', 'ea', ht.lsp.buf_eval_all, opts) + vim.keymap.set('n', 'rr', ht.repl.toggle, opts) + vim.keymap.set('n', 'rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) + end, opts) + vim.keymap.set('n', 'rq', ht.repl.quit, opts) + end, + }, + ''} + ${optionalString cfg.dap.enable '' + dap = { + cmd = ${ + if isList cfg.dap.package + then expToLua cfg.dap.package + else ''${cfg.dap.package}/bin/haskell-debug-adapter'' + }, + }, + ''} + } + ''; + }; + }) + ]); +} diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index ec1887cb3..7e9cb6270 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -13,7 +13,7 @@ inherit (lib.types) bool package str listOf either enum; inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.dag) entryAfter entryAnywhere; cfg = config.vim.languages.rust; @@ -127,7 +127,7 @@ in { vim = { startPlugins = ["rustaceanvim"]; - luaConfigRC.rustaceanvim = entryAnywhere '' + pluginRC.rustaceanvim = entryAfter ["lsp-setup"] '' vim.g.rustaceanvim = { ${optionalString cfg.lsp.enable '' -- LSP From 99a4eafa34450fc94e43e3f0ed4df559a40f9b35 Mon Sep 17 00:00:00 2001 From: Yoni Firroloni Date: Fri, 20 Dec 2024 04:11:18 +0000 Subject: [PATCH 19/25] languages/typescript: prevent ts_ls from formatting (#495) * ts_ls: prevent from formatting prevent ts_ls from touching the formating. ts formatting: remove useless indent * fix unnecessary whitespace --------- Co-authored-by: raf --- modules/plugins/languages/ts.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index 8843cc466..2530d3527 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -23,8 +23,11 @@ package = pkgs.typescript-language-server; lspConfig = '' lspconfig.ts_ls.setup { - capabilities = capabilities; - on_attach = attach_keymaps, + capabilities = capabilities, + on_attach = function(client, bufnr) + attach_keymaps(client, bufnr); + client.server_capabilities.documentFormattingProvider = false; + end, cmd = ${ if isList cfg.lsp.package then expToLua cfg.lsp.package @@ -79,6 +82,7 @@ ls_sources, null_ls.builtins.formatting.prettier.with({ command = "${cfg.format.package}/bin/prettier", + filetypes = { "typescript" }, }) ) ''; From ed69816f68414a91104f7abe9a77a9e1b5630467 Mon Sep 17 00:00:00 2001 From: diniamo Date: Fri, 20 Dec 2024 10:43:36 +0100 Subject: [PATCH 20/25] wrapper/lazy: add beforeSetup option Useful for avoiding a million require calls in setupOpts. --- modules/wrapper/lazy/config.nix | 1 + modules/wrapper/lazy/lazy.nix | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix index 6a9a6ea2b..3468d5ec1 100644 --- a/modules/wrapper/lazy/config.nix +++ b/modules/wrapper/lazy/config.nix @@ -76,6 +76,7 @@ else mkLuaInline '' function() + ${optionalString (spec.beforeSetup != null) spec.beforeSetup} ${ optionalString (spec.setupModule != null) "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix index e0dbea858..730bf267c 100644 --- a/modules/wrapper/lazy/lazy.nix +++ b/modules/wrapper/lazy/lazy.nix @@ -74,6 +74,15 @@ ''; }; + beforeSetup = mkOption { + type = nullOr lines; + default = null; + description = '' + Lua code to run after the plugin is loaded, but before the setup + function is called. + ''; + }; + setupModule = mkOption { type = nullOr str; default = null; From 5d898da816dbfe117167fce3179f7757cbccb696 Mon Sep 17 00:00:00 2001 From: diniamo Date: Fri, 20 Dec 2024 16:27:44 +0100 Subject: [PATCH 21/25] nvim-notify: fix some stuff --- .../ui/notifications/nvim-notify/config.nix | 14 +++----------- .../ui/notifications/nvim-notify/nvim-notify.nix | 4 ++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/modules/plugins/ui/notifications/nvim-notify/config.nix b/modules/plugins/ui/notifications/nvim-notify/config.nix index 0ee23017e..509721768 100644 --- a/modules/plugins/ui/notifications/nvim-notify/config.nix +++ b/modules/plugins/ui/notifications/nvim-notify/config.nix @@ -14,17 +14,9 @@ in { startPlugins = ["nvim-notify"]; pluginRC.nvim-notify = entryAnywhere '' - require('notify').setup(${toLuaObject cfg.setupOpts}) - - -- required to fix offset_encoding errors - local notify = vim.notify - vim.notify = function(msg, ...) - if msg:match("warning: multiple different client offset_encodings") then - return - end - - notify(msg, ...) - end + local notify = require("notify") + notify.setup(${toLuaObject cfg.setupOpts}) + vim.notify = notify ''; }; }; diff --git a/modules/plugins/ui/notifications/nvim-notify/nvim-notify.nix b/modules/plugins/ui/notifications/nvim-notify/nvim-notify.nix index f30d19cd0..b09100da2 100644 --- a/modules/plugins/ui/notifications/nvim-notify/nvim-notify.nix +++ b/modules/plugins/ui/notifications/nvim-notify/nvim-notify.nix @@ -28,7 +28,7 @@ in { }; stages = mkOption { - type = enum ["fade_in_slide_out" "fade_in" "slide_out" "none"]; + type = enum ["fade_in_slide_out" "fade" "slide" "static"]; default = "fade_in_slide_out"; description = "The stages of the notification"; }; @@ -41,7 +41,7 @@ in { background_colour = mkOption { type = str; - default = "#000000"; + default = "NotifyBackground"; description = "The background colour of the notification"; }; From 7eb8d07bcf91672a723c8ecf1df1e4e5df917f24 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sat, 21 Dec 2024 01:14:52 +0100 Subject: [PATCH 22/25] surround: cleanup --- modules/plugins/utility/surround/config.nix | 48 +++++++-------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index 7161cf6bd..31b4033dd 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -4,51 +4,33 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.utility.surround; mkLznKey = mode: key: { - inherit key mode; + inherit mode key; }; in { config = mkIf cfg.enable { vim = { - startPlugins = ["nvim-surround"]; - pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; - lazy.plugins.nvim-surround = { package = "nvim-surround"; + setupModule = "nvim-surround"; inherit (cfg) setupOpts; - keys = - [ - (mkLznKey ["i"] cfg.setupOpts.keymaps.insert) - (mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line) - (mkLznKey ["x"] cfg.setupOpts.keymaps.visual) - (mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line) - (mkLznKey ["n"] cfg.setupOpts.keymaps.normal) - (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur) - (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line) - (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line) - (mkLznKey ["n"] cfg.setupOpts.keymaps.delete) - (mkLznKey ["n"] cfg.setupOpts.keymaps.change) - (mkLznKey ["n"] cfg.setupOpts.keymaps.change_line) - ] - ++ map (mkLznKey ["n" "i" "v"]) [ - "(nvim-surround-insert)" - "(nvim-surround-insert-line)" - "(nvim-surround-normal)" - "(nvim-surround-normal-cur)" - "(nvim-surround-normal-line)" - "(nvim-surround-normal-cur-line)" - "(nvim-surround-visual)" - "(nvim-surround-visual-line)" - "(nvim-surround-delete)" - "(nvim-surround-change)" - "(nvim-surround-change-line)" - ]; + keys = [ + (mkLznKey "i" cfg.setupOpts.keymaps.insert) + (mkLznKey "i" cfg.setupOpts.keymaps.insert_line) + (mkLznKey "x" cfg.setupOpts.keymaps.visual) + (mkLznKey "x" cfg.setupOpts.keymaps.visual_line) + (mkLznKey "n" cfg.setupOpts.keymaps.normal) + (mkLznKey "n" cfg.setupOpts.keymaps.normal_cur) + (mkLznKey "n" cfg.setupOpts.keymaps.normal_line) + (mkLznKey "n" cfg.setupOpts.keymaps.normal_cur_line) + (mkLznKey "n" cfg.setupOpts.keymaps.delete) + (mkLznKey "n" cfg.setupOpts.keymaps.change) + (mkLznKey "n" cfg.setupOpts.keymaps.change_line) + ]; }; }; }; From 0946d439210b19eee5fb57d8ec0ae563de5deb49 Mon Sep 17 00:00:00 2001 From: Artur Manuel Date: Sat, 21 Dec 2024 00:51:41 +0000 Subject: [PATCH 23/25] languages/haskell: fix DAP command definition --- modules/plugins/languages/haskell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index f8e17b750..62f4cd41a 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -92,7 +92,7 @@ in { cmd = ${ if isList cfg.dap.package then expToLua cfg.dap.package - else ''${cfg.dap.package}/bin/haskell-debug-adapter'' + else ''{"${cfg.dap.package}/bin/haskell-debug-adapter"}'' }, }, ''} From 90a5a42742850dc95e8cab2c3de936718d9055cc Mon Sep 17 00:00:00 2001 From: diniamo Date: Sat, 21 Dec 2024 01:15:10 +0100 Subject: [PATCH 24/25] languages/odin: init --- docs/release-notes/rl-0.8.md | 6 ++- modules/plugins/languages/default.nix | 1 + modules/plugins/languages/odin.nix | 71 +++++++++++++++++++++++++++ modules/plugins/languages/zig.nix | 1 + 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 modules/plugins/languages/odin.nix diff --git a/docs/release-notes/rl-0.8.md b/docs/release-notes/rl-0.8.md index 36209ff72..03d4d0102 100644 --- a/docs/release-notes/rl-0.8.md +++ b/docs/release-notes/rl-0.8.md @@ -13,4 +13,8 @@ [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim -- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim] +- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]. + +[diniamo](https://github.com/diniamo): + +- Add Odin support under `vim.languages.odin`. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 48945b38e..ee9f55e15 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -37,6 +37,7 @@ in { ./csharp.nix ./julia.nix ./nu.nix + ./odin.nix ]; options.vim.languages = { diff --git a/modules/plugins/languages/odin.nix b/modules/plugins/languages/odin.nix new file mode 100644 index 000000000..7a32db931 --- /dev/null +++ b/modules/plugins/languages/odin.nix @@ -0,0 +1,71 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) either listOf package str enum; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; + + defaultServer = "ols"; + servers = { + ols = { + package = pkgs.ols; + lspConfig = '' + lspconfig.ols.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else "{'${cfg.lsp.package}/bin/ols'}" + } + } + ''; + }; + }; + + cfg = config.vim.languages.odin; +in { + options.vim.languages.odin = { + enable = mkEnableOption "Odin language support"; + + treesitter = { + enable = mkEnableOption "Odin treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "odin"; + }; + + lsp = { + enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;}; + + server = mkOption { + type = enum (attrNames servers); + default = defaultServer; + description = "Odin LSP server to use"; + }; + + package = mkOption { + description = "Ols package, or the command to run as a list of strings"; + type = either package (listOf str); + default = pkgs.ols; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.odin-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +} diff --git a/modules/plugins/languages/zig.nix b/modules/plugins/languages/zig.nix index 7ae8a5c2e..3618d6d8c 100644 --- a/modules/plugins/languages/zig.nix +++ b/modules/plugins/languages/zig.nix @@ -57,6 +57,7 @@ in { }; }; }; + config = mkIf cfg.enable (mkMerge [ (mkIf cfg.treesitter.enable { vim.treesitter.enable = true; From 9aad80d5e6d61cc6f5c256eed1fb13dd6d0d8473 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sat, 21 Dec 2024 20:38:31 +0100 Subject: [PATCH 25/25] flake: update run.nvim --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index dc9cd81af..97ff67548 100644 --- a/flake.lock +++ b/flake.lock @@ -1729,11 +1729,11 @@ "plugin-run-nvim": { "flake": false, "locked": { - "lastModified": 1732918526, - "narHash": "sha256-kiszNmZZDXG8tAPMQKuGJDCkqCMzsWT7BkCvkVsH2lA=", + "lastModified": 1734816675, + "narHash": "sha256-Wuk5HG+vHXAbifzp5YB5V/FxBhBRNWLeypkRczpXbvQ=", "owner": "diniamo", "repo": "run.nvim", - "rev": "d867466e01b8fa4e54a589b9ef446cf43fb966de", + "rev": "6cd971afdce6443d7a070dcc23af51da1cc932f9", "type": "github" }, "original": {