Setting up nvim for java
- Install
jdtlsfrom the mason using:MasonInstall jdtlsor:Mason - Then add jdtls in list of lsp’s :
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'ts_ls', 'gopls', 'jdtls' }
[–more–]
- If your are working with just basic java files, Initialize git in you working directory and create .project file.
git init
touch .project
- Now, open any java file and check if
jdtlslsp is attached using:LspInfo, check for this:
- 1 client(s) attached to this buffer
- Client: `jdtls` (id: 1, bufnr: [1])
if bufnr is > 0 then, it worked.
Reference: ChatGPT