From c466775789541c885e0801a90eb2e759347c6fd4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:33:14 +0300 Subject: [PATCH 01/11] docs: improve project readme --- .github/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index c12f462c..30900462 100644 --- a/.github/README.md +++ b/.github/README.md @@ -123,22 +123,26 @@ instead of the `maximal` output. This will reduce size by a lot, but you will lo **A**: Yes. As a matter of fact, I am actively working on making this flake smaller. Unfortunately the process of providing everything possible by itself makes the flake large. Best I can do is to optimize the flake as much as possible by selecting plugins that are small and fast. And the binary cache, so at least you don't have to build it from source.

-**Q**: Will you use a plugin manager? +**Q**: Will you use a plugin manager/language server installer?
-**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. We load plugins with raw lua. +**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. The whole reason we use nix is to be able to handle EVERYTHING declaratively, well including the LSP and plugin installations.

**Q**: Can you add *X*?
-**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add every plugin that is in existence, but I will consider it, should it offer something useful to the flake. +**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add *every plugin that is in existence*, but I will consider it, should it offer something useful to the flake. ## Credits ### Contributors +Special thanks to + - [@fufexan](https://github.com/fufexan) - For the transition to flake-parts - [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work +and everyone who has submitted issues or pull requests! + ### Inspiration This configuration borrows from and is based on a few other configurations, including: From a6264dcf733848b507791adc23b3acb148e6beba Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:33:50 +0300 Subject: [PATCH 02/11] CI: fix typo in workflow description --- .github/workflows/cachix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index cc79a5e4..5df8c32c 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -44,5 +44,5 @@ jobs: run: git config --global init.defaultBranch main - name: Validate Flakes run: nix flake check - - name: Build Hneovim-flake with default settings + - name: Build neovim-flake with default settings run: nix build .#${{ matrix.package }} --print-build-logs From 8f5b27d0690f305990adc8702413b00b1dc352a5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:34:34 +0300 Subject: [PATCH 03/11] CI: test documentation builds on PR --- .github/workflows/check-docs.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/check-docs.yml diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml new file mode 100644 index 00000000..ed4998e3 --- /dev/null +++ b/.github/workflows/check-docs.yml @@ -0,0 +1,30 @@ +name: "Validate flake & check formatting" +on: + pull_request: + workflow_dispatch: + push: + branches: + - main + paths: + - docs/** +jobs: + nix-flake-check: + name: Validate Flake + runs-on: ubuntu-latest + strategy: + matrix: + package: + - docs + - docs-html + - docs-manpages + - docs-json + steps: + - uses: actions/checkout@v3 + - name: Set default git branch (to reduce log spam) + run: git config --global init.defaultBranch main + - name: Validate Flakes + run: nix flake check + - name: Build neovim-flake with default settings + run: nix build .#${{ matrix.package }} --print-build-logs + + From 8545cf4748f05c7d124614b7ab736afa62351989 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:36:15 +0300 Subject: [PATCH 04/11] CI: rename workflow --- .github/workflows/check-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index ed4998e3..cbd62d3f 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -1,4 +1,4 @@ -name: "Validate flake & check formatting" +name: "Validate flake & check documentation" on: pull_request: workflow_dispatch: @@ -8,8 +8,8 @@ on: paths: - docs/** jobs: - nix-flake-check: - name: Validate Flake + flake-docs-check: + name: Validate Flake Documentation runs-on: ubuntu-latest strategy: matrix: From c7949b5ecce52ef309b86888b4f81e65bd6b9a73 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:38:51 +0300 Subject: [PATCH 05/11] CI: set up nix before checking docs --- .github/workflows/check-docs.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index cbd62d3f..95b2af17 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -19,6 +19,20 @@ jobs: - docs-manpages - docs-json steps: + - uses: easimon/maximize-build-space@v6 + with: + overprovision-lvm: true + remove-android: true + remove-dotnet: true + remove-haskell: true + - uses: cachix/install-nix-action@v20 + with: + extra_nix_config: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + auto-optimise-store = true + experimental-features = nix-command flakes + nix_path: nixpkgs=channel:nixos-unstable + - uses: actions/checkout@v3 - name: Set default git branch (to reduce log spam) run: git config --global init.defaultBranch main From 844c4c597404a12858150d05b9f07260eafba9c8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 11:44:12 +0300 Subject: [PATCH 06/11] CI: better ci workflow names --- .github/workflows/cachix.yml | 4 ++-- .github/workflows/manual.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 5df8c32c..536061a5 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -1,4 +1,4 @@ -name: build-and-cache +name: "Set up binary cache" on: workflow_dispatch: @@ -11,7 +11,7 @@ on: - .gitignore jobs: - nix: + cahix: runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index ca403c2a..5a2a50f4 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -1,4 +1,4 @@ -name: Github Pages docs +name: "Build and deploy documentation" on: workflow_dispatch: push: From d138eca7c55468306c5cd8efd541eee2a405a367 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 12:06:03 +0300 Subject: [PATCH 07/11] CI/docs: fix doc builds --- docs/try-it-out.adoc | 2 ++ modules/autopairs/nvim-autopairs/nvim-autopairs.nix | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/try-it-out.adoc b/docs/try-it-out.adoc index c2b58d6f..2311704d 100644 --- a/docs/try-it-out.adoc +++ b/docs/try-it-out.adoc @@ -21,6 +21,8 @@ Tidal is an alternative config that adds vim-tidal on top of the plugins from th Maximal is the ultimate configuration that will enable basically everything. Keep in mind, however, that this will pull a lot of dependencies. +You are strongly recommended to use the binary cache if you would like to try the Maximal configuration. + === Using Prebuilt Configs diff --git a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index ecfda6f3..2515e650 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -23,7 +23,7 @@ with builtins; { map_cr = mkOption { type = types.bool; default = true; - description = "map on insert mode"; + description = "map `CR` on insert mode"; }; map_complete = mkOption { From bbb58c8d517aa642b5d35ec0f318a5c3ddae049e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 12:43:39 +0300 Subject: [PATCH 08/11] feat: add elixir-ls to flake inputs --- flake.lock | 17 +++++++++++++++++ flake.nix | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/flake.lock b/flake.lock index baa79cae..492f5750 100644 --- a/flake.lock +++ b/flake.lock @@ -321,6 +321,22 @@ "type": "github" } }, + "elixir-ls": { + "flake": false, + "locked": { + "lastModified": 1681462421, + "narHash": "sha256-pIwZFiCLJ0f7OXi1iTza04KSn7rpFpvUsNYrFh0FoEM=", + "owner": "elixir-lsp", + "repo": "elixir-ls", + "rev": "85cfc5604edeadb0a6a683c41abff60a0c959de7", + "type": "github" + }, + "original": { + "owner": "elixir-lsp", + "repo": "elixir-ls", + "type": "github" + } + }, "fidget-nvim": { "flake": false, "locked": { @@ -1319,6 +1335,7 @@ "dashboard-nvim": "dashboard-nvim", "diffview-nvim": "diffview-nvim", "dressing-nvim": "dressing-nvim", + "elixir-ls": "elixir-ls", "fidget-nvim": "fidget-nvim", "flake-parts": "flake-parts", "flake-utils": "flake-utils", diff --git a/flake.nix b/flake.nix index ea6eaac5..b19b16d5 100644 --- a/flake.nix +++ b/flake.nix @@ -92,22 +92,27 @@ url = "github:neovim/nvim-lspconfig"; flake = false; }; + lspsaga = { url = "github:tami5/lspsaga.nvim"; flake = false; }; + lspkind = { url = "github:onsails/lspkind-nvim"; flake = false; }; + trouble = { url = "github:folke/trouble.nvim"; flake = false; }; + nvim-treesitter-context = { url = "github:lewis6991/nvim-treesitter-context"; flake = false; }; + nvim-lightbulb = { url = "github:kosayoda/nvim-lightbulb"; flake = false; @@ -117,18 +122,22 @@ url = "github:weilbith/nvim-code-action-menu"; flake = false; }; + lsp-signature = { url = "github:ray-x/lsp_signature.nvim"; flake = false; }; + null-ls = { url = "github:jose-elias-alvarez/null-ls.nvim"; flake = false; }; + sqls-nvim = { url = "github:nanotee/sqls.nvim"; flake = false; }; + rust-tools = { url = "github:simrat39/rust-tools.nvim"; flake = false; @@ -139,6 +148,11 @@ flake = false; }; + elixir-ls = { + url = "github:elixir-lsp/elixir-ls"; + flake = false; + }; + # Copying/Registers registers = { url = "github:tversteeg/registers.nvim"; From 918070aeeb1ba92441845b645927b4682bea9a09 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 12:43:45 +0300 Subject: [PATCH 09/11] fix: deprecated view.hide-root-folder opt --- extra.nix | 1 + modules/lsp/config.nix | 38 ++++++++++++++++++++------------------ modules/lsp/module.nix | 4 ++++ 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/extra.nix b/extra.nix index 55a2f6a4..e80abaab 100644 --- a/extra.nix +++ b/extra.nix @@ -33,6 +33,7 @@ inputs: let nvimCodeActionMenu.enable = true; trouble.enable = true; lspSignature.enable = true; + elixir.enable = isMaximal; rust.enable = isMaximal; python = isMaximal; clang.enable = isMaximal; diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index 581556ef..c1cb706b 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -19,25 +19,20 @@ in { [ "nvim-lspconfig" "null-ls" - ( - if (config.vim.autocomplete.enable && (config.vim.autocomplete.type == "nvim-cmp")) - then "cmp-nvim-lsp" - else null - ) - ( - if cfg.sql - then "sqls-nvim" - else null - ) ] - ++ ( - if cfg.rust.enable - then [ - "crates-nvim" - "rust-tools" - ] - else [] - ); + ++ optionals (cfg.rust.enable) [ + "crates-nvim" + "rust-tools" + ] + ++ optionals (cfg.elixir.enable) [ + "elixir-ls" + ] + ++ optionals ((config.vim.autocomplete.enable) && (config.vim.autocomplete.type == "nvim-cmp")) [ + "cmp-nvim-lsp" + ] + ++ optionals (cfg.sql) [ + "sqls-nvim" + ]; vim.configRC.lsp = nvim.dag.entryAnywhere '' ${ @@ -346,6 +341,13 @@ in { cmd = { "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio" } } ''} + + ${writeIf cfg.elixir.enable '' + lspconfig.elixirls.setup { + cmd = { "${pkgs.elixir-ls}/language_server.sh" }, + on_attach = on_attach + } + ''} ''; } ); diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index a6b95d97..87df9db6 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -65,6 +65,10 @@ in { }; }; + elixir = { + enable = mkEnableOption "Elixir LSP"; + }; + sql = mkEnableOption "SQL Language LSP"; go = mkEnableOption "Go language LSP"; ts = mkEnableOption "TS language LSP"; From 7a20488c059e6a273d1879d506e5229f1e6df7f6 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 12:43:50 +0300 Subject: [PATCH 10/11] feat: add elixir-ls to accepted plugins --- lib/types/plugins.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 3ff9dd1a..03a433ae 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -79,6 +79,7 @@ with lib; let "vim-repeat" "smartcolumn" "project-nvim" + "elixir-ls" ]; # You can either use the name of the plugin or a package. pluginsType = with types; From 3071c6bb4be4cde5936cfec533c7a8b2fd3bd9cd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 15 Apr 2023 22:51:13 +0300 Subject: [PATCH 11/11] feat: use elixir-tools.nvim for additional highlighting --- flake.lock | 17 ++++++++ flake.nix | 5 +++ lib/types/plugins.nix | 1 + modules/lsp/config.nix | 2 +- modules/lsp/default.nix | 5 ++- modules/lsp/elixir/config.nix | 67 +++++++++++++++++++++++++++++ modules/lsp/elixir/default.nix | 6 +++ modules/lsp/elixir/elixir-tools.nix | 10 +++++ modules/treesitter/treesitter.nix | 2 + 9 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 modules/lsp/elixir/config.nix create mode 100644 modules/lsp/elixir/default.nix create mode 100644 modules/lsp/elixir/elixir-tools.nix diff --git a/flake.lock b/flake.lock index 492f5750..36800427 100644 --- a/flake.lock +++ b/flake.lock @@ -337,6 +337,22 @@ "type": "github" } }, + "elixir-tools": { + "flake": false, + "locked": { + "lastModified": 1681453321, + "narHash": "sha256-7QgWrdq4p5t8WVnFhL5P948JFPR0i2C06kisxl30D2U=", + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "rev": "8ccb696c048eca667486ee005f4386c0db8c5e14", + "type": "github" + }, + "original": { + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "type": "github" + } + }, "fidget-nvim": { "flake": false, "locked": { @@ -1336,6 +1352,7 @@ "diffview-nvim": "diffview-nvim", "dressing-nvim": "dressing-nvim", "elixir-ls": "elixir-ls", + "elixir-tools": "elixir-tools", "fidget-nvim": "fidget-nvim", "flake-parts": "flake-parts", "flake-utils": "flake-utils", diff --git a/flake.nix b/flake.nix index b19b16d5..da89f516 100644 --- a/flake.nix +++ b/flake.nix @@ -153,6 +153,11 @@ flake = false; }; + elixir-tools = { + url = "github:elixir-tools/elixir-tools.nvim"; + flake = false; + }; + # Copying/Registers registers = { url = "github:tversteeg/registers.nvim"; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 03a433ae..2c1aaa9d 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -80,6 +80,7 @@ with lib; let "smartcolumn" "project-nvim" "elixir-ls" + "elixir-tools" ]; # You can either use the name of the plugin or a package. pluginsType = with types; diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index c1cb706b..6a6810ca 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -344,7 +344,7 @@ in { ${writeIf cfg.elixir.enable '' lspconfig.elixirls.setup { - cmd = { "${pkgs.elixir-ls}/language_server.sh" }, + cmd = { "${lib.getExe pkgs.elixir-ls}" }, on_attach = on_attach } ''} diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index db4f0272..cb88e3d9 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -11,7 +11,8 @@ ./lsp-signature ./lightbulb - # flutter-tools - ./flutter-tools-nvim + # language specific modules + ./flutter-tools-nvim # dart & flutter + ./elixir # elixir ]; } diff --git a/modules/lsp/elixir/config.nix b/modules/lsp/elixir/config.nix new file mode 100644 index 00000000..1b1e2a5a --- /dev/null +++ b/modules/lsp/elixir/config.nix @@ -0,0 +1,67 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; +with builtins; let + cfg = config.vim.lsp.elixir; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + "elixir-tools" + "plenary-nvim" + ]; + + vim.luaConfigRC.elixir-tools = nvim.dag.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 = "${lib.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/lsp/elixir/default.nix b/modules/lsp/elixir/default.nix new file mode 100644 index 00000000..b8ea9be6 --- /dev/null +++ b/modules/lsp/elixir/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./elixir-tools.nix + ]; +} diff --git a/modules/lsp/elixir/elixir-tools.nix b/modules/lsp/elixir/elixir-tools.nix new file mode 100644 index 00000000..d3fe1ec2 --- /dev/null +++ b/modules/lsp/elixir/elixir-tools.nix @@ -0,0 +1,10 @@ +{ + config, + lib, + ... +}: +with lib; +with builtins; { + options.vim.lsp.elixir = { + }; +} diff --git a/modules/treesitter/treesitter.nix b/modules/treesitter/treesitter.nix index ab3cea62..550e7fef 100644 --- a/modules/treesitter/treesitter.nix +++ b/modules/treesitter/treesitter.nix @@ -45,6 +45,8 @@ with builtins; { graphql json zig + elixir + heex ] ++ (optional config.vim.notes.orgmode.enable org); # add orgmode grammar if enabled description = ''