Closed Karol-Janowski closed 1 year ago
Hi, just chiming in. I just setup jdtls
(using my own neovim
config) using the package provided by mason. Since jdtls
recommends setting up via ftplugin
, it's something that needs to be done in your config. I am not familiar with how LunarVim
sets up the LSP servers but if you are writing your own config, you should add a java
filetype
to your ftplugin
directory and manually the setup (you can refer to the configuration section) for it to work.
I am not an expert on neovim
configuration, but from what I learned so far, mason.nvim
helps with the building and downloading and building of external packages (such as eclipse jdtls); but one still needs some configuration to do in order to use the mason
packages.
Hi, just chiming in. I just setup
jdtls
(using my ownneovim
config) using the package provided by mason. Sincejdtls
recommends setting up viaftplugin
, it's something that needs to be done in your config. I am not familiar with howLunarVim
sets up the LSP servers but if you are writing your own config, you should add ajava
filetype
to yourftplugin
directory and manually the setup (you can refer to the configuration section) for it to work.I am not an expert on
neovim
configuration, but from what I learned so far,mason.nvim
helps with the building and downloading and building of external packages (such as eclipse jdtls); but one still needs some configuration to do in order to use themason
packages.
Hi and thank you for the answer. I think u hit the point and i just missed this configuration file ( actually im pretty sure because i configure it once by myself and it worked fine ). I just thought Mason would do all the "dirty work" for me :)
Okey i did as u said via ftplugin/java.lua and it works fine but i still get the message on the bottom "LSP: No Lsp" - on the left "ServiceReady". In LunarVim u get the message "LSP: jdtls" - with no message on the bottom left. So i think there's need to be a way to configure it like they did. I tried to read LunarVim source code but i can't figure out how they did this - like for example clangd, pyright, Lua and others. Maybe someone have the answer how to do it like LunarVim. I like to use my own config but I really like the way how they configure jdtls in lunarVim lol
In LunarVim u get the message "LSP: jdtls" - with no message on the bottom left. So i think there's need to be a way to configure it like they did.
If by 'message', you mean the statusline
? I did a quick look on LunarVim
's repository and this is what you are looking for. Take note that LunarVim
has custom components
for lualine
, one of those is the LSP client's name. You can take a look at this example as it's much simpler that what is on LunarVim
.
For the 'ServiceReady' message, you can implement your own handler for the LSP status messages like below:
-- In your java ftplugin file
local jdtls_conf = {
handlers = {
-- This will make the progress messages like 'ServiceReady' go away.
-- Or you can customize the messages depending on what you like
['language/status'] = function() end,
},
-- settings
settings = {
-- jdtls settings goes here.
},
}
jdtls.start_or_attach(jdtls_conf)
In LunarVim u get the message "LSP: jdtls" - with no message on the bottom left. So i think there's need to be a way to configure it like they did.
If by 'message', you mean the
statusline
? I did a quick look onLunarVim
's repository and this is what you are looking for. Take note thatLunarVim
has customcomponents
forlualine
, one of those is the LSP client's name. You can take a look at this example as it's much simpler that what is onLunarVim
.For the 'ServiceReady' message, you can implement your own handler for the LSP status messages like below:
-- In your java ftplugin file local jdtls_conf = { handlers = { -- This will make the progress messages like 'ServiceReady' go away. -- Or you can customize the messages depending on what you like ['language/status'] = function() end, }, -- settings settings = { -- jdtls settings goes here. }, } jdtls.start_or_attach(jdtls_conf)
I have the same configuration in my lualine.lua file as u send in the second link. Although i'm still getting this prompt of "No Lsp" when JDTLS server is active. I see there is a bunch of configuration files in LunarVim LuaLine - your first link. I think i ll try to play around with but i see its a thought one ehh
Maybe because there is no filetype detected from the jdtls LSP. How about trying this? See the new filetypes
propety.
-- In your java ftplugin file
local jdtls_conf = {
handlers = {
-- handler here.
},
-- Add filetypes property for jdtls
filetypes = {
'java',
},
-- settings
settings = {
-- jdtls settings goes here.
},
}
jdtls.start_or_attach(jdtls_conf)
ok i opened some java project in LunarVim and when i did :LspInfo i get this:
So it looks like somehow they managed to configure JDTLS via nvim-lsp. Notice that if u do this "manually" ( ftplugin/java.lua and all the settings") u get the :LspInfo Autostart False. Very interesting i have no idea how they did this lol
Okey i manage to do this. i just add "jdtls.setup{ cmd = { 'jdtls' } }" to my lspconfig.lua file then require it from lua.init. Its works fine but i see that when u do it manually you can configure more options then if u do this via lspconfig but then u ll have this prompt "No Lsp" and autostart "false". ehh its a pity.
here is the link: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jdtls
So i see it's some kind of a trade - if u want to have more configs u cant do this via lspconfig but via ftplugins/java.lua but then u ll have no lsp prompt and autostart false. Hope they ll fix this someday to work like language servers for other languages :<
Thanks @schizophrenical for helping. However this is not the right place for support for how to use LSP servers as there are many different options to do so, all unrelated to Mason.
I've searched open issues for similar requests
I've manually reviewed logs to find potential errors
I've recently downloaded the latest plugin version of mason.nvim
Problem description
Hello, i'm trying to write java code in Neovim. Although when i download JDTLS via Mason it doesn't work properly. Basically I have no features related to JDTLS when i open java file. When i do :Mason its prompting me that everything is OK - JDTLS is installed. I know that I can configure JDTLS by myself by downloading it from eclipse site etc but i would rather prefer to use it via Mason. For example in LunarVim it works perfectly fine. I have no idea what it's not working in my own neovim configuration ( not LunarVim ). Maybe someone know what is the problem. I heard in some YT tutorial about JDTLS that its just not supported via Mason so its needed to be configured by downloading from Eclipse site and manually configured (by creating ftpplugin folder and then java.lua). But I just downloaded LunarVim about week ago and i see its work there just fine. Please help maybe someone know how to configure JDTLS via Mason. Thanks!
Expected behavior
JDTLS language server should start when opening java file.
Steps to reproduce
Affected packages
All
Neovim version (>= 0.7)
NVIM v.0.9.1
Operating system/version
Mac OS
Healthcheck
Screenshots or recordings