Describe the bug
When lsp-mode is turned on in js2-mode and derived modes, like rjsx-mode, typing is a painful experience full of lag (1 or 2 seconds or even more depending on how fast you are writing code).
To Reproduce
Steps to reproduce the behavior:
emacs -qsrc/components/Invoice/detalle.jsx:disabled under (use-package lsp to disabled lsp-mode, then try to reproduce, you will see that typing is smooth again.Expected behavior
no lag at all like typing in large files with go-mode or python-mode and lsp-mode running.
Which Language Server did you use
this is included with the configuration.
OS
GNU/Linux (Arch)
This happens with lsp-mode version 20181228.819 and only on js2-mode derived modes.
The issue is caused by the fact that the typescript language synchronization is full and when you press and hold a key lsp-mode has to send whole file content as a message which is problematic. We should introduce some mechanisim for handling that case or even https://github.com/emacs-lsp/lsp-mode/issues/362
@shackra I would suggest switching to the other javascript language server which seems to be smarter and also supports partial updates(these lines will fix the perf issue).
(setq lsp-clients-typescript-server "typescript-language-server"
lsp-clients-typescript-server-args '("--stdio"))
@alanz @MaskRay
// src/typescript-service.ts
public async textDocumentDidChange(params: DidChangeTextDocumentParams): Promise<void> {
const uri = normalizeUri(params.textDocument.uri)
let text: string | undefined
for (const change of params.contentChanges) {
if (change.range || change.rangeLength) {
throw new Error('incremental updates in textDocument/didChange not supported for file ' + uri)
}
text = change.text
}
if (!text) {
@shackra I would suggest switching to the other javascript language server which seems to be smarter and also supports partial updates(these lines will fix the perf issue).
(setq lsp-clients-typescript-server "typescript-language-server" lsp-clients-typescript-server-args '("--stdio"))
Ah, indeed @yyoncho, the current typescript server is javascript-typescript-stdio, I will switch as you recommend.
@MaskRay IMO it is not server side issue since full sync is a valid option according to latest LSP spec and we should provide reasonable handling/performance. I am thinking about adding client-side debounce only for full sync text messages.
Most helpful comment
The issue is caused by the fact that the typescript language synchronization is
fulland when you press and hold a key lsp-mode has to send whole file content as a message which is problematic. We should introduce some mechanisim for handling that case or even https://github.com/emacs-lsp/lsp-mode/issues/362@shackra I would suggest switching to the other javascript language server which seems to be smarter and also supports partial updates(these lines will fix the perf issue).
@alanz @MaskRay