[Plugin Update] LuaScript v0.6.0
LuaScript v0.6.0 is now available. Enhancements and new features:
- Better performance (up to 3x in some cases)
- More keys accepted when adding custom shortcuts (See here)
Ctrl+Spaceto auto-complete global values
- Auto-complete is more user-friendly
- Implement nearly all Scintilla and Notepad++ notifications
- Several more Notepad++ messages are now supported
- Added a toolbar icon to toggle the console
Source code/Github project: https://github.com/dail8859/LuaScript
As always comments/questions/concerns/bug reports are welcome.
Note: There is one change to the API that breaks backwards compatibility. The
"OnClose"notification now provides 0 parameters instead of 2. If you need the buffer id or file name of the file being closed you can catch the
"OnBeforeClose"notification and save the info.
Thank you for your great work. I appreciate it.
Thanks @dail this is a great tool! Any chance for these features:
- Include external .lua files within script?
- API to add/remove toolbar buttons (or even new sidebars/toolbars)
- Show scripts in menu
Glad you are finding it useful.
Include external .lua files within script?
This is already possible using Lua’s require().
You have to make sure the external files are in the right location or adjust the path that Lua searches for. In my startup script I have:
package.path = package.path .. ";" .. npp:GetPluginsConfigDir() .. "\\scripts\\?.lua" require "myfile" require "myotherfile"
My external files are in a subdirectory next to the
startup.luafile in a file called
API to add/remove toolbar buttons (or even new sidebars/toolbars)
In theory adding/removing buttons should be possible, though I don’t have any immediate plans to implement it. I assume by “sidebars/toolbars” you mean docked dialogs…though not impossible this probably won’t be added any time soon if ever.
Show scripts in menu
As most people are familiar with PythonScript adding an individual script to a menu…LuaScript works differently. You don’t add entire scripts to the menu, but rather register functions to be called. This is done by using AddShortcut. For example this script adds 2 new menu items.
@dail thanks for your help. I have been tinkering with LuaScript the past couple of days and I am quite excited by the results. I want to start porting my pythonscript plugins over to LuaScript.
FYI, since I am lazy, I dont want to modify my
plugins/config/startup.luaevery time I make a new script, so I played with your code above and am able to dynamically load the modules without having to add a new “require” every time.
-- Auto load all ".lua" script files from "plugins/config/lua" folder package.path = package.path .. ";" .. npp:GetPluginsConfigDir() .. "\\lua\\?.lua" local f = io.popen('dir "' .. npp:GetPluginsConfigDir() .. '\\lua\\*.lua" /b') for mod in f:lines() do require( mod:sub(0,-5) ) end
Question: Is it possible to register a function without a keyboard shortcut? (Just to appear in the menu, and not have to worry about finding an empty keyboard shortcut)
Thanks for a wonderful new addition to the NPP ecosystem.
Someone posted a similar snippet here.
Is it possible to register a function without a keyboard shortcut?
Yes, you can use an empty string or
Amazing! Thanks for all the great work. I would love to see some of these in your readme.md because as a newbie it was very time consuming to search forums and github to figure all this basic stuff out.
I added some additional example PRs on GitHub, I am happy to contribute to the readme if you wouldnt mind…
I would love to see some of these in your readme.md
I’d prefer to keep the readme on the lighter side as there is full documentation (though not perfect) here.
I added some additional example PRs on GitHub
Thanks I’ll try to take a look at them this weekend if I get some time.
I am happy to contribute to the readme if you wouldnt mind
Contributions are always welcome. As mentioned above, the documentation would probably be a better place to contribute…though that might not be immediately straight forward as the documentation is mostly auto-generated from these files.