Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Troubleshooting

Srinesh Nisala edited this pageNov 19, 2024 ·6 revisions

⛔ Mason failed to install jdtls ->Cannot find package "xxxxx"

Solution

nvim-java is using specific versions for some packages such asjdtls 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-registryhere containing those packages.nvim-java passes that custom registry in the lazy configuration usinglazy.lua however, this might not be passed to therequire('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.

Method 1: useopts instead ofconfig function to setup mason

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}

Method 2: If you have complex configuration insideconfig, you can pass a function toopts

return {'williamboman/mason.nvim',opts=function()-- do all your complex stuff herereturn {ui= {icons= {package_installed='',package_pending='',package_uninstalled='',},},}end,}

Method 3: If you really want to useconfig property for some reason, consider the default values

return {'williamboman/mason.nvim',config=function(_,opts)localconf=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-javarequire('mason').setup(conf)end,}

⛔ How to clean rebuild

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

⛔ LSP doesn't work on Maven projects

Solution
  • Go to the project and run
mvn eclipse:clean eclipse:eclipse
  • Now open the project in Neovim

Readthis article for more information


To enrich the config, XXX should already be present

Solution

If you are getting this error, that meansjdtls having a hard time finding the root of the project.This mostly happens when one of the parent directories is agit repository. If you are someone whomanages 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 runninggit init
  • Another option would be to pass the root markers when setting upnvim-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

⛔ How to remove noisy and annoyingjdtls notifications

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.

image

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,},})

⛔ Disable OpenJDK-17 auto installation

Solution

We are installingjdk-17 because that's the recommended runtime to runjdtls. However, if you havejdk-17 already, you can use that instead. To disable auto install, setjdk.auto_install tofalse

require('java').setup({jdk= {auto_install=false,  },})

Unknown purl type: openvsx

Solution

This is not related tonvim-java but you can solve it by updatingmason.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.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp