From 1c36d605f0558cd5c48da674e9a90d49aba75759 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Tue, 24 Sep 2024 14:09:12 +0200 Subject: [PATCH] Fix `warning: multiple different client offset_encodings detected for buffer, this is not supported yet` by forcing offsetEncoding to utf16. utf8 has problems with copilot. --- home/.config/nvim/lua/plugs/mason_lsp.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/home/.config/nvim/lua/plugs/mason_lsp.lua b/home/.config/nvim/lua/plugs/mason_lsp.lua index cf9eb44..5d6b556 100644 --- a/home/.config/nvim/lua/plugs/mason_lsp.lua +++ b/home/.config/nvim/lua/plugs/mason_lsp.lua @@ -3,14 +3,15 @@ local utils = require("utils") local function setup_lsp(server_names) local capabilities = require("cmp_nvim_lsp").default_capabilities() + capabilities.offsetEncoding = { "utf-16" } local lspconfig = require("lspconfig") for _, server_name in ipairs(server_names) do local server = lspconfig[server_name] if server then - local server_table = require("language_servers/" .. server_name) + local server_conf = require("language_servers/" .. server_name) capabilities.textDocument.completion.completionItem.snippetSupport = false - server_table.capabilities = capabilities - server_table.on_attach = function(client, bufnr) + server_conf.capabilities = capabilities + server_conf.on_attach = function(client, bufnr) vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) if client.server_capabilities.documentFormattingProvider then @@ -47,11 +48,11 @@ local function setup_lsp(server_names) }) end - server.setup(server_table) + server.setup(server_conf) -- Run the post_setup function if it exists - if server_table.post_setup then - server_table.post_setup() + if server_conf.post_setup then + server_conf.post_setup() end else error("LSP server not found: " .. server_name)