Home

Awesome

<!-- LTeX: enabled=false -->

nvim-origami 🐦

<!-- LTeX: enabled=true --> <a href="https://dotfyle.com/plugins/chrisgrieser/nvim-origami"> <img alt="badge" src="https://dotfyle.com/plugins/chrisgrieser/nvim-origami/shield"/></a>

Features

[!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.

Installation

-- 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

-- 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 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:

vim.keymap.set("n", "<Left>", function() require("origami").h() end)
vim.keymap.set("n", "<Right>", function() require("origami").l() end)

Limitations

Many formatting plugins open all your folds 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 and conform.nvim.

Other useful folding plugins

<!-- vale Google.FirstPerson = NO -->

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

<a href='https://ko-fi.com/Y8Y86SQ91' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

Footnotes

  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.