MIB file (SNMP) syntax highlighting [User Defined Language]
-
I work on a lot of SNMP projects where I need to read MIB files. I could not find a UDL for MIB files anywhere on the net, but I found a few forum posts here and there where people request it. In the end I decided to make one for personal use, and figured i might as well share it.
Download here: pastebin.com (save as i.e.
userDefineLang-MIB.xml
, and place in directory.\Notepad++\userDefineLangs
)It’s very rough around the edges, and does not do folding (I could not get it to work due to the complexity of delimiters in ASN.1). It’s purely for visual syntax highlighting to ease on-screen reading of MIB files.
-
wonderful :) I was looking for MIB/SNMP compatibility today :)
But the BackColor is not working associated to DarkTheme :
[https://github.com/Ludomancer/VS2015-Dark-Npp](link url) -
@Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:
But the BackColor is not working associated to DarkTheme
User Defined Languages do not honor themes: if you change your theme, it does not change the coloring for the UDL syntax highlighter. You can use Language > User Defined Language > Define Your Language… to change the colors for your specific UDL.
-
@Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:
wonderful :) I was looking for MIB/SNMP compatibility today :)
Why use a UDL? The default theme already has ASN.1 and that can be copied into (and adjusted for color) into your preferred theme (as @PeterJones mentions). I did this for Obsidian Theme which I use exclusively.
You may need to associate your MIB extension with ASN.1 for Notepad++ to recognize the file on opening:
Settings => Style Configurator… =>
Cheers.
-
@Vincent-Duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:
wonderful :) I was looking for MIB/SNMP compatibility today :)
You may also want it in the function list. I’ve added in my
$(NPP_INSTALL_DIR)/functionList.xml
file:<association id="asn1_syntax" langID="65" />
[…] then down in the parsers section:
<!-- ============== [ ASN.1 ] --> <parser displayName="ASN.1" id ="asn1_syntax" commentExpr="(?x) (?m-s:\-\-.*$) # Single Line Comment " > <classRange mainExpr="(?:^\s*\w+\s+::=\s+[\w-]+\s*)"> <className> <nameExpr expr="(?:\s*)\K[\w]+"/> </className> <function mainExpr="(?:^\s*\w+\s+)"> <functionName> <funcNameExpr expr="(?:\s*)\K[\w]+"/> </functionName> </function> </classRange> <function mainExpr="(?:^\s*\w+\s+OBJECT-\w+[\n\s]*)"> <functionName> <nameExpr expr="(?:\s*)\K[\w]+"/> </functionName> </function> </parser>
Cheers.
-
@vincent-duvernet said in MIB file (SNMP) syntax highlighting [User Defined Language]:
wonderful :) I was looking for MIB/SNMP compatibility today :)
But the BackColor is not working associated to DarkTheme :
Just stumbled on this UDL but you’re right it doesn’t come up very well in Dark Mode.
So I tweaked it for DM here: at pastebin, with the URL: zC7fCauP
(Sorry for the lack of a hyperlink, spam filters were blocking me.)
Hope it can be useful.
Cheers -
@unknown14725
Long ago I worked with MIB files for ~1 year and wrote the lexamples plugin that provides MIB files and GNU Makefiles lexing.
This is an external DLL lexer, not user defined language.I used it for writing GNU Makefiles for years. I haven’t touched MIB for 7 years.
Haven’t used it for a while, it is possible that it was broken in latest NPP version but it should be possible to test the lexing quality with old NPP version. If the lexing is superior we could consider porting it to newer NPP version.
-
Haven’t used it for a while, it is possible that it was broken in latest NPP version
This definitely won’t work:
ILexer *LexerMib::LexerFactoryMib() { return new LexerMib; } ILexer *lexamples_create_mib_lexer() { return LexerMib::LexerFactoryMib(); }
As other plugin developers are finding out, Scintilla 5 moved the lexer interface to the Lexilla library. The new API is ultimately better for external lexers — basically, every lexer is external now — once you get the hang of it.
-
@rdipardo said in MIB file (SNMP) syntax highlighting [User Defined Language]:
This definitely won’t work:
That is why I said “test the lexing quality with old NPP version”.
if there is interest, I may invest the time. Or since the source code is available then maybe someone else will take over.If everyone is happy with UDL, great.