Skip to content

Bidirectional (bidi) text support in neovim

License

Notifications You must be signed in to change notification settings

mcookly/bidi.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bidi.nvim

Bidirectional (bidi) text support in neovim.

Introduction

bidi.nvim aims to be a simple, easy-to-configure, and lightweight plugin which adds a bidirectional display mode to neovim on a per-buffer basis. Currently, this is in early development. I recommend using rosetta.nvim in the meantime.

Depedencies

Required

Optional

Usage

Toggle Bidi-Mode

Use :BidiEnable <base direction> to enable Bidi-Mode. The base direction is case insensitive.

" Example: Enable RTL Bidi-Mode
:BidiEnable RL

" Or
:BidiEnable rl

If no base direction is supplied (:BidiEnable), Bidi-Mode will activate using the default base direction.

Use :BidiDisable to disable Bidi-Mode.

Statusline Indicator

I highly recommend adding this to your statusline so that you know when Bidi-Mode is enabled and in what base direction. It will display LR (LTR), RL (RTL), ML (weak LTR), or MR (weak RTL) depending on the base direction you choose. Add the following to your statusline:

%!luaeval('require("bidi").buf_get_bidi_mode(vim.api.nvim_win_get_buf(0))')
-- For example (if ALL you want is the Bidi-Mode status)
vim.o.statusline = [[%!luaeval('require("bidi").buf_get_bidi_mode(vim.api.nvim_win_get_buf(0))')]]

Roadmap

I plan to work extensively on bidi.nvim this summer, but feel free to suggest features or mention concerns before then. Below is a simple roadmap, more or less in the order I plan to add functionality.

  • GNU FriBidi piping (0c5861a)
  • Bidi-Mode toggleability (331de66)
  • Bidi-Mode statusline option (dcba4df)
  • Manually choose base direction
  • Save files only in logical mode
  • Switch to revins automatically
  • Paste in properly in Bidi-Mode
  • Dynamic padding for RTL paragraphs
  • Ability to use exclusively in rightleft mode
  • Extensive testing framework

Testing

There is an init.lua in /test. It can also be used as a MWE.

Footnotes

  1. Alacritty cannot render Hebrew diacritical marks properly for fonts with those characters (issue #3830), so I recommend choosing another terminal if you want to see niqqud and te'amim.