vim-iawriter
vim-iawriter copied to clipboard
iAwriter's Focus mode for vim
vim-iawriter

This is a minimal plugin that aims to provide an experience similar to iAwriter's Focus mode. Currently it can only highlight paragraphs. Sentence highlighting is a TODO.
It acts as a wrapper around three other plugins -
For optimal experience, it is recommended to use a GUI or a terminal that supports 24-bit color
Installation
Install the plugins mentioned above, and then install this plugin any way you like :smile:
In case you have never installed plugins before, I recommend you to check out vim-plug
Using vim-plug, the configuration should be -
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'reedes/vim-colors-pencil'
Plug 'subnut/vim-iawriter'
Usage
:Iawriter
Configuration
vim-iawriter
does not touch the configurations defined individually for the abovementioned three plugins. If they are defined, vim-iawriter shall respect them.
In addition, vim-iawriter provides a few configuration options -
-
iawriter_force_defaults
-
iawriter_change_cursorline
-
iawriter_change_underline
-
iawriter_show_signcolumn
-
iawriter_center_cursor
(experimental)
iawriter_force_defaults
This option shall override ALL other options
It enforces the defaults that ship with vim-iAwriter
i.e. let g:iawriter_force_defaults = 1
implies -
let g:goyo_width = '70%'
let g:goyo_height = '85%'
let g:limelight_paragraph_span = 0
let g:limelight_default_coefficient = 0.7
let g:iawriter_change_underline = 1
let g:iawriter_change_cursorline = 1
let g:iawriter_center_cursor = 0
let g:iawriter_show_signcolumn = 0
iawriter_change_cursorline
vim-iawriter
turns off cursorline (if enabled) by default. To keep it on -
let g:iawriter_change_cursorline = 0
iawriter_change_underline
vim-iawriter
turns off the underlining of the cursorline (if enabled) by default. To keep it on -
let g:iawriter_change_underline = 0
iawriter_show_signcolumn
vim-iawriter
hides the signcolumn by default. To keep it -
let g:iawriter_show_signcolumn = 1
iawriter_center_cursor
This is an experimental feature. If enabled, vim-iawriter
shall try to keep the cursor in the vertical center of the screen. To turn it on -
let g:iawriter_center_cursor = 1
Overrides
vim-iawriter
provides some overrides. Useful if you use both Iawriter and Goyo/Limelight. It overrides the defaults set in .vimrc
Configuration Option | Overrides |
---|---|
g:iawriter_goyo_width |
g:goyo_width |
g:iawriter_goyo_height |
g:goyo_height |
g:iawriter_goyo_linenr |
g:goyo_linenr |
g:iawriter_limelight_default_coefficient |
g:limelight_default_coefficient |
g:iawriter_limelight_paragraph_span |
g:limelight_paragraph_span |
Extras
Screenshots: here
For the preview feature, I personally use markdown-preview.nvim
Advanced configuration
vim-iawriter
provides plenty of autocommands -
Autocommand | When |
---|---|
IawriterToggleTriggered |
s:toggle() enter |
IawriterToggleFinished |
s:toggle() exit |
IawriterPrePreEnter |
s:pre_enter() enter |
IawriterPostPreEnter |
s:pre_enter() exit |
IawriterPrePostEnter |
s:post_enter() enter |
IawriterPostPostEnter |
s:post_enter() exit |
IawriterPreLeave |
s:leave() enter |
IawriterPostLeave |
s:leave() exit |
s:toggle()
- Checks if vim-iawriter is already running. If yes, closes it (by closing Goyo). Else starts it.
s:pre_enter()
-
Closes Goyo (not vim-iawriter) if running
-
Checks if vim-airline is installed & enabled
-
Sets up autocmds to call
s:post_enter()
on entering Goyo -
Loads configs
-
Changes colorscheme
-
Starts Goyo
s:post_enter()
- Runs after Goyo starts
- Enables Limelight
- Sets up autocmds to call
s:leave()
on closing Goyo - Applies configs
s:leave()
- Runs when Goyo closes
- Restores original configs
See plugin/vim_iawriter.vim
for more information on these functions
Screenshots