diff --git a/flake.lock b/flake.lock index a855308..2575bc4 100644 --- a/flake.lock +++ b/flake.lock @@ -449,14 +449,32 @@ "nvim-ts-rainbow": "nvim-ts-rainbow", "nvim-web-devicons": "nvim-web-devicons", "plenary-nvim": "plenary-nvim", + "rust-tools": "rust-tools", "telescope-nvim": "telescope-nvim", "theme-catppuccin": "theme-catppuccin", "theme-doom-one": "theme-doom-one", "theme-rose-pine": "theme-rose-pine", + "typescript-nvim": "typescript-nvim", "vim-sexp": "vim-sexp", "vim-sexp-mappings": "vim-sexp-mappings" } }, + "rust-tools": { + "flake": false, + "locked": { + "lastModified": 1676929960, + "narHash": "sha256-Cuk/vdoviB9ibt2rrkNRmNFy4S+6czhbExmIjTJRdZM=", + "owner": "simrat39", + "repo": "rust-tools.nvim", + "rev": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f", + "type": "github" + }, + "original": { + "owner": "simrat39", + "repo": "rust-tools.nvim", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -538,6 +556,22 @@ "type": "github" } }, + "typescript-nvim": { + "flake": false, + "locked": { + "lastModified": 1672710615, + "narHash": "sha256-PHVY5NJbOGvY9p0F0QNSfMKmAWdqjw1RB0Vspq88qMI=", + "owner": "jose-elias-alvarez", + "repo": "typescript.nvim", + "rev": "f66d4472606cb24615dfb7dbc6557e779d177624", + "type": "github" + }, + "original": { + "owner": "jose-elias-alvarez", + "repo": "typescript.nvim", + "type": "github" + } + }, "vim-sexp": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 7287a24..9fc4fd1 100644 --- a/flake.nix +++ b/flake.nix @@ -126,13 +126,8 @@ flake = false; }; - vim-sexp = { - url = "github:guns/vim-sexp"; - flake = false; - }; - - vim-sexp-mappings = { - url = "github:tpope/vim-sexp-mappings-for-regular-people"; + rust-tools = { + url = "github:simrat39/rust-tools.nvim"; flake = false; }; @@ -155,6 +150,21 @@ url = "github:rose-pine/neovim/v1.2.0"; flake = false; }; + + typescript-nvim = { + url = "github:jose-elias-alvarez/typescript.nvim"; + flake = false; + }; + + vim-sexp = { + url = "github:guns/vim-sexp"; + flake = false; + }; + + vim-sexp-mappings = { + url = "github:tpope/vim-sexp-mappings-for-regular-people"; + flake = false; + }; }; outputs = { self, nixpkgs, flake-utils, ... }@inputs: @@ -192,8 +202,12 @@ }; lsp = { enable = true; - clojurelsp.enable = true; - elixirls.enable = true; + clojure.enable = true; + dart.enable = true; + elixir.enable = true; + nix.enable = true; + rust.enable = false; + typescript.enable = false; }; surround.enable = true; telescope.enable = true; diff --git a/modules/lsp/clojure.nix b/modules/lsp/clojure.nix index f096afb..fb08fd8 100644 --- a/modules/lsp/clojure.nix +++ b/modules/lsp/clojure.nix @@ -3,11 +3,11 @@ let inherit (lib) mkEnableOption mkIf writeIf; cfg = config.lvim.lsp; - clojure = cfg.enable && cfg.clojurelsp.enable; + clojure = cfg.enable && cfg.clojure.enable; completion = config.lvim.completion.enable && cfg.enable; in { - options.lvim.lsp.clojurelsp.enable = mkEnableOption "Enables Clojure support plugins"; + options.lvim.lsp.clojure.enable = mkEnableOption "Enables Clojure support plugins"; config.lvim = mkIf clojure { startPlugins = with pkgs.neovimPlugins; [ conjure vim-sexp vim-sexp-mappings ]; diff --git a/modules/lsp/dart.nix b/modules/lsp/dart.nix new file mode 100644 index 0000000..3009eff --- /dev/null +++ b/modules/lsp/dart.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, config, ... }: + +let + inherit (lib) mkEnableOption mkIf writeIf; + cfg = config.lvim.lsp; + dart = cfg.enable && cfg.dart.enable; + completion = config.lvim.completion.enable && cfg.enable; +in +{ + options.lvim.lsp.dart.enable = mkEnableOption "Enables Dart support plugins"; + + config.lvim = mkIf dart { + rawConfig = '' + -- DART LSP CONFIG + require('lspconfig').dartls.setup({ + ${writeIf completion '' + capabilities = require("cmp_nvim_lsp").default_capabilities(), + ''} + cmd = {"${pkgs.dart}/bin/dart", "language-server", "--protocol=lsp"} + }) + -- END DART LSP CONFIG + ''; + }; +} diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 849d527..70b2e0d 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -5,7 +5,7 @@ let cfg = config.lvim.lsp; in { - imports = [ ./clojure.nix ./elixir.nix ]; + imports = [ ./clojure.nix ./dart.nix ./elixir.nix ./nix.nix ./rust.nix ./typescript.nix ]; options.lvim.lsp.enable = mkEnableOption "Enables programming languages support"; diff --git a/modules/lsp/elixir.nix b/modules/lsp/elixir.nix index 1de4d67..43b01e9 100644 --- a/modules/lsp/elixir.nix +++ b/modules/lsp/elixir.nix @@ -3,11 +3,11 @@ let inherit (lib) mkEnableOption mkIf writeIf; cfg = config.lvim.lsp; - elixir = cfg.enable && cfg.elixirls.enable; + elixir = cfg.enable && cfg.elixir.enable; completion = config.lvim.completion.enable && cfg.enable; in { - options.lvim.lsp.elixirls.enable = mkEnableOption "Enables Elixir support plugins"; + options.lvim.lsp.elixir.enable = mkEnableOption "Enables Elixir support plugins"; config.lvim = mkIf elixir { startPlugins = with pkgs.neovimPlugins; [ nvim-elixir ]; diff --git a/modules/lsp/nix.nix b/modules/lsp/nix.nix new file mode 100644 index 0000000..d4c4ac9 --- /dev/null +++ b/modules/lsp/nix.nix @@ -0,0 +1,24 @@ +{ lib, pkgs, config, ... }: + +let + inherit (lib) mkEnableOption mkIf writeIf; + cfg = config.lvim.lsp; + nix = cfg.enable && cfg.nix.enable; + completion = config.lvim.completion.enable && cfg.enable; +in +{ + options.lvim.lsp.nix.enable = mkEnableOption "Enables Nix support plugins"; + + config.lvim = mkIf nix { + rawConfig = '' + -- NIX LSP CONFIG + require('lspconfig').nil_ls.setup({ + ${writeIf completion '' + capabilities = require("cmp_nvim_lsp").default_capabilities(), + ''} + cmd = {"${pkgs.nil}/bin/nil"} + }) + -- END NIX LSP CONFIG + ''; + }; +} diff --git a/modules/lsp/rust.nix b/modules/lsp/rust.nix new file mode 100644 index 0000000..68146a1 --- /dev/null +++ b/modules/lsp/rust.nix @@ -0,0 +1,43 @@ +{ lib, pkgs, config, ... }: + +let + inherit (lib) mkEnableOption mkIf writeIf; + cfg = config.lvim.lsp; + rust = cfg.enable && cfg.rust.enable; + completion = config.lvim.completion.enable && cfg.enable; +in +{ + options.lvim.lsp.rust.enable = mkEnableOption "Enables Rust support plugins"; + + config.lvim = mkIf rust { + startPlugins = with pkgs.neovimPlugins; [ rust-tools ]; + nnoremap = { + "ri" = "lua require('rust-tools.inlay_hints').toggle_inlay_hints()"; + "rr" = "lua require('rust-tools.runnables').runnables()"; + "re" = "lua require('rust-tools.expand_macro').expand_macro()"; + "rc" = "lua require('rust-tools.open_cargo_toml').open_cargo_toml()"; + "rg" = "lua require('rust-tools.crate_graph').view_crate_graph('x11', nil)"; + }; + rawConfig = '' + -- NIX LSP CONFIG + local rustopts = { + tools = { + autoSetHints = true, + hover_with_actions = false, + inlay_hints = { + only_current_line = false, + } + }, + server = { + ${writeIf completion '' + capabilities = require("cmp_nvim_lsp").default_capabilities(),, + ''} + cmd = {"${pkgs.rust-analyzer}/bin/rust-analyzer"}, + } + } + + require('rust-tools').setup(rustopts) + -- END RUST LSP CONFIG + ''; + }; +} diff --git a/modules/lsp/typescript.nix b/modules/lsp/typescript.nix new file mode 100644 index 0000000..a80d357 --- /dev/null +++ b/modules/lsp/typescript.nix @@ -0,0 +1,27 @@ +{ lib, pkgs, config, ... }: + +let + inherit (lib) mkEnableOption mkIf writeIf; + cfg = config.lvim.lsp; + ts = cfg.enable && cfg.typescript.enable; + completion = config.lvim.completion.enable && cfg.enable; +in +{ + options.lvim.lsp.typescript.enable = mkEnableOption "Enables Typescript support plugins"; + + config.lvim = mkIf ts { + startPlugins = with pkgs.neovimPlugins; [ typescript-nvim ]; + rawConfig = '' + -- NIX LSP CONFIG + require("typescript").setup({ + server = { + ${writeIf completion '' + capabilities = require("cmp_nvim_lsp").default_capabilities(),, + ''} + cmd = { "${pkgs.nodePackages.typescript-language-server}/bin/typescript-language-server", "--stdio" } + } + }) + -- END NIX LSP CONFIG + ''; + }; +}