def register(self): u""" Registration of plugin. Key bindings and other initialization should be done. """ cmd = Command( u'OrgHyperlinkFollow', u'%s ORGMODE.plugins[u"Hyperlinks"].follow()' % VIM_PY_CALL) self.commands.append(cmd) self.keybindings.append( Keybinding(u'gl', Plug(u'OrgHyperlinkFollow', self.commands[-1]))) self.menu + ActionEntry(u'&Follow Link', self.keybindings[-1]) cmd = Command( u'OrgHyperlinkCopy', u'%s ORGMODE.plugins[u"Hyperlinks"].follow(action=u"copy")' % VIM_PY_CALL) self.commands.append(cmd) self.keybindings.append( Keybinding(u'gyl', Plug(u'OrgHyperlinkCopy', self.commands[-1]))) self.menu + ActionEntry(u'&Copy Link', self.keybindings[-1]) cmd = Command(u'OrgHyperlinkInsert', u'%s ORGMODE.plugins[u"Hyperlinks"].insert(<f-args>)' % VIM_PY_CALL, arguments=u'*') self.commands.append(cmd) self.keybindings.append( Keybinding(u'gil', Plug(u'OrgHyperlinkInsert', self.commands[-1]))) self.menu + ActionEntry(u'&Insert Link', self.keybindings[-1]) self.menu + Separator() # find next link cmd = Command( u'OrgHyperlinkNextLink', u":if search('\[\{2}\zs[^][]*\(\]\[[^][]*\)\?\ze\]\{2}', 's') == 0 | echo 'No further link found.' | endif" ) self.commands.append(cmd) self.keybindings.append( Keybinding(u'gn', Plug(u'OrgHyperlinkNextLink', self.commands[-1]))) self.menu + ActionEntry(u'&Next Link', self.keybindings[-1]) # find previous link cmd = Command( u'OrgHyperlinkPreviousLink', u":if search('\[\{2}\zs[^][]*\(\]\[[^][]*\)\?\ze\]\{2}', 'bs') == 0 | echo 'No further link found.' | endif" ) self.commands.append(cmd) self.keybindings.append( Keybinding(u'go', Plug(u'OrgHyperlinkPreviousLink', self.commands[-1]))) self.menu + ActionEntry(u'&Previous Link', self.keybindings[-1]) self.menu + Separator() # Descriptive Links cmd = Command(u'OrgHyperlinkDescriptiveLinks', u':setlocal cole=2') self.commands.append(cmd) self.menu + ActionEntry(u'&Descriptive Links', self.commands[-1]) # Literal Links cmd = Command(u'OrgHyperlinkLiteralLinks', u':setlocal cole=0') self.commands.append(cmd) self.menu + ActionEntry(u'&Literal Links', self.commands[-1])
def register(self): u""" Registration of plugin. Key bindings and other initialization should be done. """ # an Action menu entry which binds "keybinding" to action ":action" settings.set(u'org_tag_column', vim.eval(u'&textwidth')) settings.set(u'org_tag_completion_ignorecase', int(vim.eval(u'&ignorecase'))) cmd = Command( u'OrgSetTags', u'%s ORGMODE.plugins[u"TagsProperties"].set_tags()' % VIM_PY_CALL) self.commands.append(cmd) keybinding = Keybinding(u'<localleader>st', Plug(u'OrgSetTags', cmd)) self.keybindings.append(keybinding) self.menu + ActionEntry(u'Set &Tags', keybinding) cmd = Command( u'OrgFindTags', u'%s ORGMODE.plugins[u"TagsProperties"].find_tags()' % VIM_PY_CALL) self.commands.append(cmd) keybinding = Keybinding(u'<localleader>ft', Plug(u'OrgFindTags', cmd)) self.keybindings.append(keybinding) self.menu + ActionEntry(u'&Find Tags', keybinding) cmd = Command( u'OrgTagsRealign', u"%s ORGMODE.plugins[u'TagsProperties'].realign_all_tags()" % VIM_PY_CALL) self.commands.append(cmd) # workaround to align tags when user is leaving insert mode vim.command( u_encode( u"""function Org_complete_tags(ArgLead, CmdLine, CursorPos) python << EOF ORGMODE.plugins[u'TagsProperties'].complete_tags() EOF if exists('b:org_complete_tags') let tmp = b:org_complete_tags unlet b:org_complete_tags return tmp else return [] endif endfunction""")) vim.command( u_encode(u""" function Org_realign_tags_on_insert_leave() if !exists('b:org_complete_tag_on_insertleave_au') :au orgmode InsertLeave <buffer> %s ORGMODE.plugins[u'TagsProperties'].realign_tags() let b:org_complete_tag_on_insertleave_au = 1 endif endfunction""" % VIM_PY_CALL)) # this is for all org files opened after this file vim.command( u_encode( u"au orgmode FileType org call Org_realign_tags_on_insert_leave()" )) # this is for the current file vim.command(u_encode(u"call Org_realign_tags_on_insert_leave()"))