diff --git a/.github/README.md b/.github/README.md index c12f462..3090046 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: diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index cc79a5e..536061a 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: @@ -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 diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml new file mode 100644 index 0000000..95b2af1 --- /dev/null +++ b/.github/workflows/check-docs.yml @@ -0,0 +1,44 @@ +name: "Validate flake & check documentation" +on: + pull_request: + workflow_dispatch: + push: + branches: + - main + paths: + - docs/** +jobs: + flake-docs-check: + name: Validate Flake Documentation + runs-on: ubuntu-latest + strategy: + matrix: + package: + - docs + - docs-html + - 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 + - name: Validate Flakes + run: nix flake check + - name: Build neovim-flake with default settings + run: nix build .#${{ matrix.package }} --print-build-logs + + diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index ca403c2..5a2a50f 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: diff --git a/docs/try-it-out.adoc b/docs/try-it-out.adoc index c2b58d6..2311704 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/flake.lock b/flake.lock index 15262b0..41ebb7e 100644 --- a/flake.lock +++ b/flake.lock @@ -337,6 +337,38 @@ "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" + } + }, + "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": { @@ -1262,6 +1294,8 @@ "diffview-nvim": "diffview-nvim", "dracula": "dracula", "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 7678e24..18f712b 100644 --- a/flake.nix +++ b/flake.nix @@ -74,22 +74,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:nvim-treesitter/nvim-treesitter-context"; flake = false; }; + nvim-lightbulb = { url = "github:kosayoda/nvim-lightbulb"; flake = false; @@ -99,18 +104,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; @@ -121,6 +130,16 @@ flake = false; }; + elixir-ls = { + url = "github:elixir-lsp/elixir-ls"; + 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 770a47a..0c1d0d3 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -80,6 +80,8 @@ with lib; let "vim-repeat" "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/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix index 1b3f8b7..f807459 100644 --- a/modules/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -24,6 +24,7 @@ with builtins; { type = types.bool; default = true; description = nvim.nmd.asciiDoc ''map on insert mode''; + }; map_complete = mkOption { diff --git a/modules/lsp/config.nix b/modules/lsp/config.nix index 5e56b9c..86f5069 100644 --- a/modules/lsp/config.nix +++ b/modules/lsp/config.nix @@ -45,6 +45,7 @@ in { if client.supports_method("textDocument/formatting") then local params = require'vim.lsp.util'.make_formatting_params({}) client.request('textDocument/formatting', params, nil, bufnr) + end end end @@ -60,4 +61,5 @@ in { ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"} ''; }; + } diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 050187b..a6f1e52 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -16,7 +16,8 @@ _: { ./lightbulb ./lspkind - # 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 0000000..1b1e2a5 --- /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 0000000..b8ea9be --- /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 0000000..d3fe1ec --- /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 84a09ea..cd4476d 100644 --- a/modules/treesitter/treesitter.nix +++ b/modules/treesitter/treesitter.nix @@ -22,6 +22,7 @@ in { description = nvim.nmd.asciiDoc '' List of treesitter grammars to install. For supported languages use the `vim.language..treesitter` option + ''; }; };