From ddc6f72c5b1cf6916ef2705b226d0c53950b9386 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 23 Jul 2024 20:26:43 +0100 Subject: init --- lua/lsp.lua | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 lua/lsp.lua (limited to 'lua/lsp.lua') diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..349c719 --- /dev/null +++ b/lua/lsp.lua @@ -0,0 +1,68 @@ +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"}; +} + -- cgit v1.2.3