folke / trouble.nvim

🚦 A pretty diagnostics, references, telescope results, quickfix and location list to help you solve all the trouble your code is causing.
Apache License 2.0
5.44k stars 177 forks source link

bug v3: Error with Lualine component #424

Closed dpetka2001 closed 4 months ago

dpetka2001 commented 5 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.10.0-dev-3078+g3a8265266

Operating system/version

Linux Mint 21.3

Describe the bug

When I was trying to skim through some of lazy.nvim's code today in my locally forked repo, when i went on this line, I got the following error

   Error  07:41:31 PM notify.error Trouble ...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:98: Error executing lua: ...e/nvim/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: E539: Illegal character <d>
stack traceback:
    [C]: in function 'nvim_win_set_option'
    ...e/nvim/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: in function 'setter_fn'
    ...e/nvim/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:50: in function 'set_opt'
    ...e/nvim/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:74: in function 'set'
    ...rn23/.local/share/nvim/lazy/lualine.nvim/lua/lualine.lua:432: in function 'refresh'
    .../.local/share/nvim/lazy/trouble.nvim/lua/trouble/api.lua:150: in function 'on_update'
    ...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:108: in function 'update'
    ...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:72: in function 'finder'
    ...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:66: in function 'fn'
    ...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:99: in function <...hare/nvim/lazy/trouble.nvim/lua/trouble/view/section.lua:98>
    [C]: in function 'nvim_win_call'
    ...
    ....local/share/nvim/lazy/trouble.nvim/lua/trouble/util.lua:115: in function <....local/share/nvim/lazy/trouble.nvim/lua/trouble/util.lua:114>
    [C]: at 0x5608fb05d846
    [C]: in function 'pcall'
    ...ocal/share/nvim/lazy/noice.nvim/lua/noice/util/hacks.lua:177: in function <...ocal/share/nvim/lazy/noice.nvim/lua/noice/util/hacks.lua:162>
    [C]: in function 'pcall'
    ...al/share/nvim/lazy/which-key.nvim/lua/which-key/view.lua:126: in function 'getchar'
    ...al/share/nvim/lazy/which-key.nvim/lua/which-key/view.lua:317: in function 'on_keys'
    ...al/share/nvim/lazy/which-key.nvim/lua/which-key/view.lua:255: in function 'open'
    ...al/share/nvim/lazy/which-key.nvim/lua/which-key/init.lua:49: in function 'show'
    [string ":lua"]:1: in main chunk

Steps To Reproduce

  1. Clone lazy.nvim repo locally
  2. Open Neovim with Trouble v3 installed (in my case I enabled the LazyVim extra)
  3. Go to this file and line https://github.com/folke/lazy.nvim/blob/d3974346b6cef2116c8e7b08423256a834cb7cbc/lua/lazy/view/init.lua#L170
  4. Observe the error

Expected Behavior

No error

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/trouble.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
folke commented 4 months ago

Good catch. Fixed!

dpetka2001 commented 4 months ago

I also observe something similar in the .vim files that are from session save/restore in the directory ~/.local/state/nvim/sessions.

...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:98: Error executing lua: ...VimDev/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: E539: Illegal character <j>
stack traceback:
    [C]: in function 'nvim_win_set_option'
    ...VimDev/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: in function 'setter_fn'
    ...VimDev/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:50: in function 'set_opt'
    ...VimDev/lazy/lualine.nvim/lua/lualine/utils/nvim_opts.lua:74: in function 'set'
    ...local/share/LazyVimDev/lazy/lualine.nvim/lua/lualine.lua:432: in function 'refresh'
    ...l/share/LazyVimDev/lazy/trouble.nvim/lua/trouble/api.lua:150: in function 'on_update'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:108: in function 'update'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:72: in function 'finder'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:66: in function 'fn'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:99: in function <...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:98>
    [C]: in function 'nvim_win_call'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:98: in function 'main_call'
    ...azyVimDev/lazy/trouble.nvim/lua/trouble/view/section.lua:64: in function 'fn'
    .../share/LazyVimDev/lazy/trouble.nvim/lua/trouble/util.lua:119: in function <.../share/LazyVimDev/lazy/trouble.nvim/lua/trouble/util.lua:115>
    [C]: in function 'xpcall'
    .../share/LazyVimDev/lazy/trouble.nvim/lua/trouble/util.lua:115: in function <.../share/LazyVimDev/lazy/trouble.nvim/lua/trouble/util.lua:114>

I thought maybe it was the same error and it would be resolved if you fixed the one I mentioned in my OP, so that's why I didn't mention it before. Initially I thought it happened in vim files in general but I opened other vim files in ~/.local/share/nvim/lazy and that didn't happen. This only happens in vim files that are from session save/restore. For now I just disable the specific component in my config. Of course it's not something major as when skimming through code like in my OP.

folke commented 4 months ago

It's the escaping of % characters that still fails.

Can be easily reproduced with for example: nvim foo%j.txt.

Will further look into this.

folke commented 4 months ago

hmm, it seems that I can trigger the same issue even without trouble

folke commented 4 months ago

It seems that LazyVim's pretty path triggered the same issue. Fixed it in LazyVim