nvimdev / dashboard-nvim

vim dashboard
MIT License
2.19k stars 177 forks source link

Misaligned cursor position with the Doom theme for some entries #422

Closed polirritmico closed 4 months ago

polirritmico commented 4 months ago

Describe the bug

In the Doom theme, with some fonts icons, the cursor position isn't aligned with the first character of the menu entry:

Misaligned Cursor

To Reproduce

  1. Use a font with variant width glyphs like: FiraCode form Nerd Fonts. For the screenshots I use FiraCodeNerdFont-Medium.ttf
  2. Run the minimal config with nvim -u repro.lua:
-- repro.lua
local root = vim.fn.fnamemodify("./repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

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)

local plugins = {
  {
    "nvimdev/dashboard-nvim",
    event = "VimEnter",
    opts = function()
      local opts = {
        theme = "doom",
        config = {
          header = { "HEADER" },
          center = {
            { action = "ene | startinsert", desc = " Aligned", icon = " ", key = "e", },
            { action = "Lazy", desc = " Not aligned", icon = "󰒲 ", key = "<leader>cl", },
            { action = "qa", desc = " Aligned", icon = " ", key = "q" },
          },
        },
      }
      return opts
    end,
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
  1. Restart neovim or close the Lazy float window and run :Dashboard.
  2. Scroll down and up through the menu entries.
  3. At the Not aligned entry the cursor should be at the left of the character N.

Expected behavior

Correctly align the cursor regardless of the icon used:

Aligned Cursor


System info

Konsole: 23.08.4 Gentoo Linux 2.14 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.113.0 Qt Version: 5.15.12 Kernel Version: 6.6.13-gentoo (64-bit)

NVIM v0.9.5 Build type: Release LuaJIT 2.1.0-beta3

Compilation: /usr/bin/x86_64-pc-linux-gnu-gcc  -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/usr/include/luajit-2.1 -I/usr/include -I/usr/include -I/var/tmp/portage/app-editors/neovim-0.9.5/work/neovim-0.9.5_build/src/nvim/auto -I/var/tmp/portage/app-editors/neovim-0.9.5/work/neovim-0.9.5_build/include -I/var/tmp/portage/app-editors/neovim-0.9.5/work/neovim-0.9.5_build/cmake.config -I/var/tmp/portage/app-editors/neovim-0.9.5/work/neovim-0.9.5/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include