Code Monkey home page Code Monkey logo

Comments (2)

jeff-hykin avatar jeff-hykin commented on June 12, 2024

(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.

alexdima avatar alexdima commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.