chore: Update lsp config
This commit is contained in:
parent
ca5fe4d489
commit
62d59f480f
7 changed files with 376 additions and 53 deletions
|
|
@ -14,7 +14,7 @@
|
|||
"flash.nvim": { "branch": "main", "commit": "cc8c7e03987134997d74ee87e55a5717279f2d05" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "ebf6d6e83494cdd88a54a429340256f4dbb6a052" },
|
||||
"git-blame.nvim": { "branch": "master", "commit": "a36b277e527f9d34efe16c3636555ce0e0c0464c" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "bce4576a9047085a528c479a7fe1e2f6b787b6c1" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "f0e9f5dd3218774fa725e55965b40ca78c2104eb" },
|
||||
"harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
|
||||
"instant.nvim": { "branch": "master", "commit": "294b6d08143b3db8f9db7f606829270149e1a786" },
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
"neotest-python": { "branch": "master", "commit": "81d2265efac717bb567bc15cc652ae10801286b3" },
|
||||
"neotest-rust": { "branch": "main", "commit": "139cff7c85598ec591b5ed7d71ce8ed3b5313b97" },
|
||||
"nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" },
|
||||
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
||||
"null.nvim": { "branch": "main", "commit": "bc6ea9deac03b791cdd980d8c84a5d923a26381c" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
|
||||
"nvim-dap": { "branch": "master", "commit": "b3d4408e29d924fe130c9397a7c3b3630b3ea671" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" },
|
||||
|
|
@ -52,14 +52,14 @@
|
|||
"nvim-navic": { "branch": "master", "commit": "0ffa7ffe6588f3417e680439872f5049e38a24db" },
|
||||
"nvim-spectre": { "branch": "master", "commit": "97cfd1b0f5a6ab35979ce1bee6c17f54745fd1e5" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "a3aa3b47eac8b6289f028743bef4ce9eb0f6782e" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "b7f2dd5dfbd24a1239844e15637b637b990df164" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "fc93fa5c07df7cd578a3ea82d7c075c0460a6884" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "95e9ba9de4289d221666b66fd930d157c7ca08c6" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "973ab742f143a796a779af4d786ec409116a0d87" },
|
||||
"persistence.nvim": { "branch": "main", "commit": "4b8051c01f696d8849a5cb8afa9767be8db16e40" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" },
|
||||
"tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "bc25c56083939f274edcfe395c6ff7de23b67c50" },
|
||||
"telescope-file-browser.nvim": { "branch": "master", "commit": "c3670c088bfb83e892ae69989875a1dfdd5cff99" },
|
||||
"telescope-file-browser.nvim": { "branch": "master", "commit": "c21bdaee7657439e07fb2ebb9ce2ab7221ba1b68" },
|
||||
"telescope-project.nvim": { "branch": "master", "commit": "7c64b181dd4e72deddcf6f319e3bf1e95b2a2f30" },
|
||||
"telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "40c8d2fc2b729dd442eda093cf8c9496d6e23732" },
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ M._keys = nil
|
|||
|
||||
---@return (LazyKeys|{has?:string})[]
|
||||
function M.get()
|
||||
local format = require("lazyvim.plugins.lsp.format").format
|
||||
local format = function()
|
||||
require("lazyvim.plugins.lsp.format").format({ force = true })
|
||||
end
|
||||
if not M._keys then
|
||||
---@class PluginLspKeys
|
||||
M._keys = {
|
||||
|
|
@ -25,7 +27,7 @@ function M.get()
|
|||
{ "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" },
|
||||
{ "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" },
|
||||
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
|
||||
{ "<F4>", format, desc = "Format Document", has = "documentFormatting" },
|
||||
{ "<F4>", format, desc = "Format Document", has = "formatting" },
|
||||
-- { "<leader>cf", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" },
|
||||
{
|
||||
"<leader>cq",
|
||||
|
|
@ -84,21 +86,51 @@ function M.get()
|
|||
return M._keys
|
||||
end
|
||||
|
||||
function M.on_attach(client, buffer)
|
||||
---@param method string
|
||||
function M.has(buffer, method)
|
||||
method = method:find("/") and method or "textDocument/" .. method
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
if client.supports_method(method) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.resolve(buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = {} ---@type table<string,LazyKeys|{has?:string}>
|
||||
|
||||
for _, value in ipairs(M.get()) do
|
||||
local keys = Keys.parse(value)
|
||||
if keys[2] == vim.NIL or keys[2] == false then
|
||||
local function add(keymap)
|
||||
local keys = Keys.parse(keymap)
|
||||
if keys[2] == false then
|
||||
keymaps[keys.id] = nil
|
||||
else
|
||||
keymaps[keys.id] = keys
|
||||
end
|
||||
end
|
||||
for _, keymap in ipairs(M.get()) do
|
||||
add(keymap)
|
||||
end
|
||||
|
||||
local opts = require("lazyvim.util").opts("nvim-lspconfig")
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
|
||||
for _, keymap in ipairs(maps) do
|
||||
add(keymap)
|
||||
end
|
||||
end
|
||||
return keymaps
|
||||
end
|
||||
|
||||
function M.on_attach(client, buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = M.resolve(buffer)
|
||||
|
||||
for _, keys in pairs(keymaps) do
|
||||
if not keys.has or client.server_capabilities[keys.has .. "Provider"] then
|
||||
if not keys.has or M.has(buffer, keys.has) then
|
||||
local opts = Keys.opts(keys)
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
opts.has = nil
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ return {
|
|||
{ "rcarriga/nvim-notify", enabled = false },
|
||||
},
|
||||
{ { "folke/noice.nvim", enabled = false } },
|
||||
{ { "jose-elias-alvarez/null-ls.nvim", enabled = false } },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@ return {
|
|||
lazy = true,
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } },
|
||||
{ "folke/neodev.nvim", opts = { experimental = { pathStrict = true } } },
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
"mfussenegger/nvim-jdtls",
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
|
|
@ -23,14 +22,15 @@ return {
|
|||
diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 4, prefix = "●" },
|
||||
virtual_text = { spacing = 4, source = "if_many", prefix = "●" },
|
||||
severity_sort = true,
|
||||
},
|
||||
-- Automatically format on save
|
||||
inlay_hints = {
|
||||
enabled = true,
|
||||
},
|
||||
capabilities = {},
|
||||
autoformat = false,
|
||||
-- options for vim.lsp.buf.format
|
||||
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
||||
-- but can be also overridden when specified
|
||||
format_notify = false,
|
||||
format = {
|
||||
formatting_options = nil,
|
||||
timeout_ms = nil,
|
||||
|
|
@ -104,7 +104,7 @@ return {
|
|||
},
|
||||
typst_lsp = {
|
||||
settings = {
|
||||
experimentalFormatterMode = "On",
|
||||
experimentalFormatterMode = "on",
|
||||
exportPdf = "onSave",
|
||||
},
|
||||
},
|
||||
|
|
@ -158,44 +158,75 @@ return {
|
|||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local Util = require("lazyvim.util")
|
||||
|
||||
if Util.has("neoconf.nvim") then
|
||||
local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"]
|
||||
require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false))
|
||||
end
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
||||
require("lazyvim.plugins.lsp.format").setup(opts)
|
||||
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").setup(opts)
|
||||
Util.on_attach(function(client, buffer)
|
||||
require("config.lsp-keymap").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
local register_capability = vim.lsp.handlers["client/registerCapability"]
|
||||
|
||||
vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
|
||||
local ret = register_capability(err, res, ctx)
|
||||
local client_id = ctx.client_id
|
||||
---@type lsp.Client
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
local buffer = vim.api.nvim_get_current_buf()
|
||||
require("config.lsp-keymap").on_attach(client, buffer)
|
||||
return ret
|
||||
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
|
||||
vim.diagnostic.config(opts.diagnostics)
|
||||
|
||||
require("lsp-inlayhints").setup({})
|
||||
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
|
||||
|
||||
if opts.inlay_hints.enabled and inlay_hint then
|
||||
Util.on_attach(function(client, buffer)
|
||||
if client.supports_method("textDocument/inlayHint") then
|
||||
inlay_hint(buffer, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
||||
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
||||
or 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(opts.diagnostics))
|
||||
|
||||
local servers = opts.servers
|
||||
local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities(),
|
||||
has_cmp and cmp_nvim_lsp.default_capabilities() or {},
|
||||
opts.capabilities or {}
|
||||
)
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||
require("lsp-inlayhints").on_attach(client, bufnr, true)
|
||||
end
|
||||
|
||||
local function setup(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
capabilities = vim.deepcopy(capabilities),
|
||||
on_attach = on_attach,
|
||||
vim.lsp.diagnostic.on_publish_diagnostics,
|
||||
{
|
||||
virtual_text = true,
|
||||
},
|
||||
}, servers[server] or {})
|
||||
|
||||
if opts.setup[server] then
|
||||
|
|
@ -210,23 +241,19 @@ return {
|
|||
require("lspconfig")[server].setup(server_opts)
|
||||
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"
|
||||
-- get all the servers that are available through mason-lspconfig
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
local all_mslp_servers = {}
|
||||
if have_mason then
|
||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
||||
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
|
||||
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
|
||||
setup(server)
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = server
|
||||
|
|
@ -234,19 +261,30 @@ return {
|
|||
end
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup({ ensure_installed = ensure_installed })
|
||||
require("mason-lspconfig").setup_handlers({ setup })
|
||||
if have_mason then
|
||||
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
|
||||
end
|
||||
|
||||
if Util.lsp_get_config("denols") and Util.lsp_get_config("tsserver") then
|
||||
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
|
||||
Util.lsp_disable("tsserver", is_deno)
|
||||
Util.lsp_disable("denols", function(root_dir)
|
||||
return not is_deno(root_dir)
|
||||
end)
|
||||
end
|
||||
|
||||
vim.cmd([[highlight LspInlayHint guibg=#1A1B26]])
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
"DashieTM/null.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "mason.nvim" },
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
return {
|
||||
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
|
||||
|
||||
sources = {
|
||||
nls.builtins.formatting.fish_indent,
|
||||
nls.builtins.diagnostics.fish,
|
||||
|
|
@ -255,6 +293,7 @@ return {
|
|||
nls.builtins.diagnostics.flake8,
|
||||
nls.builtins.formatting.autopep8,
|
||||
nls.builtins.formatting.prettierd,
|
||||
nls.builtins.formatting.typst,
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
|
|
|||
255
nvim/lua/plugins/lspbackup
Normal file
255
nvim/lua/plugins/lspbackup
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
lazy = true,
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neodev.nvim", opts = { experimental = { pathStrict = true } } },
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
"mfussenegger/nvim-jdtls",
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
cond = function()
|
||||
return require("lazyvim.util").has("nvim-cmp")
|
||||
end,
|
||||
},
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
-- options for vim.diagnostic.config()
|
||||
diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 4, prefix = "●" },
|
||||
severity_sort = true,
|
||||
},
|
||||
-- Automatically format on save
|
||||
autoformat = false,
|
||||
-- options for vim.lsp.buf.format
|
||||
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
||||
-- but can be also overridden when specified
|
||||
format = {
|
||||
formatting_options = nil,
|
||||
timeout_ms = nil,
|
||||
},
|
||||
-- LSP Server Settings
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
jsonls = {},
|
||||
tailwindcss = {},
|
||||
cssls = {},
|
||||
html = {},
|
||||
clangd = {
|
||||
root_pattern = {
|
||||
".clangd",
|
||||
".clang-tidy",
|
||||
".clang-format",
|
||||
"compile_commands.json",
|
||||
"compile_flags.txt",
|
||||
"configure.ac",
|
||||
".git",
|
||||
"build/compile_commands.json",
|
||||
},
|
||||
filetypes = {
|
||||
"c",
|
||||
"cpp",
|
||||
"objc",
|
||||
"objcpp",
|
||||
"cuda",
|
||||
"proto",
|
||||
"cl",
|
||||
},
|
||||
},
|
||||
pyright = {},
|
||||
cmake = {},
|
||||
bashls = {},
|
||||
ansiblels = {},
|
||||
marksman = {},
|
||||
asm_lsp = {},
|
||||
omnisharp = {},
|
||||
rust_analyzer = {
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
experimental = true,
|
||||
},
|
||||
},
|
||||
tsserver = {
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
typst_lsp = {
|
||||
settings = {
|
||||
experimentalFormatterMode = "on",
|
||||
exportPdf = "onSave",
|
||||
},
|
||||
},
|
||||
ltex = {
|
||||
settings = {
|
||||
ltex = {
|
||||
checkFrequency = "save",
|
||||
},
|
||||
},
|
||||
filetypes = {
|
||||
"bib",
|
||||
"gitcommit",
|
||||
"markdown",
|
||||
"org",
|
||||
"plaintex",
|
||||
"rst",
|
||||
"rnoweb",
|
||||
"tex",
|
||||
"pandoc",
|
||||
"typst",
|
||||
"typ",
|
||||
},
|
||||
},
|
||||
texlab = {},
|
||||
gopls = {
|
||||
staticcheck = true,
|
||||
},
|
||||
sqlls = {},
|
||||
taplo = {},
|
||||
lemminx = {},
|
||||
opencl_ls = {},
|
||||
yamlls = {},
|
||||
lua_ls = {
|
||||
-- mason = false, -- set to false if you don't want this server to be installed with mason
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
jdtls = function()
|
||||
return true
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").setup(opts)
|
||||
require("config.lsp-keymap").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
|
||||
vim.diagnostic.config(opts.diagnostics)
|
||||
|
||||
require("lsp-inlayhints").setup({})
|
||||
local servers = opts.servers
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities(),
|
||||
opts.capabilities or {}
|
||||
)
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||
require("lsp-inlayhints").on_attach(client, bufnr, true)
|
||||
end
|
||||
|
||||
local function setup(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
capabilities = vim.deepcopy(capabilities),
|
||||
on_attach = on_attach,
|
||||
vim.lsp.diagnostic.on_publish_diagnostics,
|
||||
{
|
||||
virtual_text = true,
|
||||
},
|
||||
}, servers[server] or {})
|
||||
|
||||
if opts.setup[server] then
|
||||
if opts.setup[server](server, server_opts) then
|
||||
return
|
||||
end
|
||||
elseif opts.setup["*"] then
|
||||
if opts.setup["*"](server, server_opts) then
|
||||
return
|
||||
end
|
||||
end
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
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 })
|
||||
|
||||
vim.cmd([[highlight LspInlayHint guibg=#1A1B26]])
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = { "mason.nvim" },
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
return {
|
||||
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
|
||||
sources = {
|
||||
nls.builtins.formatting.fish_indent,
|
||||
nls.builtins.diagnostics.fish,
|
||||
nls.builtins.formatting.stylua,
|
||||
nls.builtins.formatting.shfmt,
|
||||
nls.builtins.diagnostics.flake8,
|
||||
nls.builtins.formatting.autopep8,
|
||||
nls.builtins.formatting.prettierd,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -16,11 +16,6 @@ return {
|
|||
require("telescope").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"lvimuser/lsp-inlayhints.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
lazy = true,
|
||||
},
|
||||
{
|
||||
"ThePrimeagen/harpoon",
|
||||
lazy = true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue