Setting up nvim for java
- Install
jdtls
from the mason using:MasonInstall jdtls
or: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
jdtls
lsp 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