-
-
Notifications
You must be signed in to change notification settings - Fork 70
Troubleshooting
Solution
nvim-java
is using specific versions for some packages such as jdtls
that's different from the main Mason.nvim registry. Reason for that is to avoid breakage due to package update. For this, nvim-java
has a custom mason-registry here containing those packages. nvim-java
passes that custom registry in the lazy configuration using lazy.lua however, this might not be passed to the require('mason').setup()
function if you skips passing the default options.
So, this issue probably occurs due to the way you have configured Mason.nvim. Follow the instructions below to correctly configure Mason.nvim using Lazy.nvim.
return {
'williamboman/mason.nvim',
opts = {
ui = {
icons = {
package_installed = '✓',
package_pending = '➜',
package_uninstalled = '✗',
},
},
},
-- use OPTS property to pass the configuration
-- lazy vim call the setup function for you
-- config = function()
-- require('mason').setup({})
-- end
-- ^^^^^^^^^^^^^^^^ DON'T DO THIS
}
return {
'williamboman/mason.nvim',
opts = function()
-- do all your complex stuff here
return {
ui = {
icons = {
package_installed = '✓',
package_pending = '➜',
package_uninstalled = '✗',
},
},
}
end,
}
return {
'williamboman/mason.nvim',
config = function(_, opts)
local conf = vim.tbl_deep_extend('keep', opts, {
ui = {
icons = {
package_installed = '✓',
package_pending = '➜',
package_uninstalled = '✗',
},
},
})
-- ^^^^^ Here we are basically merge you configuration with OPTS
-- OPTS contains configurations defined elsewhere like nvim-java
require('mason').setup(conf)
end,
}
Solution
Unfortunately, we don't have command to auto update the classpath when you change dependencies, or jdk. Without force rebuild, changes will not be applied. So for now, you can manually remove following files.
In the project, remove,
.classpath
.project
In cache, remove,
$HOME/.cache/jdtls
$HOME/.cache/nvim/jdtls
Solution
- Go to the project and run
mvn eclipse:clean eclipse:eclipse
- Now open the project in Neovim
Read this article for more information
Solution
If you are getting this error, that means jdtls
having a hard time finding the root of the project.
This mostly happens when one of the parent directories is a git
repository. If you are someone who
manages the dotfiles in the $HOME
directory using a git repository, you might see this error.
- As a solution, you can make the current project root a git repository by running
git init
- Another option would be to pass the root markers when setting up
nvim-java
but not pass.git
require('java').setup({
root_markers = {
'settings.gradle',
'settings.gradle.kts',
'pom.xml',
'build.gradle',
'mvnw',
'gradlew',
'build.gradle',
'build.gradle.kts'
},
})
- Make current folder a git repository
git init
- Re-open neovim
Solution
If you find following notifications annoying, first of all, this has nothing to do with this plugin, BUT you can simply remove them when you are setting up the language server.
Here is how you can do it.
require("lspconfig").jdtls.setup({
handlers = {
-- By assigning an empty function, you can remove the notifications
-- printed to the cmd
["$/progress"] = function(_, result, ctx) end,
},
})
Solution
We are installing jdk-17
because that's the recommended runtime to run jdtls
. However, if you have jdk-17
already, you can use that instead. To disable auto install, set jdk.auto_install
to false
require('java').setup({
jdk = {
auto_install = false,
},
})
Solution
This is not related to nvim-java
but you can solve it by updating mason.nvim
plugin.
Case of this error is, mason-registry recently added packages from openvsx registry. However, old mason.nvim plugin does not know how to process this registry type.