Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endif without if in context.vim file #74

Closed
RanjitV17 opened this issue Jun 20, 2020 · 5 comments
Closed

endif without if in context.vim file #74

RanjitV17 opened this issue Jun 20, 2020 · 5 comments

Comments

@RanjitV17
Copy link

In file autoload/context/context.vim, in s:limit function, there is an extra endif towards the end without if.

@wellle
Copy link
Owner

wellle commented Jun 22, 2020

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

@RanjitV17
Copy link
Author

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.

@wellle
Copy link
Owner

wellle commented Jun 26, 2020

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.

@RanjitV17
Copy link
Author

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?

@wellle
Copy link
Owner

wellle commented Jul 11, 2020

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 🤞

@wellle wellle closed this as completed Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants