vimwiki icon indicating copy to clipboard operation
vimwiki copied to clipboard

Feature: Open wiki navigation panel using vimpanel

Open linuxcaffe opened this issue 11 years ago • 21 comments

I'm looking at vimpanel, (https://github.com/mihaifm/vimpanel) a project that provides NerdTree-like side-panels, and thinking "wouldn't it be handy to open a WikiTree side-panel that showed the bare outline of a wiki, for navigation?" so I thought I'd share the idea. Have a look at the screenshots.

Fot that matter, how about two side-bars? One on the left, for whole-wiki outline and one wikipanel on the right, essentially a %toc of the headings of the document in focus ?

linuxcaffe avatar Feb 15 '14 15:02 linuxcaffe

I love this idea, especially if they can be opened / closed at will. I use this same setup in Zim, which is the wiki system that I'm migrating to vimwiki from. The wiki page tree is in a (collapsible) sidebar on the left, and the outline of the current page is in a (collapsible) sidebar on the right.

Note though that vimwiki does not currently support a page hierarchy, only individual pages.

dotancohen avatar Feb 16 '14 09:02 dotancohen

Here is an example of the Zim sidebars for navigating the wiki tree on the left and the current page outline on the right: zim-sidebars

dotancohen avatar Feb 16 '14 09:02 dotancohen

Note that the taglist plugin also uses a similar sidepanel that can be hidden.

dotancohen avatar Feb 16 '14 10:02 dotancohen

@dotancohen , yeah, that screenshot is pretty much exactly what I was thinking.

When you say "vimwiki does not currently support a page hierarchy", isn't a set of inter-linked files (ie wiki) always a hierarchy, of sorts?

linuxcaffe avatar Feb 16 '14 19:02 linuxcaffe

No, vimwiki pages are all top-level from what I understand. No intrinsic nesting, which is actually what is preventing me from moving to vimwiki fully.

My current workaround is to have the index page as an indented bulleted list of links to the pages organized as seen in the screenshot.

dotancohen avatar Feb 16 '14 21:02 dotancohen

A side panel with the outline of the current document is easy, you can use Tagbar and a script that extracts the headers from a file. I made a Python script which I can share the next days.

A panel for the outline of all wiki files is more complicated. Vimpanel looks interesting, but as far as I can see it supports only file system hierarchies. Maybe you can also misuse Tagbar to show files instead of tags. @dotancohen: You can put your wiki files in arbitrary subdirectories, if you want to have a hierarchy. Just make a link like [[subdir/file]]. Maybe this helps you a little bit. Personally, I think a real hierarchy of files is not a wiki is made for.

EinfachToll avatar Feb 17 '14 08:02 EinfachToll

Here is my script for Tagbar integration. Look in the comment for how to use it. https://gist.github.com/EinfachToll/9071573

EinfachToll avatar Feb 18 '14 14:02 EinfachToll

I'm also attempting to move from zim, and this is one feature that I really miss. I attempted to use your script, but I'm not sure if I'm doing it right. I installed tagbar, created your script at ~/.vim/vwtags.py, then added the following to ~/.vimrc:

let g:tagbar_type_vimwiki = {
\ 'ctagstype':'vimwiki'
\ , 'kinds':['h:header']
\ , 'sro':'&&&'
\ , 'kind2scope':{'h':'header'}
\ , 'sort':0
\ , 'ctagsbin':'~/.vim/vwtags.py'
\ , 'ctagsargs': 'default'
\ }

Then, after opening my wiki, and using :TagbarToggle, I get the following error.

