Neorg plugin to extend the functionality of links
NOTE: Includes changes removing neorgs keybindings api
For packer users -
use {
'nvim-neorg/neorg',
-- ...
requires = {
-- ...
{'phenax/neorg-hop-extras'},
}
}
require('neorg').setup {
load = {
['external.hop-extras'] = {},
},
}
require('neorg').setup {
load = {
-- ...
['external.hop-extras'] = {
config = {
bind_enter_key = false,
}
},
},
}
vim.keymap.set('n', '<leader>gl', '<plug>(neorg.external.hop-extras.hop-link)')
Run an arbitrary vim command when a link is activated
- View yesterday's journal {+Neorg journal yesterday}[Yesterday] - Opens yesterday's journal
- Log the time using timelog module {+Neorg timelog insert routine}[Log routine] (requires https://github.com/phenax/neorg-timelog)
- Run shell commands {+!ls}
* Counter example
- count: 28
- Increment: {+/-\s*count:/ | call feedkeys("\<C-a>\<C-o>")}
- Decrement: {+/-\s*count:/ | call feedkeys("\<C-x>\<C-o>")}
Use aliases for links
- Github url - {&gh phenax/neorg-timelog}
- Npm package link - {&npm react}
- Rust package link - {&crates serde}
- Dart package link - {&pub serde}
- Twitter user @Neovim - {&tw Neovim} (Custom alias defined below)
To define the custom alias, use -
require('neorg').setup {
load = {
-- ...
['external.hop-extras'] = {
config = {
aliases = {
tw = 'https://twitter.com/{}'
},
},
},
},
}
Ask for confirmation (uses vim.fn.confirm
) before activating a link
- Asks for confirmation before opening external link - {! https://example.com}
- Confirm before opening alias - {! &npm react}
- Confirm before running command {! +echo "Dangerous commands need confirmation"}