Syntax Highlighting for Custom Filetype conflicts with Textmate bundle
已完成
We have a custom internal language and have run into the following problem:
- We import a Textmate bundle that gives syntax highlighting for the language.
- We register the language as a custom FileType so that we can trigger a FileWatcher based on this new file type.
- The syntax highlighting added in #1 stops working. I assume this is because the default syntax highlighting for a new FileType overrides the custom syntax highlighting I added.
I looked for a while, and could see no way to fix this issue. Is there a way to disable the default syntax highlighting for a custom FileType so that our Textmate highlighting works? Or, alternatively, is there a way to register a FileWatcher for a particular file extension without declaring a custom FileType for that extension?
This problem seems like a design flaw, where two features (Custom FileType and Custom Syntax Highlighting) conflict with one another in an unexpected way.
请先登录再写评论。
Hi Andyk,
I cannot reproduce it so far. I've installed a custom textmate bundle for haskell (this also adds custom FileType) and configured a file watcher for this fileType - it works as expected. Do you create an extra fileType in addition to one added by the textmate bundle?
The TextMate bundle doesn't create a custom FileType (didn't know that was a possibility). So I'm just manually creating the custom FileType after installing the bundle.
Actually, here is the bundle for you to try, since it's an Open Source project: https://github.com/cockroachdb/cockroach/tree/master/pkg/sql/opt/optgen/lang/support. It's the textmate/OptGen.tmbundle directory at that link. It's meant to be used with .opt files, such as those in this directory: https://github.com/cockroachdb/cockroach/tree/master/pkg/sql/opt/norm/rules.
Looking in the optgen.tmLanguage file, there is a section that declares the filetype, but I don't see Goland automatically creating a custom FileType when importing the bundle:
Sorry, I confused myself: haskell fileType wasn't added by textmate bundle, it is bundled in the IDE. So installing textmate plugin doesn't really add a fileType. I found an issue about missing ability to associate textmate bundle with a file type: https://youtrack.jetbrains.com/issue/PY-15356 The only workaround I can see at the moment is to specify 'File Type = Files Supported via Textmate Bundles' in the File Watcher settings. This will invoke the file watcher for all supported types, then you can add a logic to a file watcher based on file extension.
OK, that workaround seems to work well enough. Another workaround I found was to create a scope similar to `file[cockroach]:pkg/sql/opt//*.opt`(i.e. all .opt files in the project). Thanks for the help.
I am faced with the same problem: highlighting imported by TextMate Bundle doesn't work for registered custom language type.
the issue can be solved by extending the `editorHighlighterProvider` to set TextMate Bundle's Highlighter as its syntax highlighter explicitly.
The two implementation classes are not available by default, is there a dependency to pull in ? I cannot find it on google :(
Please see: https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#bundled-and-other-plugins