136 lines
3.2 KiB
Lua
136 lines
3.2 KiB
Lua
return {
|
|
-- lspconfig
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
event = "BufReadPre",
|
|
dependencies = {
|
|
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
|
{ "folke/neodev.nvim", config = true },
|
|
"mason.nvim",
|
|
"williamboman/mason-lspconfig.nvim",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
},
|
|
---@type lspconfig.options
|
|
opts = {
|
|
servers = {
|
|
jsonls = {},
|
|
sumneko_lua = {
|
|
settings = {
|
|
Lua = {
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
},
|
|
completion = {
|
|
callSnippet = "Replace",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
setup = {
|
|
-- additional setup can be added here.
|
|
},
|
|
},
|
|
config = function(plugin, opts)
|
|
-- 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)
|
|
require("lazyvim.plugins.lsp.misc").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({
|
|
underline = true,
|
|
update_in_insert = false,
|
|
virtual_text = { spacing = 4, prefix = "●" },
|
|
severity_sort = true,
|
|
})
|
|
|
|
---@type lspconfig.options
|
|
local servers = opts.servers
|
|
local capabilities =
|
|
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
|
|
require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) })
|
|
require("mason-lspconfig").setup_handlers({
|
|
function(server)
|
|
local server_opts = servers[server] or {}
|
|
server_opts.capabilities = capabilities
|
|
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,
|
|
})
|
|
end,
|
|
},
|
|
|
|
-- formatters
|
|
{
|
|
"jose-elias-alvarez/null-ls.nvim",
|
|
event = "BufReadPre",
|
|
dependencies = { "mason.nvim" },
|
|
opts = function()
|
|
local nls = require("null-ls")
|
|
return {
|
|
debug = false,
|
|
sources = {
|
|
nls.builtins.formatting.stylua,
|
|
nls.builtins.diagnostics.flake8,
|
|
nls.builtins.formatting.prettier.with({
|
|
filetypes = {
|
|
"javascript",
|
|
"typescript",
|
|
"css",
|
|
"scss",
|
|
"html",
|
|
"json",
|
|
"yaml",
|
|
},
|
|
}),
|
|
nls.builtins.formatting.black.with({ extra_args = { "--fast" } }),
|
|
nls.builtins.formatting.bibclean,
|
|
nls.builtins.formatting.beautysh,
|
|
nls.builtins.diagnostics.shellcheck,
|
|
},
|
|
}
|
|
end,
|
|
},
|
|
|
|
-- cmdline tools and lsp servers
|
|
{
|
|
"williamboman/mason.nvim",
|
|
cmd = "Mason",
|
|
keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } },
|
|
opts = {
|
|
ensure_installed = {
|
|
"stylua",
|
|
"shellcheck",
|
|
"shfmt",
|
|
"flake8",
|
|
},
|
|
},
|
|
config = function(plugin, opts)
|
|
require("mason").setup()
|
|
local mr = require("mason-registry")
|
|
for _, tool in ipairs(opts.ensure_installed) do
|
|
local p = mr.get_package(tool)
|
|
if not p:is_installed() then
|
|
p:install()
|
|
end
|
|
end
|
|
end,
|
|
},
|
|
}
|