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

perf: use builtin for key normalization #1935

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

tomtomjhj
Copy link
Contributor

@tomtomjhj tomtomjhj commented May 17, 2024

After #986, @zeertzjq added the keytrans() function for translating byte rep of keys to key notation form in neovim/neovim@907fc8a. This can be used for normalization.

This reduces running time of prepare() from about 16ms to 6ms on my setup.

btw I' curious about why keymap.t manually replaces < instead of using nvim_replace_termcodes (f2f6dce). nvim_replace_termcodes is slightly faster.

@hrsh7th
Copy link
Owner

hrsh7th commented Oct 21, 2024

thank you.

@hrsh7th hrsh7th merged commit 2c93d5e into hrsh7th:main Oct 21, 2024
2 checks passed
@tomtomjhj tomtomjhj deleted the keytrans branch October 21, 2024 02:08
@RayGuo-ergou
Copy link

Hi @tomtomjhj @hrsh7th This seems breaks keybind for <c-j>. I don't have too much knowledge about key binds but <c-j> seems a special key that always has issue? ( I have seen in different places like nvim and zellij )

To reproduce what I am facing, with the config below

vim.api.nvim_set_keymap('i', '<c-j>', '<cmd>echo "Hello"<cr>', {})

local cmp_select_next_item = function(fallback)
  if cmp.visible() then
    cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
  else
    fallback()
  end
end

cmp.setup({
  mapping = cmp.mapping.preset.insert({
    ['<C-j>'] = cmp.mapping(cmp_select_next_item),
...

Even the cmp menu is opened, it still prints Hello, However, I bind <c-k> the same way but it does not have this issue.

I have removed my keybind to <c-j>, so this is more like a report/FYI this might cause some compatibility issue.

Thank you for your work on this plugin btw!

@tomtomjhj
Copy link
Contributor Author

Thta seems to be nvim bug. reported neovim/neovim#30887

xzbdmw pushed a commit to xzbdmw/nvim-cmp that referenced this pull request Oct 22, 2024
xzbdmw pushed a commit to xzbdmw/nvim-cmp that referenced this pull request Oct 22, 2024
@phanen phanen mentioned this pull request Oct 26, 2024
2 tasks
@dav-cho
Copy link

dav-cho commented Oct 28, 2024

After this commit, I'm seeing a slight delay when typing < in insert mode. #2069 does not fix this. Any ideas on how to address?

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 this pull request may close these issues.

4 participants