From dcbed9b838d9a180860a28d95781dd82737a485e Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Mon, 17 May 2021 09:54:16 +0100 Subject: [PATCH 1/2] ocamllsp: prepare for filetype to language_id translation --- lua/lspconfig/ocamllsp.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/lspconfig/ocamllsp.lua b/lua/lspconfig/ocamllsp.lua index 155ec1c840..c588b39ddc 100644 --- a/lua/lspconfig/ocamllsp.lua +++ b/lua/lspconfig/ocamllsp.lua @@ -1,11 +1,25 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' +local language_id_of = { + ocaml = 'ocaml'; + reason = 'reason'; +} + +local filetypes = {} + +for ftype, _ in pairs(language_id_of) do + table.insert(filetypes, ftype) +end + +local get_language_id = function (_, ftype) return language_id_of[ftype] end + configs.ocamllsp = { default_config = { cmd = {"ocamllsp",}; - filetypes = {'ocaml', 'reason'}; + filetypes = filetypes; root_dir = util.root_pattern("*.opam", "esy.json", "package.json", ".git"); + get_language_id = get_language_id; }; docs = { description = [[ From b9e79ca471e0479734209da2138d3a0664c8d93d Mon Sep 17 00:00:00 2001 From: Pau Ruiz Safont Date: Mon, 17 May 2021 09:56:16 +0100 Subject: [PATCH 2/2] ocamllsp: add more filetypes These are ocamlinterface, ocamllex and menhir. This is in preparation when these filetypes will be introduced in order to keep lsp working on them. The change is backwards compatible. For more information about the rationale of this change please read https://github.com/ocaml/vim-ocaml/pull/61 --- lua/lspconfig/ocamllsp.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/lspconfig/ocamllsp.lua b/lua/lspconfig/ocamllsp.lua index c588b39ddc..5ce8441d9b 100644 --- a/lua/lspconfig/ocamllsp.lua +++ b/lua/lspconfig/ocamllsp.lua @@ -2,7 +2,10 @@ local configs = require 'lspconfig/configs' local util = require 'lspconfig/util' local language_id_of = { + menhir = 'ocaml.menhir'; ocaml = 'ocaml'; + ocamlinterface = 'ocaml.interface'; + ocamllex = 'ocaml.ocamllex'; reason = 'reason'; }