Skip to content
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

Pressing enter to create a [[double bracket]] #892

Open
santiyounger opened this issue May 29, 2020 · 23 comments
Open

Pressing enter to create a [[double bracket]] #892

santiyounger opened this issue May 29, 2020 · 23 comments
Assignees
Labels
config Related to configuration: default, customization enhancement link Related to link and path creation, modification, use [See #478] markdown Problems specific to markdown syntax work-around-exists
Projects

Comments

@santiyounger
Copy link

Hey,

I'm new to github, apologies if this is not properly structure, if you need more info let me konw.
This is probably an easy solve but I am stuck trying to solve it. Any help or suggestions are greatly appreciated.
I'm on vimwiki Stable Version 2.5.
I recently moved my whole set up from ubuntu to manjaro kde plasma. Vimwiki is my post important vim plug-in and I absolutely love it.

I rebuilt my vimrc with all the plug-ins. vimwiki seems to work alright, the only problem I have is the ENTER fucnction.

When I press enter on some text to create a new vimwiki markdown file. I get this kind of situation.

[new note](new note)

I used to have this kind of result

[[new note]]

I really want to go back to the double bracket and I don't know why that changed since everything in my vimrc is the same.

I istanlled vim wiki with Plug like this:

Plug 'vimwiki/vimwiki'

Here I'll copy everything I have in my vimrc regarding vimwiki.

Vimrc

". .............................................................................
  Vim wiki
"............................................................................

"set nocompatible
filetype plugin on
syntax on

"".... vimwiki with markdown support
"let g:vimwiki_ext2syntax = {'.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
"".... helppage -> :h vimwiki-syntax

let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]

@sharingtom
Copy link

Hi, I just want to chime in and say that I would also very much prefer the double brackets in Markdown files.

If Markdown style links are the default for the Markdown syntax, would you consider adding something like g:vimwiki_link_format, or an option to g:vimwiki_list?

@Nudin Nudin added enhancement markdown Problems specific to markdown syntax regression labels May 30, 2020
@Nudin
Copy link
Member

Nudin commented May 30, 2020


I really want to go back to the double bracket and I don't know why that changed since everything in my vimrc is the same.

We just released v2.5 a few days ago, so you likely have upgraded vimwiki without realizing when moving to the new setup.
I am however a bit confused, I tried with 2.3, 2.4.1 and 2.5 and in all three cased the markdown syntax [text](text) is used.

@ranebrown @tinmarino: Do you know if there was a change in 2.5 that affects this?

@sharingtom: Do you also have a regression (meaning previously double brackets in Markdown worked) or is this "just" a feature request?

@santiyounger: Can you try downgrading to 2.4 and check if it works then again?

Plug 'vimwiki/vimwiki', { 'tag': 'v2.4.1' }

and :PlugClean then :PlugInstall should do it.

@tinmarino
Copy link
Member

Do you know if there was a change in 2.5 that affects this?

No. I've always got [text](text) to and from blame, it seems to me that all lines concerning ENTER key were there in 2017

The stack trace for someone wanting to create an PR for an option:
vimwiki#base#follow_link ->
vimwiki#base#normalize_link ->
vimwiki#vars#get_syntaxlocal ->
vimwiki#vars#populate_syntax_vars ->
let g:vimwiki_syntax_variables[a:syntax].rxWikiLink = g:vimwiki_global_vars.rx_wikilink_prefix.

Where you can see that the issue author would like a link format that the dev have called rxWikiLink or latter rxWikiLink0 (for markdown). And the one we (I like to) use is called WikiLink1Template2.

More:

  • vars.vim is well commented and is the target.
  • :h h vimwiki-syntax-links

@sharingtom
Copy link

It’s a feature request from my side.

A few days ago I found Obsidian, which has a lot of the functionality of Vimwiki – minus Vim – but uses Markdown and square bracket links. It would be great to be able to easily collaborate on wikis with non-Vim users. I absolutely love Vimwiki, but convincing most non-technical people to learn Vim for wiki collaboration is just not an option.

While square brackets can be added manually in Vimwiki to create the links, the Enter link formatting would be a quality of life improvement for me. I’m not at a skill level where I can make a PR to make it work. Not yet at least.

@santiyounger
Copy link
Author

Hey @Nudin, thank you so much for your kind reply. I tried installing v2.4.1, unfortunately it is still showing this format text
I did it as instructed :
Plug 'vimwiki/vimwiki', { 'tag': 'v2.4.1' }
with :PlugClean then :PlugInstall

Since I completely wiped my ubuntu set up into my new manjaro KDE I have no way of finding what was the exact version I was on.
To me things were working perfect with the [[double braket]] in a previous version.
If anyone knows which version allows this, I'd be more than happy to downgrade to that version.

I fully agree with @sharingtom with this being a really essential function.

More thank anything I want to truly thank you for making such an amazing tool, and for using your valuable time to help those of us who use it everyday, you guys are amazing.

@santiyounger
Copy link
Author

@tinmarino Thanks a lot for your reply, unfortunately my skill level didn't allow me to fully understand your suggestions. I can comfortably modify things in my .vimrc file. But things such as creating a PR I don't fully understand what that means.

If you can put it in simple terms that would be much appreciated, I'm happy with a workaround solution if needed.
Thanks a lot!

@sharingtom
Copy link

I know that the question wasn't directed at me, but PR is short for pull request.

If you modify the Vimwiki codebase (not just the .vimrc) to add the double square bracket functionality to the Markdown syntax, a pull request is basically how to ask the maintainers of Vimwiki here on GitHub to add the change to the main codebase and thus make it available to everyone.

I would also like to thank everyone who is a part of making Vimwiki. For all its simplicity (in use) it is wonderfully powerful.

@santiyounger
Copy link
Author

@sharingtom Thanks, great explanation I appreciate it! I'll keep looking for solutions to this situation if I find one I'll post it here! Thanks guys

@tinmarino tinmarino added this to In progress in v2.6 Jun 16, 2020
@tinmarino tinmarino self-assigned this Jun 16, 2020
@tinmarino tinmarino moved this from In progress to To do in v2.6 Jun 16, 2020
@tinmarino tinmarino added the link Related to link and path creation, modification, use [See #478] label Jul 25, 2020
tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 27, 2020
…(Issue vimwiki#892)

Main change:
        Create function: normalize_syntax_settings(syntax)

Problem:
        Some user prefer [[]] links more than []().
        As vimwiki know both of them, they should be able to choose
        without regex mastery and with tests

Solution:
        let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
@tinmarino
Copy link
Member

tinmarino commented Jul 27, 2020

Read the commit message of the commit referencing this issue. (The last one: they often break tests and I commit amend in my repo)

Adding in vars.vim the function: normalize_syntax_settings(syntax)

Fixed: Workaround or better say ...

undocumented solution :

let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')

This may change and get documented. Meanwhile, follow the changes in test/link_creation.vader or grep the issue number in the repo

Related: #894

tinmarino added a commit to tinmarino/vimwiki that referenced this issue Jul 27, 2020
…(Issue vimwiki#892)

Main change:
        Create function: normalize_syntax_settings(syntax)

Problem:
        Some user prefer [[]] links more than []().
        As vimwiki know both of them, they should be able to choose
        without regex mastery and with tests

Solution:
        let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
@tinmarino tinmarino added config Related to configuration: default, customization and removed regression labels Jul 27, 2020
@nelai1
Copy link

nelai1 commented Sep 8, 2020

I observed the same change in behaviour.
Removing: 'syntax':'markdown' from the vimwiki_list variable in the .vimrc:

let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]

changed the link creation back to [[...]]-syntax when pressing enter

@ericboehs
Copy link

Yeah that does fix it but now everything else is broke in regards to markdown formatting. 😄

@Thomascountz
Copy link

Thomascountz commented Sep 23, 2020

After installing the dev branch and updating the config, I'm receiving this error:

Error detected while processing /Users/thomascountz/.config/nvim/init.vim:
line  123:
E121: Undefined variable: g:vimwiki_syntax_list

This is the relevant line in my .vimrc (actually .config/nvim/init.vim)

let g:vimwiki_syntax_list['markdown']['Link1'] = vimwiki#vars#get_global('WikiLinkTemplate1')

I'm not super familiar with vimscript, so I may not be instantiating the dict correctly?

I modeled the configuration off of the tests here:

# And configuration
# Issues: #892
####################
Execute (Log):
Log 'Markdown change Link1 : Pressing enter to create a [[double bracket]] #892'
Given vimwiki (abc def ghi jkl):
abc def ghi jkl
Execute (Set filename wiki_test.md):
call SetSyntax('markdown')
let save_link = g:vimwiki_syntaxlocal_vars.markdown.Link1
let g:vimwiki_syntaxlocal_vars.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
Do (vee<CR>):
vee\<CR>
Expect (append md suffix):
[[abc def]] ghi jkl
Execute (restore):
let g:vimwiki_syntaxlocal_vars.markdown.Link1 = save_link

And in the new docs:

vimwiki/doc/vimwiki.txt

Lines 2850 to 2863 in a687801

------------------------------------------------------------------------------
12.4 Syntax Options *vimwiki-syntax-options*
Syntax options are configured using the following pattern: >
let g:vimwiki_syntax_list['markdown']['bullet_type'] = ['*', '-', '+']
Where:
- `markdown` is the syntax name. It can be (`default`, `markdown` or `media`)
- `bullet_type` is the option_name (see below)
- `['*', '-', '+']` is the option value
------------------------------------------------------------------------------

Thank you so much for your time and assistance!

@Thomascountz
Copy link

Thomascountz commented Sep 23, 2020

On the dev branch, when I open vimwiki <Leader>ww, I can enter the following command:

:let g:vimwiki_syntaxlocal_vars['markdown']['Link1'] = g:vimwiki_syntaxlocal_vars['default']['Link1']

Now when I have the following markdown file:

hello, world

and I press ee<CR>

I see this:

hello, [[world]]

@ericboehs
Copy link

I knew if I watched this thread long enough I'd find the answer. Thanks @Thomascountz!

I've added the relevant config changes to my dotfiles. Essentially you just need to defer setting the variable until after the vimwiki plugin has loaded. I've done this via autocmd VimEnter *. There may be a more efficient way to do this though.

@alexcardell
Copy link

@ericboehs that autocmd still throws an error for me because the dict is not initialised. Perhaps a custom vimwiki autocmd would be useful for this (though at that point is it just easier to configure it in vimwiki_list?)

@ericboehs
Copy link

@alexcardell I'm not sure I'm understanding your problem but I'm guessing you're on the master branch instead of dev. This feature is exclusive to the dev branch for now.

@alexcardell
Copy link

alexcardell commented Oct 28, 2020

Ah no, my apologies, I was on dev but the issue was with my autocmds; Just the quirks of my setup, I should have tried it with a clean vim before commenting, it works now!

Edit: I did a little more tinkering and noticed that this solution doesn't work if you defer loading vimwiki using packadd.

Vimwiki does seem a likely candidate to defer until needed, and if you do that the autocmd throws an error on startup:

Error detected while processing VimEnter Autocommands for "*":
E15: Invalid expression: g:vimwiki_syntaxlocal_vars['default']['Link1']
Press ENTER or type command to continue

Not too big of an issue since you can write a function to load vimwiki and do the setup, but just something to be aware of if this is going to be an official solution.

@ericboehs
Copy link

Yeah, my solution is definitely a hack. I think the official solution should be a vimwiki_list config var.

deepredsky pushed a commit to deepredsky/vimwiki that referenced this issue Jan 16, 2021
…(Issue vimwiki#892)

Main change:
        Create function: normalize_syntax_settings(syntax)

Problem:
        Some user prefer [[]] links more than []().
        As vimwiki know both of them, they should be able to choose
        without regex mastery and with tests

Solution:
        let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
@omichaelo
Copy link

:let g:vimwiki_syntaxlocal_vars['markdown']['Link1'] = g:vimwiki_syntaxlocal_vars['default']['Link1']

This workaround works for me. However, :VimwikiBacklinks doesn't seem to recognize the double bracket links if the syntax is still set to markdown.

@lyndhurst
Copy link

lyndhurst commented Aug 22, 2021

First of all, thanks for all the tips shared here.

Adding an autocmd as suggested by @ericboehs works for me too on the dev branch, but I was wondering if anyone found a workaround for the :VimwikiBacklinks issue pointed by @omichaelo that I am experiencing as well with that configuration.
I also find that links pointing to a file renamed using :VimwikiRenameFile are not modified accordingly...

@Pepedou
Copy link

Pepedou commented Nov 24, 2021

Any update on this? I'm also using Obsidian and it'd be great to be able to have markdown with [[wikilinks]].

@jls83
Copy link

jls83 commented Mar 15, 2022

Howdy folks, I put together a hacky workaround to get the backlinks working with double-square bracket link syntax. It also supports the "standard" Markdown syntax ([description](url)), as the diary links seem to use that syntax even with the g:vimwiki_syntaxlocal_vars override. The commit on my local branch is linked here: jls83@3726e49

@s-cassidy
Copy link

Any update on this? I'm also using Obsidian and it'd be great to be able to have markdown with [[wikilinks]].

Exactly, editing with vimwiki and reading in Obsidian would be a great workflow for me.

jls83 pushed a commit to jls83/vimwiki that referenced this issue Jan 17, 2023
…(Issue vimwiki#892)

Main change:
        Create function: normalize_syntax_settings(syntax)

Problem:
        Some user prefer [[]] links more than []().
        As vimwiki know both of them, they should be able to choose
        without regex mastery and with tests

Solution:
        let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Related to configuration: default, customization enhancement link Related to link and path creation, modification, use [See #478] markdown Problems specific to markdown syntax work-around-exists
Projects
No open projects
v2.6
  
To do
Development

No branches or pull requests