mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-19 13:30:17 +00:00
languages/ocaml: refactor lsp.servers to use lsp/presets/<name>
This commit is contained in:
parent
00a372118a
commit
cf981331a3
1 changed files with 10 additions and 47 deletions
|
|
@ -7,53 +7,16 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib) genAttrs;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) enum;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
||||||
inherit (lib.generators) mkLuaInline;
|
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
cfg = config.vim.languages.ocaml;
|
cfg = config.vim.languages.ocaml;
|
||||||
|
|
||||||
defaultServers = ["ocaml-lsp"];
|
defaultServers = ["ocaml-lsp"];
|
||||||
servers = {
|
servers = ["ocaml-lsp"];
|
||||||
ocaml-lsp = {
|
|
||||||
enable = true;
|
|
||||||
cmd = [(getExe pkgs.ocamlPackages.ocaml-lsp)];
|
|
||||||
filetypes = ["ocaml" "menhir" "ocamlinterface" "ocamllex" "reason" "dune"];
|
|
||||||
root_dir =
|
|
||||||
mkLuaInline
|
|
||||||
/*
|
|
||||||
lua
|
|
||||||
*/
|
|
||||||
''
|
|
||||||
function(bufnr, on_dir)
|
|
||||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
|
||||||
on_dir(util.root_pattern('*.opam', 'esy.json', 'package.json', '.git', 'dune-project', 'dune-workspace')(fname))
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
get_language_id =
|
|
||||||
mkLuaInline
|
|
||||||
/*
|
|
||||||
lua
|
|
||||||
*/
|
|
||||||
''
|
|
||||||
function(_, ftype)
|
|
||||||
local language_id_of = {
|
|
||||||
menhir = 'ocaml.menhir',
|
|
||||||
ocaml = 'ocaml',
|
|
||||||
ocamlinterface = 'ocaml.interface',
|
|
||||||
ocamllex = 'ocaml.ocamllex',
|
|
||||||
reason = 'reason',
|
|
||||||
dune = 'dune',
|
|
||||||
}
|
|
||||||
|
|
||||||
return language_id_of[ftype]
|
|
||||||
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultFormat = ["ocamlformat"];
|
defaultFormat = ["ocamlformat"];
|
||||||
formats = {
|
formats = {
|
||||||
|
|
@ -84,7 +47,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
servers = mkOption {
|
servers = mkOption {
|
||||||
type = deprecatedSingleOrListOf "vim.language.ocaml.lsp.servers" (enum (attrNames servers));
|
type = listOf (enum servers);
|
||||||
default = defaultServers;
|
default = defaultServers;
|
||||||
description = "OCaml LSP server to use";
|
description = "OCaml LSP server to use";
|
||||||
};
|
};
|
||||||
|
|
@ -102,12 +65,12 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.servers =
|
vim.lsp = {
|
||||||
mapListToAttrs (n: {
|
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||||
name = n;
|
servers = genAttrs cfg.lsp.servers (_: {
|
||||||
value = servers.${n};
|
filetypes = ["ocaml" "menhir" "ocamlinterface" "ocamllex" "reason" "dune"];
|
||||||
})
|
});
|
||||||
cfg.lsp.servers;
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue