mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-24 07:15:46 +01:00
Rename :mksyntax to :mkvimruntime.
This now generates and installs all Vim runtime files. Closes issue #653.
This commit is contained in:
@@ -204,6 +204,7 @@ io.commandFailed = E472: Command failed
|
|||||||
io.definedAt = Defined at
|
io.definedAt = Defined at
|
||||||
io.downloadFinished-2 = Download of %S to %S finished
|
io.downloadFinished-2 = Download of %S to %S finished
|
||||||
io.eNotDir = Not a directory
|
io.eNotDir = Not a directory
|
||||||
|
io.eNotDir-1 = Not a directory %S
|
||||||
io.exists = File exists (add ! to override)
|
io.exists = File exists (add ! to override)
|
||||||
io.exists-1 = File %S exists (add ! to override)
|
io.exists-1 = File %S exists (add ! to override)
|
||||||
io.noCommand-1 = Command not found: %S
|
io.noCommand-1 = Command not found: %S
|
||||||
@@ -220,6 +221,7 @@ io.shellReturn-1 = shell returned %S
|
|||||||
io.sourcing-1 = sourcing %S
|
io.sourcing-1 = sourcing %S
|
||||||
io.sourcingEnd-1 = finished sourcing %S
|
io.sourcingEnd-1 = finished sourcing %S
|
||||||
io.sourcingError-1 = Sourcing file: %S
|
io.sourcingError-1 = Sourcing file: %S
|
||||||
|
io.writing-1 = writing %S
|
||||||
|
|
||||||
macro.canceled-1 = Canceled playback of macro '%S'
|
macro.canceled-1 = Canceled playback of macro '%S'
|
||||||
macro.recorded-1 = Recorded macro '%S'
|
macro.recorded-1 = Recorded macro '%S'
|
||||||
|
|||||||
@@ -73,15 +73,19 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>:mks :mksyntax</tags>
|
<tags>:mkv :mkvimruntime</tags>
|
||||||
<spec>:mks<oa>yntax</oa><oa>!</oa> <oa>path</oa></spec>
|
<spec>:mkv<oa>imruntime</oa><oa>!</oa> <oa>dir</oa></spec>
|
||||||
<description>
|
<description>
|
||||||
<p>
|
<p>
|
||||||
Generate a Vim syntax file. If <oa>path</oa> is not given, the local
|
Creates and installs Vim ftdetect, ftplugin and syntax files. If
|
||||||
Vim runtime path is guessed. If <oa>path</oa> is a directory, the
|
<oa>dir</oa> is not given, the local Vim runtime path is guessed.
|
||||||
file <str delim="">&dactyl.name;.vim</str> in that directory is
|
An existing file will never be overwritten unless <oa>!</oa> is
|
||||||
used. An existing file will never be overwritten unless
|
given.
|
||||||
<oa>bang</oa> is given.
|
</p>
|
||||||
|
<p>
|
||||||
|
See <em>:help 'runtimepath'</em> and <em>:help after-directory</em>
|
||||||
|
in Vim for an explanation of how best to manage personal changes to
|
||||||
|
these files.
|
||||||
</p>
|
</p>
|
||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||||
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
|
// Copyright (c) 2007-2012 by Doug Kearns <dougkearns@gmail.com>
|
||||||
// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
|
// Copyright (c) 2008-2012 by Kris Maglione <maglione.k@gmail.com>
|
||||||
// Some code based on Venkman
|
// Some code based on Venkman
|
||||||
//
|
//
|
||||||
// This work is licensed for reuse under an MIT license. Details are
|
// This work is licensed for reuse under an MIT license. Details are
|
||||||
@@ -638,6 +638,7 @@ var IO = Module("io", {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
file.write(lines.join("\n"));
|
file.write(lines.join("\n"));
|
||||||
|
dactyl.echomsg(_("io.writing", file.path.quote()), 2);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
dactyl.echoerr(_("io.notWriteable", file.path.quote()));
|
dactyl.echoerr(_("io.notWriteable", file.path.quote()));
|
||||||
@@ -649,24 +650,66 @@ var IO = Module("io", {
|
|||||||
completer: function (context) completion.file(context, true)
|
completer: function (context) completion.file(context, true)
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["mks[yntax]"],
|
commands.add(["mkv[imruntime]"],
|
||||||
"Generate a Vim syntax file",
|
"Create and install Vim runtime files for " + config.appName,
|
||||||
function (args) {
|
function (args) {
|
||||||
let runtime = config.OS.isWindows ? "~/vimfiles/" : "~/.vim/";
|
dactyl.assert(args.length <= 1, _("io.oneFileAllowed"));
|
||||||
let file = io.File(runtime + "syntax/" + config.name + ".vim");
|
|
||||||
if (args.length)
|
|
||||||
file = io.File(args[0]);
|
|
||||||
|
|
||||||
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");
|
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(<![CDATA[
|
rtItems.ftdetect.template = <![CDATA[au BufNewFile,BufRead *<name>rc*,*.<fileext> set filetype=<name>]]>;
|
||||||
" Vim syntax file
|
rtItems.ftplugin.template = // {{{
|
||||||
" Language: Pentadactyl configuration file
|
<![CDATA[" Vim filetype plugin file
|
||||||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
" Language: <appname> configuration file
|
||||||
|
" Maintainer: <maintainer>
|
||||||
|
" Version: <version>
|
||||||
|
|
||||||
" TODO: make this <name> 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 = "<appname> Config Files (*.<fileext>)\t*.<fileext>\n" .
|
||||||
|
\ "All Files (*.*)\t*.*\n"
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
]]>;//}}}
|
||||||
|
rtItems.syntax.template = // {{{
|
||||||
|
<![CDATA[" Vim syntax file
|
||||||
|
" Language: <appname> configuration file
|
||||||
|
" Maintainer: <maintainer>
|
||||||
|
" Version: <version>
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
@@ -744,10 +787,30 @@ let &cpo = s:cpo_save
|
|||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
||||||
" vim: tw=130 et ts=4 sw=4:
|
" 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 <dougkearns@gmail.com>",
|
||||||
|
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;
|
const WIDTH = 80;
|
||||||
function wrap(prefix, items, sep) {
|
function wrap(prefix, items, sep) {//{{{
|
||||||
sep = sep || " ";
|
sep = sep || " ";
|
||||||
let width = 0;
|
let width = 0;
|
||||||
let lines = [];
|
let lines = [];
|
||||||
@@ -764,26 +827,22 @@ unlet s:cpo_save
|
|||||||
}
|
}
|
||||||
lines.last.pop();
|
lines.last.pop();
|
||||||
return lines.map(function (l) l.join("")).join("\n").replace(/\s+\n/gm, "\n");
|
return lines.map(function (l) l.join("")).join("\n").replace(/\s+\n/gm, "\n");
|
||||||
}
|
}//}}}
|
||||||
|
|
||||||
const { commands, options } = modules;
|
for (let { file, template } in values(rtItems)) {
|
||||||
file.write(template({
|
try {
|
||||||
name: config.name,
|
file.write(util.compileMacro(template, true)(params));
|
||||||
autocommands: wrap("syn keyword " + config.name + "AutoEvent ",
|
dactyl.echomsg(_("io.writing", file.path.quote()), 2);
|
||||||
keys(config.autocommands)),
|
}
|
||||||
commands: wrap("syn keyword " + config.name + "Command ",
|
catch (e) {
|
||||||
array(c.specs for (c in commands.iterator())).flatten()),
|
dactyl.echoerr(_("io.notWriteable", file.path.quote()));
|
||||||
options: wrap("syn keyword " + config.name + "Option ",
|
dactyl.log(_("error.notWriteable", file.path, e.message));
|
||||||
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),
|
|
||||||
", ") + "]"
|
|
||||||
}));
|
|
||||||
}, {
|
}, {
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) completion.file(context, true),
|
completer: function (context) completion.directory(context, true),
|
||||||
literal: 1
|
literal: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -474,21 +474,13 @@ var tests = {
|
|||||||
completions: [""],
|
completions: [""],
|
||||||
cleanup: ["silent !rm some-nonexistent-rc.penta"]
|
cleanup: ["silent !rm some-nonexistent-rc.penta"]
|
||||||
},
|
},
|
||||||
mksyntax: {
|
mkvimruntime: {
|
||||||
noOutput: [
|
|
||||||
"some-nonexistent-pentadactyl-dir/",
|
|
||||||
"! some-nonexistent-pentadactyl-dir/",
|
|
||||||
"some-nonexistent-pentadactyl-dir/foo.vim",
|
|
||||||
"! some-nonexistent-pentadactyl-dir/foo.vim",
|
|
||||||
],
|
|
||||||
error: [
|
error: [
|
||||||
"some-nonexistent-pentadactyl-dir/",
|
"some-nonexistent-pentadactyl-dir/"
|
||||||
"some-nonexistent-pentadactyl-dir/foo.vim"
|
|
||||||
],
|
],
|
||||||
completions: [
|
completions: [
|
||||||
["", hasItems]
|
["", hasItems]
|
||||||
],
|
]
|
||||||
cleanup: ["silent !rm -r some-nonexistent-pentadactyl-dir/"]
|
|
||||||
},
|
},
|
||||||
get mlistkeys() this.listcommands,
|
get mlistkeys() this.listcommands,
|
||||||
mmap: {},
|
mmap: {},
|
||||||
|
|||||||
@@ -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}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
au BufNewFile,BufRead *melodactylrc*,*.melo set filetype=melodactyl
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
syntax/melodactyl.vim
|
|
||||||
ftdetect/melodactyl.vim
|
|
||||||
@@ -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:
|
• Extensive Firefox 4 support, including:
|
||||||
- Fully restartless. Can now be installed, uninstalled,
|
- Fully restartless. Can now be installed, uninstalled,
|
||||||
enabled, disabled, and upgraded without restarting Firefox.
|
enabled, disabled, and upgraded without restarting Firefox.
|
||||||
|
|||||||
@@ -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}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
au BufNewFile,BufRead *pentadactylrc*,*.penta set filetype=pentadactyl
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
syntax/pentadactyl.vim
|
|
||||||
ftdetect/pentadactyl.vim
|
|
||||||
@@ -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}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
au BufNewFile,BufRead *teledactylrc*,*.tele set filetype=teledactyl
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
syntax/teledactyl.vim
|
|
||||||
ftdetect/teledactyl.vim
|
|
||||||
Reference in New Issue
Block a user