require('plugins') require('keymaps') map('n', '', vim.diagnostic.goto_prev) map('n', '', vim.diagnostic.goto_next) -- Only map the following keys after the language server attaches to the -- current buffer -- TODO: get key mappings to work. local on_attach = function(client, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') local function maplsp(mode, shortcut, command) vim.keymap.set(mode, shortcut, command, { noremap = true, silent = true, buffer=bufnr }) end maplsp('n', 'gD', vim.lsp.buf.declaration) maplsp('n', 'gd', vim.lsp.buf.definition) maplsp('n', 'K', vim.lsp.buf.hover) maplsp('n', 'gi', vim.lsp.buf.implementation) maplsp('n', '', vim.lsp.buf.signature_help) maplsp('n', 'wa', vim.lsp.buf.add_workspace_folder) maplsp('n', 'wr', vim.lsp.buf.remove_workspace_folder) maplsp('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) maplsp('n', 'D', vim.lsp.buf.type_definition) maplsp('n', 'rn', vim.lsp.buf.rename) maplsp('n', 'ca', vim.lsp.buf.code_action) maplsp('n', 'gr', vim.lsp.buf.references) maplsp('n', 'f', vim.lsp.buf.formatting) end -- setup servers require'lspconfig'.clangd.setup{ cmd = { 'clangd', '--compile-commands-dir=build', '--clang-tidy', -- needs >=clangd-9 '--ranking-model=decision_forest' -- needs >=clangd-12 } }