From f4aea56bce6b17c1beecac69a8c67e0f013bc903 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 31 Oct 2021 13:40:50 -0700 Subject: fix: set offset encoding by default (#1360) Some servers (clangd, rust-analyzer) support using byte ranges (utf-8 encodings). Currently this logic is handled in the configuration's on_init. This is moved into the on_init wrapper to avoid being overridden accidentally by users. --- lua/lspconfig/configs.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lua/lspconfig/configs.lua') diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index a374e842..72ab401c 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -123,7 +123,13 @@ function configs.__newindex(t, config_name, config_def) pcall(config.on_new_config, new_config, _root_dir) end - new_config.on_init = util.add_hook_after(new_config.on_init, function(client, _result) + new_config.on_init = util.add_hook_after(new_config.on_init, function(client, result) + -- Handle offset encoding by default + if result.offsetEncoding then + client.offset_encoding = result.offsetEncoding + end + + -- Send `settings to server via workspace/didChangeConfiguration function client.workspace_did_change_configuration(settings) if not settings then return -- cgit v1.2.3-70-g09d2