3.6 KiB
Vimwiki Markdown Utilities
A powerful set of utilities for enhancing the Vimwiki experience in Neovim. This project combines Lua keybindings with a custom shell script to provide seamless Markdown preview, conversion to HTML, and browser integration. Designed for developers and note-takers who rely on Vimwiki and Markdown for their workflows.
Features
1. Markdown Preview
- Preview your entire Vimwiki in Markdown format.
- Automatically indexes and renders the wiki files.
- Opens the preview in your default web browser.
2. Convert Markdown to HTML
- Convert the current Markdown file into an HTML document.
- Moves the HTML file to a designated location and opens it in Qutebrowser.
- Ensures compatibility by checking file existence and format.
3. Neovim Integration
- Custom Lua keybindings for quick access to preview and conversion features.
- Built-in error handling to notify you of issues (e.g., missing files or unsupported formats).
Installation
1. Clone the Repository
git clone https://github.com/kleinpanic/vimwiki-markdown-utilities.git
2. Configure Neovim
- Include
keybindings.luain your Neovim configuration:require('path-to-keybindings/keybindings') - Alternatively, source it directly in your
init.lua:dofile('~/.config/nvim/keybindings.lua')
3. Place the Shell Script
- Move
vimwiki-markdown-preview.shto your Neovim scripts directory:mkdir -p ~/.config/nvim/scripts/ cp vimwiki-markdown-preview.sh ~/.config/nvim/scripts/ - Ensure the path in
keybindings.luamatches the script location.
4. Install Dependencies
Make sure the following are installed and accessible from your system:
bashpandoc(for Markdown-to-HTML conversion)qutebrowser(or modify the script for your preferred browser)sedfindrsyncgrepmkdirbasenmediff
Usage
Keybindings:
Preview Markdown Wiki
- Keybinding:
<leader>mip - Description: Renders and indexes your Vimwiki Markdown files, then opens them in a web browser.
Convert and Open Markdown
- Keybinding:
<leader>mp - Description: Converts the current Markdown file to HTML and opens it in Qutebrowser.
Script Functionality
The vimwiki-markdown-preview.sh script performs the following:
--index-wiki
- Generates an index of your Vimwiki files.
- Prepares a single HTML file for all wikis in your configuration.
--convert <file>
- Converts a specified Markdown file to HTML using
pandoc. - Moves the resulting HTML file to
~/.config/nvim/scripts/vimwiki_html/. - Opens the HTML file in Qutebrowser.
Example Usage:
bash vimwiki-markdown-preview.sh --index-wiki
bash vimwiki-markdown-preview.sh --convert ~/vimwiki/notes.md
Troubleshooting
-
Script Not Found:
- Ensure the
vimwiki-markdown-preview.shpath inkeybindings.luamatches its actual location.
- Ensure the
-
File Not Markdown:
- The "Convert and Open" command only works for
.mdfiles. Check the file format before running the command.
- The "Convert and Open" command only works for
-
Browser Not Opening:
- Verify that
qutebrowseris installed and accessible. Alternatively, modify the script to use a different browser.
- Verify that
-
Missing Dependencies:
- Install
pandocif HTML conversion fails:sudo apt install pandoc
- Install
Contribution
Contributions are welcome! If you find bugs, want to suggest features, or improve the code, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.