https://github.com/jiaoshijie/undotree
neovim undotree written in lua
https://github.com/jiaoshijie/undotree
neovim-plugin neovim-plugin-lua nvim-plugin
Last synced: 5 months ago
JSON representation
neovim undotree written in lua
- Host: GitHub
- URL: https://github.com/jiaoshijie/undotree
- Owner: jiaoshijie
- License: mit
- Created: 2022-03-14T09:18:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-09T15:01:46.000Z (about 1 year ago)
- Last Synced: 2024-08-03T13:06:04.885Z (9 months ago)
- Topics: neovim-plugin, neovim-plugin-lua, nvim-plugin
- Language: Lua
- Homepage:
- Size: 177 KB
- Stars: 166
- Watchers: 1
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- stars - jiaoshijie/undotree - neovim undotree written in lua (Lua)
README
# undotree
A neovim undotree plugin written in lua.
**Screenshot**

Diff previewer window shows the difference between the current node and the node under the cursor.
### Requirements
- nvim 0.7.0 or above
### Download and Install
Using Vim's built-in package manager:
```sh
mkdir -p ~/.config/nvim/pack/github/start/
cd ~/.config/nvim/pack/github/start/
git clone https://github.com/nvim-lua/plenary.nvim.git
git clone https://github.com/jiaoshijie/undotree.git
```Using [vim-plug](https://github.com/junegunn/vim-plug)
```
Plug 'nvim-lua/plenary.nvim'
Plug 'jiaoshijie/undotree'
```Using [packer.nvim](https://github.com/wbthomason/packer.nvim)
```lua
use {
"jiaoshijie/undotree",
requires = {
"nvim-lua/plenary.nvim",
},
}
```Using [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{
"jiaoshijie/undotree",
dependencies = "nvim-lua/plenary.nvim",
config = true,
keys = { -- load the plugin only when using it's keybinding:
{ "u", "lua require('undotree').toggle()" },
},
}
```### Usage
Basic setup
```lua
require('undotree').setup()
```If using [packer.nvim](https://github.com/wbthomason/packer.nvim) undotree can be setup directly in the plugin spec:
```lua
use {
"jiaoshijie/undotree",
config = function()
require('undotree').setup()
end,
requires = {
"nvim-lua/plenary.nvim",
},
}
```Configuration can be passed to the setup function. Here is an example with the default settings:
```lua
local undotree = require('undotree')undotree.setup({
float_diff = true, -- using float window previews diff, set this `true` will disable layout option
layout = "left_bottom", -- "left_bottom", "left_left_bottom"
position = "left", -- "right", "bottom"
ignore_filetype = { 'undotree', 'undotreeDiff', 'qf', 'TelescopePrompt', 'spectre_panel', 'tsplayground' },
window = {
winblend = 30,
},
keymaps = {
['j'] = "move_next",
['k'] = "move_prev",
['gj'] = "move2parent",
['J'] = "move_change_next",
['K'] = "move_change_prev",
[''] = "action_enter",
['p'] = "enter_diffbuf",
['q'] = "quit",
},
})
```You can directly use `:lua require('undotree').toggle()` for toggling undotree panel, or set the following keymaps for convenient using.
```lua
vim.keymap.set('n', 'u', require('undotree').toggle, { noremap = true, silent = true })-- or
vim.keymap.set('n', 'uo', require('undotree').open, { noremap = true, silent = true })
vim.keymap.set('n', 'uc', require('undotree').close, { noremap = true, silent = true })
```2. Some Mappings
| Mappings | Action |
| ---- | ---- |
| j | jump to next undo node |
| gj | jump to the parent node of the node under the cursor |
| k | jump to prev undo node |
| J | jump to next undo node and undo to this state |
| K | jump to prev undo node and undo to this state |
| q | quit undotree |
| p | jump into the undotree diff window |
| Enter | undo to this state |### License
**MIT**