nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
623 stars 42 forks source link

E539: Illegal character <,> #86

Open naquad opened 1 year ago

naquad commented 1 year ago

I'm using lualine with lsp-status and I get the following error when I'm trying phpactor:

Error executing vim.schedule lua callback: ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: E539: Illegal character <,>                                                                                                                                                        
stack traceback:
        [C]: in function 'nvim_win_set_option'
        ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: in function 'setter_fn'
        ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:50: in function 'set_opt'
        ...acker/start/lualine.nvim/lua/lualine/utils/nvim_opts.lua:74: in function 'set'
        ...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:432: in function 'refresh'
        ...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:353: in function <...nvim/site/pack/packer/start/lualine.nvim/lua/lualine.lua:352>

Sometimes I see that error using other language servers. I've already seen a similar https://github.com/neoclide/coc.nvim/issues/3051 but there it was related to the VIM script encoding.

naquad commented 1 year ago

Update

It was happening only for PHPActor LS, after some digging it figured out that the generated message looked like this:

[phpactor]   Indexing workspace 4500/6874 (65.46%, 243/5096 mb) (65%%)

Mind the single %.

A somewhat simplistic fix:

local function lsp_status_check()
  if #vim.lsp.buf_get_clients() == 0 then
    return ''
  end

  local status = lsp_status.status()
  status = status:gsub('%%%%', '%%') -- decode the encoded % sign
  status = status:gsub('%%', '%%%%') -- and encode them all
  return status
end