local u = require "core.utils" local attach = {} function attach.basic(_, _) u.map("n", "lf", function() vim.lsp.buf.format { async = true } end, true) u.map("n", "]d", function() vim.diagnostic.goto_next { float = false } end, true) u.map("n", "[d", function() vim.diagnostic.goto_prev { float = false } end, true) u.map("n", "]D", vim.diagnostic.goto_next, true) u.map("n", "[D", vim.diagnostic.goto_prev, true) end function attach.common(client, bufnr) if client.name == "gopls" then vim.lsp.codelens.refresh() end attach.basic(client, bufnr) u.map("n", "K", vim.lsp.buf.hover, true) u.map("n", "gd", "Telescope lsp_definitions", true) u.map("n", "gr", "Telescope lsp_references", true) u.map("n", "gi", "Telescope lsp_implementations", true) u.map("n", "gl", vim.diagnostic.open_float, true) u.map("n", "la", vim.lsp.buf.code_action, true) u.map("n", "lr", vim.lsp.buf.rename, true) u.map("n", "ls", "Telescope lsp_document_symbols", true) u.map("n", "ll", vim.lsp.codelens.run, true) u.map("n", "li", function() if vim.lsp.inlay_hint.is_enabled(bufnr) then vim.lsp.inlay_hint.enable(bufnr, false) vim.print "Inlay hints disabled" else vim.lsp.inlay_hint.enable(bufnr, true) vim.print "Inlay hints enabled" end end, true) end return attach