98 lines
3.7 KiB
Lua
98 lines
3.7 KiB
Lua
local M = { "williamboman/mason-lspconfig.nvim" }
|
|
|
|
M.dependencies = { "mason.nvim" }
|
|
|
|
M.cmd = { "LspInstall", "LspUninstall" }
|
|
|
|
local opts = {
|
|
ensure_installed = { "lua_ls", "bashls" },
|
|
handlers = {
|
|
function(server_name)
|
|
require("lspconfig")[server_name].setup({})
|
|
end,
|
|
["intelephense"] = function()
|
|
require("lspconfig")["intelephense"].setup({
|
|
init_options = {
|
|
storagePath = os.getenv('XDG_CACHE_HOME') .. '/intelephense',
|
|
globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
|
|
licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licence.txt',
|
|
}
|
|
})
|
|
end,
|
|
["lua_ls"] = function()
|
|
require("lspconfig")["lua_ls"].setup({
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
workspace = {
|
|
library = {
|
|
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
|
[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true,
|
|
},
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
maxPreload = 100000,
|
|
preloadFileSize = 10000,
|
|
},
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
}
|
|
|
|
M.config = function()
|
|
local icons = require("config.icons")
|
|
local signs = {
|
|
{ name = "DiagnosticSignError", text = icons.DiagnosticError, texthl = "DiagnosticSignError" },
|
|
{ name = "DiagnosticSignWarn", text = icons.DiagnosticWarn, texthl = "DiagnosticSignWarn" },
|
|
{ name = "DiagnosticSignHint", text = icons.DiagnosticHint, texthl = "DiagnosticSignHint" },
|
|
{ name = "DiagnosticSignInfo", text = icons.DiagnosticInfo, texthl = "DiagnosticSignInfo" },
|
|
{ name = "DapStopped", text = icons.DapStopped, texthl = "DiagnosticWarn" },
|
|
{ name = "DapBreakpoint", text = icons.DapBreakpoint, texthl = "DiagnosticInfo" },
|
|
{ name = "DapBreakpointRejected", text = icons.DapBreakpointRejected, texthl = "DiagnosticError" },
|
|
{ name = "DapBreakpointCondition", text = icons.DapBreakpointCondition, texthl = "DiagnosticInfo" },
|
|
{ name = "DapLogPoint", text = icons.DapLogPoint, texthl = "DiagnosticInfo" },
|
|
}
|
|
for _, sign in ipairs(signs) do
|
|
vim.fn.sign_define(sign.name, sign)
|
|
end
|
|
|
|
vim.diagnostic.config({
|
|
virtual_text = true,
|
|
signs = {
|
|
text = {
|
|
[vim.diagnostic.severity.ERROR] = icons.DiagnosticError,
|
|
[vim.diagnostic.severity.HINT] = icons.DiagnosticHint,
|
|
[vim.diagnostic.severity.WARN] = icons.DiagnosticWarn,
|
|
[vim.diagnostic.severity.INFO] = icons.DiagnosticInfo,
|
|
},
|
|
active = signs,
|
|
},
|
|
update_in_insert = true,
|
|
underline = true,
|
|
severity_sort = true,
|
|
float = {
|
|
focused = false,
|
|
style = "minimal",
|
|
border = "rounded",
|
|
source = "always",
|
|
header = "",
|
|
prefix = "",
|
|
},
|
|
})
|
|
|
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded", silent = true })
|
|
vim.lsp.handlers["textDocument/signatureHelp"] =
|
|
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded", silent = true })
|
|
|
|
local mlsp = require('mason-lspconfig')
|
|
mlsp.setup({ ensure_installed = opts.ensure_installed })
|
|
mlsp.setup_handlers(opts.handlers)
|
|
end
|
|
|
|
return M
|