Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rhysd/nyaovim-markdown-preview

Live Markdown Preview on NyaoVim
https://github.com/rhysd/nyaovim-markdown-preview

Last synced: about 2 months ago
JSON representation

Live Markdown Preview on NyaoVim

Awesome Lists containing this project

README

        

Live Markdown Preview in [NyaoVim](https://github.com/rhysd/NyaoVim)
====================================================================

This is a UI plugin to provide live markdown preview UI for [NyaoVim](https://github.com/rhysd/NyaoVim).
Preview is automatically opened/closed on `markdown` filetype and updated in real-time. [marked](https://github.com/chjj/marked) converts current buffer to HTML and [highlight.js](https://github.com/isagalaev/highlight.js/) adds syntax highlight to code block.

![screenshot](https://raw.githubusercontent.com/rhysd/ss/master/nyaovim-markdown-preview/main.gif)

## Installation

At first, install this repository as normal Neovim plugin with your favorite plugin manager.

Then put `` component to your `~/.config/nyaovim/nyaovimrc.html` as below.

```html

/* CSS configurations here */
.horizontal {
display: flex;
width: 100%;
height: 100%;
}
neovim-editor {
width: 100%;
height: 100%;
}






```

Note that this is just an example. You can put this component as you like. But I recommend flex layout to use space effectively.

## How to Start Preview

If you set `g:markdown_preview_auto` (default: `1`) to `1`, this plugin automatically starts preview on `markdown` filetype. Or you can start markdown preview by `:StartMarkdownPreview` commands.

The preview is updated on `TextChanged` by default. If you want to update more frequently, you can set `g:markdown_preview_eager` to `1`. If it is set to `1`, the preview is also updated on `TextChangedI`.

If you set `g:markdown_preview_auto` to `1`, it also stops automatically when the markdown document buffer gets hidden or is unloaded. Or you can stop and dismiss markdown preview by `:StopMarkdownPreview` command manually.

## Mappings

If you don't set `g:markdown_preview_no_default_mapping` to `1`, this plugin automatically defines some mappings only in `markdown` filetype buffer to scroll preview.

- `(markdown-preview-scroll-up)` (default: `k`)

Scroll markdown preview up by 3 lines.

- `(markdown-preview-scroll-down)` (default: `j`)

Scroll markdown preview down by 3 lines.

- `(markdown-preview-scroll-top)` (default: `gg`)

Scroll markdown preview to top of window.

- `(markdown-preview-scroll-bottom)` (default: `G`)

Scroll markdown preview to bottom of window.

## `` Properties

| Name | Description | Default |
| ---- | ----------- | ------- |
| `expand-width` (`Number`) | Expanding width of window on starting preview. (**optional**) | `undefined` |
| `expand-height` (`Number`) | Expanding height of window on starting preview. (**optional**)| `undefined` |
| `editor` (`Object`) | [Editor instance](https://github.com/rhysd/neovim-component#neovim-editor-apis) of ` component (**required**) | `undefined` |

## License

Under MIT license.

```
Copyright (c) 2015 rhysd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```