Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3rd/diagram.nvim
Diagrams as code in Neovim.
https://github.com/3rd/diagram.nvim
neovim neovim-plugin
Last synced: 2 days ago
JSON representation
Diagrams as code in Neovim.
- Host: GitHub
- URL: https://github.com/3rd/diagram.nvim
- Owner: 3rd
- Created: 2024-08-15T14:11:09.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-11-02T06:41:10.000Z (14 days ago)
- Last Synced: 2024-11-07T04:12:22.264Z (9 days ago)
- Topics: neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 30.3 KB
- Stars: 131
- Watchers: 1
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- my-neovim-pluginlist - 3rd/diagram.nvim - commit/3rd/diagram.nvim) ![](https://img.shields.io/github/commit-activity/y/3rd/diagram.nvim) (New features / Diagram)
README
# diagram.nvim
A Neovim plugin for rendering diagrams, powered by [image.nvim](https://github.com/3rd/image.nvim).
\
You'll **need to set up [image.nvim](https://github.com/3rd/image.nvim)** to use this plugin, and either [Kitty](https://github.com/kovidgoyal/kitty) or [Überzug++](https://github.com/jstkdng/ueberzugpp).### Integrations & renderers
The plugin has a generic design with pluggable **renderers** and **integrations**.
\
Renderers take source code as input and render it to an image, often by calling an external process.
\
Integrations read buffers, extract diagram code, and dispatch work to the renderers.| Integration | Supported renderers |
| ----------- | --------------------------- |
| `markdown` | `mermaid`, `plantuml`, `d2` |
| `neorg` | `mermaid`, `plantuml`, `d2` || Renderer | Requirements |
| ---------- | ------------------------------------------------- |
| `mermaid` | [mmdc](https://github.com/mermaid-js/mermaid-cli) |
| `plantuml` | [plantuml](https://plantuml.com/download) |
| `d2` | [d2](https://d2lang.com/) |### Installation
With **lazy.nvim**:
```lua
{
"3rd/diagram.nvim",
dependencies = {
"3rd/image.nvim",
},
opts = { -- you can just pass {}, defaults below
renderer_options = {
mermaid = {
background = nil, -- nil | "transparent" | "white" | "#hex"
theme = nil, -- nil | "default" | "dark" | "forest" | "neutral"
scale = 1, -- nil | 1 (default) | 2 | 3 | ...
},
plantuml = {
charset = nil,
},
d2 = {
theme_id = nil,
dark_theme_id = nil,
scale = nil,
layout = nil,
sketch = nil,
},
}
},
},
```### Usage
To use the plugin, you need to set up the integrations and renderers in your Neovim configuration. Here's an example:
```lua
require("diagram").setup({
integrations = {
require("diagram.integrations.markdown"),
require("diagram.integrations.neorg"),
},
renderer_options = {
mermaid = {
theme = "forest",
},
plantuml = {
charset = "utf-8",
},
d2 = {
theme_id = 1,
},
},
})
```### API
The plugin exposes the following API functions:
- `setup(opts)`: Sets up the plugin with the given options.
- `get_cache_dir()`: Returns the root cache directory.```