vim-go's syntactic highlighting makes vim super slow when dealing with long lines

Created on 13 Aug 2014  路  12Comments  路  Source: fatih/vim-go

I needed to run a quick test on a snipped of text, which I pasted directly into my code (+/- 800 chars), between quotes. Immediately, the whole editor became unresponsive, taking seconds to make simple moves with hjkl.

Disabling vim-go or syntactic highlighting makes the problem go away instantly.

Most helpful comment

I agree with @mgutz. I also have this in my vimrc:

set nocursorcolumn
syntax sync minlines=256
set re=1

All 12 comments

Probably due to large regex rules defined here: https://github.com/fatih/vim-go/blob/master/syntax/go.vim

You can try to use the old regex engine:

set re=1

Btw there are lots of settings for each syntax group that you can disable, does it help if you disable some of them?

https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt#L425

If yes maybe it's due one of those syntax groups that causes which we can try to solve

I've played a bit with settings and it seems that go_highlight_functions produces the major hog of performances. When disabling it and disabling/enabling syntactic highlighting, vim goes a lot faster (but still feels irresponsive).

With more testing, disabling go_highlight_structs at the same time makes the editor responsive again.

Those were added later additionally to the other syntax groups. What I can do is, disable them by default and let the users enable it.

Isn't there a way to optimize those, even if that means disabling them on long lines? They are very useful for syntax highlighting, and the very long line problem is a bit an edge-case since most developers will limit their code to 80 characters per line.

You are right. My idea was just an improvement over the current situation, which would make other people experience better for the sake of loosing a nice syntax for functions/structs .. etc. I'm going to change the default, but will not close this issue until we fixed that issue completely :)

It's not vim-go. Had same issues accidentally opening concatenated files. Try this in your .vimrc

" disable current line hilite
set nocursorline

" color to col 128
set synmaxcol=128

I agree with @mgutz. I also have this in my vimrc:

set nocursorcolumn
syntax sync minlines=256
set re=1

Following @mgutz advice effectively solves the problem. Any idea why disabling the syntax groups speeds up vim like that?

Thanks for your help to you two!

Coloring is expensive, and Vim is really bad at rendering colors (I have to use MacVim, it's slow under Terminal). I think that's why it's slow.

For the record, I only had 4 functions colored by the syntax groups. Also, it's really the set synmaxcol=128 that boosts everything, enabling current line highlighting does not seems to affect performance.

Thanks again, and keep up the good work at Koding @fatih!

@Artemis2 thank you too for the good feedback on the issue. Happy that I could help you! :)

I've played a bit with settings and it seems that go_highlight_functions produces the major hog of performances. When disabling it and disabling/enabling syntactic highlighting, vim goes a lot faster (but still feels irresponsive).

With more testing, disabling go_highlight_structs at the same time makes the editor responsive again.

Function and function calls both slow down completion. For me function call and fields highlighting slowed down.

" Highlight Function Calls
let g:go_highlight_functions      = 1
let g:go_highlight_function_calls = 1

" Highlight struct fields 
let g:go_highlight_fields = 1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joeblubaugh picture joeblubaugh  路  3Comments

orlangure picture orlangure  路  3Comments

mnarrell picture mnarrell  路  3Comments

preslavmihaylov picture preslavmihaylov  路  3Comments

surest picture surest  路  3Comments