GithubHelp home page GithubHelp logo

Comments (5)

wellle avatar wellle commented on August 28, 2024 1

Fixed in #76. Thanks again!

And regarding your last comment, yes you're right, the context itself could definitely be smarter if it were implemented in a language specific way. But so far I opted for a general purpose approach and I'm hoping that it's going to be good enough 🤞

from context.vim.

wellle avatar wellle commented on August 28, 2024

Thank you! Do you want to open a PR to remove it?

from context.vim.

RanjitV17 avatar RanjitV17 commented on August 28, 2024

You please go ahead and fix this as part of your next planned release. Thank you so much for your great work. I use targets too.

May I know the reason why you wanted to skip the pre-processor directives in C code? IMO they add a lot of value to the context.

from context.vim.

wellle avatar wellle commented on August 28, 2024

Thanks, will do 👍

May I know the reason why you wanted to skip the pre-processor directives in C code? IMO they add a lot of value to the context.

Sure. The context currently works based on indentation. Because the pre-processor directives often have zero indentation that means that the context will effectively have no more context lines above. A bit hard to explain, here's an example. Consider this code: https://gist.github.com/wellle/981686e250e6bc1851b78fbcc6dc6b3a#file-v-c-L126

Currently the context of the highlighted line is

find_some_match(argvars, rettv, type) ··· {
    if (regmatch.regprog != NULL) {
        for (;;) {
            if (l != NULL) { ··· }
            else {

If I update the skip regex to effectively allow the # lines, then the context looks like this:

#ifdef FEAT_MBYTE

It might be possible to come up with more complex logic to allow both pre-processor directives and retain the full context from above, but that would be a lot of extra work. For now I had just decided to exclude those lines, as in my example above the result seems more useful. Hope that makes sense.

from context.vim.

RanjitV17 avatar RanjitV17 commented on August 28, 2024

Got it. I updated the skip regex to allow the # and I see the same behavior as you mentioned. I wasnt aware that the context update is heavily relying upon the indentation. I was thinking more in terms of C code only not in a generic way.
If this was made to work only with C, may be we can rely only on keywords + braces etc regex and not on indentation. Am I right here?

from context.vim.

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.