1
Fork 0

Move lspconfig from lua to nix

This commit is contained in:
prescientmoon 2024-03-09 16:57:38 +01:00
parent e4b7645102
commit e30d42e8f2
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
4 changed files with 137 additions and 77 deletions

View file

@ -30,6 +30,7 @@
"lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" },
"lean": { "branch": "main", "commit": "1a2a2dfbc7e6775e9ec8b84e5eadaf31fde1894e" }, "lean": { "branch": "main", "commit": "1a2a2dfbc7e6775e9ec8b84e5eadaf31fde1894e" },
"live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" }, "live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" },
"lspconfig": { "branch": "master", "commit": "16295b79410f131c4fa7870c663b4ace6a761fb2" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"luasnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, "luasnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" },
@ -40,12 +41,12 @@
"mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" }, "mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" },
"navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, "navigator": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
"neoconf": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" }, "neoconf": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" },
"neodev.nvim": { "branch": "main", "commit": "b0ccf605c952eb0d1efe3692d5b241c52ceee187" }, "neodev": { "branch": "main", "commit": "84e0290f5600e8b89c0dfcafc864f45496a53400" },
"nui": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" }, "nui": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" },
"null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, "null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-lspconfig": { "branch": "master", "commit": "6b9f4bbe0aa1f351fd4845dc5fd4f3450b010f88" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "7f00d94543f1fd37cab2afa2e9a6cd54e1c6b9ef" },
"plenary": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "plenary": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
"purescript": { "branch": "main", "commit": "82348352e6568fcc0385bd7c99a8ead3a479feea" },
"rust-tools": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, "rust-tools": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" },
"scrap": { "branch": "main", "commit": "cc8453ed613932c744c3d1ec42f379b78bd8b92c" }, "scrap": { "branch": "main", "commit": "cc8453ed613932c744c3d1ec42f379b78bd8b92c" },
"ssr": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" }, "ssr": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" },

View file

