diff --git a/.github/workflows/panvimdoc.yml b/.github/workflows/panvimdoc.yml index 6937840..35fbfbc 100644 --- a/.github/workflows/panvimdoc.yml +++ b/.github/workflows/panvimdoc.yml @@ -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 diff --git a/README.md b/README.md index 89f1780..291e573 100644 --- a/README.md +++ b/README.md @@ -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 = "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) diff --git a/lua/readermode/init.lua b/lua/readermode/init.lua index 3ccadd7..bd43f22 100644 --- a/lua/readermode/init.lua +++ b/lua/readermode/init.lua @@ -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() diff --git a/readermode.gif b/readermode.gif new file mode 100644 index 0000000..6ed3e4a Binary files /dev/null and b/readermode.gif differ