Plugin neovim for making a TOC navigator, similar to the one in RStudio
It is a very simple plugin, and it currently works well enough in a very limited set of examples from my personal work (in Lua, R, Python files, it works OK). It doesn't use any dependency, which is good, but also makes it more plain.
Disclaimer: I'm currently working on implementing a treesitter based approach.
I'm an R programmer, and I use RStudio a lot. A key feature that makes my life much easier when using this IDE is the RStudio document outlines
That is, the ability to create bookmarks in a file by way of formatting some comments in a certain way:
# 1 Import ----
# * 1.1 Databases ----
# * * 1.1.1 Postgres ----A big shoutout to this great tutorial into creating neovim plugins: How to write neovim plugins in Lua (by Rafał Camlet), which is where I started this.
Other inspirations:
- neovim 0.5.0+ required
This is my current installed version:
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3
- install using your favorite plugin manager (
packer.nvimin this example)
use ("jumanbar/tocnavigator.nvim")To run the main function, toggle_toc_navigator, this command should work:
:lua require("tocnavigator").toggle_toc_navigator()A more convenient way to use it, is with a remap:
local n = require("tocnavigator")
vim.keymap.set("n", "<leader>n", n.toggle_toc_navigator)-
Make it capable of telling sections from subsections (like current day RStudio, apparently)
-
Markdown: this is an exception, so instead of using the
vim.bo.commentstringvariable, it should just use# -
Telescope-like features? A Preview window would be amazing:
-
Isn't it more smart to find comments using treesitter or something similar? I don't know how to do that, or even if it is possible.
-
Set update_view to listen to movement events and then update position and highlighting. Set different highlight groups according to identity of marker (ie: toc_comments and funtions, ATM)

