p0358 / notepadpp-CodeStats

Notepad++ plugin for Code::Stats (https://codestats.net)
Other
39 stars 22 forks source link

BaanC is detected as plain text #6

Closed LunaticManiac closed 2 years ago

LunaticManiac commented 5 years ago

My Programming Language is detected as plain text, but it should be BaanC. Instead of trying to detect the language by file type, using the lexer (syntax highlighting) would be more accurate.

In case you use python script (that's a plug in) just type in the console:

editor.getLexerLanguage() 'baan'

It might be a good idea to make the conversion from the language the lexer gives in a file a user can change, as this would help small languages.

p0358 commented 5 years ago

What's the file extension for this language? I could add it to language mapping directly for everyone. Don't remember what's the current priority (will need to look into updating this plugin finally), but iirc it was also somehow taking N++'s syntax highlighting language into account. (EDIT: glancing at the code it uses that if it doesn't find a match in extension mapping file) The problem with that is that it supports significantly less languages. I think what could also be considered is a switch on whether unknown language should be reported to backend as plaintext or directly via extension (which can then be mapped in backend to something else). Can you clarify what do you mean in the last sentence? If it's file for mapping lexer-detected language into something else statically, then I don't think that's really a good idea. Unless you mean the custom language definitions.

LunaticManiac commented 5 years ago

Hi!

Thanks for your quick feedback.

BaanC uses sometimes .bc files, and sometimes files without file ending. This really sucks, but i can't change it - therefore I would recommend to change it by syntax hightlighting as i enable it anyway.

I mean the custom language definitions.

p0358 commented 5 years ago

I mean the custom language definitions. But by custom do you mean simply manually selecting language in toolbar -> Language, one of predefined ones? That would explain your quote in the first post:

editor.getLexerLanguage() 'baan' Or do you mean custom user-defined languages? (toolbar -> Language -> Define your language...) It's also possible to support those.

As for lexer language not being used at all for detection, I've created issue #11

p0358 commented 2 years ago

.bc to BaanC extension mapping was added as of https://github.com/p0358/notepadpp-CodeStats/commit/9f8c45040cbb6d5f77cd3396d1497088d56050e0

Detecting language based on selected lexer language rather than just extension is now supported in latest version as well.