Skip to content

Commit

Permalink
Merge pull request #139 from horriblename/feat-lsp-lua
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf authored Sep 23, 2023
2 parents 0a1a12e + 18dabf1 commit ce1009d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes/rl-0.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ https://github.com/horriblename[horriblename]:

* Allow using command names in place of LSP packages to avoid automatic installation.

* Add lua LSP and treesitter support, and neodev.nvim plugin support.

https://github.com/amanse[amanse]:

* Added daily notes options for obsidian plugin.
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

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

5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@
flake = false;
};

neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};

elixir-ls = {
url = "github:elixir-lsp/elixir-ls";
flake = false;
Expand Down
1 change: 1 addition & 0 deletions lib/types/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ with lib; let
"vim-repeat"
"smartcolumn"
"project-nvim"
"neodev-nvim"
"elixir-ls"
"elixir-tools"
"nvim-colorizer-lua"
Expand Down
1 change: 1 addition & 0 deletions modules/languages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ in {
./html.nix
./svelte.nix
./java.nix
./lua.nix
];

options.vim.languages = {
Expand Down
59 changes: 59 additions & 0 deletions modules/languages/lua.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.languages.lua;
in {
options.vim.languages.lua = {
enable = mkEnableOption "Lua language support";
treesitter = {
enable = mkEnableOption "Enable Lua Treesitter support" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "lua";
};
lsp = {
enable = mkEnableOption "Enable Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;};

package = mkOption {
description = "LuaLS package, or the command to run as a list of strings";
type = with types; either package (listOf str);
default = pkgs.lua-language-server;
};

neodev.enable = mkEnableOption "Enable neodev.nvim integration, useful for neovim plugin developers";
};
};

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.lua-lsp = ''
lspconfig.lua_ls.setup {
capabilities = capabilities;
on_attach = default_on_attach;
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}''
};
}
'';
})

(mkIf cfg.lsp.neodev.enable {
vim.startPlugins = ["neodev-nvim"];
vim.luaConfigRC.neodev = nvim.dag.entryBefore ["lua-lsp"] ''
require("neodev").setup({})
'';
})
]);
}

0 comments on commit ce1009d

Please sign in to comment.