Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Trouble throws an error when attaching to a buffer with some LSPs #480

Closed
3 tasks done
artursmirnov opened this issue Jun 4, 2024 · 5 comments · Fixed by #461
Closed
3 tasks done

bug: Trouble throws an error when attaching to a buffer with some LSPs #480

artursmirnov opened this issue Jun 4, 2024 · 5 comments · Fixed by #461
Labels
bug Something isn't working

Comments

@artursmirnov
Copy link

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

macOS 14.3

Describe the bug

When opening a file of a certain filetype (handlebars), Trouble throws an error:

...share/nvim/lazy/trouble.nvim/lua/trouble/sources/lsp.lua:420: table index is nil

stack traceback:
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:34: in function 'transition'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:48: in function 'reject'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:81: in function 'cb'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:31: in function 'transition'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:45: in function 'resolve'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:78: in function 'cb'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:31: in function 'transition'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:45: in function 'resolve'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:164: in function <...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:160>
	[C]: in function 'pcall'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:73: in function 'cb'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:31: in function 'transition'
	...cal/share/nvim/lazy/trouble.nvim/lua/trouble/promise.lua:45: in function 'resolve'
	...share/nvim/lazy/trouble.nvim/lua/trouble/sources/lsp.lua:141: in function 'handler'
	.../neovim/0.10.0/share/nvim/runtime/lua/vim/lsp/client.lua:685: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

Excerpt from the :LspInfo:

 Detected filetype:   handlebars
 
 3 client(s) attached to this buffer: 
 
 Client: tailwindcss (id: 2, bufnr: [5, 6])
 	filetypes:       aspnetcorerazor, astro, astro-markdown, blade, clojure, django-html, htmldjango, edge, eelixir, elixir, ejs, erb, eruby, gohtml, gohtmltmpl, haml, handlebars, hbs, html, html-eex, heex, jade, leaf, liquid, mdx, mustache, njk, nunjucks, php, razor, slim, twig, css, less, postcss, sass, scss, stylus, sugarss, javascript, javascriptreact, reason, rescript, typescript, typescriptreact, vue, svelte, templ
 	autostart:       true
 	cmd:             /Users/artur/.local/share/nvim/mason/bin/tailwindcss-language-server --stdio
 
 Client: ember (id: 3, bufnr: [5, 6])
 	filetypes:       handlebars, typescript, javascript, typescript.glimmer, javascript.glimmer
 	autostart:       true
 	cmd:             /Users/artur/.local/share/nvim/mason/bin/ember-language-server --stdio
 
 Client: glint (id: 4, bufnr: [5, 6])
 	filetypes:       html.handlebars, handlebars, typescript, typescript.glimmer, javascript, javascript.glimmer
 	autostart:       true
 	cmd:             /Users/artur/.local/share/nvim/mason/bin/glint-language-server
 
 2 active client(s) not attached to this buffer: 
 
 Client: vtsls (id: 1, bufnr: [6])
 	filetypes:       javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx
 	autostart:       true
 	cmd:             /Users/artur/.local/share/nvim/mason/bin/vtsls --stdio
 
 Client: eslint (id: 5, bufnr: [6])
 	filetypes:       javascript, javascriptreact, javascript.jsx, typescript, typescriptreact, typescript.tsx, vue, svelte, astro
 	autostart:       true
 	cmd:             /Users/artur/.local/share/nvim/mason/bin/vscode-eslint-language-server --stdio
 
 Configured servers list: pylsp, html, vtsls, denols, pyright, volar, vuels, eslint, jsonls, yamlls, tailwindcss, ruff_lsp, emmet_language_server, ember, docker_compose_language_service, glint, dockerls, solargraph, clangd, marksman, ruff, lua_ls, cssls

LSP features work properly.

Steps To Reproduce

No particular steps, just opening a .hbs file.

Expected Behavior

No error should occur.

Repro

No response

@artursmirnov artursmirnov added the bug Something isn't working label Jun 4, 2024
@folke
Copy link
Owner

folke commented Jun 4, 2024

I can't reproduce this using glint and a simple file I created.
Can you provide a test file?

The error can only happen when an invalid location is sent from the LSP server.

@artursmirnov
Copy link
Author

@folke thank you for a swift response.

The error does not occur on a simple file. You need a simple Ember.js app. I think there should be an actual component invocation.

I was able to reproduce the issue in a clean setup with the following steps:

  1. Install clean LazyVim:
git clone https://github.com/LazyVim/starter ~/.config/nvim-test
  1. Launch it to install deps:
NVIM_APPNAME=nvim-test nvim
  1. Add the following configuration to plugins (I simply edited plugins/example.lua to return the following table):
 return {
   {
    "williamboman/mason.nvim",
    opts = {
      ensure_installed = {
        -- lua stuff
        "lua-language-server",
        "stylua",

        -- web dev stuff
        "css-lsp",
        "tailwindcss-language-server",
        "html-lsp",
        "json-lsp",
        "typescript-language-server",
        "ember-language-server",
        "vetur-vls",
        "glint",
        "yaml-language-server",
        "python-lsp-server",
        "deno",
        "eslint_d",
        "prettier",
      },
    },
  },

  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = {
        "vim",
        "lua",
        "html",
        "css",
        "scss",
        "javascript",
        "typescript",
        "json",
        "jsonc",
        "python",
        "ruby",
        "vue",
        "tsx",
        "c",
        "markdown",
        "markdown_inline",
        "bash",
        "dockerfile",
        "yaml",
        "toml",
        "glimmer",
      },
    },
  },
}
  1. Install Ember CLI globally:
npm install -g ember-cli
  1. Create a new Ember app in any folder:
cd ~/test-app-folder
ember new test-app
  1. Launch neovim in the app folder:
cd ~/test-app-folder/test-app
NVIM_APPNAME=nvim-test nvim
  1. Open the app/templates/application.hbs file.

The error should be displayed.

@artursmirnov
Copy link
Author

FWIW, it's been working properly in neovim 0.9.5. After upgrade to neovim 0.10.0 and updating Trouble from a8264a65a0b894832ea642844f5b7c30112c458f to the latest version, it started to error.

@folke folke closed this as completed in 358f0ee Jun 5, 2024
@folke
Copy link
Owner

folke commented Jun 5, 2024

Fixed. Worth mentioning is that :Telescope lsp_document_symbols also fails for this doc

@artursmirnov
Copy link
Author

The fix is working perfectly, thank you so much @folke!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants