I chose jdtls because I wanted a server with slower installation. Add the following to java.lua
Click to expand
```lua
local installer = require("nvim-lsp-installer")
local servers = require("nvim-lsp-installer.servers")
local log = require("nvim-lsp-installer.log")
local server_name = "jdtls"
local config = {}
local install_notification = false
local server_available, requested_server = servers.get_server(server_name)
-- until server:on_ready() fn exists upstream
function requested_server:on_ready(cb)
installer.on_server_ready(function(server)
if server.name == server_name then
cb()
end
end)
end
if server_available then
if not requested_server:is_installed() then
install_notification = true
log.debug("Automatic server installation detected")
vim.notify("Automatic server installation detected", vim.log.levels.INFO)
requested_server:install()
end
end
requested_server:on_ready(function()
requested_server:setup(config)
if install_notification then
log.debug(string.format("Installation complete for [%s] server", requested_server.name))
vim.notify(string.format("Installation complete for [%s] server", requested_server.name), vim.log.levels.INFO)
install_notification = false
end
end)
```
Prior to #199 the server installations would run inside its "final" directory (inside ~/.cache/nvim/lsp_servers). This meant that the very first thing that happens when a server is installed is that its directory gets created. This trips up the "is installed" logic, which merely checks for the existence of the directory. This has mostly been fine for the normal use cases, but since you're calling on_server_ready() in the same event loop tick as you're calling server:install(), it'll cause nvim-lsp-installer to think the server is successfully installed when this scheduled function executes.
Could you try pulling the latest version of this plugin - by installing in a tmpdir (#199) I think we should be all good now?
Could you try pulling the latest version of this plugin - by installing in a tmpdir (#199) I think we should be all good now?
welp.. this is embarassing because I keep telling people to update before testing It was merged 2 hours before this post and about a day after #210, so maybe I get a pass? 😄
I'll try to test some more things but it does seem that the tmpdir actually solves the issue.
Hehe I'll accept it. Using tmpdirs seems to have introduced some other issues (see #215), hopefully there's a quickfix, otherwise might have to rollback.
Description
First discovered in https://github.com/LunarVim/LunarVim/pull/1863, where basically the
on_server_ready()
is executing way too early.How to reproduce
I chose
jdtls
because I wanted a server with slower installation. Add the following tojava.lua
Click to expand
```lua local installer = require("nvim-lsp-installer") local servers = require("nvim-lsp-installer.servers") local log = require("nvim-lsp-installer.log") local server_name = "jdtls" local config = {} local install_notification = false local server_available, requested_server = servers.get_server(server_name) -- until server:on_ready() fn exists upstream function requested_server:on_ready(cb) installer.on_server_ready(function(server) if server.name == server_name then cb() end end) end if server_available then if not requested_server:is_installed() then install_notification = true log.debug("Automatic server installation detected") vim.notify("Automatic server installation detected", vim.log.levels.INFO) requested_server:install() end end requested_server:on_ready(function() requested_server:setup(config) if install_notification then log.debug(string.format("Installation complete for [%s] server", requested_server.name)) vim.notify(string.format("Installation complete for [%s] server", requested_server.name), vim.log.levels.INFO) install_notification = false end end) ```https://user-images.githubusercontent.com/59826753/139529436-5ed0dcc7-5438-41b0-8313-30d34600829b.mp4
You can see how how both the notification and the log entry are appearing before the installation is actually done.
Log file
```logtalk [DEBUG Sat 30 Oct 2021 12:33:34 PM CEST] ...nvim-lsp-installer/lua/nvim-lsp-installer/ui/display.lua:393: Opening window [DEBUG Sat 30 Oct 2021 12:33:37 PM CEST] ...nvim-lsp-installer/lua/nvim-lsp-installer/ui/display.lua:199: Deleting window [DEBUG Sat 30 Oct 2021 12:33:53 PM CEST] ...nvim-lsp-installer/lua/nvim-lsp-installer/ui/display.lua:393: Opening window [DEBUG Sat 30 Oct 2021 12:33:54 PM CEST] ...nvim-lsp-installer/lua/nvim-lsp-installer/ui/display.lua:199: Deleting window [DEBUG Sat 30 Oct 2021 12:34:01 PM CEST] /home/hatsu/.config/nvim/ftplugin/java.lua:24: Automatic server installation detected [DEBUG Sat 30 Oct 2021 12:34:01 PM CEST] ...-installer/lua/nvim-lsp-installer/ui/status-win/init.lua:612: Installing server { _default_options = { 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", "-Xms1g", "-Xmx2G", "-jar", "/home/hatsu/.local/share/nvim/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher_*.jar", "-configuration", "/home/hatsu/.local/share/nvim/lsp_servers/jdtls/config_linux", "-data", "/home/hatsu/workspace", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED" } }, _installer =Aaah I think I know what's happening now.
Prior to #199 the server installations would run inside its "final" directory (inside ~/.cache/nvim/lsp_servers). This meant that the very first thing that happens when a server is installed is that its directory gets created. This trips up the "is installed" logic, which merely checks for the existence of the directory. This has mostly been fine for the normal use cases, but since you're calling on_server_ready() in the same event loop tick as you're calling
server:install()
, it'll cause nvim-lsp-installer to think the server is successfully installed when this scheduled function executes.Could you try pulling the latest version of this plugin - by installing in a tmpdir (#199) I think we should be all good now?
welp.. this is embarassing because I keep telling people to update before testingIt was merged 2 hours before this post and about a day after #210, so maybe I get a pass? 😄I'll try to test some more things but it does seem that the tmpdir actually solves the issue.
Hehe I'll accept it. Using tmpdirs seems to have introduced some other issues (see #215), hopefully there's a quickfix, otherwise might have to rollback.
@kylo252 Did you see #214 btw?