lsp/presets/ocaml-lsp: init

This commit is contained in:
Snoweuph 2026-04-11 18:03:08 +02:00
commit 16753bfc52
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55
2 changed files with 45 additions and 0 deletions

View file

@ -5,6 +5,7 @@
./harper.nix
./intelephense.nix
./lemminx.nix
./ocaml-lsp.nix
./ols.nix
./openscad-lsp.nix
./phan.nix

View file

@ -0,0 +1,44 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
inherit (lib.generators) mkLuaInline;
cfg = config.vim.lsp.presets.ocaml-lsp;
in {
options.vim.lsp.presets.ocaml-lsp = {
enable = mkEnableOption "the OCaml Language Server";
};
config = mkIf cfg.enable {
vim.lsp.servers.ocaml-lsp = {
enable = true;
cmd = [(getExe pkgs.ocamlPackages.ocaml-lsp)];
root_dir = mkLuaInline ''
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 ''
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
'';
};
};
}