local nvim_lsp = require('lspconfig') local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local bufopts = { noremap=true, silent=true, buffer=bufnr } vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) local opts = { noremap=true, silent=true } vim.keymap.set('n', 'd', vim.diagnostic.open_float, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) end local servers = { "hls", "bashls" } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach, } end local capabilities = require('cmp_nvim_lsp') .default_capabilities(vim.lsp.protocol.make_client_capabilities()) capabilities.textDocument.completion.completionItem.snippetSupport = true -- nvim_lsp.rust_analyzer.setup { -- on_attach = on_attach, -- settings = { -- ["rust-analyzer"] = { -- procMacro = { -- enable = true -- }, -- cargo = { -- allFeatures = false, -- }, -- checkOnSave = false, -- }, -- }, -- } nvim_lsp.ccls.setup { capabilities = capabilities, on_attach = on_attach, init_options = { index = { threads = 0; }; clang = { extraArgs = { "-fopenmp" }; excludeArgs = { "-frounding-math" } ; }; } } nvim_lsp.jdtls.setup{ cmd = {"jdtls"}; }