122 lines
3.3 KiB
Lua
122 lines
3.3 KiB
Lua
return {
|
|
-- lspconfig
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
dependencies = {
|
|
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
|
{ "folke/neodev.nvim", opts = {} },
|
|
"mason.nvim",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
},
|
|
---@class PluginLspOpts
|
|
opts = function()
|
|
return {
|
|
-- options for vim.diagnostic.config()
|
|
diagnostics = {
|
|
underline = true,
|
|
update_in_insert = false,
|
|
virtual_text = {
|
|
spacing = 4,
|
|
source = "if_many",
|
|
prefix = "●",
|
|
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
|
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
|
|
-- prefix = "icons",
|
|
},
|
|
severity_sort = true,
|
|
},
|
|
-- add any global capabilities here
|
|
capabilities = {},
|
|
servers = {
|
|
jsonls = {},
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
},
|
|
completion = {
|
|
callSnippet = "Replace",
|
|
},
|
|
telemetry = { enable = false },
|
|
},
|
|
},
|
|
},
|
|
pylsp = {
|
|
settings = {
|
|
pylsp = {
|
|
plugins = {
|
|
rope_autoimport = { enabled = true },
|
|
isort = { enabled = true },
|
|
pycodestyle = { maxLineLength = 120 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
lemminx = {
|
|
settings = { xml = { server = { workDir = "~/.cache/lemminx" } } },
|
|
},
|
|
tinymist = {
|
|
--- todo: these configuration from lspconfig maybe broken
|
|
single_file_support = true,
|
|
root_dir = function()
|
|
return vim.fn.getcwd()
|
|
end,
|
|
--- See [Tinymist Server Configuration](https://github.com/Myriad-Dreamin/tinymist/blob/main/Configuration.md) for references.
|
|
settings = {
|
|
exportPdf = "onType",
|
|
outputPath = "$root/target/$dir/$name",
|
|
},
|
|
},
|
|
},
|
|
-- you can do any additional lsp server setup here
|
|
-- return true if you don't want this server to be setup with lspconfig
|
|
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
|
setup = {
|
|
-- example to setup with typescript.nvim
|
|
-- tsserver = function(_, opts)
|
|
-- require("typescript").setup({ server = opts })
|
|
-- return true
|
|
-- end,
|
|
-- Specify * to use this function as a fallback for any server
|
|
-- ["*"] = function(server, opts) end,
|
|
},
|
|
}
|
|
end,
|
|
---@param opts PluginLspOpts
|
|
config = function(_, opts)
|
|
-- diagnostics
|
|
vim.diagnostic.config(require("common").icons.diagnostics)
|
|
|
|
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("common").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))
|
|
end,
|
|
},
|
|
|
|
-- formatters
|
|
-- cmdline tools and lsp servers
|
|
{
|
|
"williamboman/mason.nvim",
|
|
cmd = "Mason",
|
|
opts = {
|
|
ensure_installed = {
|
|
"jdtls",
|
|
"lua-language-server",
|
|
},
|
|
},
|
|
},
|
|
"mfussenegger/nvim-jdtls",
|
|
}
|