diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties index 2a7ce15b..795d5150 100644 --- a/common/locale/en-US/messages.properties +++ b/common/locale/en-US/messages.properties @@ -204,6 +204,7 @@ io.commandFailed = E472: Command failed io.definedAt = Defined at io.downloadFinished-2 = Download of %S to %S finished io.eNotDir = Not a directory +io.eNotDir-1 = Not a directory %S io.exists = File exists (add ! to override) io.exists-1 = File %S exists (add ! to override) io.noCommand-1 = Command not found: %S @@ -220,6 +221,7 @@ io.shellReturn-1 = shell returned %S io.sourcing-1 = sourcing %S io.sourcingEnd-1 = finished sourcing %S io.sourcingError-1 = Sourcing file: %S +io.writing-1 = writing %S macro.canceled-1 = Canceled playback of macro '%S' macro.recorded-1 = Recorded macro '%S' diff --git a/common/locale/en-US/various.xml b/common/locale/en-US/various.xml index d6e1d9c2..3d3dade6 100644 --- a/common/locale/en-US/various.xml +++ b/common/locale/en-US/various.xml @@ -73,15 +73,19 @@ - :mks :mksyntax - :mksyntax! path + :mkv :mkvimruntime + :mkvimruntime! dir

- Generate a Vim syntax file. If path is not given, the local - Vim runtime path is guessed. If path is a directory, the - file &dactyl.name;.vim in that directory is - used. An existing file will never be overwritten unless - bang is given. + Creates and installs Vim ftdetect, ftplugin and syntax files. If + dir is not given, the local Vim runtime path is guessed. + An existing file will never be overwritten unless ! is + given. +

+

+ See :help 'runtimepath' and :help after-directory + in Vim for an explanation of how best to manage personal changes to + these files.

