From d06ff3d7db7f92d64083207a4ff63ff3de2d7a2c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:22:43 +0300 Subject: [PATCH 1/8] languages/markdown: move to standalone file; add deno formatter --- configuration.nix | 8 ++-- modules/plugins/languages/default.nix | 2 +- .../languages/{markdown => }/markdown.nix | 40 ++++++++++++++++++- modules/plugins/languages/markdown/config.nix | 40 ------------------- .../plugins/languages/markdown/default.nix | 6 --- 5 files changed, 45 insertions(+), 51 deletions(-) rename modules/plugins/languages/{markdown => }/markdown.nix (62%) delete mode 100644 modules/plugins/languages/markdown/config.nix delete mode 100644 modules/plugins/languages/markdown/default.nix diff --git a/configuration.nix b/configuration.nix index 421fa8c..916f2bb 100644 --- a/configuration.nix +++ b/configuration.nix @@ -58,7 +58,12 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; + nim.enable = false; + elixir.enable = false; + nix.enable = true; + markdown.enable = true; + html.enable = isMaximal; css.enable = isMaximal; sql.enable = isMaximal; @@ -69,10 +74,7 @@ inputs: let zig.enable = isMaximal; python.enable = isMaximal; dart.enable = isMaximal; - elixir.enable = isMaximal; bash.enable = isMaximal; - terraform.enable = isMaximal; - nim.enable = false; tailwind.enable = isMaximal; typst.enable = isMaximal; clang = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 8597b72..3a33ad0 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -5,7 +5,6 @@ in { ./bash ./dart ./elixir - ./markdown ./tidal ./clang.nix @@ -14,6 +13,7 @@ in { ./html.nix ./java.nix ./lua.nix + ./markdown.nix ./nim.nix ./nix.nix ./php.nix diff --git a/modules/plugins/languages/markdown/markdown.nix b/modules/plugins/languages/markdown.nix similarity index 62% rename from modules/plugins/languages/markdown/markdown.nix rename to modules/plugins/languages/markdown.nix index a58be2a..7fcc364 100644 --- a/modules/plugins/languages/markdown/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (builtins) attrNames; + inherit (builtins) attrNames concatLists; inherit (lib.options) mkEnableOption mkOption; inherit (lib.lists) isList; inherit (lib.types) bool enum either package listOf str; @@ -29,6 +29,22 @@ ''; }; }; + + defaultFormat = "denofmt"; + formats = { + denofmt = { + package = pkgs.deno; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.deno_fmt.with({ + filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]}, + command = "${cfg.format.package}/bin/deno", + }) + ) + ''; + }; + }; in { options.vim.languages.markdown = { enable = mkEnableOption "Markdown markup language support"; @@ -59,5 +75,27 @@ in { default = servers.${cfg.lsp.server}.package; }; }; + + format = { + enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Markdown formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Markdown formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + + extraFiletypes = mkOption { + description = "Extra filetypes to format with the Markdown formatter"; + type = listOf str; + default = []; + }; + }; }; } diff --git a/modules/plugins/languages/markdown/config.nix b/modules/plugins/languages/markdown/config.nix deleted file mode 100644 index ccc8836..0000000 --- a/modules/plugins/languages/markdown/config.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.nvim.lua) expToLua; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) isList; - - cfg = config.vim.languages.markdown; - servers = { - marksman = { - package = pkgs.marksman; - lspConfig = '' - lspconfig.marksman.setup{ - capabilities = capabilities; - on_attach = default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/marksman", "server"}'' - }, - } - ''; - }; - }; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage]; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - ]); -} diff --git a/modules/plugins/languages/markdown/default.nix b/modules/plugins/languages/markdown/default.nix deleted file mode 100644 index 3834589..0000000 --- a/modules/plugins/languages/markdown/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [ - ./config.nix - ./markdown.nix - ]; -} From 1847b9f1bf65bbed9af4381c38f1b3cd9752868b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:30:06 +0300 Subject: [PATCH 2/8] languages/tidal: remove --- configuration.nix | 6 +- docs/release-notes/rl-0.7.md | 13 +- flake.lock | 160 +------------------- flake.nix | 9 +- flake/apps.nix | 28 ++-- flake/legacyPackages.nix | 1 - flake/overlays.nix | 2 - flake/packages.nix | 86 +++++------ modules/plugins/languages/default.nix | 1 - modules/plugins/languages/tidal/config.nix | 23 --- modules/plugins/languages/tidal/default.nix | 6 - modules/plugins/languages/tidal/tidal.nix | 24 --- 12 files changed, 63 insertions(+), 296 deletions(-) delete mode 100644 modules/plugins/languages/tidal/config.nix delete mode 100644 modules/plugins/languages/tidal/default.nix delete mode 100644 modules/plugins/languages/tidal/tidal.nix diff --git a/configuration.nix b/configuration.nix index 916f2bb..5c0095b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -15,10 +15,6 @@ inputs: let configuration.imports = modules; }; - tidalConfig = { - config.vim.languages.tidal.enable = true; - }; - mainConfig = isMaximal: { config.vim = { viAlias = true; @@ -254,5 +250,5 @@ inputs: let }; }; in { - inherit neovimConfiguration mainConfig tidalConfig; + inherit neovimConfiguration mainConfig; } diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ab6f9da..b5047a4 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -6,14 +6,21 @@ Release notes for release 0.7 [ItsSorae](https://github.com/ItsSorae): -- Added support for [typst](https://typst.app/) under `vim.languages.typst`. - This will enable the `typst-lsp` language server, and the `typstfmt` formatter. +- Added support for [typst](https://typst.app/) under `vim.languages.typst` + This will enable the `typst-lsp` language server, and the `typstfmt` formatter [frothymarrow](https://github.com/frothymarrow): - Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) - from `anything` to a `submodule` for better type checking. + from `anything` to a `submodule` for better type checking [horriblename](https://github.com/horriblename) - Fix broken treesitter-context keybinds in visual mode + +[NotAShelf](https://github.com/notashelf) + +- Add `deno fmt` as the default Markdown formatter. This will be enabled + automatically if you have autoformatting enabled, but can be disabled manually + if you choose to. +- Remove vim-tidal and friends diff --git a/flake.lock b/flake.lock index f590525..e706001 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,5 @@ { "nodes": { - "dirt-samples-src": { - "flake": false, - "locked": { - "lastModified": 1667426233, - "narHash": "sha256-Zl2bi9QofcrhU63eMtg+R6lhV9ExQS/0XNTJ+oq65Uo=", - "owner": "tidalcycles", - "repo": "dirt-samples", - "rev": "92f2145e661b397e62ca0ff3965819e7c7db0dad", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "ref": "master", - "repo": "dirt-samples", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -180,22 +163,6 @@ } }, "nixpkgs_3": { - "locked": { - "lastModified": 1693844670, - "narHash": "sha256-t69F2nBB8DNQUWHD809oJZJVE+23XBrth4QZuVd6IE0=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "3c15feef7770eb5500a4b8792623e2d6f598c9c1", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { "locked": { "lastModified": 1702350026, "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", @@ -1906,7 +1873,6 @@ "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", "systems": "systems_2", - "tidalcycles": "tidalcycles", "zig": "zig" } }, @@ -1935,23 +1901,6 @@ "type": "github" } }, - "superdirt-src": { - "flake": false, - "locked": { - "lastModified": 1611740180, - "narHash": "sha256-GtnqZeMFqFkVhgx2Exu0wY687cHa7mNnVCgjQd6fiIA=", - "owner": "musikinformatik", - "repo": "superdirt", - "rev": "7abb62e89649daa1232b9cbd6427241868abd30e", - "type": "github" - }, - "original": { - "owner": "musikinformatik", - "ref": "master", - "repo": "superdirt", - "type": "github" - } - }, "systems": { "locked": { "lastModified": 1681028828, @@ -1982,62 +1931,6 @@ "type": "github" } }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "tidal-src": { - "flake": false, - "locked": { - "lastModified": 1654350756, - "narHash": "sha256-tONM5SYYBca0orTLH1EUOilSC1FCluWrFt8AetUx+YQ=", - "owner": "tidalcycles", - "repo": "tidal", - "rev": "fda9c1ecb3722698935245e5409ef8ccdfca16c8", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "ref": "main", - "repo": "tidal", - "type": "github" - } - }, - "tidalcycles": { - "inputs": { - "dirt-samples-src": "dirt-samples-src", - "nixpkgs": "nixpkgs_3", - "superdirt-src": "superdirt-src", - "tidal-src": "tidal-src", - "utils": "utils_2", - "vim-tidal-src": "vim-tidal-src", - "vowel-src": "vowel-src" - }, - "locked": { - "lastModified": 1694087816, - "narHash": "sha256-GMV5ONQhLwa6xRYhZkmwc2W2jbjAfHfB/OR9vR0+PFA=", - "owner": "mitchmindtree", - "repo": "tidalcycles.nix", - "rev": "1b1c4df5303e07930d23e8361ab8253ebec0c7bb", - "type": "github" - }, - "original": { - "owner": "mitchmindtree", - "repo": "tidalcycles.nix", - "type": "github" - } - }, "utils": { "locked": { "lastModified": 1656928814, @@ -2053,62 +1946,11 @@ "type": "github" } }, - "utils_2": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "vim-tidal-src": { - "flake": false, - "locked": { - "lastModified": 1685703852, - "narHash": "sha256-8gyk17YLeKpLpz3LRtxiwbpsIbZka9bb63nK5/9IUoA=", - "owner": "tidalcycles", - "repo": "vim-tidal", - "rev": "e440fe5bdfe07f805e21e6872099685d38e8b761", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "repo": "vim-tidal", - "type": "github" - } - }, - "vowel-src": { - "flake": false, - "locked": { - "lastModified": 1641306144, - "narHash": "sha256-zfF6cvAGDNYWYsE8dOIo38b+dIymd17Pexg0HiPFbxM=", - "owner": "supercollider-quarks", - "repo": "vowel", - "rev": "ab59caa870201ecf2604b3efdd2196e21a8b5446", - "type": "github" - }, - "original": { - "owner": "supercollider-quarks", - "ref": "master", - "repo": "vowel", - "type": "github" - } - }, "zig": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1713960597, diff --git a/flake.nix b/flake.nix index e63f7ca..3425add 100644 --- a/flake.nix +++ b/flake.nix @@ -76,6 +76,7 @@ # Flake inputs inputs = { + ## Basic Inputs nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-utils.url = "github:numtide/flake-utils"; @@ -98,13 +99,7 @@ inputs.flake-utils.follows = "flake-utils"; }; - ### Plugins - # Tidal cycles - tidalcycles = { - url = "github:mitchmindtree/tidalcycles.nix"; - inputs.vim-tidal-src.url = "github:tidalcycles/vim-tidal"; - }; - + ## Plugins # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; diff --git a/flake/apps.nix b/flake/apps.nix index 6b53adf..583e297 100644 --- a/flake/apps.nix +++ b/flake/apps.nix @@ -1,21 +1,11 @@ -{lib, ...}: { - perSystem = { - system, - config, - ... - }: { - apps = - { - nix.program = lib.getExe config.packages.nix; - maximal.program = lib.getExe config.packages.maximal; - default = config.apps.nix; - } - // ( - if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) - then { - tidal.program = lib.getExe config.packages.tidal; - } - else {} - ); +{lib, ...}: let + inherit (lib.meta) getExe; +in { + perSystem = {config, ...}: { + apps = { + nix.program = getExe config.packages.nix; + maximal.program = getExe config.packages.maximal; + default = config.apps.nix; + }; }; } diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index d6fb73c..389ca0c 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -7,7 +7,6 @@ legacyPackages = import inputs.nixpkgs { inherit system; overlays = [ - inputs.tidalcycles.overlays.default inputs.self.overlays.default (_: _: { rnix-lsp = inputs'.rnix-lsp.defaultPackage; diff --git a/flake/overlays.nix b/flake/overlays.nix index c73f2c0..3c5434d 100644 --- a/flake/overlays.nix +++ b/flake/overlays.nix @@ -9,13 +9,11 @@ nixConfig = mainConfig false; maximalConfig = mainConfig true; - tidalConfig = {config.vim.tidal.enable = true;}; in { flake.overlays.default = _final: prev: { inherit neovimConfiguration; neovim-nix = buildPkg prev [nixConfig]; neovim-maximal = buildPkg prev [maximalConfig]; - neovim-tidal = buildPkg prev [tidalConfig]; devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}]; }; } diff --git a/flake/packages.nix b/flake/packages.nix index eb6c946..3724905 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -7,56 +7,50 @@ }: let docs = import ../docs {inherit pkgs inputs;}; in { - packages = - { - # Documentation - docs = docs.manual.html; - docs-html = docs.manual.html; - docs-manpages = docs.manPages; - docs-json = docs.options.json; + packages = { + # Documentation + docs = docs.manual.html; + docs-html = docs.manual.html; + docs-manpages = docs.manPages; + docs-json = docs.options.json; - # Build and open the built manual in your system browser - docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' - #!${pkgs.stdenv.shell} - # use xdg-open to open the docs in the browser - ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} - ''; + # Build and open the built manual in your system browser + docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' + #!${pkgs.stdenv.shell} + # use xdg-open to open the docs in the browser + ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} + ''; - # Exposed neovim configurations - nix = config.legacyPackages.neovim-nix; - maximal = config.legacyPackages.neovim-maximal; - default = config.legacyPackages.neovim-nix; + # Exposed neovim configurations + nix = config.legacyPackages.neovim-nix; + maximal = config.legacyPackages.neovim-maximal; + default = config.legacyPackages.neovim-nix; - # Published docker images - docker-nix = let - inherit (pkgs) bash gitFull buildEnv dockerTools; - inherit (config.legacyPackages) neovim-nix; - in - dockerTools.buildImage { - name = "nvf"; - tag = "latest"; + # Published docker images + docker-nix = let + inherit (pkgs) bash gitFull buildEnv dockerTools; + inherit (config.legacyPackages) neovim-nix; + in + dockerTools.buildImage { + name = "nvf"; + tag = "latest"; - copyToRoot = buildEnv { - name = "neovim-root"; - pathsToLink = ["/bin"]; - paths = [ - neovim-nix - gitFull - bash - ]; - }; - - config = { - Cmd = ["${neovim-nix}/bin/nvim"]; - WorkingDir = "/home/neovim/demo"; - Volumes = {"/home/neovim/demo" = {};}; - }; + copyToRoot = buildEnv { + name = "neovim-root"; + pathsToLink = ["/bin"]; + paths = [ + neovim-nix + gitFull + bash + ]; }; - } - // ( - if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) - then {tidal = config.legacyPackages.neovim-tidal;} - else {} - ); + + config = { + Cmd = ["${neovim-nix}/bin/nvim"]; + WorkingDir = "/home/neovim/demo"; + Volumes = {"/home/neovim/demo" = {};}; + }; + }; + }; }; } diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 3a33ad0..eb5125a 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -5,7 +5,6 @@ in { ./bash ./dart ./elixir - ./tidal ./clang.nix ./css.nix diff --git a/modules/plugins/languages/tidal/config.nix b/modules/plugins/languages/tidal/config.nix deleted file mode 100644 index 344c1a7..0000000 --- a/modules/plugins/languages/tidal/config.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - - cfg = config.vim.tidal; -in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - # From tidalcycles flake - pkgs.vimPlugins.vim-tidal - ]; - - vim.globals = { - "tidal_target" = "terminal"; - "tidal_flash_duration" = 150; - "tidal_sc_enable" = cfg.openSC; - }; - }; -} diff --git a/modules/plugins/languages/tidal/default.nix b/modules/plugins/languages/tidal/default.nix deleted file mode 100644 index da6dd5a..0000000 --- a/modules/plugins/languages/tidal/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [ - ./tidal.nix - ./config.nix - ]; -} diff --git a/modules/plugins/languages/tidal/tidal.nix b/modules/plugins/languages/tidal/tidal.nix deleted file mode 100644 index ebfe4a0..0000000 --- a/modules/plugins/languages/tidal/tidal.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) int bool; -in { - options.vim.tidal = { - enable = mkEnableOption "tidalcycles tools and plugins"; - - flash = mkOption { - description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds''; - type = int; - default = 150; - }; - - openSC = mkOption { - description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal."; - type = bool; - default = true; - }; - }; -} From 6eba2a5585e3cb479a85cac0cd0c125d19fe28a9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:57:27 +0300 Subject: [PATCH 3/8] languages: move bash & dart configurations to standalone files --- modules/plugins/languages/{bash => }/bash.nix | 33 +++++++- modules/plugins/languages/bash/config.nix | 83 ------------------- modules/plugins/languages/bash/default.nix | 6 -- modules/plugins/languages/{dart => }/dart.nix | 74 ++++++++++++++--- modules/plugins/languages/dart/config.nix | 76 ----------------- modules/plugins/languages/dart/default.nix | 6 -- 6 files changed, 94 insertions(+), 184 deletions(-) rename modules/plugins/languages/{bash => }/bash.nix (78%) delete mode 100644 modules/plugins/languages/bash/config.nix delete mode 100644 modules/plugins/languages/bash/default.nix rename modules/plugins/languages/{dart => }/dart.nix (61%) delete mode 100644 modules/plugins/languages/dart/config.nix delete mode 100644 modules/plugins/languages/dart/default.nix diff --git a/modules/plugins/languages/bash/bash.nix b/modules/plugins/languages/bash.nix similarity index 78% rename from modules/plugins/languages/bash/bash.nix rename to modules/plugins/languages/bash.nix index 7b5de0f..1d7e1ce 100644 --- a/modules/plugins/languages/bash/bash.nix +++ b/modules/plugins/languages/bash.nix @@ -1,15 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; inherit (lib.types) enum either package listOf str bool; - inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.types) diagnostics mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.bash; @@ -55,6 +57,7 @@ ls_sources, null_ls.builtins.diagnostics.shellcheck.with({ command = "${pkg}/bin/shellcheck", + diagnostics_format = "#{m} [#{c}]" }) ) ''; @@ -114,4 +117,30 @@ in { }; }; }; + + 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.bash-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig; + }) + + (mkIf cfg.extraDiagnostics.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources = diagnosticsToLua { + lang = "bash"; + config = cfg.extraDiagnostics.types; + inherit diagnosticsProviders; + }; + }) + ]); } diff --git a/modules/plugins/languages/bash/config.nix b/modules/plugins/languages/bash/config.nix deleted file mode 100644 index 7f2a70a..0000000 --- a/modules/plugins/languages/bash/config.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.lists) isList; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.languages) diagnosticsToLua; - - cfg = config.vim.languages.bash; - diagnosticsProviders = { - shellcheck = { - package = pkgs.shellcheck; - nullConfig = pkg: '' - table.insert( - ls_sources, - null_ls.builtins.diagnostics.shellcheck.with({ - command = "${pkg}/bin/shellcheck", - }) - ) - ''; - }; - }; - - formats = { - shfmt = { - package = pkgs.shfmt; - nullConfig = '' - table.insert( - ls_sources, - null_ls.builtins.formatting.shfmt.with({ - command = "${pkgs.shfmt}/bin/shfmt", - }) - ) - ''; - }; - }; - - servers = { - bash-ls = { - package = pkgs.nodePackages.bash-language-server; - lspConfig = '' - lspconfig.bashls.setup{ - capabilities = capabilities; - on_attach = default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' - }; - } - ''; - }; - }; -in { - 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.bash-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - - (mkIf cfg.format.enable { - vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig; - }) - - (mkIf cfg.extraDiagnostics.enable { - vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = diagnosticsToLua { - lang = "bash"; - config = cfg.extraDiagnostics.types; - inherit diagnosticsProviders; - }; - }) - ]); -} diff --git a/modules/plugins/languages/bash/default.nix b/modules/plugins/languages/bash/default.nix deleted file mode 100644 index 7bb1ea2..0000000 --- a/modules/plugins/languages/bash/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./bash.nix - ./config.nix - ]; -} diff --git a/modules/plugins/languages/dart/dart.nix b/modules/plugins/languages/dart.nix similarity index 61% rename from modules/plugins/languages/dart/dart.nix rename to modules/plugins/languages/dart.nix index 13ce3d9..8f957c9 100644 --- a/modules/plugins/languages/dart/dart.nix +++ b/modules/plugins/languages/dart.nix @@ -1,18 +1,23 @@ { config, - lib, pkgs, + lib, ... }: let inherit (builtins) attrNames; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.trivial) boolToString; inherit (lib.lists) isList; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) enum either listOf package nullOr str bool; inherit (lib.strings) optionalString; inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.dart; + ftcfg = cfg.flutter-tools; + defaultServer = "dart"; servers = { dart = { @@ -48,15 +53,16 @@ in { default = defaultServer; }; package = mkOption { - description = "Dart LSP server package, or the command to run as a list of strings"; - example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; type = either package (listOf str); default = servers.${cfg.lsp.server}.package; + example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; + description = "Dart LSP server package, or the command to run as a list of strings"; }; + opts = mkOption { - description = "Options to pass to Dart LSP server"; type = nullOr str; default = null; + description = "Options to pass to Dart LSP server"; }; }; @@ -70,23 +76,26 @@ in { flutter-tools = { enable = mkOption { - description = "Enable flutter-tools for flutter support"; type = bool; default = config.vim.languages.enableLSP; + description = "Enable flutter-tools for flutter support"; }; enableNoResolvePatch = mkOption { - description = '' - Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path. - This is required if you want to use a flutter package built with nix. - If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option. - ''; type = bool; default = true; + description = '' + Whether to patch flutter-tools so that it doesn't resolve + symlinks when detecting flutter path. + + This is required if you want to use a flutter package built with nix. + If you are using a flutter SDK installed from a different source + and encounter the error "`dart` missing from PATH", disable this option. + ''; }; color = { - enable = mkEnableOption "Whether or mot to highlight color variables at all"; + enable = mkEnableOption "highlighting color variables"; highlightBackground = mkOption { type = bool; @@ -112,4 +121,47 @@ in { }; }; }; + + 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.dart-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf ftcfg.enable { + vim.startPlugins = + if ftcfg.enableNoResolvePatch + then ["flutter-tools-patched"] + else ["flutter-tools"]; + + vim.luaConfigRC.flutter-tools = entryAnywhere '' + require('flutter-tools').setup { + lsp = { + color = { -- show the derived colours for dart variables + enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 + background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background + foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground + virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text + virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight + }, + + capabilities = capabilities, + on_attach = default_on_attach; + flags = lsp_flags, + }, + ${optionalString cfg.dap.enable '' + debugger = { + enabled = true, + }, + ''} + } + ''; + }) + ]); } diff --git a/modules/plugins/languages/dart/config.nix b/modules/plugins/languages/dart/config.nix deleted file mode 100644 index be7c111..0000000 --- a/modules/plugins/languages/dart/config.nix +++ /dev/null @@ -1,76 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib.lists) isList; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.dag) entryAnywhere; - - cfg = config.vim.languages.dart; - ftcfg = cfg.flutter-tools; - servers = { - dart = { - package = pkgs.dart; - lspConfig = '' - lspconfig.dartls.setup{ - capabilities = capabilities; - on_attach=default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' - }; - ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} - } - ''; - }; - }; -in { - 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.dart-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - - (mkIf ftcfg.enable { - vim.startPlugins = - if ftcfg.enableNoResolvePatch - then ["flutter-tools-patched"] - else ["flutter-tools"]; - - vim.luaConfigRC.flutter-tools = entryAnywhere '' - require('flutter-tools').setup { - lsp = { - color = { -- show the derived colours for dart variables - enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 - background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background - foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground - virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text - virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight - }, - - capabilities = capabilities, - on_attach = default_on_attach; - flags = lsp_flags, - }, - ${optionalString cfg.dap.enable '' - debugger = { - enabled = true, - }, - ''} - } - ''; - }) - ]); -} diff --git a/modules/plugins/languages/dart/default.nix b/modules/plugins/languages/dart/default.nix deleted file mode 100644 index 2ad34f3..0000000 --- a/modules/plugins/languages/dart/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./dart.nix - ./config.nix - ]; -} From 7481423bed82c3d869cb6a67a4bd572e8fe84dd2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:57:36 +0300 Subject: [PATCH 4/8] docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index b5047a4..8f61a89 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -23,4 +23,10 @@ Release notes for release 0.7 - Add `deno fmt` as the default Markdown formatter. This will be enabled automatically if you have autoformatting enabled, but can be disabled manually if you choose to. + - Remove vim-tidal and friends + +- Remove unmaintained Elixir language module. This has been long broken, and was + unmaintained due to my disinterest in using Elixir. If you depend on Elixir + language support, please create an issue. Do keep in mind that elixirls **does + not exist in nixpkgs**. From bf090172d2aaed2731a7c2661f4cc68791eb0e87 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 23:09:40 +0300 Subject: [PATCH 5/8] modules/extra: init deprecations module; warn for elixir & vim-tidal --- modules/extra/deprecations.nix | 16 ++++++++++++++++ modules/modules.nix | 8 +++++++- modules/plugins/languages/default.nix | 6 ++---- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 modules/extra/deprecations.nix diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix new file mode 100644 index 0000000..b2bf522 --- /dev/null +++ b/modules/extra/deprecations.nix @@ -0,0 +1,16 @@ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; +in { + imports = [ + # 2024-06-06 + (mkRemovedOptionModule ["vim" "languages" "elixir"] '' + Elixir language support has been removed as of 2024-06-06 as it was long unmaintained. If + you dependend on this language support, please consider contributing to its maintenance. + '') + + (mkRemovedOptionModule ["vim" "tidal"] '' + 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. + '') + ]; +} diff --git a/modules/modules.nix b/modules/modules.nix index 620111f..0de5984 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,7 +53,13 @@ "warnings" ]; - allModules = concatLists [neovim plugins wrapper]; + # 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 = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index eb5125a..802dfe7 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -2,10 +2,8 @@ inherit (lib.nvim.languages) mkEnable; in { imports = [ - ./bash - ./dart - ./elixir - + ./bash.nix + ./dart.nix ./clang.nix ./css.nix ./go.nix From e0790f2bdb132c77a23dae3626601be1bb960321 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 23:09:59 +0300 Subject: [PATCH 6/8] docs: remove remaining references to elixir & vim-tidal related pkgs --- configuration.nix | 2 -- docs/manual/try-it-out.md | 6 ------ flake.lock | 34 ---------------------------------- flake.nix | 10 ---------- 4 files changed, 52 deletions(-) diff --git a/configuration.nix b/configuration.nix index 5c0095b..82f86cc 100644 --- a/configuration.nix +++ b/configuration.nix @@ -55,8 +55,6 @@ inputs: let enableExtraDiagnostics = true; nim.enable = false; - elixir.enable = false; - nix.enable = true; markdown.enable = true; diff --git a/docs/manual/try-it-out.md b/docs/manual/try-it-out.md index 70aee50..bd8c69b 100644 --- a/docs/manual/try-it-out.md +++ b/docs/manual/try-it-out.md @@ -5,7 +5,6 @@ Below are the commands you may run to try out different configurations provided configurations are provided: - Nix -- Tidal - Maximal You may try out any of the provided configurations using the `nix run` command on a system where Nix is installed. @@ -22,7 +21,6 @@ once you garbage collect. ```console $ nix run github:notashelf/nvf#nix -$ nix run github:notashelf/nvf#tidal $ nix run github:notashelf/nvf#maximal ``` @@ -33,10 +31,6 @@ $ nix run github:notashelf/nvf#maximal `Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins. By running `nix run .#`, which is the default package, you will build Neovim with this config. -#### Tidal {#sec-configs-tidal} - -Tidal is an alternative config that adds vim-tidal on top of the plugins from the Nix configuration. - #### Maximal {#sec-configs-maximal} `Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional diff --git a/flake.lock b/flake.lock index e706001..cd2a3ee 100644 --- a/flake.lock +++ b/flake.lock @@ -546,38 +546,6 @@ "type": "github" } }, - "plugin-elixir-ls": { - "flake": false, - "locked": { - "lastModified": 1713724318, - "narHash": "sha256-1kLMxznNRRJ7M10zkuWexA/sPFaN449M0SKUjLrnc8c=", - "owner": "elixir-lsp", - "repo": "elixir-ls", - "rev": "8486de473a219dcdb72408702f8d56d0227c7366", - "type": "github" - }, - "original": { - "owner": "elixir-lsp", - "repo": "elixir-ls", - "type": "github" - } - }, - "plugin-elixir-tools": { - "flake": false, - "locked": { - "lastModified": 1713617654, - "narHash": "sha256-pJgtW51FLs+Yr+tlQckRmGkRnSUQNI3fEROn3D51mMs=", - "owner": "elixir-tools", - "repo": "elixir-tools.nvim", - "rev": "3c4f8344a341818417b3d75c04eb96d894cb4640", - "type": "github" - }, - "original": { - "owner": "elixir-tools", - "repo": "elixir-tools.nvim", - "type": "github" - } - }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1796,8 +1764,6 @@ "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", - "plugin-elixir-ls": "plugin-elixir-ls", - "plugin-elixir-tools": "plugin-elixir-tools", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", diff --git a/flake.nix b/flake.nix index 3425add..d51617a 100644 --- a/flake.nix +++ b/flake.nix @@ -178,16 +178,6 @@ flake = false; }; - plugin-elixir-ls = { - url = "github:elixir-lsp/elixir-ls"; - flake = false; - }; - - plugin-elixir-tools = { - url = "github:elixir-tools/elixir-tools.nvim"; - flake = false; - }; - plugin-glow-nvim = { url = "github:ellisonleao/glow.nvim"; flake = false; From e96897f6b3e60183e81a04a45593f837f4e101d8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 May 2024 00:52:33 +0300 Subject: [PATCH 7/8] languages/elixir: readd; format module options --- configuration.nix | 3 +- docs/release-notes/rl-0.7.md | 10 +- flake.lock | 17 +++ flake.nix | 19 ++- modules/extra/deprecations.nix | 5 - modules/plugins/languages/default.nix | 1 + modules/plugins/languages/elixir.nix | 138 ++++++++++++++++++ modules/plugins/languages/elixir/config.nix | 67 --------- modules/plugins/languages/elixir/default.nix | 6 - .../plugins/languages/elixir/elixir-tools.nix | 7 - 10 files changed, 175 insertions(+), 98 deletions(-) create mode 100644 modules/plugins/languages/elixir.nix delete mode 100644 modules/plugins/languages/elixir/config.nix delete mode 100644 modules/plugins/languages/elixir/default.nix delete mode 100644 modules/plugins/languages/elixir/elixir-tools.nix diff --git a/configuration.nix b/configuration.nix index 82f86cc..56e5d90 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,7 +54,6 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; - nim.enable = false; nix.enable = true; markdown.enable = true; @@ -65,12 +64,14 @@ inputs: let ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; + elixir.enable = isMaximal; zig.enable = isMaximal; python.enable = isMaximal; dart.enable = isMaximal; bash.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; + nim.enable = isMaximal; clang = { enable = isMaximal; lsp.server = "clangd"; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 8f61a89..0cf265f 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -24,9 +24,9 @@ Release notes for release 0.7 automatically if you have autoformatting enabled, but can be disabled manually if you choose to. -- Remove vim-tidal and friends +- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and + formatter setups respectively. Diagnostics support is considered, and may be + added once the [credo](https://github.com/rrrene/credo) linter has been added + to nixpkgs. A pull request is currently open. -- Remove unmaintained Elixir language module. This has been long broken, and was - unmaintained due to my disinterest in using Elixir. If you depend on Elixir - language support, please create an issue. Do keep in mind that elixirls **does - not exist in nixpkgs**. +- Remove vim-tidal and friends diff --git a/flake.lock b/flake.lock index cd2a3ee..c34ef94 100644 --- a/flake.lock +++ b/flake.lock @@ -546,6 +546,22 @@ "type": "github" } }, + "plugin-elixir-tools": { + "flake": false, + "locked": { + "lastModified": 1714657398, + "narHash": "sha256-U6db1n/RIpT7Dd54e9iI/PjO1BhDpMyNPfaph+dUk7k=", + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "rev": "51eddb03a7a8c9f00d6415b356a4d3b75d8e75b6", + "type": "github" + }, + "original": { + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "type": "github" + } + }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1764,6 +1780,7 @@ "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", + "plugin-elixir-tools": "plugin-elixir-tools", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", diff --git a/flake.nix b/flake.nix index d51617a..ae6885a 100644 --- a/flake.nix +++ b/flake.nix @@ -178,13 +178,8 @@ flake = false; }; - plugin-glow-nvim = { - url = "github:ellisonleao/glow.nvim"; - flake = false; - }; - - plugin-image-nvim = { - url = "github:3rd/image.nvim"; + plugin-elixir-tools = { + url = "github:elixir-tools/elixir-tools.nvim"; flake = false; }; @@ -487,6 +482,16 @@ flake = false; }; + plugin-glow-nvim = { + url = "github:ellisonleao/glow.nvim"; + flake = false; + }; + + plugin-image-nvim = { + url = "github:3rd/image.nvim"; + flake = false; + }; + # Note-taking plugin-obsidian-nvim = { url = "github:epwalsh/obsidian.nvim"; diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index b2bf522..cb06380 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -3,11 +3,6 @@ in { imports = [ # 2024-06-06 - (mkRemovedOptionModule ["vim" "languages" "elixir"] '' - Elixir language support has been removed as of 2024-06-06 as it was long unmaintained. If - you dependend on this language support, please consider contributing to its maintenance. - '') - (mkRemovedOptionModule ["vim" "tidal"] '' 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. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 802dfe7..279d46b 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -6,6 +6,7 @@ in { ./dart.nix ./clang.nix ./css.nix + ./elixir.nix ./go.nix ./html.nix ./java.nix diff --git a/modules/plugins/languages/elixir.nix b/modules/plugins/languages/elixir.nix new file mode 100644 index 0000000..7f969ad --- /dev/null +++ b/modules/plugins/languages/elixir.nix @@ -0,0 +1,138 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.languages.elixir; + + defaultServer = "elixirls"; + servers = { + elixirls = { + package = pkgs.elixir-ls; + lspConfig = '' + -- elixirls setup + lspconfig.elixirls.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/elixir-ls"}'' + } + } + ''; + }; + }; + + defaultFormat = "mix"; + formats = { + mix = { + package = pkgs.elixir; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.mix.with({ + command = "${cfg.format.package}/bin/mix", + }) + ) + ''; + }; + }; +in { + options.vim.languages.elixir = { + enable = mkEnableOption "Elixir language support"; + + treesitter = { + enable = mkEnableOption "Elixir treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "elixir"; + }; + + lsp = { + enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;}; + + server = mkOption { + description = "Elixir LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + + package = mkOption { + description = "Elixir LSP server package, or the command to run as a list of strings"; + example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; + type = either package (listOf str); + default = servers.${cfg.lsp.server}.package; + }; + }; + + format = { + enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Elixir formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Elixir formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + }; + + elixir-tools = { + enable = mkEnableOption "Elixir tools"; + }; + }; + + 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.elixir-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.elixir-format = formats.${cfg.format.type}.nullConfig; + }) + + (mkIf cfg.elixir-tools.enable { + vim.startPlugins = ["elixir-tools"]; + vim.luaConfigRC.elixir-tools = entryAnywhere '' + local elixir-tools = require("elixir") + local elixirls = require("elixir-tools.elixirls") + + -- disable imperative insstallations of various + -- elixir related tools installed by elixir-tools + elixir-tools.setup { + nextls = { + enable = false -- defaults to false + }, + + credo = { + enable = false -- defaults to true + }, + + elixirls = { + enable = false, -- defaults to true + } + } + ''; + }) + ]); +} diff --git a/modules/plugins/languages/elixir/config.nix b/modules/plugins/languages/elixir/config.nix deleted file mode 100644 index eaf26ea..0000000 --- a/modules/plugins/languages/elixir/config.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.meta) getExe; - inherit (lib.nvim.dag) entryAnywhere; - - cfg = config.vim.languages.elixir; -in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "elixir-tools" - ]; - - vim.luaConfigRC.elixir-tools = entryAnywhere '' - local elixir = require("elixir") - local elixirls = require("elixir.elixirls") - - elixir.setup { - elixirls = { - -- alternatively, point to an existing elixir-ls installation (optional) - -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` - cmd = "${getExe pkgs.elixir-ls}", - - -- default settings, use the `settings` function to override settings - settings = elixirls.settings { - dialyzerEnabled = true, - fetchDeps = false, - enableTestLenses = false, - suggestSpecs = false, - }, - - on_attach = function(client, bufnr) - local map_opts = { buffer = true, noremap = true} - - -- run the codelens under the cursor - vim.keymap.set("n", "r", vim.lsp.codelens.run, map_opts) - -- remove the pipe operator - vim.keymap.set("n", "fp", ":ElixirFromPipe", map_opts) - -- add the pipe operator - vim.keymap.set("n", "tp", ":ElixirToPipe", map_opts) - vim.keymap.set("v", "em", ":ElixirExpandMacro", map_opts) - - -- bindings for standard LSP functions. - vim.keymap.set("n", "df", "lua vim.lsp.buf.format()", map_opts) - vim.keymap.set("n", "gd", "lua vim.diagnostic.open_float()", map_opts) - vim.keymap.set("n", "dt", "lua vim.lsp.buf.definition()", map_opts) - vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", map_opts) - vim.keymap.set("n", "gD","lua vim.lsp.buf.implementation()", map_opts) - vim.keymap.set("n", "1gD","lua vim.lsp.buf.type_definition()", map_opts) - - -- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim - -- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim - -- there are also core vim.lsp functions that put the same data in the loclist - vim.keymap.set("n", "gr", ":References", map_opts) - vim.keymap.set("n", "g0", ":DocumentSymbols", map_opts) - vim.keymap.set("n", "gW", ":WorkspaceSymbols", map_opts) - vim.keymap.set("n", "d", ":Diagnostics", map_opts) - end - } - } - ''; - }; -} diff --git a/modules/plugins/languages/elixir/default.nix b/modules/plugins/languages/elixir/default.nix deleted file mode 100644 index c84acf0..0000000 --- a/modules/plugins/languages/elixir/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./config.nix - ./elixir-tools.nix - ]; -} diff --git a/modules/plugins/languages/elixir/elixir-tools.nix b/modules/plugins/languages/elixir/elixir-tools.nix deleted file mode 100644 index 0527359..0000000 --- a/modules/plugins/languages/elixir/elixir-tools.nix +++ /dev/null @@ -1,7 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; -in { - options.vim.languages.elixir = { - enable = mkEnableOption "Elixir language support"; - }; -} From 96b92b5652cfd192a953b01f34630714b48a96b9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 May 2024 15:40:08 +0300 Subject: [PATCH 8/8] configuration.nix: disable nim by default It is broken on Darwin, and pkgs is not in scope here to check --- configuration.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/configuration.nix b/configuration.nix index 56e5d90..e2c02f7 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,9 +54,16 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; - nix.enable = true; - markdown.enable = 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; + nix.enable = true; + + markdown.enable = isMaximal; html.enable = isMaximal; css.enable = isMaximal; sql.enable = isMaximal; @@ -71,7 +78,6 @@ inputs: let bash.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; - nim.enable = isMaximal; clang = { enable = isMaximal; lsp.server = "clangd"; @@ -79,14 +85,14 @@ inputs: let rust = { enable = isMaximal; - crates.enable = true; + crates.enable = isMaximal; }; }; visuals = { enable = true; nvimWebDevicons.enable = true; - scrollBar.enable = true; + scrollBar.enable = isMaximal; smoothScroll.enable = true; cellularAutomaton.enable = false; fidget-nvim.enable = true;