-
Notifications
You must be signed in to change notification settings - Fork 621
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
Allow hyphens instead of spaces and search case-insensitive in jump_to_anchor function #840
Conversation
Fixed messed up log. That's why commit date changed to 15 minutes ago. |
Although this implementation partially works I think there are some cases that might be missed. See this comment of #666. Things like |
I'm not sure I understand why The Issue was not intended to be about the Are you saying the generation with As for tags within two lines of a header, I am not too familiar with this functionality yet. Do you mean that tags in within two lines of a header can be referenced by anchors? Edit: Maybe with cases that might be missed you refer to what is explained in this comment. I could make special characters work as well. Numberings for duplicates could be ignored to always jump to the first occurence. That is how the current TOC anchors work too. |
It would be nice if auto generated links to headers used the GFM format but I'm ok with that being a separate issue if you don't want to add it to this one. The bigger concern is making sure all headers are properly supported such as ones with special characters.
Sounds reasonable. |
I'm afraid I don't have the time right now. I may be able in the future, but I am not sure yet. Hence I would like to keep this a separate issue that can be resolved soon. This way it is possible to e.g. copy existing GFM style markdown in vimwiki and navigate the anchors.
That's clear. I will improve the code. I just tried using links to tags within 2 lines of a heading with |
Probably makes sense to create a function in |
How can I get this working in the meantime? I've made the same change in my autoload/vimwiki/base.vim, but it doesn't seem to trigger on "enter". |
Update -- I ended up adding |
This is very bad. You got cannot jump to files with Uppercase or spaces
This seems a possible start. |
autoload/vimwiki/base.vim
Outdated
@@ -659,6 +659,10 @@ function! s:jump_to_anchor(anchor) abort | |||
|
|||
for segment in segments | |||
|
|||
" prepare segment pattern so that it is case insensitive and also matches dashes | |||
" in anchor link with spaces in heading | |||
let segment = substitute(substitute(segment, '\<\(.\)', '\\c\1', 'g'), '-', '[ -]', 'g') |
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.
Why one liner ?
" Craft Segment regexp
" Ignore case
let segment = substitute(segment, '\<\(.\)', '\\c\1', 'g')
" Treat - as [- or space]
let segment = substitute(segment , '-', '[ -]', 'g')
From the famous comment: still missing the opposite of:
|
So what must be done before using the anchor:
@bratekarate can you do that ? I can take the non regression test if you dont want to install the docker |
…#840 from @bratekarate) Brief: Permits: ``` [Link to heading](#heading-example) ``` Issue: Feature Request: Support GFM anchor links inside wiki files vimwiki#831 Original PR: Allow hyphens instead of spaces and search case-insensitive in jump_to_anchor function vimwiki#840 Author: @bratekarate (implementation) @tinmarino (test) Related: vimwiki#666
FIxed: 355c1f7 @bratekarate Thank you very much for the collaboration. Some related changes can be found at #666 |
@tinmarino Thank you so much for for completing this fix! No need to thank me, I punched in a one liner and then pretty much ghosted this PR whilst saying I would continue to work on it. Your test cases will probably help me better understand the testing framework in use. I'm currently in the final stage of my studies at university and can't find any time for github projects in my free time. That is also why I did not respond. I look forward to further contributing to vimwiki after I finally finish my studies, as I still use vimwiki daily at work and privately. Without it, I probably would have to switch to Doom emacs and use org mode. Also, sorry for necrobumping this PR with non-technical boilerplate text :) |
Hi @bratekarate, Happy to see some people with the will to work. Don't worry, the project can wait for you. Once you feel ready: you have some time and want to code, better than making flappy bird, try to fix one or two good first issues.
Same here. Plus Emacs has the advantage that it is not What You See is What You Get but the big drawback that it is never on my machine
I forgive you, if you forgive me 🐻. In reality, it is always motivating to see some happy users and much more to treat with some potential contributors (Imagine if would be 10 for 2 months on Vimwiki: even Emacs people would come) |
Glad to hear that there are "not so hard" things to fix, since that probably fits my almost nonexistent vimscript skills. I will check out some of these said labelled issues as soon as I find time. 👍 |
…#840 from @bratekarate) Brief: Permits: ``` [Link to heading](#heading-example) ``` Issue: Feature Request: Support GFM anchor links inside wiki files vimwiki#831 Original PR: Allow hyphens instead of spaces and search case-insensitive in jump_to_anchor function vimwiki#840 Author: @bratekarate (implementation) @tinmarino (test) Related: vimwiki#666
…#840 from @bratekarate) Brief: Permits: ``` [Link to heading](#heading-example) ``` Issue: Feature Request: Support GFM anchor links inside wiki files vimwiki#831 Original PR: Allow hyphens instead of spaces and search case-insensitive in jump_to_anchor function vimwiki#840 Author: @bratekarate (implementation) @tinmarino (test) Related: vimwiki#666
Steps for submitting a pull request:
Disclaimer: Log is kind of messed up because I maintain my own fork and needed to pull the latest version in to my repo
dev
branch!doc/vimwiki.txt
if applicable,including the Changelog and Contributors sections.
This PR allows GFM style links to be used (Issue #831).
jump_to_anchor
has been altered so that search for anchors is now case-insensitive and dashes may be included instead of whitespaces.Code works as follows: before the anchor is transformed into the regex patterns, a
\c
is prepended before the first character of each word and spaces are replaced by[ -]
. This way the search function also matches GFM style links.I'm not a vimscript expert, so I don't know if this solution is the prettiest, but it is a one liner. Feel free to improve if I missed something or if it's too hacky.