neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.35k stars 2.05k forks source link

Volar (containerised) crashes shortly after startup #1436

Closed WhyNotHugo closed 2 years ago

WhyNotHugo commented 2 years ago

Description

Volar crashes shortly after startup. I can't quite figure out why, nor have any clue on how to debug this further.

I'm running it containerised. I've logged all communication with the LSP by slipping in a special wrapper (note: I only used the wrapper for this bit; all other gathering of logs was done using the LSP normally without this wrapper):

stdin:

Content-Length: 3431

{"params":{"trace":"off","workspaceFolders":[{"uri":"file:\/\/\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3","name":"\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3"}],"capabilities":{"window":{"workDoneProgress":true,"showDocument":{"support":false},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":false}}},"callHierarchy":{"dynamicRegistration":false},"textDocument":{"references":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]}},"typeDefinition":{"linkSupport":true},"rename":{"dynamicRegistration":false,"prepareSupport":true},"declaration":{"linkSupport":true},"codeAction":{"dataSupport":true,"resolveSupport":{"properties":["edit"]},"dynamicRegistration":false,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","Empty","QuickFix","Refactor","RefactorExtract","RefactorInline","RefactorRewrite","Source","SourceOrganizeImports","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"contextSupport":false,"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"snippetSupport":false,"preselectSupport":false,"documentationFormat":["markdown","plaintext"]},"dynamicRegistration":false,"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"signatureHelp":{"dynamicRegistration":false,"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"]}},"documentHighlight":{"dynamicRegistration":false},"definition":{"linkSupport":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true,"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"implementation":{"linkSupport":true},"synchronization":{"didSave":true,"willSave":false,"dynamicRegistration":false,"willSaveWaitUntil":false}},"workspace":{"workspaceFolders":true,"symbol":{"hierarchicalWorkspaceSymbolSupport":true,"dynamicRegistration":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"resourceOperations":["rename","create","delete"]},"applyEdit":true,"configuration":true}},"processId":1188405,"initializationOptions":{"documentFeatures":{"documentColor":false,"foldingRange":true,"documentSymbol":true,"selectionRange":true,"linkedEditingRange":true,"documentFormatting":{"defaultPrintWidth":100}},"typescript":{"serverPath":"\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3\/node_modules\/typescript\/lib\/tsserverlibrary.js"},"languageFeatures":{"typeDefinition":true,"references":true,"semanticTokens":false,"rename":true,"documentHighlight":true,"documentLink":true,"codeAction":true,"callHierarchy":true,"completion":{"defaultTagNameCase":"both","defaultAttrNameCase":"kebabCase"},"definition":true,"signatureHelp":true,"diagnostics":true,"renameFileRefactoring":true,"hover":true,"codeLens":true,"schemaRequestService":true}},"rootUri":"file:\/\/\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3","clientInfo":{"name":"Neovim","version":"0.6.0"},"rootPath":"\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3"},"method":"initialize","jsonrpc":"2.0","id":1}Content-Length: 52

{"params":{},"method":"initialized","jsonrpc":"2.0"}Content-Length: 824

{"params":{"textDocument":{"uri":"file:\/\/\/home\/hugo\/clones\/gitlab.com\/fotus\/photostore\/vue3\/src\/App.vue","languageId":"vue","version":0,"text":"<script setup lang=\"ts\">\n\/\/ This starter template is using Vue 3 <script setup> SFCs\n\/\/ Check out https:\/\/v3.vuejs.org\/api\/sfc-script-setup.html#sfc-script-setup\nimport HelloWorld from '.\/components\/HelloWorld.vue'\n<\/script>\n\n<template>\n  <img alt=\"Vue logo\" src=\".\/assets\/logo.png\" \/>\n  <HelloWorld msg=\"Hello Vue 3 + TypeScript + Vite\" \/>\n<\/template>\n\n<style>\n#app {\n  font-family: Avenir, Helvetica, Arial, sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  text-align: center;\n  color: #2c3e50;\n  margin-top: 60px;\n}\n<\/style>\n"}},"method":"textDocument\/didOpen","jsonrpc":"2.0"}Content-Length: 45

{"result":[null,null],"jsonrpc":"2.0","id":0}Content-Length: 38

{"result":null,"jsonrpc":"2.0","id":1}Content-Length: 40

{"result":[null],"jsonrpc":"2.0","id":2}Content-Length: 40

{"result":[null],"jsonrpc":"2.0","id":3}

stdout:

Content-Length: 1494

{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"textDocumentSync":2,"selectionRangeProvider":true,"foldingRangeProvider":true,"linkedEditingRangeProvider":true,"documentSymbolProvider":true,"documentFormattingProvider":true,"referencesProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"callHierarchyProvider":true,"hoverProvider":true,"renameProvider":{"prepareProvider":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.vue"}},{"pattern":{"glob":"**/*.js"}},{"pattern":{"glob":"**/*.ts"}},{"pattern":{"glob":"**/*.jsx"}},{"pattern":{"glob":"**/*.tsx"}},{"pattern":{"glob":"**/*.json"}}]}}},"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]},"completionProvider":{"triggerCharacters":[".","\"","'","`","/","<","@","#"," ","<",":","@",".","/",".","@","/","\"",":"],"resolveProvider":true},"executeCommandProvider":{"commands":["volar.server.executeConvertToKebabCase","volar.server.executeConvertToPascalCase","volar.html-to-pug","volar.pug-to-html","volar.use-setup-sugar","volar.unuse-setup-sugar","volar.use-ref-sugar","volar.unuse-ref-sugar","volar.show-references"]},"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"codeLensProvider":{"resolveProvider":true},"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.fixAll","source.organizeImports"],"resolveProvider":true}}}}Content-Length: 169

