spring-boot.nvim icon indicating copy to clipboard operation
spring-boot.nvim copied to clipboard

Does not get auto suggestions for application.properties and .yaml

Open Kabil777 opened this issue 7 months ago • 11 comments

Issue: No auto-completion suggestions with blink.cmp and nvim-jdtls

Description: I am using blink.cmp along with mfussenegger/nvim-jdtls (Distro nvchad). While diagnostics from the language server appear correctly, I am not receiving any auto-completion suggestions.


nvim/lua/plugins/java.lua

return {
  "mfussenegger/nvim-jdtls",
  ft = { "java", "properties", "yaml", "yml" },
  config = function()
    local function get_pkg_path(pkg_name)
      return vim.fn.stdpath("data") .. "/mason/packages/" .. pkg_name
    end

    local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
    local workspace_dir = vim.fn.stdpath("data") .. "/site/java/workspace-root/" .. project_name

    local bundles = {}

    -- Add Spring Boot extensions
    local spring_boot_extensions = require("spring_boot").java_extensions()
    vim.list_extend(bundles, spring_boot_extensions)

    local config = {
      cmd = {
        "java",
        "-Declipse.application=org.eclipse.jdt.ls.core.id1",
        "-Dosgi.bundles.defaultStartLevel=4",
        "-Declipse.product=org.eclipse.jdt.ls.core.product",
        "-Dlog.protocol=true",
        "-Dlog.level=ALL",
        "-javaagent:" .. vim.fn.expand("$MASON/packages/lombok-nightly/lombok.jar"),
        "-Xms1g",
        "--add-modules=ALL-SYSTEM",
        "--add-opens", "java.base/java.util=ALL-UNNAMED",
        "--add-opens", "java.base/java.lang=ALL-UNNAMED",
        "-jar", vim.fn.glob("$MASON/share/jdtls/plugins/org.eclipse.equinox.launcher_*.jar"),
        "-configuration", vim.fn.expand("$MASON/share/jdtls/config"),
        "-data", workspace_dir,
      },
      root_dir = vim.fs.root(0, { ".git", "mvnw", "gradlew" }),
      settings = {
        java = {
          eclipse = { downloadSources = true },
          configuration = { updateBuildConfiguration = "interactive" },
          maven = { downloadSources = true },
          implementationsCodeLens = { enabled = true },
          referencesCodeLens = { enabled = true },
          inlayHints = { parameterNames = { enabled = "all" } },
          signatureHelp = { enabled = true },
          completion = {
            favoriteStaticMembers = {
              "org.hamcrest.MatcherAssert.assertThat",
              "org.hamcrest.Matchers.*",
              "org.hamcrest.CoreMatchers.*",
              "org.junit.jupiter.api.Assertions.*",
              "java.util.Objects.requireNonNull",
              "java.util.Objects.requireNonNullElse",
              "org.mockito.Mockito.*",
            },
          },
          sources = {
            organizeImports = {
              starThreshold = 9999,
              staticStarThreshold = 9999,
            },
          },
        },
      },
      init_options = {
        bundles = bundles,
      },
      handlers = {
        ["$/progress"] = function() end, -- disable progress updates
      },
      filetypes = { "java" },
    }

    vim.api.nvim_create_autocmd("FileType", {
      pattern = { "java", "properties", "yaml", "yml" },
      callback = function()
        require("jdtls").start_or_attach(config)
      end,
    })
  end,
}

nvim/lua/plugins/springBoot.lua

return {
  "JavaHello/spring-boot.nvim",
  ft = { "java", "yaml", "properties" },
  specs = {
    {
      "mfussenegger/nvim-jdtls",
      optional = true,
      opts = function(_, opts)
        if not opts.init_options then
          opts.init_options = {}
        end
        if not opts.init_options.bundles then
          opts.init_options.bundles = {}
        end

        vim.list_extend(opts.init_options.bundles, require("spring_boot").java_extensions())
      end,
    },
  },
  opts = {},
}

Kabil777 avatar Jun 04 '25 17:06 Kabil777

Were you able to get this working? I'm running into the same issue.

Livingnight avatar Jun 11 '25 00:06 Livingnight

No , I'm not able to solve the issue still now ..!

Kabil777 avatar Jun 11 '25 10:06 Kabil777

:checkhealth vim.lsp checks if spring-boot is started?

JavaHello avatar Jun 11 '25 12:06 JavaHello

I'm experiencing the same issue.

Here's what checkhealth vim.lsp says on an application.properties file. I've been having a similar issue when I tried to just use nvim-java to have the integration setup already. It will work once and then stop and it never worked as far as I could tell on a application.yml file

  • spring-boot (id: 1)
    • Version: ? (no serverInfo.version response)
    • Root directory: ~/dev/java/covRealty
    • Command: { "{home}/.sdkman/candidates/java/current/bin/java", "-XX:TieredStopAtLevel=1", "-Xmx1G", "-XX:+UseZGC", "-Dsts.lsp.client=vscode", "-Dsts.log.file=/dev/null", "-jar", "{home directory}/.local/share/nvim/mason/share/vscode-spring-boot-tools/language-server.jar" }
    • Settings: {}
    • Attached buffers: 9

I'm using LazyVim and running neovim 0.11.2 on a windows 11 WSL.

here are the vim.lsp.logs for my most recent spring-boot lsp server starts:

[START][2025-06-11 12:41:45] LSP logging initiated [WARN][2025-06-11 12:41:45] ...m/lsp/client.lua:872 "The language server yamlls triggers a registerCapability handler for workspace/didChangeConfiguration despite dynamicRegistration set to false. Report upstream, this warning is harmless" [ERROR][2025-06-11 12:41:45] ...p/_transport.lua:36 "rpc" "/home/livingnight/.sdkman/candidates/java/current/bin/java" "stderr" "Disabling server log output. No more output will be sent after this.\n" [WARN][2025-06-11 12:41:46] ...m/lsp/client.lua:872 "The language server spring-boot triggers a registerCapability handler for workspace/didChangeWorkspaceFolders despite dynamicRegistration set to false. Report upstream, this warning is harmless"

I'm happy to provide any other information you might need as well.

Livingnight avatar Jun 11 '25 16:06 Livingnight

https://github.com/JavaHello/spring-boot.nvim/commit/5ae5714e401b926898b5c461814331ab016e93e5 It should be fixed in this commit, please try again

JavaHello avatar Jun 12 '25 11:06 JavaHello

it's fixed! thank you very much! I was able to get the auto-completion to work now

Livingnight avatar Jun 13 '25 16:06 Livingnight

I've also run into the issue where the auto-generation doesn't work when the jdtls server doesn't start at the same time as the spring-boot server since it is required to setup the spring-boot bundles needed.

As a quick fix, I've added "yaml" and "jproperties" filetypes to my autocommand for starting jdtls which will probably cause some issues down the line but works for now.

It's probably more of an annoyance than anything but I've been making changes my application.properties and having to open a java file and restart the server is annoying if I open the application.properties file first.

Livingnight avatar Jun 13 '25 20:06 Livingnight

But I can't still make this work . Suggest me how to setup spring-boot.nvim

Kabil777 avatar Jun 14 '25 14:06 Kabil777

Here's my repo for lazyvim: https://github.com/Livingnight/LazyVim

check out the nvim-jdtls.lua file, the nvim-lspconfig.lua file, and the spring-boot.lua file. I'm not sure why it works but it does.

Livingnight avatar Jun 16 '25 16:06 Livingnight

A further question, would spring-boot lsp server and the yamlls lsp server clash? or does the spring-boot server use the yamlls lsp server for .yaml files?

Livingnight avatar Jun 17 '25 16:06 Livingnight

@Kabil777 Please open a new issue and I'll try helping you as best as I can. @Livingnight Two LSP servers shouldn't clash in general; they will each provide their own features.

goldeneas avatar Sep 03 '25 09:09 goldeneas