A Neovim plugin that emulates a typewriter, keeping the cursor centered on the screen for a focused writing experience.
- Keeps the cursor centered on the screen while you type or navigate.
- Simple commands to enable, disable, and toggle the typewriter mode.
- Integrates with ZenMode and True Zen for a seamless distraction-free environment.
- New
:TWCenter
command to center the view around the current code block or function using Tree-sitter.
Typewriter requires the following dependencies:
nvim-treesitter: Typewriter uses Tree-sitter to determine the current code block or function for the :TWCenter
command.
Make sure to install and configure nvim-treesitter before using Typewriter.
Using Packer
Add the following to your Packer configuration:
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
use {
'joshuadanpeterson/typewriter',
requires = 'nvim-treesitter/nvim-treesitter',
config = function()
require('typewriter').setup()
end
}
Using Lazy.nvim
Add the following to your Lazy.nvim configuration:
local lazy = require('lazy')
lazy.setup({
-- Other plugins...
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
},
{
'joshuadanpeterson/typewriter',
dependencies = {
'nvim-treesitter/nvim-treesitter',
},
config = function()
require('typewriter').setup()
end,
opts = {}
},
})
Here is a markdown table that summarizes the commands available in Typewriter.nvim:
Command | Description |
---|---|
:TWEnable |
Enable typewriter mode |
:TWDisable |
Disable typewriter mode |
:TWToggle |
Toggle typewriter mode on and off |
:TWCenter |
Center the view around the current code block or function using Tree-sitter |
These commands allow you to control the typewriter mode in Neovim, enhancing your writing and coding experience by maintaining focus and reducing distractions. The new :TWCenter
command leverages Tree-sitter to intelligently center the view around the current code block or function, providing a more focused view of your code.
ZenMode is a plugin for Neovim written by folke that provides a distraction-free coding environment by opening the current buffer in a new full-screen floating window. It hides various UI elements, works well with other floating windows, and integrates with plugins like Telescope and gitsigns. Typewriter integrates with ZenMode to automatically enable typewriter mode when entering ZenMode and disable it when exiting.
True Zen is another plugin for Neovim written by pocco81 that offers multiple modes to unclutter your screen, including Ataraxis (a zen mode), Minimalist, Narrow, and Focus. True Zen allows you to disable UI components, narrow a text region for better focus, and customize callbacks for each mode. Typewriter integrates with True Zen, particularly the Ataraxis mode, to automatically enable typewriter mode when entering Ataraxis and disable it when exiting.
-- ~/.config/nvim/init.lua
require('packer').startup(function()
-- Other plugins...
use {
'joshuadanpeterson/typewriter',
config = function()
require('typewriter').setup({
enable_with_zen_mode = true,
enable_with_true_zen = true,
})
end
}
use {
'folke/zen-mode.nvim',
opts = {
on_open = function()
vim.cmd('TWEnable')
end,
on_close = function()
vim.cmd('TWDisable')
end
}
}
use {
'pocco81/true-zen.nvim',
config = function()
require("true-zen").setup {
modes = {
ataraxis = {
callbacks = {
open_pre = function()
vim.cmd('TWEnable')
end,
close_pos = function()
vim.cmd('TWDisable')
end
}
}
}
}
end
}
end)
-- ~/.config/nvim/lua/plugins/init.lua
local lazy = require('lazy')
lazy.setup({
-- Other plugins...
{
'joshuadanpeterson/typewriter',
config = function()
require('typewriter').setup({
enable_with_zen_mode = true,
enable_with_true_zen = true,
})
end,
opts = {}
},
{
'folke/zen-mode.nvim',
opts = {
on_open = function()
vim.cmd('TWEnable')
end,
on_close = function()
vim.cmd('TWDisable')
end
}
},
{
'pocco81/true-zen.nvim',
config = function()
require("true-zen").setup {
modes = {
ataraxis = {
callbacks = {
open_pre = function()
vim.cmd('TWEnable')
end,
close_pos = function()
vim.cmd('TWDisable')
end
}
}
}
}
end,
opts = {}
}
})
This plugin was inspired by:
Special thanks to the following for their inspiration and ideas:
- The Reddit post "Typewriter Scrolling".
- The Obsidian plugin "Typewriter Mode".
- JotterPad Typewriter Scrolling
- Scrivener Typewriter Scrolling
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to open up an issue or a pull request to contribute to the project.