mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
simplify and remove unnecessary stuff
This commit is contained in:
parent
1a1569e6dd
commit
7ae81ca51b
3 changed files with 27 additions and 94 deletions
|
@ -18,36 +18,12 @@
|
|||
|
||||
lspConfigurations =
|
||||
mapAttrsToList (
|
||||
# TODO: Determine the best thing to do about merging in lspconfig
|
||||
name: value:
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''vim.lsp.config["${name}"] = ${toLuaObject value}''
|
||||
name: value: ''
|
||||
vim.lsp.config["${name}"] = ${toLuaObject value}
|
||||
''
|
||||
)
|
||||
cfg.servers;
|
||||
|
||||
# Approach 1:
|
||||
# Create function perhaps called mkLspConfig
|
||||
# mkLspConfig servers;
|
||||
# that expands to something like
|
||||
# vim.lsp.servers = cfg.lsp.servers......
|
||||
# vim.luaConfigRC.lspconfigMerge = entryAfter ["lsp-servers"] ''vim.lsp.config["${name}"] = vim.tbl_deep_extend("force", lspconfig.${name}, vim.lsp.config["${name}"])''
|
||||
|
||||
|
||||
# Approach 2:
|
||||
# lspConfigurations =
|
||||
# mapAttrsToList (
|
||||
# name: value: ''vim.lsp.config["${name}"] = vim.tbl_deep_extend("force", lspconfig.${name}, ${toLuaObject value})''
|
||||
# )
|
||||
# (filterAttrs (n: _: n != "*") cfg.servers);
|
||||
# Then also need to configure global * settings
|
||||
# globalConfiguration =
|
||||
# mapAttrsToList (
|
||||
# name: value: ''vim.lsp.config["${name}"] = ${toLuaObject value}''
|
||||
# )
|
||||
# (filterAttrs (n: _: n == "*") cfg.servers);
|
||||
|
||||
enabledServers = filterAttrs (_: u: u.enable) cfg.servers;
|
||||
in {
|
||||
options = {
|
||||
|
@ -105,18 +81,13 @@ in {
|
|||
}
|
||||
|
||||
(mkIf (cfg.servers != {}) {
|
||||
vim.luaConfigRC.lsp-servers =
|
||||
entryAnywhere
|
||||
# Or entryAfter ["lspconfig"] if we go with the second approach
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
${concatLines lspConfigurations}
|
||||
vim.luaConfigRC.lsp-servers = entryAnywhere ''
|
||||
-- Individual LSP configurations managed by nvf.
|
||||
${concatLines lspConfigurations}
|
||||
|
||||
-- Enable configured LSPs explicitly
|
||||
vim.lsp.enable(${toLuaObject (filter (name: name != "*") (attrNames enabledServers))});
|
||||
'';
|
||||
-- Enable configured LSPs explicitly
|
||||
vim.lsp.enable(${toLuaObject (filter (name: name != "*") (attrNames enabledServers))})
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -6,15 +6,14 @@
|
|||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) concatStringsSep;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) enum package;
|
||||
inherit (lib.types) enum package listOf;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.languages) resolveLspOptions mkLspOption;
|
||||
|
||||
cfg = config.vim.languages.nix;
|
||||
|
||||
|
@ -23,18 +22,18 @@
|
|||
then expToLua package
|
||||
else ''{"${package}/bin/${defaultCmd}"}'';
|
||||
|
||||
formattingCmd = lib.mkIf (cfg.format.enable && cfg.lsp.enable) {
|
||||
formatting = lib.mkMerge [
|
||||
(lib.mkIf (cfg.format.type == "alejandra") {
|
||||
formattingCmd = mkIf (cfg.format.enable && cfg.lsp.enable) {
|
||||
formatting = mkMerge [
|
||||
(mkIf (cfg.format.type == "alejandra") {
|
||||
command = ["${cfg.format.package}/bin/alejandra" "--quiet"];
|
||||
})
|
||||
(lib.mkIf (cfg.format.type == "nixfmt") {
|
||||
(mkIf (cfg.format.type == "nixfmt") {
|
||||
command = ["${cfg.format.package}/bin/nixfmt"];
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
defaultServers = ["nil_ls"]
|
||||
defaultServers = ["nil_ls"];
|
||||
servers = {
|
||||
nil_ls = {
|
||||
enable = true;
|
||||
|
@ -101,9 +100,11 @@ in {
|
|||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Nix LSP support" // {default = config.vim.lsp.enable;};
|
||||
servers = mkLspOption {
|
||||
inherit servers;
|
||||
servers = mkOption {
|
||||
description = "Nix LSP server to use";
|
||||
type = listOf (enum (attrNames servers));
|
||||
default = defaultServers;
|
||||
example = ["nixd"];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -153,14 +154,14 @@ in {
|
|||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
# TODO: Map this to include lspconfig stuff so that we can do
|
||||
vim.lsp.servers = resolveLspOptions {
|
||||
inherit servers;
|
||||
selected = cfg.lsp.servers;
|
||||
};
|
||||
vim.lsp.servers =
|
||||
mapListToAttrs (n: {
|
||||
name = n;
|
||||
value = servers.${n};
|
||||
})
|
||||
cfg.lsp.servers;
|
||||
})
|
||||
|
||||
# TODO: Figure out what do here. This is not necessarily correct as other lsps might not have formatting by default
|
||||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue