Skip to content

feature: additional link element for the Vimwiki link #117

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

Closed
greyHairChooseLife opened this issue Aug 4, 2024 · 3 comments
Closed

feature: additional link element for the Vimwiki link #117

greyHairChooseLife opened this issue Aug 4, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@greyHairChooseLife
Copy link

Is your feature request related to a problem? Please describe.

I might be able to say it's a problem.

The Vimwiki users have different kinds of links. I, as a noob, use 2 of them. Links for another wiki(.md) and for a URL.

It would be great if we can select icons and highlight for each of them.

Describe the solution you'd like

Links can be identified with simple regex. They start with 'http' or 'file' or something like that.

Describe alternatives you've considered

I am 100% sure that above is simple solution!!

Additional information

No response

@greyHairChooseLife greyHairChooseLife added the enhancement New feature or request label Aug 4, 2024
@MeanderingProgrammer
Copy link
Owner

What kind of link are you referring to?

Is it the standard markdown link syntax: [link](https://example.com), and you want to be able to set a different icon based on the value looking like a URL?

I'm confused on what part of this is related to Vimwiki.

MeanderingProgrammer added a commit that referenced this issue Aug 4, 2024
## Details

Requested: #117

Similar to callouts and checkbox states this change allows link
destinations to be matched against configured patterns when selecting an
icon rather than using the same one everytime. For instance web links
now use a little globe rather than the default chain link icon.

More defaults can be added in if requested, for now mostly to allow
individuals to use as they wish.
@MeanderingProgrammer
Copy link
Owner

Feature added here: d5b57b3

Uses lua patterns.

@greyHairChooseLife
Copy link
Author

@MeanderingProgrammer
Thank you so much, and I apologize for any confusion.

You've managed to address my issue even though I didn't clearly explain what I was asking for.

I've just applied the changes to my config, and I'm really pleased with the result. Here's a screenshot of how it looks:

2024-08-14-155800_429x159_scrot


What kind of link are you referring to?

Is it the standard markdown link syntax: [link](https://example.com), and you want to be able to set a different icon based on the value looking like a URL?

I'm confused on what part of this is related to Vimwiki.

Sorry for the delayed response. I'm copying a part of the Vimwiki help doc, just in case.

vimwiki syntax links from :help doc
5.2. Links                                              *vimwiki-syntax-links*

Wikilinks~

Plain link: >
  [[This is a link]]
With description: >
  [[This is a link source|Description of the link]]

Wiki files don't need to be in the root directory of your wiki, you can put
them in subdirectories as well: >
  [[projects/Important Project 1]]
To jump from that file back to the index file, use this link: >
  [[../index]]
or: >
  [[/index]]
The latter works because wiki links starting with "/" are considered to be
absolute to the wiki root directory, that is, the link [[/index]] always opens
the file /path/to/your/wiki/index.wiki, no matter in which subdirectory you
are currently in.

If you want to use an absolute path to a wiki page on your local filesystem,
you can prefix the path with // >
  [[//absolute_path]]
For example: >
  [[///tmp/in_root_tmp]]
  [[//~/in_home_dir]]
  [[//$HOME/in_home_dir]]
In a wiki with the default wiki extension, this link: >
  [[///tmp/foo]]
Links to the file: >
  /tmp/foo.wiki

Links to subdirectories inside the wiki directory are also supported. They
end with a "/": >
  [[a subdirectory/|Other files]]
Use |g:vimwiki_dir_link| to control the behavior when opening directories.

Typing wikilinks can be simplified by using Vim's omni completion (see
|compl-omni|) like so: >
  [[ind<C-X><C-O>
which opens up a popup menu with all the wiki files starting with "ind".

When |vimwiki-option-maxhi| equals 1, a distinct highlighting style is used to
identify wikilinks whose targets are not found.

Interwiki~

If you maintain more than one wiki, you can create interwiki links between
them by adding a numbered prefix "wikiX:" in front of a link: >
  [[wiki1:This is a link]]
or: >
  [[wiki1:This is a link source|Description of the link]]

The number behind "wiki" is in the range 0..N-1 and identifies the destination
wiki in |g:vimwiki_list|.

Named interwiki links are also supported in the format "wn.name:link" >
  [[wn.My Name:This is a link]]
or: >
  [[wn.MyWiki:This is a link source|Description of the link]]

See |vimwiki-option-name| to set a per wiki name.

Diary~

The "diary:" scheme is used to link to diary entries: >
  [[diary:2012-03-05]]

Anchors~

A wikilink, interwiki link or diary link can be followed by a '#' and the name
of an anchor.  When opening a link, the cursor jumps to the anchor. >
  [[Todo List#Tomorrow|Tasks for tomorrow]]

To jump inside the current wiki file you can omit the file: >
  [[#Tomorrow]]

See |vimwiki-anchors| for how to set an anchor.

Raw URLs~

Raw URLs are also supported: >
  https://github.com/vimwiki/vimwiki.git
  mailto:[email protected]
  ftp://vim.org

External files~

The "file:" and "local:" schemes allow you to directly link to arbitrary
resources using absolute or relative paths: >
  [[file:/home/somebody/a/b/c/music.mp3]]
  [[file:C:/Users/somebody/d/e/f/music.mp3]]
  [[file:~/a/b/c/music.mp3]]
  [[file:../assets/data.csv|Important Data]]
  [[local:C:/Users/somebody/d/e/f/music.mp3]]
  [[file:/home/user/documents/|Link to a directory]]

These links are opened with the system command, i.e. !xdg-open (Linux), !open
(Mac), or !start (Windows).  To customize this behavior, see
|VimwikiLinkHandler|.

In Vim, "file:" and "local:" behave the same, i.e. you can use them with both
relative and absolute links. When converted to HTML, however, "file:" links
will become absolute links, while "local:" links become relative to the HTML
output directory. The latter can be useful if you copy your HTML files to
another computer.
To customize the HTML conversion of links, see |VimwikiLinkConverter|.

Transclusion (Wiki-Include) Links~

Links that use "{{" and "}}" delimiters signify content that is to be
included into the HTML output, rather than referenced via hyperlink.

Wiki-include URLs may use any of the supported schemes, may be absolute or
relative, and need not end with an extension.

The primary purpose for wiki-include links is to include images.

Transclude from a local URL: >
  {{file:../../images/vimwiki_logo.png}}
or from a universal URL: >
  {{https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png}}

Transclude image with alternate text: >
  {{https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png|Vimwiki}}
in HTML: >
  <img src="https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png"
  alt="Vimwiki"/>

Transclude image with alternate text and some style: >
  {{https://.../vimwiki_logo.png|cool stuff|style="width:150px;height:120px;"}}
in HTML: >
  <img src="https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png"
  alt="cool stuff" style="width:150px; height:120px"/>

Transclude image _without_ alternate text and with a CSS class: >
  {{https://.../vimwiki_logo.png||class="center flow blabla"}}
in HTML: >
  <img src="https://raw.githubusercontent.com/vimwiki/vimwiki/master/doc/splash.png"
  alt="" class="center flow blabla"/>

A trial feature allows you to supply your own handler for wiki-include links.
See |VimwikiWikiIncludeHandler|.

Thumbnail links~
>
Thumbnail links are constructed like this: >
  [[https://someaddr.com/bigpicture.jpg|{{https://someaddr.com/thumbnail.jpg}}]]

in HTML: >
  <a href="https://someaddr.com/ ... /.jpg">
  <img src="https://../thumbnail.jpg /></a>

Markdown Links~

These links are only available for Markdown syntax.  See
https://daringfireball.net/projects/markdown/syntax#link.

Inline link: >
  [Looks like this](URL)

Image link: >
  ![Looks like this](URL)

Reference-style links: >
  a) [Link Name][Id]
  b) [Id][], using the "implicit link name" shortcut

Reference style links must always include two consecutive pairs of
[-brackets, and field entries can not use "[" or "]".


NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid
of Vimwiki's default "Wikilink" and the tradition reference-style link.

If the Id is defined elsewhere in the source, as per the Markdown standard: >
  [Id]: URL

then the URL is opened with the system default handler.  Otherwise, Vimwiki
treats the reference-style link as a Wikilink, interpreting the Id field as a
wiki page name.

Highlighting of existing links when |vimwiki-option-maxhi| is activated
identifies links whose Id field is not defined, either as a reference-link or
as a wiki page.

To scan the page for new or changed definitions for reference-links, simply
re-open the page ":e<CR>".

Extract title from external links~

It is possible to automagically extract the title of a web page to create a
link. The function #vimwiki#base#linkify() will get the URL under the cursor
and replace the url with a markdown link.

If the URL cannot be retrieved, nothing is changed.
If the <title> html tag cannot be extracted, the url is used as the link
title.

Suggested mapping: >
  nnoremap <silent> <leader>uu :call vimwiki#base#linkify()<cr>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants