nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.09k stars 464 forks source link

Bug: lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: E539: Illegal character <d> #1136

Closed linrongbin16 closed 11 months ago

linrongbin16 commented 11 months ago

Self Checks

How to reproduce the problem

Step-0: prepare the environment

  1. machine: macOS M1 chip, OS version: ventura 13.6 (linux like ubuntu should be good too).
  2. wezterm (other terminal should be good too).
  3. install the Sauce Code Pro nerd font and configure it in wezterm.

    local wezterm = require("wezterm")
    local config = {}
    config.font = wezterm.font("SauceCodePro Nerd Font Mono")
    return config

This is because usually we're using patched fonts with icons, and the nvim-web-devicons plugin.

Step-1: download the neovide code base (a rust project):

git clone --depth=1 https://github.com/neovide/neovide.git ~/.neovide

Step-2: cd into the project folder & open the main.rs with the minimal init:

cd ~/.neovide
nvim -u minimal_init.lua src/main.rs

The minimal_init.lua is attached in the end of this issue.

Note, the minimal_init.lua contains multiple plugins:

When you're using this minimal_init.lua, the first time you won't re-produce the issue, that's because lazy.nvim need to install plugins, and mason need to install rust_analyzer, wait for all the dependencies installed successfully, then re-open the file src/main.rs in the second time.

Expected behaviour

Correctly shows the lsp progress status messages.

Actual behaviour

It shows:

image

https://github.com/nvim-lualine/lualine.nvim/assets/6496887/508612a9-211a-408d-8b99-2b7df7c737b6

The error is:

lualine.nvim/lua/lualine/utils/nvim_opts.lua:77: E539: Illegal character <d>

Sometimes it will also report for <+>, <i>.

To help debugging, I add debug log in the lsp-progress.nvim/lua/lsp-progress.lua:

local function progress(option)
  local content = ''
  ...
  logger.debug( -- add log in this line
    "|lsp-progress.progress| returned content: %s",
    vim.inspect(content)
  )
  return content
end

return {
  setup = setup,
  progress = progress,
}

Here's the log file:

lsp-progress.nvim.log

I guess it's relate to the % escaping when formatting lua string.

Also see issue: https://github.com/linrongbin16/lsp-progress.nvim/pull/95.

Minimal config to reproduce the issue

-- options
vim.opt.number = true
vim.opt.relativenumber = false
vim.opt.signcolumn = "yes"
vim.opt.showmode = false
vim.opt.laststatus = 3
vim.opt.autoread = true
vim.opt.autowrite = true
vim.opt.swapfile = false
vim.opt.confirm = false

-- lazy plugin manager
local lazypath = vim.fn.stdpath("config") .. "/lazy/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",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "neovim/nvim-lspconfig",
        config = function() end,
    },
    {
        "williamboman/mason.nvim",
        dependencies = { "neovim/nvim-lspconfig" },
        build = ":MasonUpdate",
        config = function()
            require("mason").setup({
                ui = {
                    icons = {
                        package_installed = "✓",
                        package_pending = "➜",
                        package_uninstalled = "✗",
                    },
                },
            })
        end,
    },
    {
        "williamboman/mason-lspconfig.nvim",
        dependencies = { "neovim/nvim-lspconfig", "williamboman/mason.nvim" },
        config = function()
            require("mason-lspconfig").setup({
                ensure_installed = {
                    "rust_analyzer",
                },
            })
            require("mason-lspconfig").setup_handlers({
                function(server)
                    require("lspconfig")[server].setup({})
                end,
            })
        end,
    },
    {
        "nvim-tree/nvim-web-devicons",
        lazy = true,
    },
    {
        "linrongbin16/lsp-progress.nvim",
        dependencies = { "nvim-tree/nvim-web-devicons" },
        lazy = true,
        config = function()
            require("lsp-progress").setup()
        end,
    },
    {
        "nvim-lualine/lualine.nvim",
        event = { "UIEnter" },
        dependencies = {
            "linrongbin16/lsp-progress.nvim",
            "nvim-tree/nvim-web-devicons",
        },
        config = function()
            local empty_component_separators = { left = "", right = "" }
            local angle_section_separators = { left = "", right = "" }

            local config = {
                options = {
                    icons_enabled = true,
                    component_separators = empty_component_separators,
                    section_separators = angle_section_separators,
                },
                sections = {
                    lualine_a = { "mode" },
                    lualine_b = {
                        "filename",
                        require("lsp-progress").progress,
                    },
                },
                inactive_sections = {},
                tabline = {},
                winbar = {},
                inactive_winbar = {},
                extensions = {},
            }

            require("lualine").setup(config)

            -- listen to lsp-progress event and refresh
            vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
            vim.api.nvim_create_autocmd("User", {
                group = "lualine_augroup",
                pattern = "LspProgressStatusUpdated",
                callback = require("lualine").refresh,
            })
        end,
    },
})

Additional information

linrongbin16 commented 11 months ago

I need to double confirm again, close for now.