Function List for language with External Lexer
-
In the past (6.x series npp), I have been able to use the FunctionList feature for a language parsed by the GedcomLexer plugin. This required using the langID=“nn” for the external lexer. At that time it wasn’t possible to associate a parser definition with the language’s file extension - and that appears to still be the case.
My question is, how does an external lexer plugin determine its langID through the plugin/lexer interface? In general, its value should be L_EXTERNAL plus some offset, but the offset could be affected by loading multiple lexers and if Scintilla adds more languages in the future. The message NPPM_GETBUFFERLANGTYPE seems to do the trick but it requires a BufferID. You would think that the langID would be available somehow to the plugin as a constant.
-
So after digging into this, a solution did materialize. I’ll share it in case someone else may need it some day…
The message NPPM_GETLANGUAGENAME can be sent to Npp to request the language name string for a value of the LangType enumeration. This enumeration ends with the value L_EXTERNAL which corresponds to the first external lexer. By iterating from L_EXTERNAL to the limit of external lexers (+15), the (non-localized) name of each external lexer is retrieved and compared to the desired lexer’s name - on finding a match the LangType (or langId) is known. If the supplied LangType value exceeds the range of defined lexers, the string “Normal text” is returned as the language name.
NPPM_GETLANGUAGENAME was added to Npp in version 5.9.3
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login