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 colorInstallation
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 -
- [
iawriterforcedefaults][1.1] - [
iawriterchangecursorline][1.2] - [
iawriterchangeunderline][1.3] - [
iawritershowsigncolumn][1.4] - [
iawritercentercursor][1.5] (experimental)
iawriterforcedefaults
This option shall override ALL other optionsIt enforces the defaults that ship with
vim-iAwriter
i.e. let g:iawriterforcedefaults = 1 implies -
let g:goyo_width = '70%' let g:goyo_height = '85%' let g:limelightparagraphspan = 0 let g:limelightdefaultcoefficient = 0.7 let g:iawriterchangeunderline = 1 let g:iawriterchangecursorline = 1 let g:iawritercentercursor = 0 let g:iawritershowsigncolumn = 0
iawriterchangecursorline
vim-iawriter turns off cursorline (if enabled) by default. To keep it on -
let g:iawriterchangecursorline = 0
iawriterchangeunderline
vim-iawriter turns off the underlining of the cursorline (if enabled) by default. To keep it on -
let g:iawriterchangeunderline = 0
iawritershowsigncolumn
vim-iawriter hides the signcolumn by default. To keep it -
let g:iawritershowsigncolumn = 1
iawritercentercursor
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:iawritercentercursor = 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:iawritergoyowidth | [g:goyo_width][2.1] | | g:iawritergoyoheight | [g:goyo_height][2.2] | | g:iawritergoyolinenr | [g:goyo_linenr][2.3] | | g:iawriterlimelightdefaultcoefficient | [g:limelightdefault_coefficient][2.4] | | g:iawriterlimelightparagraphspan | [g:limelightparagraph_span][2.5] |
[2.1]: https://github.com/junegunn/goyo.vim#configuration [2.2]: https://github.com/junegunn/goyo.vim#configuration [2.3]: https://github.com/junegunn/goyo.vim#configuration [2.4]: https://github.com/junegunn/limelight.vim#options [2.5]: https://github.com/junegunn/limelight.vim#options
Extras
Screenshots: hereFor 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][3] is installed & enabled
- Sets up autocmds to call s:post_enter() on entering Goyo
- Loads configs
- Changes colorscheme
- Starts Goyo
[3]: https://github.com/vim-airline/vim-airline
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
