Comments (2)
(I'm just a random guy that does a lot of highlighting not a VS Code contributor btw)
how can I achieve this highlighting
There's only two tools in Textmate parsers (VS Code and many editors use Textmate grammars for highlighting).
- The pattern (which can only match one line)
- The pattern range (which has a start pattern, which can only match one line, and an end pattern, which can only match one line)
Thats it.
So you could get creative, use a pattern range, have it start with group 1, have it end when it sees a blank line, and then restrict what patterns are allowed inside of the pattern range.
Here's some code snippets to show a little bit of what I mean.
"What if the start-trigger/start-pattern requires multiple lines to be identified?"
Well then you're straight outta luck. Textmate parsers are hacky, very-limited things. Its actually more amazing that they work at all. Stuff like the C++ pre-processor just straight up break it with no good workaround. Its sad but that's how it is. One day (maybe) VS Code will switch to the Tree Sitter Parser and these problems won't exist.
from vscode-textmate.
I can't use a language server since this needs to work in VSCode web, how can I achieve this highlighting?
You could try using semantic tokens. There you can look at the entire file contents when creating them, not just one line at a time, looking for patterns. You can create an extension that uses a nodejs language server and our libraries for that. They are fit for running in a web worker, and creating a new worker on the web or a new nodejs process on the desktop. In our codebase, you can take a look at css.
from vscode-textmate.
Related Issues (20)
- Add Option to Format in often used match expression parts HOT 1
- Vscodes TextMate doesn't support the any scope selector `*` in `injections` HOT 2
- lacks of some type export on latest version
- Unable to exclude elements with "textmate" scope selectors in custom themes HOT 1
- Textmate engine bug for `\k<>` backreferences HOT 2
- Please add back IRawGrammar as top level export!
- YAML Syntax interprets IP-Style Strings as numbers HOT 1
- Tagging releases HOT 4
- Cannot read property 'INITIAL' of undefine.
- Consider using end pattern as bail out for embedded languages HOT 12
- Scopes on Recursive Regex Cause Problems
- Nested `begin`/`while` rules do not continue past begin match HOT 3
- Misclassification of PHP syntax tokens HOT 3
- How to find all local variables? HOT 2
- JSON grammar without `filePath` parsed incorrectly as PList
- How to make the embedded language have corresponding language id
- Clarification about concurrent tokenization using multiple themes
- PHPdoc highlighting issue HOT 1
- Incorrect 'no more matches'? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-textmate.