Community
    • Login

    [Plugin Update] LuaScript v0.6.0

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    8 Posts 3 Posters 4.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dailD
      dail
      last edited by

      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+Space to 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

      Download: https://github.com/dail8859/LuaScript/releases/tag/v0.6.0
      Documentation: https://dail8859.github.io/LuaScript/index.html
      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.

      1 Reply Last reply Reply Quote 1
      • YaronY
        Yaron
        last edited by

        Hello dail,

        Thank you for your great work. I appreciate it.

        Best regards.

        1 Reply Last reply Reply Quote 0
        • Ethan PiliavinE
          Ethan Piliavin
          last edited by

          Thanks @dail this is a great tool! Any chance for these features:

          1. Include external .lua files within script?
          2. API to add/remove toolbar buttons (or even new sidebars/toolbars)
          3. Show scripts in menu
          dailD 1 Reply Last reply Reply Quote 0
          • dailD
            dail @Ethan Piliavin
            last edited by

            @Ethan-Piliavin

            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.lua file in a file called scripts

            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.

            1 Reply Last reply Reply Quote 0
            • Ethan PiliavinE
              Ethan Piliavin
              last edited by

              @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.lua every 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.

              1 Reply Last reply Reply Quote 0
              • dailD
                dail
                last edited by

                @Ethan-Piliavin

                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 nil

                1 Reply Last reply Reply Quote 0
                • Ethan PiliavinE
                  Ethan Piliavin
                  last edited by

                  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…

                  1 Reply Last reply Reply Quote 0
                  • dailD
                    dail
                    last edited by

                    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.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors