FluxxField / bionic-reading.nvim

Toggle Bionic Reading for Neovim buffers using syllable based highlighting
MIT License
44 stars 0 forks source link
bionic-reading lua nvim nvim-lua nvim-plugin vim vim-plugin
    ____  _             _         ____                 ___            
   / __ )(_)___  ____  (_)____   / __ \___  ____ _____/ (_)___  ____ _
  / __  / / __ \/ __ \/ / ___/  / /_/ / _ \/ __ `/ __  / / __ \/ __ `/
 / /_/ / / /_/ / / / / / /__   / _, _/  __/ /_/ / /_/ / / / / / /_/ / 
/_____/_/\____/_/ /_/_/\___/  /_/ |_|\___/\__,_/\__,_/_/_/ /_/\__, /  
                                                             /____/   

Togglable and customizable bionic reading for Neovim using syllable based highlighting and TreeSitter!

What is BionicReading?

bionic-reading.nvim is a simple but powerful Neovim plugin designed to improve reading and writing efficiency. By highlighting the first syllable of each word, it aims to aid comprehension and to highlight on logical sections of the code. By using the power of TreeSitter you have complete control over what is highlighted in your files. Just highlight comments? Sure! Strings? Of course! Function names? Why not! Or just highlight the whole file! The choice is yours

Syllable Algorithm

One of the standout features of bionic-reading.nvim is its innovative syllable algorithm. I developed this algorithm from scratch, drawing inspiration from linguistic studies and natural language processing techniques. The result is a fairly precise method for identifying syllables within words, enabling accurate highlighting of their initial sounds

Read more below in Why Syllable Highlighting

demo gif

Font is VictorMono and my NeoVim setup uses AstroNvim with my config here

BionicReading Table of Contents

Features

Getting Started

This section should guide you to getting your plugin up and running!

Requirements

In order for the default styling to work, you will need to make sure your terminal and fonts allow for bold text. The default styling just bolds the text. So, if your terminal is not showing bold text, it will look like the plugin does not work

iTerm2:

iTerm2 -> Settings... -> Profiles -> Text -> Text Rendering -> enable "Draw bold text in bold font"

Terminal:

Terminal -> Settings... -> Profiles -> Text -> enable "Use bold fonts"

Installation

Install your favorite package manager

Using lazy.nvim

{
  'FluxxField/bionic-reading.nvim',
}

Using packer.nvim

use {
  'FluxxField/bionic-reading.nvim',
}

Usage

Try the command :BRToggle to see if bionic-reading.nvim is installed correctly.

Customization

This section should help you explore the available options you have to configure and customize bionic-reading.nvim.

BionicReading setup structure

Example using lazy.nvim

{
  'FluxxField/bionic-reading.nvim',
  config = function()
    require('bionic-reading').setup({
      -- determines if the file types below will be
      -- automatically highlighted on buffer open
      auto_highlight = true,
      -- the file types you want to highlight with
      -- the node types you would like to target
      -- using treesitter
      file_types = {
        ["text"] = "any" -- highlight any node
        -- EX: only highlights comments in lua files
        ["lua"] = {
            "comment",
        },
      },
      -- the highlighting styles applied as val to nvim_set_hl()
      -- Please see :help nvim_set_hl() to see vals that can be passed
      hl_group_value = {
        bold = true
      },
      -- Flag used to control if the user is prompted
      -- if BRToggle is called on a file type that is not
      -- explicitly defined above
      prompt_user = true,
      -- Enable or disable the use of treesitter
      treesitter = true,
      -- Flag used to control if highlighting is applied as
      -- you type
      update_in_insert_mode = true,
    })
  end,
}

TreeSitter

TreeSitter is used to target node types listed in your config above. This allows for BionicReading to highlight as much code or as little as you would like. For instance, the default config highlights only comments for Lua files. This allows you to tweak what is highlighted on a filetype bases.

NOTE: you need to have a the language parser installed for TreeSitter to work

-- example
:TSInstall lua

Mappings

No mapping are added. Feel free to map as you would like

Vim Commands

bionic-reading provides several user commands.

Please see autocmd code here

" Toggle bionic reading highlighting for the current buffer
" Will prompt you if run on a file type no in the config
:BRToggle

" Toggle the update_in_insert_mode flag
:BRToggleUpdateInsertMode

" Toggles the auto_highlight flag
:BRToggleAutoHighlight

TODO

Why Syllable Highlighting