missing file
This commit is contained in:
parent
70b01c9263
commit
605abd5772
151
.config/nvim/lua/lazyvim/plugins/lsp/config.lua
Normal file
151
.config/nvim/lua/lazyvim/plugins/lsp/config.lua
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.opts = {
|
||||||
|
-- could just set this in format.lua buuuut, it's nice to have here
|
||||||
|
autoformat = true,
|
||||||
|
-- options for vim.diagnostic.config()
|
||||||
|
diagnostics = {
|
||||||
|
underline = true,
|
||||||
|
update_in_insert = true,
|
||||||
|
virtual_text = { spacing = 4, prefix = "●" },
|
||||||
|
severity_sort = true,
|
||||||
|
},
|
||||||
|
servers = {
|
||||||
|
lua_ls = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace",
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cspell_ls = {
|
||||||
|
settings = {
|
||||||
|
filetypes = {
|
||||||
|
"lua",
|
||||||
|
"python",
|
||||||
|
"javascript",
|
||||||
|
"typescript",
|
||||||
|
"html",
|
||||||
|
"css",
|
||||||
|
"json",
|
||||||
|
"yaml",
|
||||||
|
"markdown",
|
||||||
|
"gitcommit",
|
||||||
|
},
|
||||||
|
root_markers = { ".git" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
omnisharp = {},
|
||||||
|
powershell_es = {
|
||||||
|
bundle_path = "c:/Users/Solomon/scripts/PowerShellEditorServices",
|
||||||
|
shell = "powershell.exe",
|
||||||
|
},
|
||||||
|
-- angularls = {
|
||||||
|
-- -- cmd = { "ngserver", "--stdio", "--tsProbeLocations", require("lazyvim.utils").get_root(), "--ngProbeLocations", require("lazyvim.utils").get_root(), },
|
||||||
|
-- -- on_new_config = function(new_config, new_root_dir)
|
||||||
|
-- -- new_config.cmd = cmd
|
||||||
|
-- -- end,
|
||||||
|
-- },
|
||||||
|
-- ltex = {
|
||||||
|
-- mason = true,
|
||||||
|
-- settings = {
|
||||||
|
-- ltex = {
|
||||||
|
-- language = "en-AU",
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
},
|
||||||
|
setup = {
|
||||||
|
-- additional setup can be added here.
|
||||||
|
omnisharp = function(_, _)
|
||||||
|
require("lazyvim.utils").on_attach(function(client, _)
|
||||||
|
if client.name == "omnisharp" then
|
||||||
|
---@type string[]
|
||||||
|
local tokenModifiers = client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
|
||||||
|
for i, v in ipairs(tokenModifiers) do
|
||||||
|
tokenModifiers[i] = v:gsub(" ", "_")
|
||||||
|
end
|
||||||
|
---@type string[]
|
||||||
|
local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
|
||||||
|
for i, v in ipairs(tokenTypes) do
|
||||||
|
tokenTypes[i] = v:gsub(" ", "_")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
-- setup autoformat
|
||||||
|
require("lazyvim.plugins.lsp.format").autoformat = M.opts.autoformat
|
||||||
|
|
||||||
|
-- setup formatting and keymaps
|
||||||
|
require("lazyvim.utils").on_attach(function(client, buffer)
|
||||||
|
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||||
|
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- diagnostics
|
||||||
|
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
|
||||||
|
name = "DiagnosticSign" .. name
|
||||||
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(M.opts.diagnostics.virtual_text) == "table" and M.opts.diagnostics.virtual_text.prefix == "icons" then
|
||||||
|
M.opts.diagnostics.virtual_text.prefix = function(diagnostic)
|
||||||
|
local icons = require("lazyvim.config").icons.diagnostics
|
||||||
|
for d, icon in pairs(icons) do
|
||||||
|
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
||||||
|
return icon
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.diagnostic.config(vim.deepcopy(M.opts.diagnostics))
|
||||||
|
|
||||||
|
-- lsp
|
||||||
|
local servers = M.opts.servers
|
||||||
|
|
||||||
|
local capabilities = vim.tbl_deep_extend(
|
||||||
|
"force",
|
||||||
|
{},
|
||||||
|
vim.lsp.protocol.make_client_capabilities(),
|
||||||
|
-- require("cmp_nvim_lsp").default_capabilities(),
|
||||||
|
require("blink.cmp").get_lsp_capabilities(),
|
||||||
|
M.opts.capabilities or {}
|
||||||
|
)
|
||||||
|
|
||||||
|
local function setup(server)
|
||||||
|
local server_opts = vim.tbl_deep_extend("force", {
|
||||||
|
capabilities = vim.deepcopy(capabilities),
|
||||||
|
}, servers[server] or {})
|
||||||
|
|
||||||
|
local server_opts = servers[server] or {}
|
||||||
|
|
||||||
|
-- if server has custom setup function, run that and don't call config
|
||||||
|
if M.opts.setup[server] then
|
||||||
|
if M.opts.setup[server](server, server_opts) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.config(server, server_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
for server, _ in pairs(servers) do
|
||||||
|
setup(server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
Loading…
Reference in New Issue
Block a user