I have a java library in a folder in my home folder (on linux) and I've been trying to edit my neovim config to let it be available for any java project. I'm having trouble finding the exact config I need though. I'm using lspconfig, and have tried setting the environment variable JDTLS_JVM_ARGS (like the lspconfig wiki says) to "-cp $JAVA_LIB", where $JAVA_LIB holds the path to this folder, but this doesn't work. Here's the relevant config for my lsp:
-- Skip to the bottom for the jdtls implementation
vim.opt.completeopt = 'menuone,noinsert,noselect'
-- Set up nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
window = {
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
["<C-J>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<C-J>`.
end
end, { "i", "s" }),
["<C-K>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
require'lspconfig'.cssls.setup { capabilities = capabilities }
require'lspconfig'.html.setup { capabilities = capabilities }
require'lspconfig'.pyright.setup { capabilities = capabilities }
require'lspconfig'.csharp_ls.setup { capabilities = capabilities }
require'lspconfig'.rust_analyzer.setup { capabilities = capabilities }
require'lspconfig'.gdscript.setup { capabilities = capabilities }
require'lspconfig'.jdtls.setup { capabilities = capabilities }
Most of it is copy-pasted from the lspconfig github page. Any help would be greatly appreciated!