Code Monkey home page Code Monkey logo

Comments (8)

EinfachToll avatar EinfachToll commented on May 10, 2024

In principle, this is already possible by defining your own VimwikiLinkHandler function, see :h VimwikiLinkHandler. It is called every time the user tries to open a link. Inside the function, you can do whatever you want, roughly like this:

function! VimwikiLinkHandler(link)
    if a:link =~ "command:"
        let command = a:link[8:]
        exe ":r!".command
        return 1
    endif
    return 0
endfunction

(BTW: cool, syntax highlight in github comments, is this new?)

This is the applied unix principle: one tool for every task, combined through shell calls.

(BTW 2: I guess you don't want to actually replace your executable link with the output, because then you can use the link only once. Although you can make the file readonly, so that the inserted text is not saved but every time recomputed when the file is opened or the user activates the link.)

from vimwiki.

linuxcaffe avatar linuxcaffe commented on May 10, 2024

Einfach wrote: "(BTW 2: I guess you don't want to actually replace your executable link with the output, because then you can use the link only once."

Ahhh well there's the rub, I think s/actual replace/visually replace/
I'd like it to output to a block of text defined as a region. Full behavior handling would include actions for hitting enter within that region.

With the cursor over the top line of the new block, (the same line that contained the Description a second ago) the raw link should become visible, like normal link behavior. Hitting Enter again (or just cursor-position-over?) reverts the block back to the description, so enter-enter toggles the block visibility.

Move the cursor down into the block text region (presuming it is more than one line) and hitting enter anywhere in there could take yet another (pre-defined) action. If the block opened a task-query-output, then hitting enter in that region could then launch plugin command :TW withthatquery, for example.

Einfach wrote: "..the inserted text is not saved but every time recomputed when the file is opened or the user activates the link"
and I agree :)

from vimwiki.

EinfachToll avatar EinfachToll commented on May 10, 2024

OK, as far as I understand, you want something similar to a popup that shows some specific infos if you activate a link. There is this project: http://vimuiex.sourceforge.net/index.html that tries to provide pseudo-UI inside a terminal Vim, and I believe I once saw another “library” with roughly the same purpose.
But… it seems to me like really complicated stuff.
Why not follow the approach I suggested? You could have in your wiki file a link like [[showtasklist|click here to show the current task list]] and write a VimwikiLinkHandler that, when given a link showtasklist, adds lines beneath the link into the Vim buffer that look like task1 2013-11-04 description [[taskdone:task1|click here to mark the task as done]] and maybe changes the link to [[deletenextlines|click here to hide the task list]]. Of course, the link handler has to handle links of the form taskdone:taskname and deletenextlines appropriately.
And in order to prevent the open task list from being saved, set and unset the 'readonly' option or whatever.

from vimwiki.

linuxcaffe avatar linuxcaffe commented on May 10, 2024

@EinfachToll, thanks for the examples, I'm going to have to learn a bit more, try them out and then have better feedback, but I think that's the idea.

but on the topic, of linking or embedding a command to see the results in a wiki page, does transclusion behavior have anything to add here? If the link is a command-with-args and the result is inline, as a block, that's sort-of transclusion, isn't it?

{{:! task overdue +foo}}

from vimwiki.

EinfachToll avatar EinfachToll commented on May 10, 2024

When using transclusions, the content is only expanded and included in the .html file, when you convert your file, not in your .wiki file.

from vimwiki.

linuxcaffe avatar linuxcaffe commented on May 10, 2024

Ohh.. copy that :)

from vimwiki.

matt-snider avatar matt-snider commented on May 10, 2024

Hi, I came across this because I use vimwiki and was looking for a similar feature. This sounds to me like orgmode's babel. Is there anyway to get this functionality in vim/vimwiki? Would something like this fit into vimwiki's vision?

EDIT: btw, VimOrganizer seems to do this by calling into org-babel itself. I think having emacs and orgmode as a dependency is not an option, but maybe the implementation could be helpful and for example just Vimscript or python could be supported initially.

from vimwiki.

ranebrown avatar ranebrown commented on May 10, 2024

Using a custom VimwikiLinkHandler is the best option for this functionality.

from vimwiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.