return {
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.noyalib then
configs.noyalib = {
default_config = {
cmd = { "noyalib-lsp" },
filetypes = { "yaml" },
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
or vim.fn.getcwd()
end,
single_file_support = true,
settings = {},
},
}
end
lspconfig.noyalib.setup({
on_attach = function(_client, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ async = false, timeout_ms = 2000 })
end,
})
local map = function(lhs, rhs)
vim.keymap.set("n", lhs, rhs, { buffer = bufnr, silent = true })
end
map("K", vim.lsp.buf.hover) map("[d", vim.diagnostic.goto_prev)
map("]d", vim.diagnostic.goto_next)
map("<leader>f", function()
vim.lsp.buf.format({ async = true })
end)
end,
})
end,
},
}