Messages maintainer: Mike Williams <[email protected]>
"/HDD/protist/Computer/vimwiki/general/index.wiki" 3L, 27C
Error detected while processing function tagbar#ToggleWindow..<SNR>39_ToggleWindow..<SNR>39_OpenWindow..
<SNR>39_AutoUpdate..<SNR>39_ProcessFile..<SNR>39_ExecuteCtagsOnFile:
line   64:
Tagbar: Could not execute ctags for /tmp/vyTpAtX/8.wiki!
Executed command: "'/home/protist/.vim/vwtags.py'  default  '/tmp/vyTpAtX/8.wiki'"
Command output:
  File "/home/protist/.vim/vwtags.py", line 53
    print '{0}\t{1}\t/{2}/;"\t{3}\tline:{4}{5}'.format(cur_tag, filename,
                                              ^
SyntaxError: invalid syntax

I wasn't sure that I installed correctly, so I also tried changing to 'ctagsargs': 'markdown', but it still failed.

protist avatar Mar 07 '15 09:03 protist

Seems like you are using Python 3. A newer version of the script is here: https://github.com/vimwiki/utils/blob/master/vwtags.py . It should work with Python 3 as well as with Python 2.

EinfachToll avatar Mar 09 '15 08:03 EinfachToll

Yes, I am using Python 3, and yes that works great! Thank you!

Also, I created a simple script to create a navigation tree. It has a dependency on tree, to show a pretty output. It will write to a file, so it's not quite as "interactive" as a panel, but it works well enough for me. https://gist.github.com/protist/820bb6a25722083a2edd

protist avatar Mar 09 '15 10:03 protist

@protist: if you want, you can add it to https://github.com/vimwiki/utils . Maybe there are some more people who find your script useful. Just create a pull request at https://github.com/vimwiki/utils

EinfachToll avatar Mar 10 '15 08:03 EinfachToll

@EinfachToll Done. This is the first time I've made a pull request, so I'm not sure if I should have created a new branch. Please let me know if I've done something wrong. Cheers.

protist avatar Mar 10 '15 11:03 protist

Everything's good. The utils repository is just a collection of scripts, so there's no need to branch something off.

EinfachToll avatar Mar 10 '15 11:03 EinfachToll

There hasn't been any interest in this for a few years so I'm going to close.

ranebrown avatar Mar 30 '19 00:03 ranebrown

Oh, I was actually following this thread since recently and didn't notice the date. Well, I'll leave my comment to see if anyone else has any interest

adrianrocamora avatar Mar 30 '19 00:03 adrianrocamora

Well, I'd still be keen for this too. I haven't re-commented, because I imagined bumping it regularly wouldn't be great etiquette. FWIW I use tagbar to navigate the headers of the current file, so an additional navigator would still be useful. Not high on the list of priorities for me personally, but still useful.

protist avatar Mar 30 '19 05:03 protist

@adrianrocamora @protist , It looks like the PR referenced in this issue was merged. Is there something else that you're interested in that hasn't been resolved?

hq6 avatar Mar 30 '19 07:03 hq6

@hq6 As per my comments above, this PR just creates a static page as an index. It also has to be run manually. If I understand correctly, this issue is about having an automated, interactive, navigation panel within vim itself, similar to tagbar.

protist avatar Mar 30 '19 08:03 protist

@protist , In that case, I will reopen this issue.

PR's are welcome; otherwise it will likely take us a while to implement something like this.

hq6 avatar Mar 30 '19 09:03 hq6

@hq6 Thank you. As per above, for me personally, it's not super-high priority, but it would be a welcome addition.

protist avatar Mar 30 '19 09:03 protist

I've been using Vimwiki for a few weeks now, and the lack of the sidebar is definitely my biggest issue so far. I tried most of the stuff mentioned in this thread and did some thinking on what an optimal workflow would look like. My naive initial thoughts were around a better automated index but with hindsight, this is not really addressing the core issue.

First of all, if we look at @dotancohen screenshot of Zim, and in particular the left side bar index, I think it pretty much sums up the ideal interface for me. That index is basically an always visible NERDTree with extracted page titles instead of displaying filenames. That way, whatever our notes content, we have an overall view of the structures and entries at all times, without manually maintaining an index that potentially reproduce that whole structure.

Note: with regard to the right-side bar of that same screenshot, I think this is basically what the tagbar + vmtags.py hack does. While I don't need it personally (my wiki pages are usually small enough), I think this issue already has a form of solution.

Also, I'm a heavy user of fzf (generic fuzzy finder) and its Vim integration. Long story short: nnoremap <C-p> :FZF<CR> to jump to anything from anywhere in a fraction of second. While this may sound trivial, that tool brutally destroyed all my workflows within vim, and that of course includes my navigation within vimwiki. Most modern complex graphical tools also have a similar kind of feature. I'm mentioning this here, because it affects my reasoning here. Basically, while I can jump to any file in an instant, I may not exactly know where I end up: that's why I believe one important feature of the NERDTree-like sidebar would be to focus on the current wikipage, unrolling the directories as necessary, with an highlight on the current file. I believe @brennen mentioned something along these lines recently on IRC.

Now that we addressed the navigation, there is one last point: how to create pages? Indeed, with that sidebar, we basically remove the need for the usual root index (which could now simply be your daily TODO, some random ASCII art or whatever). Which means when you create a page, you're likely not going to first write its title into that index anymore (before creating the page pressing enter). The easy answer could be :e tools/foobar.md, but this lacks practicability: first of all, you'll have to explicit the potential subdirectories, as well as the filename which could have been derived from the title. This makes me believe the sidebar should prompt the creation of a new file by just pressing enter on your target directory in the side-bar, asking for your page title and derive the rest (path, filename, and a new page with the title inserted).

This pretty much sums up my thinking on the issue. I'll be happy to discuss this further.

Now onto the limitations this would introduce, I think the main one would be that using the side bar will make you dependent on your filesystem or file-naming for link ordering (which was more flexible while maintaining it in your index yourself). I think that's secondary compared to all the benefits this brings, especially since the sidebar could be optional, and nothing would prevent you from still using the index like we currently do.

ubitux avatar Apr 05 '20 14:04 ubitux