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

mkd.vim: open URL (gx) based on mkdID/mkdLinkDef #506

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sim590
Copy link
Contributor

@sim590 sim590 commented Aug 8, 2020

This change lets gx open URLs when the cursor is on either mkdID, mkdLinkDef syntax regions. It also supports mkdLink region where the following syntax region is a mkdID and not an mkdURL. Indeed, the old setting is still preserved.

  • FindNextSyntax was repurposed for finding the next syntax object (whatever the name is). Then, we call repeatedly the function for getting where we want. Most of the time, we just need to call it twice or so.
  • New functions FindMkdLinkDefTargetPosition, GetUrlPositionFromMkdLink, GetUrlPositionFromMkdIDOrDef: handle cases where we're presently looking at mkdLink, mkdID and mkdLinkDef.
  • Markdown_GetUrlForPosition: the approach was slightly changed so that we first find out if we're on a delimiter, then move from there to the delimited region. Then, we handle other cases seperatly from the delimiters case. This makes for an approach that is more readable and easier to maintain.
  • Doc was also updated to express the support for the new syntax regions.

This effectively fixes #382.

I don't know about people that expressed the issue #353, but the code seems to work OK before these changes according to the supported regions. May be the people from #353 will find a fix for their issue with this change if for some reason they didn't express their issue appropriately and that they were rather having an issue with mkdID and mkdLinkDef not working. This was by design and consistent with the doc. However, it would be clearly more intuitive for the user if my change was merged. I may be misinterpreting. In the latter case, the issue is orthogonal to my change anyway.

This change lets gx open URLs when the cursor is on either mkdID,
mkdLinkDef syntax regions. It also supports mkdLink region where the
following syntax region is a mkdID and not an mkdURL.

* FindNextSyntax was repurposed for finding the next syntax object
  (whatever the name is). Then, we call repeatedly the function for
  getting where we want. Most of the time, we just need to call it
  twice or so.
* New functions FindMkdLinkDefTargetPosition, GetUrlPositionFromMkdLink,
  GetUrlPositionFromMkdIDOrDef: handle cases where we're presently
  looking at mkdLink, mkdID and mkdLinkDef.
* Markdown_GetUrlForPosition: the approach was slightly changed so that
  we first find out if we're on a delimiter, then move from there to the
  delimited region. Then, we handle other cases seperatly from the
  delimiters case. This makes for an approach that is more readable and
  easier to maintain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] Enhance gx
1 participant