Skip to content

tanloong/interlaced.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

interlaced.nvim

Join/split current line to align bilingual sentence pairs.

Features

1. Join current line up to previous pair

GIF

2. Split current line down to the next pair

GIF

Requirements

  • Neovim >= 0.9.0

Installation

{
  'tanloong/interlaced.nvim',
  config = function()
    require("interlaced").setup()
    -- or setup with your own config (see Configuration in README)
    -- require("interlaced").setup(config)
  end,
  ft = "text",
},

Configuration

Bellow is a linked snippet with the default values.

local config = {
mappings = {
JoinUp = ",",
JoinUpPair = "<",
PullUp = ".",
PullUpPair = ">",
SplitAtCursor = "d",
JoinDown = "D",
NavigateDown = "J",
NavigateUp = "K"
},
-- automatically enable mappings for *interlaced.txt files, or
-- otherwise you need to run "MapInterlaced" manually to enable
-- them
setup_mappings_now = (((vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())):find("interlaced%.txt$")) ~= nil),
separator_L1 = "",
separator_L2 = " ",
}

Commands

  • SplitEnglishSentences and SplitChineseSentences: These commands are used for sentence segmentation in a monolingual buffer. It is important to note that they may not handle all cases perfectly, as they use simple regex patterns to identify sentence boundaries. For more accurate splitting, it is recommended to use an NLP tool. However, if you just want a quick and not-that-accurate splitting, these commands can be helpful.

  • MapInterlaced and UnmapInterlaced: MapInterlaced sets keybindings for text manipulations; UnmapInterlaced restores them to their previous mappings, if any.

  • InterlaceWithL1 and InterlaceWithL2: Take lines from the current buffer and interlaces them with lines from a specified file, forming an array of (l1, l2) pairs. These commands also filter out any empty lines from both the buffer and the file to ensure that only non-empty lines are interlaced. The resulting interlaced text is then saved to a new file and opened for further editing. After openning the interlaced file, keybindings are setup if they have not been previously.

Releases

No releases published

Packages

No packages published

Languages