{"jsonrpc":"2.0","id":0,"method":"workspace/configuration","params":{"items":[{"section":"js/ts.implicitProjectConfig"},{"section":"javascript.implicitProjectConfig"}]}}Content-Length: 124

{"jsonrpc":"2.0","id":1,"method":"window/workDoneProgress/create","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b"}}Content-Length: 194

{"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/hugo/clones/gitlab.com/fotus/photostore/vue3/src/App.vue.template.css","section":"css"}]}}Content-Length: 187

{"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/hugo/clones/gitlab.com/fotus/photostore/vue3/src/App.vue.0.css","section":"css"}]}}Content-Length: 181

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b","value":{"kind":"begin","title":"Initializing Vue language features (15 features)"}}}Content-Length: 138

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b","value":{"kind":"report","percentage":0}}}Content-Length: 139

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b","value":{"kind":"report","percentage":50}}}Content-Length: 120

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b","value":{"kind":"end"}}}Content-Length: 120

{"jsonrpc":"2.0","method":"$/progress","params":{"token":"242cb0c5-7731-4d09-ab88-a6b6aebf082b","value":{"kind":"end"}}}

stderr is empty.

Neovim version

NVIM v0.6.0-dev+529-g97ae0ab4d Build type: RelWithDebInfo LuaJIT 2.0.5 Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-git/src/build/config -I/build/neovim-git/src/neovim-git/src -I/usr/include -I/build/neovim-git/src/build/src/nvim/auto -I/build/neovim-git/src/build/include Compiled by builduser

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Nvim-lspconfig version

27d2c116fdea5614f422dcbcae63da01a1415fcf

Operating system and version

Linux 5.15.2-arch1-1 GNU/Linux

Affected language servers

Volar, bash-language-server

Steps to reproduce

  1. Create a sample project with npm init vite@latest, picking the vue-ts option.
  2. nvim -u minimal.lua src/App.vue

Actual behavior

LSP should not crash, or should show some clues as to what went wrong.

Expected behavior

LSP exits silently with no indicator of what's wrong.

Minimal config

local on_windows = vim.loop.os_uname().version:match 'Windows'

local function join_paths(...)
  local path_sep = on_windows and '\\' or '/'
  local result = table.concat({ ... }, path_sep)
  return result
end

vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir
if on_windows then
  temp_dir = vim.loop.os_getenv 'TEMP'
else
  temp_dir = '/tmp'
end

vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))

local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')

local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'neovim/nvim-lspconfig',
    },
    config = {
      package_root = package_root,
      compile_path = compile_path,
    },
  }
end

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  if vim.fn.has 'nvim-0.5.1' == 1 then
    require('vim.lsp.log').set_format_func(vim.inspect)
  end
  local nvim_lsp = require 'lspconfig'
  local on_attach = function(_, bufnr)
    local function buf_set_keymap(...)
      vim.api.nvim_buf_set_keymap(bufnr, ...)
    end
    local function buf_set_option(...)
      vim.api.nvim_buf_set_option(bufnr, ...)
    end

    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    local opts = { noremap = true, silent = true }
    buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
    buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
    buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
    buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
    buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
    buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
    buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
    buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
    buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  end

  -- Add the server that troubles you here
  local name = 'volar'
  local cmd = { 'podman', 'container', 'run', '--interactive', '--workdir=/home/hugo/tmp/vue3', '--volume=/home/hugo/tmp/vue3:/home/hugo/tmp/vue3', 'volar' } -- needed for elixirls, omnisharp, sumneko_lua
  if not name then
    print 'You have not defined a server name, please edit minimal_init.lua'
  end
  if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
    print [[You have not defined a server default cmd for a server
      that requires it please edit minimal_init.lua]]
  end

  nvim_lsp[name].setup {
    cmd = cmd,
    on_attach = on_attach,
  }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
  load_plugins()
  require('packer').sync()
  vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
  load_plugins()
  require('packer').sync()
  _G.load_config()
end

Health check

 s/App.vue  [No Name]                                                                                                         X

lspconfig: require("lspconfig.health").check()
========================================================================
  - INFO: volar: configuration checked.

LSP log

https://gist.github.com/WhyNotHugo/9347009cf52f8baf05ce0958ae6d5f7b

mjlbach commented 2 years ago

Does it crash non-containerized? If the answer is no, this belongs on our discourse.

WhyNotHugo commented 2 years ago

Sorry, I didn't actually mention this here: my question is how to debug this further. I don't mind attempting to address this myself, but am kinda stuck trying to figure out how to debug in LSP in general.

I haven't tried in a non-containerised context; haven't gotten around to setting up a suitable environment for that.

clason commented 2 years ago

Sorry, I didn't actually mention this here: my question is how to debug this further.

And the point is that such questions don't belong on a bug tracker, sorry. Use the Discourse link from the issue template or ask on Matrix.

clason commented 2 years ago

(If it turns out to be a bug in lspconfig, feel free to edit the issue and reopen or ping a maintainer to do it.)

WhyNotHugo commented 2 years ago

For anyone curious on this, it turned out to be related to https://github.com/microsoft/vscode-languageserver-node/issues/857. https://github.com/lspcontainers/lspcontainers.nvim/pull/49/files has further details.