fix: added global position encoding
This commit is contained in:
parent
161310a072
commit
49581942c7
|
@ -3,24 +3,28 @@ local M = {}
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
local lspconfig = require 'lspconfig'
|
local lspconfig = require 'lspconfig'
|
||||||
|
|
||||||
-- Get capabilities from blink.cmp if available
|
-- Get capabilities from blink.cmp if available
|
||||||
local capabilities = {}
|
local capabilities = {}
|
||||||
pcall(function()
|
pcall(function()
|
||||||
capabilities = require('blink.cmp').get_lsp_capabilities()
|
capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||||
end)
|
end)
|
||||||
|
--
|
||||||
|
-- Set global position encoding preference
|
||||||
|
capabilities.offsetEncoding = { 'utf-8', 'utf-16' }
|
||||||
|
|
||||||
-- Load server configurations
|
-- Load server configurations
|
||||||
local servers = require('plugins.config.lsp.servers').get_servers()
|
local servers = require('plugins.config.lsp.servers').get_servers()
|
||||||
|
|
||||||
-- Setup each server with capabilities
|
-- Setup each server with capabilities
|
||||||
for name, config in pairs(servers) do
|
for name, config in pairs(servers) do
|
||||||
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
|
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
|
||||||
lspconfig[name].setup(config)
|
lspconfig[name].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Setup LSP keymaps
|
-- Setup LSP keymaps
|
||||||
require('plugins.config.lsp.keymaps').setup()
|
require('plugins.config.lsp.keymaps').setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,15 @@ local util = require 'lspconfig.util'
|
||||||
-- Get clang-wrapper resource-root for Nix environments
|
-- Get clang-wrapper resource-root for Nix environments
|
||||||
local function get_clang_resource_dir()
|
local function get_clang_resource_dir()
|
||||||
-- Try to find clang-wrapper's resource-root
|
-- Try to find clang-wrapper's resource-root
|
||||||
local handle = io.popen('ls -d /nix/store/*clang-wrapper*/resource-root 2>/dev/null | head -1')
|
local handle = io.popen 'ls -d /nix/store/*clang-wrapper*/resource-root 2>/dev/null | head -1'
|
||||||
if handle then
|
if handle then
|
||||||
local resource_root = handle:read('*l')
|
local resource_root = handle:read '*l'
|
||||||
handle:close()
|
handle:close()
|
||||||
if resource_root and resource_root ~= '' then
|
if resource_root and resource_root ~= '' then
|
||||||
return resource_root
|
return resource_root
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil -- Let clangd use its default
|
return nil -- Let clangd use its default
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_servers()
|
function M.get_servers()
|
||||||
|
@ -30,7 +30,7 @@ function M.get_servers()
|
||||||
'--header-insertion-decorators',
|
'--header-insertion-decorators',
|
||||||
'--header-insertion=iwyu',
|
'--header-insertion=iwyu',
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Add resource-dir if in Nix environment
|
-- Add resource-dir if in Nix environment
|
||||||
local resource_dir = get_clang_resource_dir()
|
local resource_dir = get_clang_resource_dir()
|
||||||
if resource_dir then
|
if resource_dir then
|
||||||
|
@ -72,7 +72,6 @@ function M.get_servers()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
positionEncoding = 'utf-8',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Python Linter/Formatter
|
-- Python Linter/Formatter
|
||||||
|
@ -106,4 +105,3 @@ function M.get_servers()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue