From 1a1cf3c12b762873696076c557c54b8719c45cbc Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Tue, 8 Nov 2016 23:12:49 +0100 Subject: [PATCH] Nim: Added support for nim script files Added a new entry inside the "New" menu for creating a new nim script file (*.nims) Added support for editing them inside the editor Change-Id: I09a514fdd4e4a0e9a78bb557db3e8c7e97683b8d Reviewed-by: hjk Reviewed-by: Alessandro Portale --- .../wizards/files/nimscript/file.nims | 1 + .../wizards/files/nimscript/icon.png | Bin 0 -> 1511 bytes .../wizards/files/nimscript/wizard.json | 37 ++++++++++++++++++ src/plugins/nim/Nim.mimetypes.xml | 6 +++ src/plugins/nim/editor/nimeditorfactory.cpp | 1 + src/plugins/nim/nimconstants.h | 1 + src/plugins/nim/nimplugin.cpp | 4 +- src/plugins/nim/settings/nimsettings.cpp | 1 + 8 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 share/qtcreator/templates/wizards/files/nimscript/file.nims create mode 100644 share/qtcreator/templates/wizards/files/nimscript/icon.png create mode 100644 share/qtcreator/templates/wizards/files/nimscript/wizard.json diff --git a/share/qtcreator/templates/wizards/files/nimscript/file.nims b/share/qtcreator/templates/wizards/files/nimscript/file.nims new file mode 100644 index 00000000000..73b2eaf3881 --- /dev/null +++ b/share/qtcreator/templates/wizards/files/nimscript/file.nims @@ -0,0 +1 @@ + echo "Hello World" diff --git a/share/qtcreator/templates/wizards/files/nimscript/icon.png b/share/qtcreator/templates/wizards/files/nimscript/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a08e474e6dc4be7e2434851c152d742af3e74716 GIT binary patch literal 1511 zcmeAS@N?(olHy`uVBq!ia0y~yV2}V|4mJh`h6m-gKNuJo*pj^6T^Rm@;DWu&Co?cG za29w(7Bet#3xP1>rMq>17#JAXOFVsD+3&N8^Ghqm&d~H{U|=orba4#vIKFghc23Mu z$+r2H>H7EHtlN9e%FNGc7I)ul({06uBJ7V^x;t|N6DMbMvoNr~P_-W2Z>4 z!=6hM)6UJTy!SJ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u1tCL`lYvv zlHk%QK`TSNuF9Dlfc zzV_y&r>EU|{!3U`_{+C1d(tkJI^{lm{dmjHV^5!L&TzVL(e}sdZ|B}|+z*s}E1TTB z_iz5oUu%yZEGk}ZUek8{aC*c>i{I1dm0aI)_hn~n+r(MACFUmj z4|e?b$f%4!W@)Z<;g5)lzS|cld!68@=}Swqv{WO1G75Ezj}tQRiU!YqG7*H2a8o zYy7^gv*w-S4#}^V+I~A!C*a-6iamOAy^p@jFWr=+%~;>S{Z_XoU3X`#>HYA}ZUwg| z*_h?l2`H+Hbsu{ftUlwf_ochHKmO&Jx1x@3rkCPUMvXPI4&+_Dkj8#}o|R{K{B`rD g&(oeNwmjNzTix}zb-QR00|Nttr>mdKI;Vst01|cVdjJ3c literal 0 HcmV?d00001 diff --git a/share/qtcreator/templates/wizards/files/nimscript/wizard.json b/share/qtcreator/templates/wizards/files/nimscript/wizard.json new file mode 100644 index 00000000000..1b0233f7540 --- /dev/null +++ b/share/qtcreator/templates/wizards/files/nimscript/wizard.json @@ -0,0 +1,37 @@ +{ + "version": 1, + "kind": "file", + "id": "Z.NimScript", + "category": "Z.Nim", + "trDescription": "Creates an empty Nim script file using UTF-8 charset.", + "trDisplayName": "Nim Script File", + "trDisplayCategory": "Nim", + "icon": "icon.png", + "enabled": "%{JS: [ %{Plugins} ].indexOf('Nim') >= 0}", + + "pages" : + [ + { + "trDisplayName": "Location", + "trShortTitle": "Location", + "typeId": "File" + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators" : + [ + { + "typeId": "File", + "data": + { + "source": "file.nims", + "target": "%{JS: Util.fileName('%{TargetPath}', 'nims')}", + "openInEditor": true + } + } + ] +} diff --git a/src/plugins/nim/Nim.mimetypes.xml b/src/plugins/nim/Nim.mimetypes.xml index 3e06d398fd8..f7e94aa3dd4 100644 --- a/src/plugins/nim/Nim.mimetypes.xml +++ b/src/plugins/nim/Nim.mimetypes.xml @@ -12,4 +12,10 @@ Nim source file + + + + Nim script file + + diff --git a/src/plugins/nim/editor/nimeditorfactory.cpp b/src/plugins/nim/editor/nimeditorfactory.cpp index 32e23d0eeb4..8e733b2adb3 100644 --- a/src/plugins/nim/editor/nimeditorfactory.cpp +++ b/src/plugins/nim/editor/nimeditorfactory.cpp @@ -45,6 +45,7 @@ NimEditorFactory::NimEditorFactory() setId(Constants::C_NIMEDITOR_ID); setDisplayName(tr(Nim::Constants::C_EDITOR_DISPLAY_NAME)); addMimeType(QLatin1String(Nim::Constants::C_NIM_MIMETYPE)); + addMimeType(QLatin1String(Nim::Constants::C_NIM_SCRIPT_MIMETYPE)); setEditorActionHandlers(TextEditorActionHandler::Format | TextEditorActionHandler::UnCommentSelection diff --git a/src/plugins/nim/nimconstants.h b/src/plugins/nim/nimconstants.h index 7f2dc90d8ef..65fbeb611f3 100644 --- a/src/plugins/nim/nimconstants.h +++ b/src/plugins/nim/nimconstants.h @@ -104,6 +104,7 @@ const char C_NIMCODESTYLEPREVIEWSNIPPET[] = * MIME type ******************************************************************************/ const char C_NIM_MIMETYPE[] = "text/x-nim"; +const char C_NIM_SCRIPT_MIMETYPE[] = "text/x-nim-script"; const char C_NIM_MIME_ICON[] = "text-x-nim"; const char C_NIM_PROJECT_MIMETYPE[] = "text/x-nim-project"; diff --git a/src/plugins/nim/nimplugin.cpp b/src/plugins/nim/nimplugin.cpp index b89676e0eb6..98760d7b6e0 100644 --- a/src/plugins/nim/nimplugin.cpp +++ b/src/plugins/nim/nimplugin.cpp @@ -81,8 +81,10 @@ bool NimPlugin::initialize(const QStringList &arguments, QString *errorMessage) // Add MIME overlay icons (these icons displayed at Project dock panel) const QIcon icon((QLatin1String(Constants::C_NIM_ICON_PATH))); - if (!icon.isNull()) + if (!icon.isNull()) { Core::FileIconProvider::registerIconOverlayForMimeType(icon, Constants::C_NIM_MIMETYPE); + Core::FileIconProvider::registerIconOverlayForMimeType(icon, Constants::C_NIM_SCRIPT_MIMETYPE); + } return true; } diff --git a/src/plugins/nim/settings/nimsettings.cpp b/src/plugins/nim/settings/nimsettings.cpp index 40ac7b74a2f..cd43df48490 100644 --- a/src/plugins/nim/settings/nimsettings.cpp +++ b/src/plugins/nim/settings/nimsettings.cpp @@ -80,6 +80,7 @@ NimSettings::NimSettings(QObject *parent) m_globalCodeStyle->fromSettings(QLatin1String(Nim::Constants::C_NIMLANGUAGE_ID), s); TextEditorSettings::registerMimeTypeForLanguageId(Nim::Constants::C_NIM_MIMETYPE, Nim::Constants::C_NIMLANGUAGE_ID); + TextEditorSettings::registerMimeTypeForLanguageId(Nim::Constants::C_NIM_SCRIPT_MIMETYPE, Nim::Constants::C_NIMLANGUAGE_ID); } NimSettings::~NimSettings()