72 lines
1.9 KiB
Lua
72 lines
1.9 KiB
Lua
return {
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = {
|
|
"mason-org/mason.nvim",
|
|
"mason-org/mason-lspconfig.nvim",
|
|
{
|
|
"folke/lazydev.nvim",
|
|
ft = "lua", -- only load on lua files
|
|
opts = {
|
|
library = {
|
|
-- See the configuration section for more details
|
|
-- Load luvit types when the `vim.uv` word is found
|
|
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
config = function()
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
local handlers = {
|
|
-- ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
|
|
-- ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }),
|
|
}
|
|
|
|
require("mason").setup()
|
|
require("mason-lspconfig").setup({
|
|
ensure_installed = {
|
|
"lua_ls",
|
|
"gopls",
|
|
"html",
|
|
"basedpyright",
|
|
"clangd",
|
|
"yamlls",
|
|
"ansiblels",
|
|
},
|
|
handlers = {
|
|
function(server_name)
|
|
require("lspconfig")[server_name].setup {
|
|
capabilities = capabilities,
|
|
handlers = handlers
|
|
}
|
|
end,
|
|
clangd = function()
|
|
local lspconfig = require("lspconfig")
|
|
lspconfig.clangd.setup({
|
|
capabilities = capabilities,
|
|
handlers = handlers,
|
|
init_options = {
|
|
fallbackFlags = { '--std=c++20' }
|
|
},
|
|
})
|
|
end,
|
|
}
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
|
callback = function(args)
|
|
-- 2
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
-- 3
|
|
buffer = args.buf,
|
|
callback = function()
|
|
-- 4 + 5
|
|
vim.lsp.buf.format { async = false, id = args.data.client_id }
|
|
end,
|
|
})
|
|
end
|
|
})
|
|
end,
|
|
}
|