Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisgrieser/nvim-origami
Fold with relentless elegance.
https://github.com/chrisgrieser/nvim-origami
Last synced: 2 days ago
JSON representation
Fold with relentless elegance.
- Host: GitHub
- URL: https://github.com/chrisgrieser/nvim-origami
- Owner: chrisgrieser
- License: mit
- Created: 2023-07-27T15:33:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-03T14:40:06.000Z (about 1 month ago)
- Last Synced: 2024-10-15T07:32:26.379Z (20 days ago)
- Language: Lua
- Homepage:
- Size: 53.7 KB
- Stars: 185
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - chrisgrieser/nvim-origami - Fold with relentless elegance. (Utility / Cursorline)
README
# nvim-origami 🐦
## Features
- Use `h` at the first non-blank character of a line (or before) to fold. Use
`l` anywhere on a folded line to unfold it.[^1] This allows you to ditch `zc`,
`zo`, and `za` – you can just use `h` and `l` to work with folds. (`h` still
moves left if not at the beginning of a line, and `l` still moves right when
on an unfolded line – this plugin basically "overloads" those keys.)
- Pause folds while searching, restore folds when done with searching.
(Normally, folds are opened when you search for some text inside a fold, and
*stay* open afterward.)
- Remember folds across sessions (and as a side effect, also the cursor position).> [!NOTE]
> This plugin only opens and closes folds. It does **not** provide a
> `foldmethod`. For this plugin to work, you either need to set a `foldmethod`
> on your own, or use plugin providing folding information, such as
> [nvim-ufo](http://github.com/kevinhwang91/nvim-ufo).## Installation
```lua
-- lazy.nvim
{
"chrisgrieser/nvim-origami",
event = "VeryLazy",
opts = {}, -- needed even when using default config
},-- packer
use {
"chrisgrieser/nvim-origami",
config = function() require("origami").setup({}) end, -- setup call needed
}
```The `.setup()` call (or `lazy`'s `opts`) is required. Otherwise, the plugin
works out of the box without any need for further configuration.## Configuration
```lua
-- default settings
require("origami").setup {
keepFoldsAcrossSessions = true,
pauseFoldsOnSearch = true,
setupFoldKeymaps = true,-- `h` key opens on first column, not at first non-blank character or before
hOnlyOpensOnFirstColumn = false,
}
```> [!TIP]
> By setting
> [vim.opt.startofline](https://neovim.io/doc/user/options.html#'startofline')
> to `true`, bigger movements move you to the start of the line, which works
> well with this plugin's `h` key.If you use other keys than `h` and `l` for vertical movement, set
`setupFoldKeymaps = false` and map the keys yourself:```lua
vim.keymap.set("n", "", function() require("origami").h() end)
vim.keymap.set("n", "", function() require("origami").l() end)
```## Limitations
[Many formatting plugins open all your
folds](https://www.reddit.com/r/neovim/comments/164gg5v/preserve_folds_when_formatting/)
and unfortunately, there is nothing this plugin can do about it. The only two
tools that are able to preserve folds are the
[efm-language-server](https://github.com/mattn/efm-langserver) and
[conform.nvim](https://github.com/stevearc/conform.nvim).## Other useful folding plugins
- [fold-cycle.nvim](https://github.com/jghauser/fold-cycle.nvim)
- [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo)## About the developer
In my day job, I am a sociologist studying the social mechanisms underlying the
digital economy. For my PhD project, I investigate the governance of the app
economy and how software ecosystems manage the tension between innovation and
compatibility. If you are interested in this subject, feel free to get in touch.I also occasionally blog about vim: [Nano Tips for Vim](https://nanotipsforvim.prose.sh)
- [Academic Website](https://chris-grieser.de/)
- [Mastodon](https://pkm.social/@pseudometa)
- [ResearchGate](https://www.researchgate.net/profile/Christopher-Grieser)
- [LinkedIn](https://www.linkedin.com/in/christopher-grieser-ba693b17a/)[^1]: Technically, unfolding with `l` is already a built-in vim feature when
`vim.opt.foldopen` includes `hor`. However, this plugin still sets up a `l`
key replicating that behavior, since the built-in version still moves you to
one character to the side, which can be considered a bit counterintuitive.