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

feat(hop): wiki links #1679

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

benlubas
Copy link
Contributor

@benlubas benlubas commented Apr 5, 2025

Ability to follow wiki links. No auto-completion for wiki links in this PR

@adaviloper
Copy link

adaviloper commented Apr 6, 2025

// header.norg
* Header

** Subheading
   - {? wiki.norg}

** Notes
   - {:$/Definition:}

**    Action Items
   - ( ) 

wiki.norg is a sibling to the above file.

Given the above content, when I press enter over the wiki link, I get the following errors after pressing the related keys:

f:

E5108: Error executing lua: ...ovim/0.11.0/share/nvim/runtime/lua/vim/func/_memoize.lua:75: invalid value (nil) at index 2 in table for 'concat'
stack traceback:
	[C]: in function '_hash'
	...ovim/0.11.0/share/nvim/runtime/lua/vim/func/_memoize.lua:75: in function 'ts_parse_query'
	...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:828: in function 'fix_link_strict'
	...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:219: in function <...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:218>
	...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:329: in function <...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:315>
	...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:22: in function 'invoke_key_in_selection'
	...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:182: in function <...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:179>

F: The link is updated to point to the ** Action Items heading.

a|b: No noticeable change.

{
  "benlubas/neorg",
  branch = "push-yzmnmvtuuuon",
  lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
  version = "*", -- Pin Neorg to the latest stable release
  dependencies = {
    { "pysan3/neorg-templates", dependencies = { "L3MON4D3/LuaSnip" } },
  },
  -- ...
}

I've got the above as part of my config, so if there's something else here that might be giving me these results, let me know and I can test again.

Image of installed version info:
image

@benlubas
Copy link
Contributor Author

benlubas commented Apr 6, 2025

{? wiki.norg} would look for a heading named wiki.norg. You can read the spec for wiki links to understand how they work. They search for headings.

https://github.com/nvim-neorg/norg-specs/blob/main/1.0-specification.norg#L1467

That said, this definitely shouldn't error. I'll take a look at that, ty

@benlubas
Copy link
Contributor Author

benlubas commented Apr 6, 2025

Actually, now that I actually go to look at this, you're not correctly loading this PR. You've loaded an old version because you have version = "*", in your config. Remove that for your testing

@adaviloper
Copy link

Ah, I see. Sorry about that. I misunderstood the conversation we had in Discord. I was talking about creating links to files rather than to headings in any file in the workspace.

When the wiki link destination is spelled correctly, it jumps to the file, but it's throwing an error saying:

[neorg] (18:24:03)
...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:196
Failed to jump to line: 8 - make sure the line number exists!

Which doesn't make sense since the line definitely exists.

Given that, here are the new results I'm seeing when there is an incorrectly typed wiki link destination:

// header.norg
* Header

** Subheading
   - {? Attendes} <---- Typo here; should be `Attendees`

** Notes
   - {:$/Definition:}

**    Action Items
   - ( ) 
* Wiki

** Attendees
   - 

** Notes
   -

**    Action Items
   - ( ) 

f:

                    (wiki
                     ^

stack traceback:
	[C]: in function '_ts_parse_query'
	...m/0.11.0/share/nvim/runtime/lua/vim/treesitter/query.lua:373: in function 'fn'
	...ovim/0.11.0/share/nvim/runtime/lua/vim/func/_memoize.lua:78: in function 'ts_parse_query'
	...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:917: in function 'fix_link_strict'
	...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:316: in function <...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:315>
	...org/lua/neorg/modules/core/ui/selection_popup/module.lua:275: in function <...org/lua/neorg/modules/core/ui/selection_popup/module.lua:261>

F: Still just updates the link to point to Action Items. I tested with a different final heading and it seems like it's matching against the closest on the current file, which I believe is expected behavior.

a|b: No noticeable difference.


image

{
  -- "nvim-neorg/neorg",
  "benlubas/neorg",
  branch = "push-yzmnmvtuuuon",
  lazy = false, -- Disable lazy loading as some `lazy.nvim` distributions set `lazy = true` by default
  -- version = "*", -- Pin Neorg to the latest stable release
  dependencies = {
    { "pysan3/neorg-templates", dependencies = { "L3MON4D3/LuaSnip" } },
  },
}

@benlubas benlubas force-pushed the push-yzmnmvtuuuon branch from ef345b6 to 2e1d1cf Compare April 6, 2025 23:57
@benlubas benlubas force-pushed the push-yzmnmvtuuuon branch from 2e1d1cf to 8e40697 Compare April 7, 2025 00:04
@benlubas
Copy link
Contributor Author

benlubas commented Apr 7, 2025

I've fixed these errors, I never think to check the link fixer, I never use it. The line number warning I must have just missed somehow. Noice hiding errors away in the corner of the screen I guess. I was passing a string line number instead of converting it a number.

a/b don't work for any link types. They're unimplemented.

I appreciate the thorough testing and detailed issues!

@adaviloper
Copy link

I'm not seeing any other issues. The only thing is the auto-matching when the wiki link destination is misspelled, though this is probably a feature enhancement on top of this functionality.
I'm unsure what the vision is for matching wiki links across files or when there are duplicate matches.

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.

2 participants