Open LESS file with Notepad++ and auto compile when file saved.
Environment:
Windows 7
Notepad++ 6.5.5
Python Script 1.0.4.0
node.js
Lessc
:::python#Justincase,we'll clear all the existing callbacksnotepad.clearCallbacks([NOTIFICATION.FILEOPENED])notepad.clearCallbacks([NOTIFICATION.FILESAVED])class LessFileHelper: # Define the function to call just after the file is opened def fileOpened(self, args): bufferID = args['bufferID'] filename = notepad.getBufferFilename(bufferID) if filename[-5:] == '.less': notepad.activateBufferID(bufferID) notepad.setLangType(LANGTYPE.CSS) editor.setProperty('lexer.css.less.language', '1') # Define the function to call just after the file is saved def fileSaved(self, args): bufferID = args['bufferID'] filename = notepad.getBufferFilename(bufferID) if filename[-5:] == '.less': cmd = r'cmd/c%APPDATA%\npm\lessc.cmd "{0}" > "{1}.css"'.format(filename, filename[:-5])console.write(cmd+"\n")console.run(cmd)lessFileHelper=LessFileHelper()#...andregisterthecallbacknotepad.callback(lessFileHelper.fileOpened,[NOTIFICATION.FILEOPENED])notepad.callback(lessFileHelper.fileSaved,[NOTIFICATION.FILESAVED])
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Open LESS file with Notepad++ and auto compile when file saved.
Environment:
Windows 7
Notepad++ 6.5.5
Python Script 1.0.4.0
node.js
Lessc
Update: add -s option to lessc, or notepad++ will hangs at lessc compile error.
This implies you have %APPDATA%\npm\lessc.cmd, which is in the "Environment" that I didn't read.
Last edit: rUiSuATP 2014-09-15