mcookly / bidi.nvim Goto Github PK
View Code? Open in Web Editor NEWBidirectional (bidi) text support in neovim
License: MIT License
Bidirectional (bidi) text support in neovim
License: MIT License
This might be clunky…
When enabling Bidi-Mode
, get window width and textwidth (see which is longer).
Use that width to inform fribidi of the padding length for the current line depending on base direction.
Insert contents into buffer, but I think it should also insert some symbol to designate a line break,
so that on a change in textwidth
(using SetOption
event) or window size (using WindowResized
event) lets some function re-wrap the lines accordingly.
↳ or ↪︎ might be good options to use on the left side of the buffer to indicate a line should wrap with the above.
For example (the m's are just to force the base direction as LTR)
|mבראשית ברא אלהים את|
|↪︎ mהשמים ואת הארץ|
^ window edges ^
This function doesn't have to be super efficient since it only is triggered when the display changes, not when the user is actively editing the file.
I can also add an option to change what the linebreak indicator is.
Things get especially tricky when the user is typing though.
I will have to add an autocmd that listens for InsertCharPre
on the current line and updates the whitespace accordingly.
When it comes to wrapping text, I'll have to watch the line-length without padding and jump the user to a new line with padding when the chars reach col 0 (and bring the current word if needbe).
If the user backspaces when in the textwidth/window-width column on a wrapped line,
delete the line and move the cursor back up.
It would be nice to create a similar/identical plugin in vimscript so that vimmers aren't left out of the bidi goodness. I don't have any experience with vimscript, but since the plugin utilizes basic vim API, I don't think it would be difficult to write.
I'll wait until I have the neovim version stable at 1.0.0. If someone hasn't picked up the work in the meantime, I'll probably begin implementing it myself.
Explain the underlying process so that users know what is happening to the buffer.
Perhaps point to clear explanation of bidi text as well.
When in insert mode
, it would be good to use nvim_buf_attach()
so that lines that are changed can be piped through fribidi without affecting the entire buffer.
The function should be aware of wrapped lines (via the wrapped symbol) so that a wrapped line is not partially-bidi'd.
The line (or wrapped lines) in which insert mode
is entered should be unbidi'd before being bidi'd with the other changed lines.
# from
This line will lose its end char\
# to
This line will lose its end char\n
Probably just a matter of escaping.
Functions within bidi.nvim
should be provide information during execution for better debugging.
If someone's file gets corrupted, they should have a way to see what code was used on it.
I'm not sure how to get around this, especially since I don't know much about that BOM.
Essentially, pipe register contents through fribidi()
before inserting the text into the buffer.
Would it make more sense to assign a specific register to this or apply to all registers?
Use the docs for reference.
This should reduce bidi.nvim
's impact on Neovim as a whole I believe.
Deleting these autocommands can be a bit of a pain and may require a restructuring of active_bufs
to include the IDs of the buffer's autocommands.
Currently, these user commands don't have descriptions:
BidiEnable
BidiDisable
It would be good to have descriptions to keep the plugin well-documented.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.