summaryrefslogtreecommitdiff
path: root/lua/lsp.lua
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-07-23 20:26:43 +0100
committerAkshay <[email protected]>2024-07-23 20:26:43 +0100
commitddc6f72c5b1cf6916ef2705b226d0c53950b9386 (patch)
tree56b1d651dfe18a5e45b8cc6477ff8cb49991d98c /lua/lsp.lua
init
Diffstat (limited to 'lua/lsp.lua')
-rw-r--r--lua/lsp.lua68
1 files changed, 68 insertions, 0 deletions
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 @@
1local nvim_lsp = require('lspconfig')
2local on_attach = function(client, bufnr)
3 local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
4 local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
5
6 buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
7
8 -- Mappings.
9 local bufopts = { noremap=true, silent=true, buffer=bufnr }
10 vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
11 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
12 vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
13 vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
14 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
15
16 local opts = { noremap=true, silent=true }
17 vim.keymap.set('n', '<space>d', vim.diagnostic.open_float, opts)
18 vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
19 vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
20 vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
21 vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
22end
23
24local servers = { "hls", "bashls" }
25for _, lsp in ipairs(servers) do
26 nvim_lsp[lsp].setup {
27 on_attach = on_attach,
28 }
29end
30
31local capabilities = require('cmp_nvim_lsp')
32 .default_capabilities(vim.lsp.protocol.make_client_capabilities())
33
34capabilities.textDocument.completion.completionItem.snippetSupport = true
35
36-- nvim_lsp.rust_analyzer.setup {
37-- on_attach = on_attach,
38-- settings = {
39-- ["rust-analyzer"] = {
40-- procMacro = {
41-- enable = true
42-- },
43-- cargo = {
44-- allFeatures = false,
45-- },
46-- checkOnSave = false,
47-- },
48-- },
49-- }
50
51nvim_lsp.ccls.setup {
52 capabilities = capabilities,
53 on_attach = on_attach,
54 init_options = {
55 index = {
56 threads = 0;
57 };
58 clang = {
59 extraArgs = { "-fopenmp" };
60 excludeArgs = { "-frounding-math" } ;
61 };
62 }
63}
64
65nvim_lsp.jdtls.setup{
66 cmd = {"jdtls"};
67}
68