diff --git a/common/modules/io.jsm b/common/modules/io.jsm index c7895b32..f4f6bee1 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -1,6 +1,6 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott -// Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2007-2012 by Doug Kearns +// Copyright (c) 2008-2012 by Kris Maglione // Some code based on Venkman // // This work is licensed for reuse under an MIT license. Details are @@ -638,6 +638,7 @@ var IO = Module("io", { try { file.write(lines.join("\n")); + dactyl.echomsg(_("io.writing", file.path.quote()), 2); } catch (e) { dactyl.echoerr(_("io.notWriteable", file.path.quote())); @@ -649,24 +650,66 @@ var IO = Module("io", { completer: function (context) completion.file(context, true) }); - commands.add(["mks[yntax]"], - "Generate a Vim syntax file", + commands.add(["mkv[imruntime]"], + "Create and install Vim runtime files for " + config.appName, function (args) { - let runtime = config.OS.isWindows ? "~/vimfiles/" : "~/.vim/"; - let file = io.File(runtime + "syntax/" + config.name + ".vim"); - if (args.length) - file = io.File(args[0]); + dactyl.assert(args.length <= 1, _("io.oneFileAllowed")); - if (file.exists() && file.isDirectory() || args[0] && /\/$/.test(args[0])) + if (args.length) { + var rtDir = io.File(args[0]); + dactyl.assert(rtDir.exists(), _("io.noSuchDir", rtDir.path.quote())); + } + else + rtDir = io.File(config.OS.isWindows ? "~/vimfiles/" : "~/.vim/"); + + dactyl.assert(!rtDir.exists() || rtDir.isDirectory(), _("io.eNotDir", rtDir.path.quote())); + + let rtItems = { ftdetect: {}, ftplugin: {}, syntax: {} }; + + // require bang if any of the paths exist + for (let [type, item] in iter(rtItems)) { + let file = io.File(rtDir); + file.append(type); file.append(config.name + ".vim"); - dactyl.assert(!file.exists() || args.bang, _("io.exists")); + dactyl.assert(!file.exists() || args.bang, _("io.exists", file.path.quote())); + item.file = file; + } - let template = util.compileMacro( + rtItems.ftdetect.template = rc*,*. set filetype=]]>; + rtItems.ftplugin.template = // {{{ + configuration file +" Maintainer: +" Version: -" TODO: make this specific - shared dactyl config? +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let b:undo_ftplugin = "setl com< cms< fo< ofu< | unlet! b:browsefilter" + +setlocal comments=:\" +setlocal commentstring=\"%s +setlocal formatoptions-=t formatoptions+=croql +setlocal omnifunc=syntaxcomplete#Complete + +if has("gui_win32") && !exists("b:browsefilter") + let b:browsefilter = " Config Files (*.)\t*.\n" . + \ "All Files (*.*)\t*.*\n" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save +]]>;//}}} + rtItems.syntax.template = // {{{ + configuration file +" Maintainer: +" Version: if exists("b:current_syntax") finish @@ -744,10 +787,30 @@ let &cpo = s:cpo_save unlet s:cpo_save " vim: tw=130 et ts=4 sw=4: -]]>, true); +]]>;//}}} + + const { options } = modules; + + let params = {//{{{ + version: config.version, + name: config.name, + appname: config.appName, + fileext: config.fileExtension, + maintainer: "Doug Kearns ", + autocommands: wrap("syn keyword " + config.name + "AutoEvent ", + keys(config.autocommands)), + commands: wrap("syn keyword " + config.name + "Command ", + array(c.specs for (c in commands.iterator())).flatten()), + options: wrap("syn keyword " + config.name + "Option ", + array(o.names for (o in options) if (o.type != "boolean")).flatten()), + toggleoptions: wrap("let s:toggleOptions = [", + array(o.realNames for (o in options) if (o.type == "boolean")) + .flatten().map(String.quote), + ", ") + "]" + };//}}} const WIDTH = 80; - function wrap(prefix, items, sep) { + function wrap(prefix, items, sep) {//{{{ sep = sep || " "; let width = 0; let lines = []; @@ -764,26 +827,22 @@ unlet s:cpo_save } lines.last.pop(); return lines.map(function (l) l.join("")).join("\n").replace(/\s+\n/gm, "\n"); - } + }//}}} - const { commands, options } = modules; - file.write(template({ - name: config.name, - autocommands: wrap("syn keyword " + config.name + "AutoEvent ", - keys(config.autocommands)), - commands: wrap("syn keyword " + config.name + "Command ", - array(c.specs for (c in commands.iterator())).flatten()), - options: wrap("syn keyword " + config.name + "Option ", - array(o.names for (o in options) if (o.type != "boolean")).flatten()), - toggleoptions: wrap("let s:toggleOptions = [", - array(o.realNames for (o in options) if (o.type == "boolean")) - .flatten().map(String.quote), - ", ") + "]" - })); + for (let { file, template } in values(rtItems)) { + try { + file.write(util.compileMacro(template, true)(params)); + dactyl.echomsg(_("io.writing", file.path.quote()), 2); + } + catch (e) { + dactyl.echoerr(_("io.notWriteable", file.path.quote())); + dactyl.log(_("error.notWriteable", file.path, e.message)); + } + } }, { argCount: "?", bang: true, - completer: function (context) completion.file(context, true), + completer: function (context) completion.directory(context, true), literal: 1 }); diff --git a/common/tests/functional/testCommands.js b/common/tests/functional/testCommands.js index 010919cb..0d7761de 100644 --- a/common/tests/functional/testCommands.js +++ b/common/tests/functional/testCommands.js @@ -474,21 +474,13 @@ var tests = { completions: [""], cleanup: ["silent !rm some-nonexistent-rc.penta"] }, - mksyntax: { - noOutput: [ - "some-nonexistent-pentadactyl-dir/", - "! some-nonexistent-pentadactyl-dir/", - "some-nonexistent-pentadactyl-dir/foo.vim", - "! some-nonexistent-pentadactyl-dir/foo.vim", - ], + mkvimruntime: { error: [ - "some-nonexistent-pentadactyl-dir/", - "some-nonexistent-pentadactyl-dir/foo.vim" + "some-nonexistent-pentadactyl-dir/" ], completions: [ ["", hasItems] - ], - cleanup: ["silent !rm -r some-nonexistent-pentadactyl-dir/"] + ] }, get mlistkeys() this.listcommands, mmap: {}, diff --git a/melodactyl/contrib/vim/Makefile b/melodactyl/contrib/vim/Makefile deleted file mode 100644 index 29972b5a..00000000 --- a/melodactyl/contrib/vim/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -VIMBALL = melodactyl.vba - -vimball: mkvimball.txt syntax/melodactyl.vim ftdetect/melodactyl.vim - -echo '%MkVimball! ${VIMBALL} .' | vim -u NORC -N -e -s mkvimball.txt - -all: vimball - -clean: - rm -f ${VIMBALL} diff --git a/melodactyl/contrib/vim/ftdetect/melodactyl.vim b/melodactyl/contrib/vim/ftdetect/melodactyl.vim deleted file mode 100644 index e7661ca3..00000000 --- a/melodactyl/contrib/vim/ftdetect/melodactyl.vim +++ /dev/null @@ -1 +0,0 @@ -au BufNewFile,BufRead *melodactylrc*,*.melo set filetype=melodactyl diff --git a/melodactyl/contrib/vim/mkvimball.txt b/melodactyl/contrib/vim/mkvimball.txt deleted file mode 100644 index ec820b41..00000000 --- a/melodactyl/contrib/vim/mkvimball.txt +++ /dev/null @@ -1,2 +0,0 @@ -syntax/melodactyl.vim -ftdetect/melodactyl.vim diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 95e5f201..876fbad5 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -1,4 +1,10 @@ -1.0rc1: +1.1: + • Vim runtime files: + - renamed :mksyntax to :mkvimruntime which now generates + all Vim related files. + - Vimball packages are no longer available. + +1.0: • Extensive Firefox 4 support, including: - Fully restartless. Can now be installed, uninstalled, enabled, disabled, and upgraded without restarting Firefox. diff --git a/pentadactyl/contrib/vim/Makefile b/pentadactyl/contrib/vim/Makefile deleted file mode 100644 index 5bb780d2..00000000 --- a/pentadactyl/contrib/vim/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -VIMBALL = pentadactyl.vba - -vimball: mkvimball.txt syntax/pentadactyl.vim ftdetect/pentadactyl.vim - -echo '%MkVimball! ${VIMBALL} .' | vim -u NORC -N -e -s mkvimball.txt - -all: vimball - -clean: - rm -f ${VIMBALL} diff --git a/pentadactyl/contrib/vim/ftdetect/pentadactyl.vim b/pentadactyl/contrib/vim/ftdetect/pentadactyl.vim deleted file mode 100644 index 19624dfc..00000000 --- a/pentadactyl/contrib/vim/ftdetect/pentadactyl.vim +++ /dev/null @@ -1 +0,0 @@ -au BufNewFile,BufRead *pentadactylrc*,*.penta set filetype=pentadactyl diff --git a/pentadactyl/contrib/vim/mkvimball.txt b/pentadactyl/contrib/vim/mkvimball.txt deleted file mode 100644 index 03506337..00000000 --- a/pentadactyl/contrib/vim/mkvimball.txt +++ /dev/null @@ -1,2 +0,0 @@ -syntax/pentadactyl.vim -ftdetect/pentadactyl.vim diff --git a/teledactyl/contrib/vim/Makefile b/teledactyl/contrib/vim/Makefile deleted file mode 100644 index c3a65aae..00000000 --- a/teledactyl/contrib/vim/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -VIMBALL = teledactyl.vba - -vimball: mkvimball.txt syntax/teledactyl.vim ftdetect/teledactyl.vim - -echo '%MkVimball! ${VIMBALL} .' | vim -u NORC -N -e -s mkvimball.txt - -all: vimball - -clean: - rm -f ${VIMBALL} diff --git a/teledactyl/contrib/vim/ftdetect/teledactyl.vim b/teledactyl/contrib/vim/ftdetect/teledactyl.vim deleted file mode 100644 index f4a303bb..00000000 --- a/teledactyl/contrib/vim/ftdetect/teledactyl.vim +++ /dev/null @@ -1 +0,0 @@ -au BufNewFile,BufRead *teledactylrc*,*.tele set filetype=teledactyl diff --git a/teledactyl/contrib/vim/mkvimball.txt b/teledactyl/contrib/vim/mkvimball.txt deleted file mode 100644 index 20148df0..00000000 --- a/teledactyl/contrib/vim/mkvimball.txt +++ /dev/null @@ -1,2 +0,0 @@ -syntax/teledactyl.vim -ftdetect/teledactyl.vim