NP Rooski  Z
NP Rooski Z

Reputation: 3657

vim almost hangs with 100 line typescript file

Intellij idea 2020.1 is extremely slow as well.

  1. From a language perspective what makes typescript so slow compared to javascript with editors and compilers alike? What are they spending time on?
  2. How can I fix vim?
» vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 10 2020 20:32:49)
macOS version
Included patches: 1-503, 505-680, 682-2292
Compiled by [email protected]

Upvotes: 3

Views: 1699

Answers (3)

PatientOtter
PatientOtter

Reputation: 2298

This was mentioned in the Vi/Vim exchange here.

It appears you need to explicitly set the regexp engine somewhere if you're on OSX. Personally, I put

" ~/.vimrc
set regexpengine=0
syntax on
filetype plugin indent on

and then specifically for typescript I have

" ~/.vim/ftplugin/typescript.vim
setlocal regexpengine=2

You can test it out for yourself by putting vim: re=2 in your modeline (provided you have this enabled set modeline) and then opening the file in Vim to see if it hangs.

You can learn more about regexpengine if you open vim and type :help 're'?

                        *'regexpengine'* *'re'*
'regexpengine' 're' number  (default 0)
            global
    This selects the default regexp engine. |two-engines|
    The possible values are:
        0   automatic selection
        1   old engine
        2   NFA engine
    Note that when using the NFA engine and the pattern contains something
    that is not supported the pattern will not match.  This is only useful
    for debugging the regexp engine.
    Using automatic selection enables Vim to switch the engine, if the
    default engine becomes too costly.  E.g., when the NFA engine uses too
    many states.  This should prevent Vim from hanging on a combination of
    a complex pattern with long text.

Sorry for not fully understanding why explicitly calling out the engine prevents Vi/Vim from hanging on OSX but it worked for me and I've seen it posted throughout stack exchange forums. Please comment if you fully understand why or if some other permanent fix has been provided.

Some helpful problem solving links:

Upvotes: 7

BradMorris
BradMorris

Reputation: 24

brew install vim

The default macos version is old and buggy.

Upvotes: -2

NP Rooski  Z
NP Rooski Z

Reputation: 3657

Something with the syntax highlighting for typescript making it very slow. syntax off on vim made it back to normal. I would still want syntax highlighting to work, so not really an answer.

Upvotes: 0

Related Questions