mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
convert lua module
This commit is contained in:
parent
7afe8674d4
commit
1f3b417469
1 changed files with 22 additions and 34 deletions
|
@ -8,32 +8,13 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) bool enum listOf package;
|
inherit (lib.lists) isList;
|
||||||
|
inherit (lib.types) bool either enum listOf package str;
|
||||||
inherit (lib.nvim.types) diagnostics mkGrammarOption;
|
inherit (lib.nvim.types) diagnostics mkGrammarOption;
|
||||||
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.lua;
|
cfg = config.vim.languages.lua;
|
||||||
|
|
||||||
defaultServers = ["lua-language-server"];
|
|
||||||
servers = {
|
|
||||||
lua-language-server = {
|
|
||||||
enable = true;
|
|
||||||
cmd = [(getExe pkgs.lua-language-server)];
|
|
||||||
filetypes = ["lua"];
|
|
||||||
root_markers = [
|
|
||||||
".luarc.json"
|
|
||||||
".luarc.jsonc"
|
|
||||||
".luacheckrc"
|
|
||||||
".stylua.toml"
|
|
||||||
"stylua.toml"
|
|
||||||
"selene.toml"
|
|
||||||
"selene.yml"
|
|
||||||
".git"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultFormat = "stylua";
|
defaultFormat = "stylua";
|
||||||
formats = {
|
formats = {
|
||||||
stylua = {
|
stylua = {
|
||||||
|
@ -62,11 +43,12 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Lua LSP support" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.lsp.enable;};
|
||||||
servers = mkOption {
|
|
||||||
description = "Lua LSP server to use";
|
package = mkOption {
|
||||||
type = listOf (enum (attrNames servers));
|
description = "LuaLS package, or the command to run as a list of strings";
|
||||||
default = defaultServers;
|
type = either package (listOf str);
|
||||||
|
default = pkgs.lua-language-server;
|
||||||
};
|
};
|
||||||
|
|
||||||
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
|
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
|
||||||
|
@ -109,17 +91,23 @@ in {
|
||||||
|
|
||||||
(mkIf cfg.enable (mkMerge [
|
(mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.servers =
|
vim.lsp.lspconfig.enable = true;
|
||||||
mapListToAttrs (n: {
|
vim.lsp.lspconfig.sources.lua-lsp = ''
|
||||||
name = n;
|
lspconfig.lua_ls.setup {
|
||||||
value = servers.${n};
|
capabilities = capabilities;
|
||||||
})
|
on_attach = default_on_attach;
|
||||||
cfg.lsp.servers;
|
cmd = ${
|
||||||
|
if isList cfg.lsp.package
|
||||||
|
then expToLua cfg.lsp.package
|
||||||
|
else ''{"${getExe cfg.lsp.package}"}''
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.lazydev.enable {
|
(mkIf cfg.lsp.lazydev.enable {
|
||||||
vim.startPlugins = ["lazydev-nvim"];
|
vim.startPlugins = ["lazydev-nvim"];
|
||||||
vim.pluginRC.lazydev = entryBefore ["lsp-servers"] ''
|
vim.pluginRC.lazydev = entryBefore ["lua-lsp"] ''
|
||||||
require("lazydev").setup({
|
require("lazydev").setup({
|
||||||
enabled = function(root_dir)
|
enabled = function(root_dir)
|
||||||
return not vim.uv.fs_stat(root_dir .. "/.luarc.json")
|
return not vim.uv.fs_stat(root_dir .. "/.luarc.json")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue