I want to write Kamailio
Language Server for Visual Studio 2022, I Create a project in GitHub with below structure
And I use kamailio.tmLanguage.json
from https://github.com/miconda/vscode-kamailio-syntax/blob/master/syntaxes/kamailio.tmLanguage.json that I sure works for Visual Studio Code, So this grammar is correct
But I do not know why my code is not working correctly and does not highlight keyword?
My test with .kcfg
file extension like below
using Microsoft.VisualStudio.LanguageServer.Client;
using Microsoft.VisualStudio.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kamailio.VisualStudio
{
#pragma warning disable 649
public class KamailioContentDefinition
{
[Export]
[Name("kamailio")]
[BaseDefinition(CodeRemoteContentDefinition.CodeRemoteContentTypeName)]
internal static ContentTypeDefinition KamailioContentTypeDefinition;
[Export]
[FileExtension(".kcfg")]
[ContentType("kamailio")]
internal static FileExtensionToContentTypeDefinition KamailioFileExtensionDefinition;
}
#pragma warning restore 649
}
Any body can find my mistake?
All code to reproduce my problem is in GitHub
The good news:
It seems that all you need to do is add fileTypes to your kamailio.tmLanguage.json file, e.g.
"fileTypes": [
".cfg"
],
VS matches TextMate grammars to files based on these properties.
The bad news:
VS is apparently not smart enough to support other ways to filter when you are or aren't applicable. Specifically, it does not seem to support the firstLineMatch
property, so it will apply your grammar to all *.cfg files. If there is another way to filter which files are or are not applicable, I wasn't able to find it.