mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +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 (lib.options) mkEnableOption mkOption literalExpression;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib) genAttrs;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.types) enum listOf;
|
||||
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
cfg = config.vim.languages.ocaml;
|
||||
|
||||
defaultServers = ["ocaml-lsp"];
|
||||
servers = {
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
servers = ["ocaml-lsp"];
|
||||
|
||||
defaultFormat = ["ocamlformat"];
|
||||
formats = {
|
||||
|
|
@ -84,7 +47,7 @@ in {
|
|||
};
|
||||
|
||||
servers = mkOption {
|
||||
type = deprecatedSingleOrListOf "vim.language.ocaml.lsp.servers" (enum (attrNames servers));
|
||||
type = listOf (enum servers);
|
||||
default = defaultServers;
|
||||
description = "OCaml LSP server to use";
|
||||
};
|
||||
|
|
@ -102,12 +65,12 @@ in {
|
|||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.servers =
|
||||
mapListToAttrs (n: {
|
||||
name = n;
|
||||
value = servers.${n};
|
||||
})
|
||||
cfg.lsp.servers;
|
||||
vim.lsp = {
|
||||
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||
servers = genAttrs cfg.lsp.servers (_: {
|
||||
filetypes = ["ocaml" "menhir" "ocamlinterface" "ocamllex" "reason" "dune"];
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue