Neovim jdtls config can't persist

371 Views Asked by At

I'm setting up my Neovim with lua and using lazy nvim as my plugin manager. I setup lsp with tsp-zero and try to setup nvim-jdtls, however it only works for the first buffer that I open. Here is the config:

return {
    'mfussenegger/nvim-jdtls',
    ft = 'java',
    config = function ()
        local config = {
            cmd = { vim.fn.stdpath('data') .. '/mason/bin/jdtls' },
            root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]),
        }
        require('jdtls').start_or_attach(config)
    end
}

and here is the LspInfo: LspInfo jdtls status

1

There are 1 best solutions below

1
Leonidas On

Found the solution, just move the config part to ~/.config/nvim/ftplugin/java.lua. However still show no filetype and autostart: false