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

Wrong alignment in cheatsheet when using icons on mapping description #74

Closed
BrunoKrugel opened this issue Mar 23, 2023 · 6 comments · Fixed by #86
Closed

Wrong alignment in cheatsheet when using icons on mapping description #74

BrunoKrugel opened this issue Mar 23, 2023 · 6 comments · Fixed by #86

Comments

@BrunoKrugel
Copy link
Contributor

BrunoKrugel commented Mar 23, 2023

Example:

["<leader>gc"] = { "<cmd>Telescope git_commits<CR>", " git commits" },

image

@siduck
Copy link
Member

siduck commented Apr 6, 2023

@kingavatar could you look into this? I tried using vim.fn.strwidth instead of #strname to get actual column count of each letter in string but that didnt work.

@kingavatar
Copy link
Contributor

@siduck, we can resolve the issue with whitespace length by using vim.fn.strdisplaywidth instead of #strname. However, for highlighting, Neovim uses byte indexing, which can cause errors when highlighting Unicode characters. This issue has been discussed in various threads such as neovim/neovim#15116, neovim/neovim#17401, and jackguo380/vim-lsp-cxx-highlight#51. To address this, I think we need to use byteidx to obtain the correct col_end for highlighting.

@siduck
Copy link
Member

siduck commented Apr 7, 2023

@siduck, we can resolve the issue with whitespace length by using vim.fn.strdisplaywidth instead of #strname. However, for highlighting, Neovim uses byte indexing, which can cause errors when highlighting Unicode characters. This issue has been discussed in various threads such as neovim/neovim#15116, neovim/neovim#17401, and jackguo380/vim-lsp-cxx-highlight#51. To address this, I think we need to use byteidx to obtain the correct col_end for highlighting.

Looks complex to me, your PRs are always welcome man! But if it's getting complex at your end then lemme know, I won't support icons in the cheatsteet

kingavatar added a commit to kingavatar/nvchad-ui.nvim that referenced this issue Apr 7, 2023
As the nvim_buf_add_highlight and other functions use byte indexing instead
of character indexing, I have fixed the whitespace length to not include the
extra bytes of unicode and also for highlighting I had to get the correct byte
index for both text and space lines of cheatsheet using builtin functions.

Additional testing is required to see all cases are handled.
I have checked for emojis and glyphs working as of now.

fixes NvChad#74
@kingavatar
Copy link
Contributor

I have pushed a PR for this issue. Additional testing is required to see if all cases are handled.

@siduck
Copy link
Member

siduck commented Apr 7, 2023

@BrunoKrugel test!

@BrunoKrugel
Copy link
Contributor Author

working!

siduck pushed a commit that referenced this issue Apr 8, 2023
…et (#86)

* fix(nvcheatsheet): fix unicode highlighting and spacing of nvcheatsheet

As the nvim_buf_add_highlight and other functions use byte indexing instead
of character indexing, I have fixed the whitespace length to not include the
extra bytes of unicode and also for highlighting I had to get the correct byte
index for both text and space lines of cheatsheet using builtin functions.

Additional testing is required to see all cases are handled.
I have checked for emojis and glyphs working as of now.

fixes #74

* fix(nvcheatsheet): handle title highlights as well

For Now this will handle spacing and highlights of title and space below as well.
But emoji in title is bit tricky to solve for now emojis or glyphs in title should not be allowed.

* fix(nvcheatsheet): fix heading nerd font as well

I have fixed nerd font icon for heading title as well. I have tried to include
emojis but yet they are causing the space highlighting to offset right side.
So emoji support yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants