Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richardbizik/nvim-toc
Generate markdown table of contents
https://github.com/richardbizik/nvim-toc
Last synced: 14 days ago
JSON representation
Generate markdown table of contents
- Host: GitHub
- URL: https://github.com/richardbizik/nvim-toc
- Owner: richardbizik
- License: mit
- Created: 2023-07-21T18:47:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-04T15:36:26.000Z (10 months ago)
- Last Synced: 2024-07-31T20:43:35.736Z (3 months ago)
- Language: Lua
- Size: 5.86 KB
- Stars: 36
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - richardbizik/nvim-toc - Easily generate table of contents for markdown files. (Programming Languages Support / Markdown and LaTeX)
README
# nvim-toc
Generate table of contents for markdown files# Installation
```vim
Plug 'richardbizik/nvim-toc'
```# Commands
- :TOC - creates an ordered list table of contents
- :TOCList - creates an unordered list table of contents# Configuration
Setup default command `:TOC` and `:TOCList` with `require('nvim-toc').setup({})`. The default commands will try to find existing table of contents based on `toc_header` configuration or they will create a new one on cursor position if it does not exist.
You can setup your own command by calling `require('nvim-toc').generate_md_toc(format)` and handling the result yourself.
Format options are currently list or numbered
```lua
require('nvim-toc').generate_md_toc("list")
require('nvim-toc').generate_md_toc("numbered")
```
The result of the command is a table containing lines of table of contents.
Command will generate a table of contents of an opened markdown file on the current line.## Config options
```lua
require("nvim-toc").setup({
toc_header = "Table of Contents"
})
```# Example
```markdown
# Table of contents (:TOC)
1. [h1](#h1)
2. [h1](#h1)
1. [h2](#h2)
1. [h3](#h3)
1. [h4](#h4)
1. [h5](#h5)
1. [h6](#h6)
2. [h6](#h6)
3. [h6](#h6)
2. [h4](#h4)
1. [h5](#h5)
2. [h2](#h2)
3. [h2](#h2)
4. [h2](#h2)
3. [h1](#h1)# Table of contents (:TOCList)
- [h1](#h1)
- [h1](#h1)
- [h2](#h2)
- [h3](#h3)
- [h4](#h4)
- [h5](#h5)
- [h6](#h6)
- [h6](#h6)
- [h6](#h6)
- [h4](#h4)
- [h5](#h5)
- [h2](#h2)
- [h2](#h2)
- [h2](#h2)
- [h1](#h1)# h1
# h1
## h2
### h3
#### h4
##### h5
###### h6
###### h6
###### h6
#### h4
##### h5
## h2
## h2
## h2
# h1
```