Open errosan opened 6 years ago
@errosan are you using visual studio?
Looks like Pygments (the library we use for language detection) already supports detecting language
attribute from Page
tags:
We might be not correctly using this information from pygments, or truncating the language name since we only support a single language while Pygments supports nested languages: https://bitbucket.org/birkenfeld/pygments-main/src/e63f7b68898445836091b51cfa81bf0613fb05eb/pygments/lexers/dotnet.py#lines-504
Here's where we use Pygments to detect the language via lexer.name
:
https://github.com/wakatime/wakatime/blob/ddc7cb3ed4626aa89a3bab2015cd2bb0b5c8754d/wakatime/stats.py#L70
Closing due to the lack of response, feel free to reopen @errosan.
@gandarez Yes, Visual Studio. Please reopen.
Here's a screenshot of our server-side language rule overrides related to asp and vb:
That means we're not overwriting the language server-side. Probably what's happening is the VB.NET Lexer
is using priority 0.5
:
wakatime/packages/pygments/lexers/dotnet.py#L470
While the C# Lexer
has a max priority of 0.2
:
wakatime/packages/pygments/lexers/dotnet.py#L513
So Pygments prefers VB.NET
over C#
.
@alanhamlett would be possible to call the api and add an extra parameter to force the language (using the parameter language)? I think the visualstudio extension
can read the first line of the file and decide if it's C#
or VB.NET
.
https://github.com/wakatime/wakatime/blob/master/wakatime/heartbeat.py#L39
Is this still happening now that we've moved from Pygments to chroma?
We can have the Visual Studio extension pass --language "VB.NET" | "C#" | "ASP.NET"
to wakatime-cli if it detects one of those languages with certainty. We should only add --language
for those three languages, because it disables language detection in wakatime-cli.
The plugin is reporting ASPX as VB.NET language. ASPX pages have a language declaration at the beginning of the file, it would be better to use the language specified since aspx pages can be either language, vb or c#.
<%@ Page Title="" Language="C#" %>