kabouzeid / nvim-lspinstall

Provides the missing :LspInstall for nvim-lspconfig
MIT License
526 stars 67 forks source link

An easier way to update language servers #8

Open SandWoodJones opened 3 years ago

SandWoodJones commented 3 years ago

This is a feature request. An :LspUpdate command for updating out of date servers would be nice, as I wouldn't have to manually run :LspInstall for each of my installed servers to check if it has an update or not

kabouzeid commented 3 years ago

I agree that this would be nice. Currently this is not possible because we don't have a simple way to check if a language server is already up to date. Any ideas how this could be done?

An easy way would be to provide a command :LspReinstallAll (or :LspUpdateAll, or :LspUpdate) to just reinstall all installed language servers?

kabouzeid commented 3 years ago

You can already do something like this, but it has a few UI problems.

function _G.lsp_reinstall_all()
  local lspinstall = require'lspinstall'
  for _, server in ipairs(lspinstall.installed_servers()) do
    lspinstall.install_server(server)
  end
end

vim.cmd 'command! -nargs=0 LspReinstallAll call v:lua.lsp_reinstall_all()'
SandWoodJones commented 3 years ago

I'm guessing you'd need a separate operation for getting the commit or release version of a specific server. I don't think this would be hard with servers downloaded from github or npm, but I'm not sure about other sources. Reinstalling all of the servers could be a minor inconvenience for a when there's a large number of installed servers, but your script worked well enough for something I may run once a week or so.

dagadbm commented 3 years ago

so this is why coc uses yarn to manage all of these dependencies. makes sense now :p can you elaborate on what the UI problem for this is and why is it difficult to implement a simple re-install for all of them?

kabouzeid commented 3 years ago

Also every coc extensions has a maintainer who releases updates. lspinstall directly installs the servers.

kabouzeid commented 3 years ago

UI problem is that when you have eg 10 servers installed, reinstalling will open 10 terminal buffers at once which becomes confusing.

dagadbm commented 3 years ago

I just experienced it yeah xD

So the solution here is code something like packer or even use packer in some way nested to this.

On Mon, 5 Apr 2021 at 22:31, Karim Abou Zeid @.***> wrote:

UI problem is that when you have eg 10 servers installed, reinstalling will open 10 terminal buffers at once which becomes confusing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kabouzeid/nvim-lspinstall/issues/8#issuecomment-813662942, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7WGR4PHVSGQKU6UQWLXK3THIT43ANCNFSM4ZTJZ6FQ .

kiuKisas commented 3 years ago

Given the current situation, we can have two differents commands:

Server compatible with :LspUpdate should be mark in the readme

Seems dope enough for me :)

strayer commented 3 years ago

I for now built me a simple bash script to update npm-based language servers:

#!/usr/bin/env bash
set -euo pipefail

if [ -e /usr/local/opt/findutils/libexec/gnubin/find ]; then
  export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
fi

NODE_LSPS="$(find . -maxdepth 2 -type d -name 'node_modules' -printf '%h\n' | sort -u)"

for i in $NODE_LSPS; do
  (
    cd $i
    echo "Upgrading $(basename $(pwd))…"
    if [ -e yarn.lock ]; then
      OUTDATED_PACKAGES="$(yarn outdated -s)"

      if [ ! -z "$OUTDATED_PACKAGES" ]; then
        yarn upgrade --latest
      fi
    else
      OUTDATED_PACKAGES="$(npm outdated)"

      if [ ! -z "$OUTDATED_PACKAGES" ]; then
        npx --package=npm-check-updates -- ncu -u
        npm install
      fi
    fi
  )
done

I dislike it very much to use npm-check-updates, but npm doesn't really have anything like yarn upgrade --latest as far as I know. Since at least yaml already uses yarn it may make sense to use yarn for everything to make updating easier.

Currently the only language servers that are not npm-based that I use are html and such that are ripped out of Visual Studio Code. Checking for updates there isn't as easy, but I think it may be possible to load this via the GitHub releases of VS Code instead of the official download URL which would allow version checks (as long as the install scripts dumps the version at install somewhere). Although a new VS Code version doesn't necessarily mean that the LSP was updated, but as long as the VS Code team doesn't publish those via npm I don't see a better way to handle this.