Skip to content

Commit

Permalink
feat: add additional languages LSP support plugins
Browse files Browse the repository at this point in the history
Langs:
- dart
- nix
- rust
- typescript
  • Loading branch information
Zoey de Souza Pessanha committed May 28, 2023
1 parent 7474e07 commit 5cef4ac
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 14 deletions.
34 changes: 34 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions modules/lsp/clojure.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
24 changes: 24 additions & 0 deletions modules/lsp/dart.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
2 changes: 1 addition & 1 deletion modules/lsp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 2 additions & 2 deletions modules/lsp/elixir.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
Expand Down
24 changes: 24 additions & 0 deletions modules/lsp/nix.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
43 changes: 43 additions & 0 deletions modules/lsp/rust.nix
Original file line number Diff line number Diff line change
@@ -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 = {
"<silent><leader>ri" = "<cmd>lua require('rust-tools.inlay_hints').toggle_inlay_hints()<CR>";
"<silent><leader>rr" = "<cmd>lua require('rust-tools.runnables').runnables()<CR>";
"<silent><leader>re" = "<cmd>lua require('rust-tools.expand_macro').expand_macro()<CR>";
"<silent><leader>rc" = "<cmd>lua require('rust-tools.open_cargo_toml').open_cargo_toml()<CR>";
"<silent><leader>rg" = "<cmd>lua require('rust-tools.crate_graph').view_crate_graph('x11', nil)<CR>";
};
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
'';
};
}
27 changes: 27 additions & 0 deletions modules/lsp/typescript.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}

0 comments on commit 5cef4ac

Please sign in to comment.