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

Implement highlighting of evaluated code #21

Merged
merged 2 commits into from
Apr 13, 2017
Merged

Implement highlighting of evaluated code #21

merged 2 commits into from
Apr 13, 2017

Conversation

gusano
Copy link
Member

@gusano gusano commented Mar 23, 2017

This is the first time I try to write vimscript ever so please bear with me if I did something stupid : )

This implements highlighting of evaluated code (line or block) (term=reverse cterm=reverse so everyone is happy! ;)
It has to be enabled with let g:scFlash = 1 in your .vimrc.

It works but it looks like there's a small delay between code evaluation and highlighting..
Could it be because of vim redrawing?

Any hints or suggestions are more than welcome!
Please test it!

ps: the changed files have mixed indention styles so I tried my best to not mess it up, but new code uses spaces, sorry :)

Fix #12
Fix sbl/scvim#42

@eirikblekesaune
Copy link
Member

The sluggishness could be that the sleep function freezes the execution. (?)
Maybe you could try the new asynch timer in Vim8 instead?

Something like:

let highlightTimer = timer_start(150, 'clearmatches')

@gusano
Copy link
Member Author

gusano commented Mar 23, 2017

@blacksound thanks that's definitely better!

@eirikblekesaune
Copy link
Member

Maybe it would be good to add a version detect for this, so that we keep compatibility with Vim < 8.0? v:version is commonly used to find the running version of vim, and the version value for vim 8 is 800.
If the user is running v:version < 800 we call sleep, else the timer_start is used.

A quick look at the vim source code also suggests that the "timers" attribute is set if the version is compiled with timers, so you could try an alternative check with has("timers"), and see if that works.

@gusano
Copy link
Member Author

gusano commented Mar 24, 2017

@blacksound Thanks, much appreciated!

redraw
sleep 150m

" timers were introdiced in vim-8.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo 'introduced'

If possible, i.e. if vim was built with timers support (>=0.8)
@gusano
Copy link
Member Author

gusano commented Mar 24, 2017

@blacksound Fixed!

@gusano
Copy link
Member Author

gusano commented Apr 3, 2017

Anyone tested that one? I find it pretty useful, even if it's a bit laggy.. I'd love to know if that works on osx.

@bagong
Copy link
Contributor

bagong commented Apr 3, 2017

Hi @gusano,

I gave it a try on MacOS Sierra/iTerm2/homebrew vim 8 (had to think about how to get that PR into my setup first ;). Solved it with doing in .vim/bundle/scvim:

git checkout origin pull/21/head:highlight
git checkout highlight

)

With light testing I can say it seems to work well in my setup. Thanks!

@gusano
Copy link
Member Author

gusano commented Apr 4, 2017

@blacksound bump =)

@eirikblekesaune eirikblekesaune merged commit b45ebc7 into supercollider:master Apr 13, 2017
@eirikblekesaune
Copy link
Member

Sorry for the delay. Merging now.

@K0F
Copy link

K0F commented Apr 18, 2017

It works great! Thanks a lot for small - yet very important improvement.

@gusano
Copy link
Member Author

gusano commented Apr 18, 2017

@K0F welcome = )

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

Successfully merging this pull request may close these issues.

4 participants