Skip to content

Instantly share code, notes, and snippets.

@kaorimatz
Last active December 18, 2015 01:48
Show Gist options
  • Save kaorimatz/5706496 to your computer and use it in GitHub Desktop.
Save kaorimatz/5706496 to your computer and use it in GitHub Desktop.
User defined vimperator command for opening a feed link in the current tab
(function() {
let completer = function (context, args) {
let feeds = buffer.pageInfo.f[0];
let completions = [];
for (let [title, template] in feeds(true)) {
let dom = util.xmlToDom(template, document);
let url = dom.firstChild.href;
completions.push([url, title]);
}
context.completions = completions;
context.title = ['Link', 'Title'];
context.compare = CompletionContext.Sort.unsorted;
};
commands.addUserCommand(
['feed'],
'Open a feed link in the current tab',
function action(args) {
liberator.open(args.string);
},
{
completer: completer,
literal: 0
},
true
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment