local M = {} function M.on_attach(bufnr) local telescope = require('utils').telescope local function map(key, rhs, desc) vim.keymap.set('n', key, rhs, { silent = true, buffer = bufnr, desc = desc, }) end map('K', vim.lsp.buf.hover, 'hover') map('lf', vim.lsp.buf.format, 'format') map('lD', vim.lsp.buf.declaration, 'declaration') map('ld', telescope 'lsp_definitions', 'definition') map('li', telescope 'lsp_implementations', 'implementation') map('lt', telescope 'lsp_type_definitions', 'type defintion') map('lr', telescope 'lsp_references', 'references') map('ly', telescope 'lsp_document_symbols', 'LSP symbols') map('ln', vim.lsp.buf.rename, 'rename') map('la', vim.lsp.buf.code_action, 'action') map('lp', vim.diagnostic.goto_prev, 'previous diagnostic') map('ll', vim.diagnostic.goto_next, 'next diagnostic') map('lw', telescope 'diagnostics', 'diagnostics list') map('ls', function() vim.diagnostic.open_float { scope = 'cursor' } end, 'cursor diagnostic') map('lS', function() vim.diagnostic.open_float { scope = 'line' } end, 'line diagnostics') end return M