Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lua/vimtex/TOC/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local NuiTree = require "nui.tree"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use lower case letters in the file names, i.e. lua/vimtex/toc/.... Also, I think we should call this script nui.lua, as this seems to aim for a TOC UI based on Nui.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok doing that now, a few things:

  1. I use NixOS so I added a seperate nix branch that allows me to use direnv-nix with flakes, if you are willing to approve that(I have it a seperate branch for a reason and will open a seperate pr if approved). I understand not wanting to add something that you personally(I assume) dont use. Another problem is that the existence of a flake.nix in a vim plugin usually implies a way to use the flake in the nixos config for config; therefore, there is a possibility of a confusion for other nix users out there. I would try and implement this though as it seems to not be extraordinarily difficult, probably just make an overlay. Although this could make me the de facto nix maintainer which is not something a responsibility I feel ready for. If you are willing to allow nix in this repo then there should be a discussion about which inputs, etc.
  2. One problem with this code currently that jumps to mind is that it assumes that vimtex#parser#toc outputs NuiTree.node which is almost certainly not the case. so that will be probably the bulk of this issue if Nui is used.
  3. my main use would be to pipe this to trouble.nvim(I am thinking probably either the location list or one of the other modes) so that will be my first target if it works, will then make it more general. What does vimtex#parser#toc ouput exactly it seems to me to be a table of strings of some sort
  4. I also looked through trouble.nvim and saw no dependency on nui. so it is possible that I could write it to not require nui. As much as I respect folke, he seems to not do enough docs on what his code does, and why it is implemented that way for those who want to extend it. That is, his actual code is hard to parse for me. Then again it is possible that his code is self explanatory and I lack the experience for it to be so. Furthermore there seems to be radio silence from folke(I think he is on vacation so no shade) so I do not expect any commits from him in his repos anytime soon, let alone documentation commits.
  5. is vimtex#parser#toc# a command available to users somehow? if not how could we make it so. I am seeing a scenario where all I need to do is just use that parser and then pipe it to anything.

----TODO: make this actually lua?
local entries = vim.cmd [[vim.eval ('vimtex#parser#toc()']]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows how to call a vimscript function in lua directly:

local entries = vim.fn["vimtex#parser#toc"]()

local tree = NuiTree { bufnr = bufnr, nodes = entries }
tree:render()