bruderstein / PythonScript

Python Script plugin for Notepad++
http://npppythonscript.sourceforge.net/
GNU General Public License v2.0
356 stars 66 forks source link

permanent setting #335

Open DomOBU opened 7 months ago

DomOBU commented 7 months ago

Hello,

I'm a new PythonScript user. I'm not a geek and I don't know Python.

On the Notepad++ forum I was recommended to install PythonScript to solve a CSS problem with Lexilla. A command was provided. I tested it in the console; it's operational but temporary. I haven't found a way to make it permanent when I launch Notepad++. How would this be possible?

Thank you for your reply.

Ekopalypse commented 7 months ago

I do not know what "command" you are referring to but to make something permanent you usually create a script and name it startup.py. It must be called startup.py and it shouldn't be the one that comes with the plugin itself. Change to configuration from LAZY to ATSTARTUP and then this script will run every time Npp starts.

DomOBU commented 7 months ago

Thank you for your reply.

I have created a file containing :

I've :

Without success.

Ekopalypse commented 7 months ago

No, the startup.py that is supplied with the plugin must remain. The "user" startup.py must be created in addition. the setProperty function must be called for both editor instances

editor1.setProperty...
editor2.setProperty...

the editor refers to the currently active instance and would only be set for this instance.

Do you have changed the Python Script Configuration from LAZY to ATSTARTUP?

Ekopalypse commented 7 months ago

No, this is a Lexer property that you want to set. This must be done differently. You need to register a callback for bufferactivated and then set the property. This should still be done in the user startup.py.

def on_buffer_activated(args):
    # check if the file needs to have the setting and then
    # call editor.setProperty('lexer.css.scss.language', 1)
    # something like
    # if editor.getLexer() == whatever_number:
    #     editor.setProperty('lexer.css.scss.language', 1)

notepad.callback(on_buffer_activated, [NOTIFICATION.BUFFERACTIVATED])