Hello, having to edit huge lua files lately, i quickly made a NotePad++ plugin to check integrity of lua code

FEATURES:
Note: This plugin only check syntactic errors on code, its not aware of programming errors.
INSTALL: Put this dll on npp plugins folder
DOWNLOAD: https://mega.nz/#!IQI3GTIB!MIrWrkneTk4l ... vNdD0TXJVY
Source code: (all code is same as NppPluginTemplate base they provide ill only dump changes)

FEATURES:
- Auto check .lua files when saved
- Also allow to check any file even not saved tab by Plugin menu
Note: This plugin only check syntactic errors on code, its not aware of programming errors.
INSTALL: Put this dll on npp plugins folder
DOWNLOAD: https://mega.nz/#!IQI3GTIB!MIrWrkneTk4l ... vNdD0TXJVY
Source code: (all code is same as NppPluginTemplate base they provide ill only dump changes)
Código: Seleccionar todo
lua_State* L;
//
// Initialize your plugin data here
// It will be called while plugin loading
void pluginInit(HANDLE /*hModule*/)
{
L = lua_open();
}
//
// Here you can do the clean up, save the parameters (if any) for the next session
//
void pluginCleanUp()
{
lua_close(L);
}
...
extern "C" __declspec(dllexport) void beNotified(SCNotification *notifyCode)
{
switch (notifyCode->nmhdr.code)
{
case NPPN_SHUTDOWN:
{
commandMenuCleanUp();
}
break;
case NPPN_FILEBEFORESAVE:
{
hello();
}
break;
default:
return;
}
}
...
void hello()
{
int which = -1;
::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&which);
if (which == -1)
return;
HWND curScintilla = (which == 0)?nppData._scintillaMainHandle:nppData._scintillaSecondHandle;
TCHAR ext[MAX_PATH];
::SendMessage(nppData._nppHandle, NPPM_GETEXTPART, 0, (LPARAM)ext);
if (wcsstr((wchar_t*)ext, L".lua") != NULL) {}
else {
::SendMessage(nppData._nppHandle, NPPM_GETCURRENTLANGTYPE, 0, (LPARAM)&langtype);
if (langtype != LangType::L_LUA) return;
}
int nLength = ::SendMessage(curScintilla, SCI_GETLENGTH, 0, NULL);
CHAR * pBuffer = new CHAR[nLength + 1];
::memset((void *)pBuffer, 0, sizeof(CHAR) * (nLength + 1));
int nTempLength = (int) ::SendMessageA(curScintilla, SCI_GETTEXT, nLength + 1, (LPARAM)pBuffer);
//lua_State* L = lua_open();
if (luaL_loadbuffer(L, (char*)pBuffer, nLength, "LuaLint") != 0) {
const char *err = lua_tostring(L, -1);
//TRIM FIRST PART
int ccstart = 0;
for (int cc = 0; cc < (int)nLength; cc++) {
if (err[cc] == ':') {
ccstart = cc + 1;
break;
}
}
char linenumberstr[12];
for (int cc = ccstart; cc < (int)nLength; cc++) {
linenumberstr[cc - ccstart] = err[cc];
if (err[cc] == ':') break;
}
int line = atoi(linenumberstr)-1;
::SendMessage(curScintilla, SCI_GOTOLINE, line, NULL);
MessageBoxA(NULL, (char*)err + ccstart, "Lua Error", MB_OK);
}
//lua_close(L);
nTempLength = 0;
delete pBuffer;
}