felipeochoa / rjsx-mode

A JSX major mode for Emacs
https://github.com/felipeochoa/rjsx-mode
MIT License
641 stars 32 forks source link

fontify is very slow and sometimes it freeze Emacs #92

Open shackra opened 6 years ago

shackra commented 6 years ago

I have test this in js-jsx-mode and is even worst.

When writing code, fontify takes a fraction of a second per key press to kick in and sometimes when there is more lines of code Emacs freeze when fontify is happening.

Here is a video https://streamable.com/vkslf

This is what is turned on on my buffer at the time of recording:

Enabled minor modes: Aggressive-Indent Async-Bytecomp-Package
Auto-Composition Auto-Compression Auto-Encryption Auto-Fill
Blink-Cursor Cl-Old-Struct-Compat Column-Number Company
Company-Posframe Company-Statistics Cursor-Sensor Delete-Selection
Diff-Auto-Refine Dired-Omit Display-Line-Numbers Eldoc Electric-Indent
Electric-Pair Emojify File-Name-Shadow Flycheck Flyspell Font-Lock
Git-Gutter Global-Aggressive-Indent Global-Auto-Revert Global-Company
Global-Eldoc Global-Emojify Global-Font-Lock Global-Git-Commit
Global-Git-Gutter Global-Hungry-Delete Global-Magit-File
Global-Subword Global-Undo-Tree Hes Highlight-Numbers Hungry-Delete
Indium-Interaction Ivy Js2-Imenu-Extras Js2-Refactor Keyfreq
Keyfreq-Autosave Line-Number Lsp Lsp--Managed Lsp-Ui Magit-Auto-Revert
Magit-File Mouse-Wheel Override-Global Pcre Prettify-Symbols
Projectile Recentf Save-Place Savehist Shackle Shell-Dirtrack
Show-Paren Subword Telephone-Line Tex-Pdf Transient-Mark Undo-Tree
Winner Ws-Butler Ws-Butler-Global Yas

(Information about these minor modes follows the major mode info.)

JSX-IDE mode defined in ‘js2-mode.el’:
Major mode for editing JSX code.

To customize the indentation for this mode, set the SGML offset
variables (‘sgml-basic-offset’ et al) locally, like so:

  (defun set-jsx-indentation ()
    (setq-local sgml-basic-offset js2-basic-offset))
  (add-hook 'js2-jsx-mode-hook #'set-jsx-indentation)
felipeochoa commented 6 years ago

Not sure what I'm supposed to see in that video. Can you explain? Haven't tested, but I'm guessing you'll have problems with Aggressive-Indent. rjsx re-parses the entire buffer every time it needs to indent, so that's always going to cause slowdowns. Can you try setting (setq-local indent-line-function 'js-jsx-indent-line) to see if that fixes things?

shackra commented 6 years ago

Not sure what I'm supposed to see in that video. Can you explain?

Sure, I meant to point the fraction of second when the text is written into the buffer and is all white and when fontify kicks in. I have had experience sometimes that slows down typing a lot. In the video test above Aggressive Indent was supposed to be off.

I will follow your recommendation and test again.

jqtruong commented 5 years ago

i'm having the issue with fontify as well. i don't have a video to show, but put simply, when i move my cursor and nearing a lot of jsx code (i.e. the html tags), it gets sluggish. i have had that problem with web mode as well, and it seemed rjsx does a better job.

anyway, wondering if @shackra is having that kind of problem too, or is it the common experience? i evaluated the statement @felipeochoa mentioned, but still sluggish. when i turned rjsx mode off, of course it was flying...

shackra commented 5 years ago

This is issue is due to this bug on LSP https://github.com/emacs-lsp/lsp-mode/issues/588

Do you use LSP?