Movatterモバイル変換


[0]ホーム

URL:


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

Sign up

Bidirectional (bidi) text support in neovim

License

NotificationsYou must be signed in to change notification settings

mcookly/bidi.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bidirectional (bidi) text support in neovim.

Introduction

bidi.nvim aims to be a simple, easy-to-configure, and lightweightplugin which adds a bidirectional display mode to neovimon a per-buffer basis.

NOTE:I no longer use neovim,so I won't be adding any extra features to this plugin.But if you would like to take over the project,by all means fork this repo,and I can update this readme to point to it.

Dependencies

Required

Optional

Configuration

-- Default plugin optionslocaldefault_opts= {create_user_commands=true,-- Generate user commands to enable and disable bidi-modedefault_base_direction='LR',-- Options: 'LR' and 'RL'intuitive_delete=true,-- Swap <DEL> and <BS> when using a keymap contra base direction}

Installation

Use any standard neovim-compatible plugin manager.Then add somewhere in yourinit.lua:

-- Eitherrequire("bidi").setup()-- Or (if you want to customize options)require("bidi").setup({create_user_commands=false,})

Usage

I would recommend backing up important documents beforehand.

ToggleBidi-Mode

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

" Example: Enable RTL Bidi-Mode:BidiEnable RL" Or:BidiEnablerl

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

Use:BidiDisable to disableBidi-Mode.

Paste bidi'd contents using:BidiPaste

Paste inBidi-Mode with:BidiPaste.For example,

" Paste from register `b`:BidiPasteb

You can also assign:BidiPaste to a keymap by using its lua function:

-- You can specify a buffer to use OR pass in `nil`,-- which will ask for a register.vim.keymap.set('n','<leader>bp',function()require('bidi').paste(nil), {})

Sometimes content will be out of sync with the rest of the bidi'd buffer.To correct this,delete the contents to a register and paste using:BidiPaste.

Statusline Indicator

I highly recommend adding this to your statuslineso that you know whenBidi-Mode is enabled and in what base direction.It will displayLR (LTR) orRL (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

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 (5b16429)
  • ✅ Save files only in logical mode (85b77d2)
  • ✅ Switch torevins automatically (83ca8a8)
  • ✅ Paste in properly inBidi-Mode (8fc5741)
  • Dynamic padding for RTL paragraphs (see issue#8)
  • ✅ Ability to use exclusively inrightleft mode (5b16429)
  • Extensive testing framework

Testing

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

Footnotes

  1. Alacrittycannot render Hebrew diacritical marks properlyfor fonts with those characters (issue#3830),so I recommend choosing another terminal if you wantto see niqqud and te'amim.


[8]ページ先頭

©2009-2025 Movatter.jp