attempted fix for sumneko_lua -> lua_ls change, it didn't work
This commit is contained in:
parent
03104eb1bf
commit
cf18461c24
@ -11,6 +11,11 @@ if not vim.loop.fs_stat(lazypath) then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- map leader and register keymap for Lazy.
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = " "
|
||||||
|
vim.api.nvim_set_keymap("n", "<leader>L", "<cmd>:Lazy<cr>", { desc = "Lazy GUI" })
|
||||||
|
|
||||||
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||||
|
|
||||||
if not vim.g.vscode then
|
if not vim.g.vscode then
|
||||||
@ -21,11 +26,6 @@ if not vim.g.vscode then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- map leader and register keymap for Lazy.
|
|
||||||
vim.g.mapleader = " "
|
|
||||||
vim.g.maplocalleader = " "
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>L", "<cmd>:Lazy<cr>", { desc = "Lazy GUI" })
|
|
||||||
|
|
||||||
-- This might not be best, but it allows for easy resetting
|
-- This might not be best, but it allows for easy resetting
|
||||||
ColorMe = function()
|
ColorMe = function()
|
||||||
local colorscheme = "gruvbox-material"
|
local colorscheme = "gruvbox-material"
|
||||||
|
|||||||
@ -12,9 +12,16 @@ return {
|
|||||||
},
|
},
|
||||||
---@type lspconfig.options
|
---@type lspconfig.options
|
||||||
opts = {
|
opts = {
|
||||||
|
-- options for vim.diagnostic.config()
|
||||||
|
diagnostics = {
|
||||||
|
underline = true,
|
||||||
|
update_in_insert = false,
|
||||||
|
virtual_text = { spacing = 4, prefix = "●" },
|
||||||
|
severity_sort = true,
|
||||||
|
},
|
||||||
servers = {
|
servers = {
|
||||||
jsonls = {},
|
jsonls = {},
|
||||||
sumneko_lua = {
|
lua_ls = {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
workspace = {
|
workspace = {
|
||||||
@ -44,23 +51,18 @@ return {
|
|||||||
name = "DiagnosticSign" .. name
|
name = "DiagnosticSign" .. name
|
||||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
end
|
end
|
||||||
vim.diagnostic.config({
|
|
||||||
underline = true,
|
|
||||||
update_in_insert = false,
|
|
||||||
virtual_text = { spacing = 4, prefix = "●" },
|
|
||||||
severity_sort = true,
|
|
||||||
})
|
|
||||||
|
|
||||||
---@type lspconfig.options
|
vim.diagnostic.config(opts.diagnostics)
|
||||||
|
|
||||||
local servers = opts.servers
|
local servers = opts.servers
|
||||||
local capabilities =
|
local capabilities =
|
||||||
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) })
|
local function setup(server)
|
||||||
require("mason-lspconfig").setup_handlers({
|
local server_opts = vim.tbl_deep_extend("force", {
|
||||||
function(server)
|
capabilities = vim.deepcopy(capabilities),
|
||||||
local server_opts = servers[server] or {}
|
}, servers[server] or {})
|
||||||
server_opts.capabilities = capabilities
|
|
||||||
if opts.setup[server] then
|
if opts.setup[server] then
|
||||||
if opts.setup[server](server, server_opts) then
|
if opts.setup[server](server, server_opts) then
|
||||||
return
|
return
|
||||||
@ -71,8 +73,34 @@ return {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
require("lspconfig")[server].setup(server_opts)
|
require("lspconfig")[server].setup(server_opts)
|
||||||
end,
|
end
|
||||||
})
|
|
||||||
|
-- temp fix for lspconfig rename
|
||||||
|
-- https://github.com/neovim/nvim-lspconfig/pull/2439
|
||||||
|
local mappings = require("mason-lspconfig.mappings.server")
|
||||||
|
if not mappings.lspconfig_to_package.lua_ls then
|
||||||
|
mappings.lspconfig_to_package.lua_ls = "lua-language-server"
|
||||||
|
mappings.package_to_lspconfig["lua-language-server"] = "lua_ls"
|
||||||
|
end
|
||||||
|
|
||||||
|
local mlsp = require("mason-lspconfig")
|
||||||
|
local available = mlsp.get_available_servers()
|
||||||
|
|
||||||
|
local ensure_installed = {} ---@type string[]
|
||||||
|
for server, server_opts in pairs(servers) do
|
||||||
|
if server_opts then
|
||||||
|
server_opts = server_opts == true and {} or server_opts
|
||||||
|
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
||||||
|
if server_opts.mason == false or not vim.tbl_contains(available, server) then
|
||||||
|
setup(server)
|
||||||
|
else
|
||||||
|
ensure_installed[#ensure_installed + 1] = server
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require("mason-lspconfig").setup({ ensure_installed = ensure_installed })
|
||||||
|
require("mason-lspconfig").setup_handlers({ setup })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user