-
Notifications
You must be signed in to change notification settings - Fork 400
feat: start work on better TOC #3167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This adds a (hard?) requirement on a (Neovim-only) external plugin, which I don't think is acceptable... |
@@ -0,0 +1,5 @@ | |||
local NuiTree = require "nui.tree" | |||
----TODO: make this actually lua? | |||
local entries = vim.cmd [[vim.eval ('vimtex#parser#toc()']] |
There was a problem hiding this comment.
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:
vimtex/lua/vimtex/fzf-lua/init.lua
Line 60 in 7d16d56
local entries = vim.fn["vimtex#parser#toc"]() |
No problem, feel free to work on the draft and ask for help while doing so.
Does this become a hard requirement immediately? Wouldn't it only become a hard requirement if you actually loaded the module? There is already an fzf-lua source for the TOC, which can be used as explained in I think we could add another TOC implementation that requires NUI, as long as it is only optionally loaded and it is properly explained with references in the docs. Similar to how I've added fzf-lua. However, I do see that we might want to add more structure on the Lua side here. Currently, the fzf-lua feature is activated with require("vimtex.toc.fzf-lua").run()
-- and then perhaps, with this PR
require("vimtex.toc.nui").run() |
@@ -0,0 +1,5 @@ | |||
local NuiTree = require "nui.tree" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- 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.
- 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. - 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 - 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.
- 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.
First, you should keep the main questions and thread as general comments to the PR. For comments on the code you should only discuss the specific code part and/or comment.
Perhaps, but that would probably be better as a separate PR? NB! You should have a space before the opening paranthesis:
I don't mind adding useful things even if I don't use it, but it should be a rationally good choice. If you open a PR with the suggestion and explain what it is and what it does, then it will be easier to discuss it. Personally, I don't use nix, but I use mise - it is awesome and satisfies most of my "reproducible environment" needs.
Yes, you will need to convert the output to whatever is needed for NuiTree.
Ok!
It returns a list of dictionaries/tables. There's a spec for it here: vimtex/autoload/vimtex/parser/toc.vim Lines 7 to 20 in 9d9f74c
Ok! I'm sorry I can't be much of a help here.
I'm not sure I quite understand what you are asking. |
I am making this very rough draft pull request as I have questions about what I am able to do and want to keep it out of discussions, as I see this being a long chain of replies.