Created
October 21, 2017 20:38
-
-
Save mikoto2000/c605415ad8fe2f026abdc26efc5fd78b to your computer and use it in GitHub Desktop.
VimFX config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const {classes: Cc, interfaces: Ci} = Components; | |
const css_prefix = `data:text/css,@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);`; | |
const css_body = ` | |
@-moz-document url('chrome://browser/content/browser.xul') { | |
#VimFxMarkersContainer .marker { | |
font-size: 25px !important; /* Specific font size. */ | |
} | |
} | |
`; | |
const css = css_prefix + encodeURIComponent(css_body); | |
const sss = Cc['@mozilla.org/content/style-sheet-service;1'] | |
.getService(Ci.nsIStyleSheetService); | |
const ios = Cc['@mozilla.org/network/io-service;1'] | |
.getService(Ci.nsIIOService); | |
const uri = ios.newURI(css, null, null); | |
if (!sss.sheetRegistered(uri, sss.USER_SHEET)) { | |
sss.loadAndRegisterSheet(uri, sss.USER_SHEET); | |
vimfx.on('shutdown', () => { | |
sss.unregisterSheet(uri, sss.USER_SHEET); | |
}); | |
} | |
vimfx.addCommand({ | |
name: 'title_url_default', | |
description: '"title: URL"形式でコピー', | |
category: 'location', | |
}, ({vim}) => { | |
const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] | |
.getService(Components.interfaces.nsIClipboardHelper); | |
let url = vim.window.gBrowser.selectedBrowser.currentURI.spec | |
let title = vim.window.gBrowser.selectedBrowser.contentTitle | |
let fmt = "[" + title + "](" + url + ")" | |
gClipboardHelper.copyString(fmt) | |
vim.notify("Copied String: "+ fmt) | |
}) | |
let map = (shortcuts, command, custom=false) => { | |
vimfx.set(`${custom ? 'custom.' : ''}mode.normal.${command}`, shortcuts) | |
} | |
map('cc', 'title_url_default', true) | |
map('', 'scroll_half_page_down') | |
map('', 'scroll_half_page_up') | |
map('d', 'tab_close') | |
map('u', 'tab_restore') | |
map('<c-p>', 'tab_select_previous') | |
map('<c-n>', 'tab_select_next') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment