return { "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" }, dependencies = { "hrsh7th/cmp-nvim-lsp", }, keys = { { "e", vim.diagnostic.open_float }, { "[d", vim.diagnostic.goto_prev }, { "]d", vim.diagnostic.goto_next }, { "q", vim.diagnostic.setloclist }, { "gD", vim.lsp.buf.declaration }, { "gd", vim.lsp.buf.definition }, { "K", vim.lsp.buf.hover }, { "gi", vim.lsp.buf.implementation }, { "", vim.lsp.buf.signature_help }, { "D", vim.lsp.buf.type_definition }, { "rn", vim.lsp.buf.rename }, { "ca", vim.lsp.buf.code_action }, { "gr", vim.lsp.buf.references }, { "f", function() vim.lsp.buf.format { async = true } end }, }, config = function() local nvim_lsp = require("lspconfig") local protocol = require("vim.lsp.protocol") local on_attach = function(client, bufnr) -- Format on save if client.server_capabilities.documentFormattingProvider then vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("Format", { clear = true }), buffer = bufnr, callback = function() vim.lsp.buf.format() end, }) end end end, }