@ -1,5 +1,18 @@
{ upkgs, pkgs, lib, config, inputs, ... }: { upkgs, pkgs, lib, config, inputs, ... }:
let let
# Toggles for including tooling related to a given language
packedTargets = {
elm = false;
latex = true;
lua = true;
nix = true;
purescript = false;
python = true;
rust = true;
typst = true;
web = true;
};
korora = inputs.korora.lib; korora = inputs.korora.lib;
nlib = import ../../../modules/common/korora-neovim.nix nlib = import ../../../modules/common/korora-neovim.nix
{ inherit lib korora; } { inherit lib korora; }
@ -283,9 +296,6 @@ let
}; };
} }
]; ];
# Make neovim aware about the existence of the purescript datatype.
callback = lua ''vim.filetype.add({ extension = { purs = "purescript" } })'';
}; };
# }}} # }}}
}; };
@ -512,10 +522,44 @@ let
indent-blankline = { indent-blankline = {
package = "lukas-reineke/indent-blankline.nvim"; package = "lukas-reineke/indent-blankline.nvim";
main = "ibl"; main = "ibl";
config = true;
cond = blacklist "vscode"; cond = blacklist "vscode";
event = "VeryLazy"; event = "VeryLazy";
config = true;
# {{{{ Keybinds
keys =
let
# {{{ List of fold-related keybinds
foldKeybinds = [
"zo"
"zO"
"zc"
"zC"
"za"
"zA"
"zv"
"zx"
"zX"
"zm"
"zM"
"zr"
"zR"
];
# }}}
in
[
(nmap
"<leader>si"
"<cmd>IBLToggle<cr>"
"Toggle blankline indentation")
] ++
(lib.forEach foldKeybinds (from: nmap
from
"${from}<cmd>IBLToggle<cr><cmd>IBLToggle<cr>"
"Overriden ${from} (fold-related thing)"
));
# }}}}
}; };
# }}} # }}}
# {{{ live-command # {{{ live-command
@ -851,9 +895,60 @@ let
# }}} # }}}
# }}} # }}}
# {{{ ide # {{{ ide
# {{{ lspconfig
lspconfig = {
# {{{ Nix dependencies
dependencies.nix = with lib.lists; with packedTargets; (
optionals web [
pkgs.nodePackages.typescript
pkgs.nodePackages_latest.vscode-langservers-extracted
pkgs.nodePackages.typescript-language-server
] ++
optionals lua [
pkgs.lua-language-server
pkgs.lua
] ++
optionals nix [
pkgs.rnix-lsp
pkgs.nil
inputs.nixd.packages.${pkgs.system}.nixd
] ++
optionals latex [
pkgs.texlab
pkgs.texlive.combined.scheme-full
] ++
optionals elm [
pkgs.elmPackages.elm
pkgs.elmPackages.elm-format
pkgs.elmPackages.elm-language-server
] ++
optionals purescript [
pkgs.purescript-language-server
pkgs.nodePackages.purs-tidy
]
);
# }}}
dependencies.lua = [ "neoconf" "neodev" ];
package = "neovim/nvim-lspconfig";
cond = blacklist "vscode";
event = "VeryLazy";
config = importFrom ./plugins/lspconfig.lua "config";
};
# }}}
# {{{ conform # {{{ conform
conform = { conform = {
dependencies.lua = [ "neovim/nvim-lspconfig" ]; dependencies.lua = [ "lspconfig" ];
dependencies.nix = with lib.lists; with packedTargets; (
[ pkgs.codespell ] ++
optional lua pkgs.stylua ++
optional python pkgs.ruff ++
optionals web [
pkgs.nodePackages_latest.prettier
pkgs.nodePackages_latest.prettier_d_slim
]
);
package = "stevearc/conform.nvim"; package = "stevearc/conform.nvim";
cond = blacklist "vscode"; cond = blacklist "vscode";
@ -862,6 +957,7 @@ let
opts.format_on_save.lsp_fallback = true; opts.format_on_save.lsp_fallback = true;
opts.formatters_by_ft = let prettier = [ [ "prettierd" "prettier" ] ]; in opts.formatters_by_ft = let prettier = [ [ "prettierd" "prettier" ] ]; in
{ {
"*" = [ "codespell" "trim_whitespace" ];
lua = [ "stylua" ]; lua = [ "stylua" ];
python = [ "ruff_format" ]; python = [ "ruff_format" ];
@ -875,6 +971,12 @@ let
}; };
}; };
# }}} # }}}
# {{{ neodev
neodev = {
package = "folke/neodev.nvim";
config = true;
};
# }}}
# {{{ neoconf # {{{ neoconf
neoconf = { neoconf = {
package = "folke/neoconf.nvim"; package = "folke/neoconf.nvim";
@ -893,7 +995,11 @@ let
# {{{ null-ls # {{{ null-ls
null-ls = { null-ls = {
package = "jose-elias-alvarez/null-ls.nvim"; package = "jose-elias-alvarez/null-ls.nvim";
dependencies.lua = [ "neovim/nvim-lspconfig" ]; dependencies.lua = [ "lspconfig" ];
dependencies.nix =
lib.lists.optional
packedTargets.python
pkgs.ruff;
cond = blacklist "vscode"; cond = blacklist "vscode";
event = "VeryLazy"; event = "VeryLazy";
@ -1073,7 +1179,10 @@ let
# {{{ rust-tools # {{{ rust-tools
rust-tools = { rust-tools = {
package = "simrat39/rust-tools.nvim"; package = "simrat39/rust-tools.nvim";
dependencies.nix = [ pkgs.rust-analyzer pkgs.rustfmt ]; dependencies.nix =
lib.lists.optionals
packedTargets.rust
[ pkgs.rust-analyzer pkgs.rustfmt ];
cond = blacklist "vscode"; cond = blacklist "vscode";
ft = "rust"; ft = "rust";
@ -1168,7 +1277,7 @@ let
name = "lean"; name = "lean";
dependencies.lua = [ dependencies.lua = [
"plenary" "plenary"
"neovim/nvim-lspconfig" "lspconfig"
]; ];
cond = blacklist "vscode"; cond = blacklist "vscode";
@ -1181,7 +1290,7 @@ let
}; };
lsp.capabilites = lsp.capabilites =
lua /* lua */ ''require("my.plugins.lspconfig").capabilities''; importFrom ./plugins/lspconfig.lua "capabilities";
lsp3 = false; # We don't want the lean 3 language server! lsp3 = false; # We don't want the lean 3 language server!
mappings = true; mappings = true;
@ -1194,7 +1303,7 @@ let
name = "idris"; name = "idris";
dependencies.lua = [ dependencies.lua = [
"nui" "nui"
"neovim/nvim-lspconfig" "lspconfig"
]; ];
cond = blacklist "vscode"; cond = blacklist "vscode";
@ -1236,19 +1345,22 @@ let
# {{{ typst support # {{{ typst support
typst = { typst = {
package = "kaarmu/typst.vim"; package = "kaarmu/typst.vim";
dependencies.nix = [ upkgs.typst upkgs.typst-lsp upkgs.typstfmt ]; dependencies.nix =
lib.lists.optionals
packedTargets.typst
[ upkgs.typst upkgs.typst-lsp upkgs.typstfmt ];
cond = blacklist "vscode"; cond = blacklist "vscode";
ft = "typst"; ft = "typst";
}; };
# }}} # }}}
# {{{ purescript support # {{{ purescript support
# purescript = { purescript = {
# package = "purescript-contrib/purescript-vim"; package = "purescript-contrib/purescript-vim";
#
# cond = blacklist "vscode"; cond = blacklist "vscode";
# ft = "purescript"; ft = "purescript";
# }; };
# }}} # }}}
# {{{ hyprland support # {{{ hyprland support
hyprland = { hyprland = {
@ -1378,35 +1490,6 @@ let
}; };
# }}} # }}}
})); }));
# {{{ extraPackages
extraPackages = with pkgs; [
# Nix
rnix-lsp
nil
inputs.nixd.packages.${system}.nixd
# Python
ruff # Python linter
# Web
nodePackages.typescript
nodePackages_latest.prettier
nodePackages_latest.prettier_d_slim
nodePackages_latest.vscode-langservers-extracted
nodePackages.typescript-language-server
# Latex
texlab
# texlive.combined.scheme-full
# Lua
lua-language-server
stylua
lua # For repls and whatnot
] ++ generated.dependencies;
# }}}
# {{{ extraRuntime # {{{ extraRuntime
# Experimental nix module generation # Experimental nix module generation
generatedConfig = (config.satellite.lib.lua.writeFile generatedConfig = (config.satellite.lib.lua.writeFile
@ -1447,7 +1530,7 @@ let
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = '' postBuild = ''
wrapProgram $out/bin/${binName} \ wrapProgram $out/bin/${binName} \
--prefix PATH : ${lib.makeBinPath extraPackages} \ --prefix PATH : ${lib.makeBinPath generated.dependencies} \
--add-flags ${extraFlags} \ --add-flags ${extraFlags} \
${extraArgs} ${extraArgs}
''; '';

View file

@ -1,17 +1,5 @@
local runtime = require("my.tempest") ---@diagnostic disable: missing-fields
local M = {}
local M = {
"neovim/nvim-lspconfig",
event = "VeryLazy",
dependencies = {
"neoconf",
{
"folke/neodev.nvim",
config = true,
},
},
cond = runtime.blacklist("vscode"),
}
-- {{{ Capabilities -- {{{ Capabilities
M.capabilities = function() M.capabilities = function()
@ -32,10 +20,8 @@ function M.config()
-- {{{ General server config -- {{{ General server config
---@type lspconfig.options ---@type lspconfig.options
---@diagnostic disable-next-line: missing-fields
local servers = { local servers = {
-- {{{ Typescript -- {{{ Typescript
---@diagnostic disable-next-line: missing-fields
tsserver = { tsserver = {
on_attach = function(client) on_attach = function(client)
-- We handle formatting using null-ls and prettierd -- We handle formatting using null-ls and prettierd
@ -47,7 +33,6 @@ function M.config()
purescriptls = { purescriptls = {
root_dir = lspconfig.util.root_pattern("spago.yaml"), root_dir = lspconfig.util.root_pattern("spago.yaml"),
settings = { settings = {
---@diagnostic disable-next-line: missing-fields
purescript = { purescript = {
censorWarnings = { censorWarnings = {
"UnusedName", "UnusedName",
@ -61,14 +46,8 @@ function M.config()
-- }}} -- }}}
-- {{{ Lua -- {{{ Lua
lua_ls = { lua_ls = {
cmd = {
"lua-language-server",
"--logpath=/home/adrielus/.local/share/lua-language-server/log",
},
settings = { settings = {
---@diagnostic disable-next-line: missing-fields
Lua = { Lua = {
---@diagnostic disable-next-line: missing-fields
format = { format = {
enable = true, enable = true,
}, },
@ -91,7 +70,7 @@ function M.config()
"-interaction=nonstopmode", "-interaction=nonstopmode",
"-synctex=1", "-synctex=1",
"%f", "%f",
-- Required for syntax highlighting inside the generated pdf aparently -- Required for syntax highlighting inside the generated pdf apparently
"-shell-escape", "-shell-escape",
}, },
executable = "latexmk", executable = "latexmk",
@ -111,15 +90,12 @@ function M.config()
-- nil_ls = {}, -- nil_ls = {},
nixd = {}, nixd = {},
-- }}} -- }}}
---@diagnostic disable-next-line: missing-fields
cssls = {}, cssls = {},
---@diagnostic disable-next-line: missing-fields
jsonls = {}, jsonls = {},
dhall_lsp_server = {}, dhall_lsp_server = {},
typst_lsp = { typst_lsp = {
exportPdf = "onType", exportPdf = "onType",
}, },
---@diagnostic disable-next-line: missing-fields
elmls = {}, elmls = {},
} }
-- }}} -- }}}

View file

@ -86,7 +86,7 @@ let
mkAttrName = s: mkAttrName = s:
let let
# These list *are* incomplete # These list *are* incomplete
forbiddenChars = lib.stringToCharacters "<>[]{}()'\".,:;\\/"; forbiddenChars = lib.stringToCharacters "<>[]{}()'\".,:;\\/*_";
keywords = [ "if" "then" "else" "do" "for" "local" "" ]; keywords = [ "if" "then" "else" "do" "for" "local" "" ];
in in
if lib.any (c: lib.hasInfix c s) forbiddenChars || lib.elem s keywords then if lib.any (c: lib.hasInfix c s) forbiddenChars || lib.elem s keywords then