Commit 1a1cf3c1 authored by Filippo Cucchetto's avatar Filippo Cucchetto Committed by Alessandro Portale

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: default avatarhjk <hjk@qt.io>
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent 8fce6059
{
"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
}
}
]
}
......@@ -12,4 +12,10 @@
<comment>Nim source file </comment>
<glob pattern="*.nim"/>
</mime-type>
<mime-type type="text/x-nim-script">
<sub-class-of type="text/plain"/>
<comment>Nim script file </comment>
<glob pattern="*.nims"/>
</mime-type>
</mime-info>
......@@ -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
......
......@@ -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";
......
......@@ -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;
}
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment