Skip to content

Commit

Permalink
Added :ReaderMode and Updated README
Browse files Browse the repository at this point in the history
- lua/readermode/init.lua -> added a :ReaderMode user command
- added demo.gif to repo
- README.md -> updated with gif, configuration options, and usage
section
  • Loading branch information
sarrisv committed Jun 4, 2024
1 parent 559800d commit c0811fc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/panvimdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
name: pandoc to vimdoc
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: kdheepak/panvimdoc@main
with:
vimdoc: readermode.nvim
Expand Down
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# readermode.nvim

Simple neovim plugin for keeping your cursor centered
Simple neovim plugin for keeping your cursor centered while reading through code/text/whatever

--- insert demo here
![readermode.gif](readermode.gif)

## Requirements

- Neovim v0.7.0+

## Setup

```lua
{
'sarrisv/readermode.nvim'
}
```
### lazy.nvim

## Usage
```lua
{
'sarrisv/readermode.nvim',
opts = { --[[ Configurations Options ]] }
}
```

Turned off by default, toggle reader mode with a keymap to enable / disable
### Configuration

Default Keymap:
```lua
{
enabled = false, -- Turned off by default
keymap = "<leader>R" -- Keymap used to toggle ReaderMode on/off
}
```

## Usage

```lua
vim.keymap.set({ "n", "i" }, M.opts.keymap, M.toggle, { silent = true })
```
Toggle **ReaderMode** using `:ReaderMode` or the provided *normal mode* keymapping

## Credits

Based on [this](https://stackoverflow.com/a/63326139) stackoverflow answer from user [pip](https://stackoverflow.com/users/8096230/pip)
Inspired by [this](https://stackoverflow.com/a/63326139) stackoverflow answer from user [pip](https://stackoverflow.com/users/8096230/pip)
5 changes: 5 additions & 0 deletions lua/readermode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ M.opts = {}
---@param opts? ReaderModeOptions
function M.setup(opts)
M.opts = opts or defaults

-- Define ways to toggle readermode
vim.api.nvim_create_user_command("ReaderMode", M.toggle(), {})
vim.keymap.set({ "n" }, M.opts.keymap, M.toggle, { desc = M.opts.desc })

-- Define Autocommand w/ new Autogroup
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
group = vim.api.nvim_create_augroup("ReaderMode", { clear = true }),
callback = function()
Expand Down
Binary file added readermode.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c0811fc

Please sign in to comment.