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

Inline error highlighting hook #71

Open
jordwalke opened this issue Oct 31, 2013 · 8 comments
Open

Inline error highlighting hook #71

jordwalke opened this issue Oct 31, 2013 · 8 comments

Comments

@jordwalke
Copy link

It would be great to have a hook for highlighting errors inline. If this is implemented, I'll create a JavaScript error/lint highlighter for Vico.

Here's a nice way to visualize errors:

errorhighlighting

@Shadowfiend
Copy link
Member

You actually should be able to do most of this by using the syntax highlighting. You should be able to add a scope to a given character range and then have the theme set certain properties based on that. Unfortunately wavy underlines aren't part of the supported options, I don't think, mostly because they're not built in to Cocoa.

I added some of this experimentally to vico-ensime a while back: https://github.com/Shadowfiend/vico-ensime.vicobundle/blob/master/ensime-status-commands.nu . I chose the scope severity.(warning|error), I believe. I did have to edit the theme file directly; it would probably be ideal if there were a default set for those theme settings.

Notably, spellcheck underlines have switched to dashed underlines instead of wavy, so that may be a possibility.

@Shadowfiend
Copy link
Member

I've tagged this feature, which I'll use to track a built-in way of doing this highlighting.

If you have access to this information, it'd be handy if you could see what if any scopes TextMate uses for these, if TextMate has this ability.

@jordwalke
Copy link
Author

Oh wow - that's awesome. I'm not set on wavy underlines - dotted probably look even better IMHO. So then I just need the ability (some kind of hook) to be able to reevaluate the syntax on every keystroke I believe (with some kind of delay + debounce). If your vico-ensime plugin already does this then I can just copy it and begin writing the javascript highlighter.

IIRC: There are some textmate themes with error colors - so we could use those - but would there be a way to just use the "misspelling dotted underline" IMHO it looks the best! Can we simply mark a region as "incorrectly spelled"?

@Shadowfiend
Copy link
Member

I'm tempted to leave it up to the theme rather than forcing a setting on the user, though I'm open to suggestions.

I still need to look into exposing the dotted underline style, however.

@jordwalke
Copy link
Author

Yeah - I always wished it was themeable in Macvim.

What do I have to do to get the script to be reevaluated continually (after some elapsed time of non-typing?) Where's the place I can start looking?

@Shadowfiend
Copy link
Member

The Vico API docs are actually still reasonably up-to-date. caretDidMove is the event that is current exposed that is perhaps best suited to this, though it'd be nice to expose an event for the actual text changing (say, when you leave insert mode). Right now it will be a bit noisy, since it'll be all caret movement, not just that caused by typing.

For the part where you wait a certain amount of time, you can use NSTimer to schedule a selector invocation after a certain interval, and use invalidate on the timer to stop it if the user takes action in the meantime.

@jordwalke
Copy link
Author

I started playing with this and it looks like some of the example scripts are outdated.
Do you know why ((document fileURL) path) no longer works? What's the new way to get the path of a document?

@Shadowfiend
Copy link
Member

I think you want ((current-document) fileURL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants