diff options
Diffstat (limited to 'lua/lsp.lua')
-rw-r--r-- | lua/lsp.lua | 68 |
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 @@ | |||
1 | local nvim_lsp = require('lspconfig') | ||
2 | local 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) | ||
22 | end | ||
23 | |||
24 | local servers = { "hls", "bashls" } | ||
25 | for _, lsp in ipairs(servers) do | ||
26 | nvim_lsp[lsp].setup { | ||
27 | on_attach = on_attach, | ||
28 | } | ||
29 | end | ||
30 | |||
31 | local capabilities = require('cmp_nvim_lsp') | ||
32 | .default_capabilities(vim.lsp.protocol.make_client_capabilities()) | ||
33 | |||
34 | capabilities.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 | |||
51 | nvim_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 | |||
65 | nvim_lsp.jdtls.setup{ | ||
66 | cmd = {"jdtls"}; | ||
67 | } | ||
68 | |||