Skip to content

Plugin for making a TOC navigator, similar to the one in RStudio

License

Notifications You must be signed in to change notification settings

jumanbar/tocnavigator.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A basic TOC Navigator for NeoVim

Because I really like this feature in RStudio...

Lua Neovim

Plugin neovim for making a TOC navigator, similar to the one in RStudio

WIP

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.

Motivation

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:

Installation

  • 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.nvim in this example)
use ("jumanbar/tocnavigator.nvim")

To run the main function, toggle_toc_navigator, this command should work:

:lua require("tocnavigator").toggle_toc_navigator()

Setup

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)

To do

  • 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.commentstring variable, 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)

About

Plugin for making a TOC navigator, similar to the one in RStudio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published