williamboman / nvim-lsp-installer

Further development has moved to https://github.com/williamboman/mason.nvim!
https://github.com/williamboman/mason.nvim
Apache License 2.0
2k stars 123 forks source link

Failed to start ltex server on Manjaro Linux #500

Closed fillipe-gsm closed 2 years ago

fillipe-gsm commented 2 years ago

Problem description

I realize this has been asked at least twice for this specific server (once for Windows and another for Linux), but the solutions there did not work for me.

My LSP configuration is shown below, but I get the same behavior even with the minimal setup of README -- all other servers work out of the box, except ltex.

-- Add additional capabilities supported by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)

-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
    -- Enable completion triggered by <c-x><c-o>
    -- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    -- See `:help vim.lsp.*` for documentation on any of the below functions
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
end

local lsp_installer = require "nvim-lsp-installer"

-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
lsp_installer.on_server_ready(function(server)
    -- Specify the default options which we'll use to setup all servers
    local opts = {
        on_attach = on_attach,
        capabilities = capabilities,
        flags = {
            -- This will be the default in neovim 0.7+
            debounce_text_changes = 150,
        },
    }

    server:setup(opts)
end)

I also tried going to /home/myuser/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin and running ltex-ls directly, but I get the following error

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/bsplines/ltexls/LtexLanguageServerLauncher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

not sure if this has anything to do or I am just not running it right -- I am not familiar with Java, so the latter may be possible.

Neovim version (>= 0.6)

NVIM v0.6.1 Build type: Release LuaJIT 2.1.0-beta3

Operating system/version

Manjaro Linux

I've recently downloaded the latest plugin version of both nvim-lsp-installer and nvim-lspconfig

Affected language servers

ltex-ls

Steps to reproduce

  1. Start neovim with minimal debug configuration.
  2. Open an .rst file with any (even empty) contents.
  3. Client quits and server does not start.

Actual behavior

Server does not start with message "Client quits with exit code 1 and signal 0"

Expected behavior

Server starts

LspInfo

Language client log: /home/fillipe/.cache/nvim/lsp.log
 Detected filetype:   rst

 0 client(s) attached to this buffer: 

 Other clients that match the filetype: rst

 Config: ltex
    filetypes:         bib, gitcommit, markdown, org, plaintex, rst, rnoweb, tex
    root directory:    NA
    cmd:               ltex-ls
    cmd is executable: Unable to find executable. Please check your path and ensure the server is installed
    autostart:         true
    custom handlers:   

 Configured servers list: r_language_server, html, terraformls, ltex, kotlin_language_server, cssls, tsserver, sumneko_lua, emmet_ls, jedi_language_server

Healthcheck

nvim-lsp-installer: require("nvim-lsp-installer.health").check()
========================================================================
## nvim-lsp-installer report
  - OK: neovim version >= 0.6.0
  - WARNING: **Ruby**: not available
  - WARNING: **RubyGem**: not available
  - WARNING: **Composer**: not available
  - WARNING: **PHP**: not available
  - WARNING: **julia**: not available
  - OK: **tar**: `tar (GNU tar) 1.34`
  - OK: **gzip**: `gzip 1.11`
  - OK: **curl**: `curl 7.81.0 (x86_64-pc-linux-gnu) libcurl/7.81.0 OpenSSL/1.1.1m zlib/1.2.11 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.2 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.10.0 nghttp2/1.46.0`
  - OK: **wget**: `GNU Wget 1.21.2 built on linux-gnu.`
  - OK: **python3**: `Python 3.10.2`
  - OK: **node**: `v16.13.2`
  - OK: **Go**: `go version go1.17.6 linux/amd64`
  - OK: **bash**: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
  - OK: **sh**: `Ok`
  - OK: **java**: `Ok`
  - OK: **javac**: `Ok`
  - OK: **npm**: `8.4.1`
  - OK: **pip3**: `pip 22.0.2 from /home/fillipe/.local/lib/python3.10/site-packages/pip (python 3.10)`

Screenshots or recordings

No response

williamboman commented 2 years ago

Hello! Hm that's odd. These ltex-ls release files should bundle a compatible JRE. What architecture are you running (ARM or x64)?

williamboman commented 2 years ago

Also, do you have the JAVA_HOME environment variable set?

$ echo $JAVA_HOME
fillipe-gsm commented 2 years ago

Hi, @williamboman , I think I figured it out.

As I mentioned before, I am not well-versed on Java, but I had to install a very specific version in order to run a work related project. And this specific version -- 8.0 Zulu -- was apparently too old for the ltex-ls server. I tried updating to version 17 and it started with no issues.

Here are my Java version and JAVA_HOME env variable values now with the working version:

> java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)
> echo $JAVA_HOME
/home/fillipe/.sdkman/candidates/java/current

image

By the way, even tough it starts the only useful thing it seems to be doing is a grammar check; I see no latex/rst autocomplete functions or syntax checks. But I think this does not concern this plugin anymore :)

Thanks for the help!

williamboman commented 2 years ago

Yeah I believe ltex-ls needs Java 11 or later in order to run. However, the ltex-ls archives that are downloaded and unpacked actually include a JRE 11 distribution. I wonder why it doesn't just always use that one since it's always available, and ignore JAVA_HOME should it be defined. It might make sense to unset the JAVA_HOME variable from the environment used to start ltex-ls (in this plugin).

fillipe-gsm commented 2 years ago

I did not install java directly with the package manager; I had to use this sdkman. In fact, the JAVA_HOME shows that in the path. So I suppose it kinda overwrites the path for any other program, such as ltex-ls.

Unfortunately I found this server not very useful and ended up installing texlab for LaTeX files and actually nothing for rST documents :)

Thanks for the quick support!