Thanks for reaching out. this issue typically arises because the default SQL language services configured to handle the .sql File extension as a built in behavior and your extensions registration needs to be prioritized or explicitly associated with a different content type.
Here is a solution based on the standard mechanism for language services and editor association in the Visual Studio SDK, which utilizes the PKGDEF registration format you provided.
Solution: by passing the default language services
to resolve this you need to adjust 2 main areas in your PKGDEF file registration:
- Associate your custom service with a distinct content type.
- Ensure your custom editor/language service is prioritized for the .sql extension over the default.
Define a custom content type
first you need to tell the editor factory that your language service handles a specific content type which you should define. Although your current PKGDEF shows the custom language association, let's explicitly define a unique content type for your service.
In your PKGDEF (all the equivalent registry keys) ensure you have a registration for a custom content type. This is usually done under the editors section. Since you are trying to override the default SQL experience you will need to link the .sql extension to a content type other than the default SQL or code type.
Configure your custom language service
you need to explicitly register your language service to handle a file extension with higher precedence than the default service
in your provided PKGDEF you have:
[RootKeys\Language\Language Services\My Custom Language]
//....
"Extensions" = ".customext1;.customext2"
//....
you must modify this line to include .sql:
[RootKeys\Language\Language Services\My Custom Language]
@"={YOUR_LANG_SERVICE_GUID}"
"Extensions"=".customext1; .customext2;.sq
"Package" = "{YOUR_PACKAGE_GUIDE}"
"CodeSenseDelay"=dword:0000001f4
//... (rest of language service settings)
by adding .sql to the extensions property of your my custom language registration, you are telling the environment that your language service can handle .sql files.
Key point: priority
the environment typically chooses the language service with the highest priority or the one most recently loaded that claims the file extension.
If your package loads before or has a higher priority settings(sometimes controlled by the D word value in the editors\extensions section if applicable) then the building SQL service your language service will be used.
- The builtin SQL language services often hardcoded to be the default for the .sql extension. Simply adding .sql to your extensions list might be enough to override it if your package is loaded correctly. If not the recommended solution is to define a custom content type for your language and then associate the .sql extension with your custom content type instead of default SQL content type.
Tool menu visibility control
the tool menu you want to hide is likely tied to the UI context of the default SQL editor/language service. Since you are attempting to completely bypass the default SQL service by prioritizing your own the default services UI context should not become active when a .sql file is opened.
You already have this section to activate your custom extensions UI context:
// UI Context Rule
[@"{YOUR_UI_CONTEXT_GUID}"]
"MyEditorContext"
"Expression" = "{MyEditorActive}"
"MyEditorActive"= "ActiveEditorContentType: MyContentType" //should be custom Content type handled by your editor.
As long as your editor factory successfully claims the .sql file and activates your custom language service the default SQL editor's UI context should not be activated. Your custom tool menu which you have registered to appear when your context is active will then be visible.
After making these changes to your PKGDEF file you will need to reinstall your package to update the system registry, which should then successfully associate your custom language service and editor factory with the .sql files, bypassing the default SQL service and enabling your custom tool menu.
Please let us know if you require any further assistance we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer".