Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add Lua API of IME event handling #3110

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
Loading
from
Open

Conversation

kanium3
Copy link

@kanium3 kanium3 commented Apr 18, 2025

What kind of change does this PR introduce?

  • Feature

Did this PR introduce a breaking change?

A breaking change includes anything that breaks backwards compatibility either at compile or run time.

  • No

About

This pull request introduces support for handling IME (Input Method Editor) preedit and commit events in Neovide, enabling better text input for languages requiring complex input methods. The changes include adding Lua scripts for IME handling, modifying the Rust backend to integrate with these scripts, and updating the keyboard manager to process IME-specific events.
Related to #1931

Sample

2025-04-18-neovide-ime.mp4

@fredizzimo
Copy link
Member

Thank you, I will take a look at this a bit later (in a few days)

It's possible that it would make sense to just implement the base API in Neovide, and implement the rest in a separate plugin for easier development, and possible faster updates. But I'm not sure yet.

@kanium3
Copy link
Author

kanium3 commented Apr 20, 2025

I don't know what you're unsure about, but there are plugins like equalsraf/neovim-gui-shim that separate GUI-related functions. I can't say that it works stably yet, so separating it as a plugin would probably be better in terms of development. Also, regarding handling IME with a plugin, in terms of performance, the focus is on the implementation using NeoVim's autocommands rather than on plugin loading.

Anyway, if you're going to merge only the base API, please let me know so I can make the change.

@chyuaner
Copy link

Hi! I build and use your commit id: e58082d
In Manjaro KDE Plasma 6 Wayland + Fcitx5 chewing.

I try to insert mode with ime input at 3rd lines.
But always insert at first line end character.

And I use direction keys move cursor.

Display Bug like this image:
Screenshot_20250421_052143

Is freeze status. Press Enter key is not response.

@kanium3
Copy link
Author

kanium3 commented Apr 21, 2025

@chyuaner,Thank you for reporting!
I would like to know what kind of behavior it has, so could you please send me the log data?

@chyuaner
Copy link

I Record Screen. And found another bug!
If I have swp file will freeze.
and output log:

ERROR [neovide::bridge::ui_commands] Input failed

Caused by:
    0: Error decoding response to request 'nvim_exec_autocmds'
    1: Error while reading from Reader
    2: EOF
ERROR [neovide::bridge::ui_commands] Input failed

Caused by:
    0: Error sending request 'nvim_exec_autocmds'
    1: Error writing to the Writer
    2: Broken pipe (os error 32)
ERROR [neovide::bridge::ui_commands] Input failed

Caused by:
    0: Error sending request 'nvim_input'
    1: Error writing to the Writer
    2: Broken pipe (os error 32)
ERROR [neovide::bridge::ui_commands] Input failed

Caused by:
    0: Error sending request 'nvim_input'
    1: Error writing to the Writer
    2: Broken pipe (os error 32)
ERROR [neovide::bridge::ui_commands] Input failed
Video_2025-04-22_22-42-15.mp4

Back to yesterday's question.

I would like to know what kind of behavior it has, so could you please send me the log data?
It doesn;t show any log. But I try to record my screen to reappear this bug.

I try to insert mode with ime input at 3rd lines.
But always insert at first line end character.

Video_2025-04-22_22-43-27.mp4
處理 User Autocommands: "ImePreedit" 時發生錯誤:
Error executing lua callback: [string "<nvim>"]:63: Invalid 'end_col': out of range
stack traceback:
        [C]: in function 'nvim_buf_set text'
        [string "<nvim>"1:63: in function <[string "<nvim>"]:44>
Press ENTER or type command to continue

@fredizzimo
Copy link
Member

Regarding the swapfile issue, it looks like Neovim is either not responding at all, or crashed. It's possible that it's caused by something else and not these changes, @chyuaner, are you able to reproduce it without?

@chyuaner
Copy link

Regarding the swapfile issue, it looks like Neovim is either not responding at all, or crashed. It's possible that it's caused by something else and not these changes, @chyuaner, are you able to reproduce it without?

I change neovide version to Arch Linux Pacman Package: neovide-0.15.0-1.
And try reproduce the swapfile issue.

Video_2025-04-22_23-36-58.mp4

All hint text is show half one second and disappeared.
But key input is normal operation can use.

@fredizzimo
Copy link
Member

I think, I know what's wrong with the hang.

This PR tries to execute autocommands, which probably isn't supported when a message is showing. Perhaps a more explicit lua API with callbacks could be created. We don't have much yet, but it can and will be extended. For example, the image support will also provide an API.

And even then, it's possible that the lua side, has to disable some things, like actually showing the pre-edit.

You might be able to reproduce this by simply opening a confirm dialog https://neovim.io/doc/user/builtin.html#confirm()

@kanium3 kanium3 marked this pull request as draft May 3, 2025 01:15
@kanium3
Copy link
Author

kanium3 commented May 3, 2025

I will change my policy to implement a Lua API. I intend to separate the pre-edit preview and other functions into a separate plugin.

@kanium3 kanium3 changed the title feat: add IME preedit support in insert mode feat: add Lua API of IME event handling May 3, 2025
kanium3 and others added 2 commits May 3, 2025 01:26
Default action is to insert commited text after the cursor. And, you can
customize the behavior when preeditted or committed.
@kanium3 kanium3 marked this pull request as ready for review May 10, 2025 04:54
@kanium3 kanium3 marked this pull request as draft May 10, 2025 04:55
Default action is to insert commited text after the cursor. And, you can customize the behavior when preeditted or committed.
@kanium3 kanium3 marked this pull request as ready for review May 10, 2025 04:59
@kanium3
Copy link
Author

kanium3 commented May 10, 2025

I separated it into a Lua API and a plugin that supports pre-edit. However, since the plugin only transferred what was written when opening pull request, I would like to address the problem there.

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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.