joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.25k stars 200 forks source link

eglot is laggy when use with polymode (i.e multiple major mode in same buffer), specifically working with rmarkdown files #1085

Open milanglacier opened 1 year ago

milanglacier commented 1 year ago

LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)

```lisp [internal] Tue Oct 18 22:21:46 2022: (:message "Running language server: (R --slave -e languageserver::run())") [client-request] (id:1) Tue Oct 18 22:21:46 2022: (:jsonrpc "2.0" :id 1 :method "initialize" :params (:processId 26359 :rootPath "/Users/northyear/Downloads/test/" :rootUri "file:///Users/northyear/Downloads/test" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()) :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport :json-false :deprecatedSupport t :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["markdown" "plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26])) :documentHighlight (:dynamicRegistration :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport (:valueSet [1 2]))) :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) :workspaceFolders [(:uri "file:///Users/northyear/Downloads/test" :name "~/Downloads/test/")])) [server-reply] (id:1) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 1 :result (:capabilities (:textDocumentSync (:openClose t :change 1 :willSave :json-false :willSaveWaitUntil :json-false :save (:includeText t)) :hoverProvider t :completionProvider (:resolveProvider t :triggerCharacters ["." ":"]) :signatureHelpProvider (:triggerCharacters ["(" ","]) :definitionProvider t :referencesProvider t :documentHighlightProvider t :documentSymbolProvider t :workspaceSymbolProvider t :codeActionProvider t :documentFormattingProvider t :documentRangeFormattingProvider t :documentOnTypeFormattingProvider (:firstTriggerCharacter "\n" :moreTriggerCharacter [")" "]" "}"]) :renameProvider t :documentLinkProvider (:resolveProvider t) :colorProvider t :foldingRangeProvider t :selectionRangeProvider t :callHierarchyProvider t))) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 0 :languageId "ess-r" :text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n"))) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()))) [client-request] (id:2) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [client-request] (id:3) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [client-request] (id:4) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [server-reply] (id:2) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 2 :result (:signatures [] :activeSignature -1)) (:start (:line 11 :character 0) :end (:line 11 :character 7)))) [server-notification] Tue Oct 18 22:21:48 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 0 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 27 :character 13) :end (:line 27 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-reply] (id:4) Tue Oct 18 22:21:48 2022: (:jsonrpc "2.0" :id 4 :result nil) [client-request] (id:5) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 5 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [client-request] (id:6) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [client-request] (id:7) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [server-reply] (id:5) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 5 :result (:signatures [] :activeSignature -1)) [server-reply] (id:6) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 6 :result nil) [server-reply] (id:7) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 7 :result nil) [client-request] (id:8) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 8 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [client-request] (id:9) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 9 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [client-request] (id:10) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 10 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [server-reply] (id:8) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 8 :result (:signatures [] :activeSignature -1)) [server-reply] (id:9) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 9 :result nil) [server-reply] (id:10) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 10 :result nil) [internal] (id:11) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/signatureHelp :id 11 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [internal] (id:12) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/hover :id 12 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [internal] (id:13) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/documentHighlight :id 13 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-notification] Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 1) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [internal] Tue Oct 18 22:21:54 2022: (:maybe-run-deferred (11 12 13)) [client-request] (id:11) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 11 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:12) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 12 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:13) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 13 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [server-reply] (id:11) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 11 :result (:signatures [] :activeSignature -1)) [server-reply] (id:12) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 12 :result nil) [server-reply] (id:13) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 13 :result nil) [server-notification] Tue Oct 18 22:21:55 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 1 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [client-notification] Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 3) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nhe\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [client-request] (id:14) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 14 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [client-request] (id:15) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 15 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [client-request] (id:16) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 16 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [server-reply] (id:14) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 14 :result (:signatures [] :activeSignature -1)) [server-reply] (id:15) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 15 :result nil) [server-reply] (id:16) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 16 :result nil) [client-notification] Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 5) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [client-request] (id:17) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 17 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:18) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 18 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:19) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 19 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [server-reply] (id:17) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 17 :result (:signatures [] :activeSignature -1)) [server-reply] (id:18) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 18 :result nil) [server-reply] (id:19) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 19 :result nil) [server-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 3 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 5 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [client-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 8) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlib\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [client-request] (id:20) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 20 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [client-request] (id:21) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 21 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [client-request] (id:22) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 22 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [server-reply] (id:20) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 20 :result (:signatures [] :activeSignature -1)) [server-reply] (id:21) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 21 :result nil) [server-reply] (id:22) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 22 :result nil) [internal] (id:23) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/signatureHelp :id 23 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [internal] (id:24) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/hover :id 24 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [internal] (id:25) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/documentHighlight :id 25 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-notification] Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 9) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlibr\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [internal] Tue Oct 18 22:21:59 2022: (:maybe-run-deferred (25 24 23)) [client-request] (id:25) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 25 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-request] (id:24) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 24 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-request] (id:23) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 23 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [server-reply] (id:25) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 25 :result nil) [server-reply] (id:24) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 24 :result nil) [server-reply] (id:23) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 23 :result (:signatures [] :activeSignature -1)) [client-request] (id:26) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 26 :method "textDocument/completion" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4) :context (:triggerKind 1))) [server-reply] (id:26) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 26 :result (:isIncomplete :json-false :items [(:label "format.libraryIQR" :kind 3 :detail "{base}" :sortText "4-format.libraryIQR" :data (:type "function" :package "base")) (:label "La_library" :kind 3 :detail "{base}" :sortText "4-La_library" :data (:type "function" :package "base")) (:label "library" :kind 3 :detail "{base}" :sortText "4-library" :data (:type "function" :package "base")) (:label "library.dynam" :kind 3 :detail "{base}" :sortText "4-library.dynam" :data (:type "function" :package "base")) (:label "library.dynam.unload" :kind 3 :detail "{base}" :sortText "4-library.dynam.unload" :data (:type "function" :package "base")) (:label "print.libraryIQR" :kind 3 :detail "{base}" :sortText "4-print.libraryIQR" :data (:type "function" :package "base")) (:label ".Library" :kind 5 :detail "{base}" :sortText "4-.Library" :data (:type "nonfunction" :package "base")) (:label ".Library.site" :kind 5 :detail "{base}" :sortText "4-.Library.site" :data (:type "nonfunction" :package "base"))])) [client-request] (id:27) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 27 :method "completionItem/resolve" :params (:label #("library" 0 1 (eglot--lsp-item #1)) :kind 3 :detail "{base}" :sortText "4-library" :data (:type "function" :package "base"))) [server-notification] Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 9 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-reply] (id:27) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 27 :result (:label "library" :kind 3 :detail "{base}" :sortText "4-library" :documentation (:kind "markdown" :value " `library` and `require` load and attach add-on packages."))) [client-notification] Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 10) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlibrary\n```\n\n\n```{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n```\n\n```{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n```\n")])) [client-request] (id:28) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 28 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7))) [client-request] (id:29) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 29 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7))) [client-request] (id:30) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 30 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7))) ```

Backtrace (mandatory, unless no error message seen or heard):

no backtrace, as this is not a error

Minimum Reproducible Example (mandatory)

minimal emacs config

;;; minimal-ess-eglot.el -*- lexical-binding: t; -*-

(require 'package)
(setq package-user-dir "~/Downloads/emacs-package-dir")

(setq package-list '(ess polymode poly-R eglot))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(add-hook 'ess-r-mode-hook #'eglot-ensure)

Here's how I suggest you structure your recipe:

  1. How is Emacs started?
emacs -Q -nw -l /path/to/minimal-config.el
  1. Where does the language server executable live in your machine and how should it be installed?

/usr/local/bin/R via official R installer (or just R-base and R-base-dev for apt-get, say) and install languageserver via R -e 'install.packages("languageserver")'

  1. What project files are needed to demonstrate the problem? Please

say there is a test.rmd located at any .git project root

https://pastebin.com/mXaDJ7yT

(since rmarkdown syntax will be conflict with github markdown syntax, attach the text in pastebin)

  1. How is Emacs operated/configured before you invoke Eglot?

emacs -Q -nw -l /path/to/minimal-config.el

  1. How is Emacs operated after you invoke Eglot

  2. What actions must be taken for the problem to manifest itself?

move point to a source code block (lines between three backquotes marker), and feel obvious lag (hang emacs) for few seconds for the first time entering a code block, and after entering the block, typing some characters may feel laggy at random(occasionally)

  1. What is the expected behaviour?

smooth typing experince, smooth moving cursor experience

  1. What is the observed behaviour?

feel obvious lag (hang emacs) for few seconds for the first time entering a code block, and after entering the block, typing some characters may feel laggy at random( more frequent than occasionally)

joaotavora commented 1 year ago

Can you try this with a more mundane language such as C or Python? The servers clangd and pylsp generally more available. I myself don't plan to install an R toolkit soon, so it'll take longer to look into your problem.

On Wed, Oct 19, 2022, 03:26 milanglacier @.***> wrote:

  • Server used: r-language-server
  • Emacs version: 28.2
  • Operating system: macos
  • Eglot version: 20221011.1102
  • Eglot installation method: package.el
  • Using Doom: no

LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)

[internal] Tue Oct 18 22:21:46 2022: (:message "Running language server: (R --slave -e languageserver::run())") [client-request] (id:1) Tue Oct 18 22:21:46 2022: (:jsonrpc "2.0" :id 1 :method "initialize" :params (:processId 26359 :rootPath "/Users/northyear/Downloads/test/" :rootUri "file:///Users/northyear/Downloads/test" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()) :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport :json-false :deprecatedSupport t :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["markdown" "plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26])) :documentHighlight (:dynamicRegistration :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport (:valueSet [1 2]))) :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) :workspaceFolders [(:uri "file:///Users/northyear/Downloads/test" :name "~/Downloads/test/")])) [server-reply] (id:1) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 1 :result (:capabilities (:textDocumentSync (:openClose t :change 1 :willSave :json-false :willSaveWaitUntil :json-false :save (:includeText t)) :hoverProvider t :completionProvider (:resolveProvider t :triggerCharacters ["." ":"]) :signatureHelpProvider (:triggerCharacters ["(" ","]) :definitionProvider t :referencesProvider t :documentHighlightProvider t :documentSymbolProvider t :workspaceSymbolProvider t :codeActionProvider t :documentFormattingProvider t :documentRangeFormattingProvider t :documentOnTypeFormattingProvider (:firstTriggerCharacter "\n" :moreTriggerCharacter [")" "]" "}"]) :renameProvider t :documentLinkProvider (:resolveProvider t) :colorProvider t :foldingRangeProvider t :selectionRangeProvider t :callHierarchyProvider t))) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ())) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "textDocument/didOpen" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 0 :languageId "ess-r" :text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n"))) [client-notification] Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params (:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()))) [client-request] (id:2) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [client-request] (id:3) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [client-request] (id:4) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 0))) [server-reply] (id:2) Tue Oct 18 22:21:47 2022: (:jsonrpc "2.0" :id 2 :result (:signatures [] :activeSignature -1)) (:start (:line 11 :character 0) :end (:line 11 :character 7)))) [server-notification] Tue Oct 18 22:21:48 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 0 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 27 :character 13) :end (:line 27 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-reply] (id:4) Tue Oct 18 22:21:48 2022: (:jsonrpc "2.0" :id 4 :result nil) [client-request] (id:5) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 5 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [client-request] (id:6) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [client-request] (id:7) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 16 :character 0))) [server-reply] (id:5) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 5 :result (:signatures [] :activeSignature -1)) [server-reply] (id:6) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 6 :result nil) [server-reply] (id:7) Tue Oct 18 22:21:51 2022: (:jsonrpc "2.0" :id 7 :result nil) [client-request] (id:8) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 8 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [client-request] (id:9) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 9 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [client-request] (id:10) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 10 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 11 :character 20))) [server-reply] (id:8) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 8 :result (:signatures [] :activeSignature -1)) [server-reply] (id:9) Tue Oct 18 22:21:53 2022: (:jsonrpc "2.0" :id 9 :result nil) [server-reply] (id:10) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 10 :result nil) [internal] (id:11) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/signatureHelp :id 11 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [internal] (id:12) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/hover :id 12 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [internal] (id:13) Tue Oct 18 22:21:54 2022: (:deferring :textDocument/documentHighlight :id 13 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-notification] Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 1) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [internal] Tue Oct 18 22:21:54 2022: (:maybe-run-deferred (11 12 13)) [client-request] (id:11) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 11 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:12) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 12 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:13) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 13 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [server-reply] (id:11) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 11 :result (:signatures [] :activeSignature -1)) [server-reply] (id:12) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 12 :result nil) [server-reply] (id:13) Tue Oct 18 22:21:54 2022: (:jsonrpc "2.0" :id 13 :result nil) [server-notification] Tue Oct 18 22:21:55 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 1 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [client-notification] Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 3) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nhe\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [client-request] (id:14) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 14 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [client-request] (id:15) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 15 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [client-request] (id:16) Tue Oct 18 22:21:56 2022: (:jsonrpc "2.0" :id 16 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 2))) [server-reply] (id:14) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 14 :result (:signatures [] :activeSignature -1)) [server-reply] (id:15) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 15 :result nil) [server-reply] (id:16) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 16 :result nil) [client-notification] Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 5) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\n\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [client-request] (id:17) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 17 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:18) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 18 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [client-request] (id:19) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 19 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 0))) [server-reply] (id:17) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 17 :result (:signatures [] :activeSignature -1)) [server-reply] (id:18) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 18 :result nil) [server-reply] (id:19) Tue Oct 18 22:21:57 2022: (:jsonrpc "2.0" :id 19 :result nil) [server-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 3 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 5 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [client-notification] Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 8) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlib\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [client-request] (id:20) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 20 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [client-request] (id:21) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 21 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [client-request] (id:22) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 22 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 3))) [server-reply] (id:20) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 20 :result (:signatures [] :activeSignature -1)) [server-reply] (id:21) Tue Oct 18 22:21:58 2022: (:jsonrpc "2.0" :id 21 :result nil) [server-reply] (id:22) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 22 :result nil) [internal] (id:23) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/signatureHelp :id 23 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [internal] (id:24) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/hover :id 24 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [internal] (id:25) Tue Oct 18 22:21:59 2022: (:deferring :textDocument/documentHighlight :id 25 :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-notification] Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 9) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlibr\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [internal] Tue Oct 18 22:21:59 2022: (:maybe-run-deferred (25 24 23)) [client-request] (id:25) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 25 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-request] (id:24) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 24 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [client-request] (id:23) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 23 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4))) [server-reply] (id:25) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 25 :result nil) [server-reply] (id:24) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 24 :result nil) [server-reply] (id:23) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 23 :result (:signatures [] :activeSignature -1)) [client-request] (id:26) Tue Oct 18 22:21:59 2022: (:jsonrpc "2.0" :id 26 :method "textDocument/completion" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 4) :context (:triggerKind 1))) [server-reply] (id:26) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 26 :result (:isIncomplete :json-false :items [(:label "format.libraryIQR" :kind 3 :detail "{base}" :sortText "4-format.libraryIQR" :data (:type "function" :package "base")) (:label "La_library" :kind 3 :detail "{base}" :sortText "4-La_library" :data (:type "function" :package "base")) (:label "library" :kind 3 :detail "{base}" :sortText "4-library" :data (:type "function" :package "base")) (:label "library.dynam" :kind 3 :detail "{base}" :sortText "4-library.dynam" :data (:type "function" :package "base")) (:label "library.dynam.unload" :kind 3 :detail "{base}" :sortText "4-library.dynam.unload" :data (:type "function" :package "base")) (:label "print.libraryIQR" :kind 3 :detail "{base}" :sortText "4-print.libraryIQR" :data (:type "function" :package "base")) (:label ".Library" :kind 5 :detail "{base}" :sortText "4-.Library" :data (:type "nonfunction" :package "base")) (:label ".Library.site" :kind 5 :detail "{base}" :sortText "4-.Library.site" :data (:type "nonfunction" :package "base"))])) [client-request] (id:27) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 27 :method "completionItem/resolve" :params (:label

("library" 0 1

   (eglot--lsp-item #1))
 :kind 3 :detail "{base}" :sortText "4-library" :data
 (:type "function" :package "base")))

[server-notification] Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 9 :diagnostics [(:range (:start (:line 10 :character 45) :end (:line 10 :character 47)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 10 :character 58) :end (:line 10 :character 60)) :severity 3 :source "T_and_F_symbol_linter" :message "Use FALSE instead of the symbol F.") (:range (:start (:line 28 :character 13) :end (:line 28 :character 14)) :severity 2 :source "for_loop_index_linter" :message "Don't re-use any sequence symbols as the index symbol in a for loop.")])) [server-reply] (id:27) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 27 :result (:label "library" :kind 3 :detail "{base}" :sortText "4-library" :documentation (:kind "markdown" :value " library and require load and attach add-on packages."))) [client-notification] Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :method "textDocument/didChange" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd" :version 10) :contentChanges [(:text "---\ntitle: 'test rmd'\nauthor: 'author'\ndate: '12/14/2021'\noutput: \n bookdown::pdf_document2:\n---\n\n\n{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE, warning = F, message = F)\noptions(scipen = 10)\nlibrary\n\n\n\n{r}\ntest = 10\nfor (i in 1:100) {\n print(i)\n}\n\n\n{r}\nanother_test = function(i) {\n if (i > 0) {\n print(i)\n } else {\n for (i in 1:i) {\n print(i + 5)\n }\n }\n}\n\n")])) [client-request] (id:28) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 28 :method "textDocument/signatureHelp" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7))) [client-request] (id:29) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 29 :method "textDocument/hover" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7))) [client-request] (id:30) Tue Oct 18 22:22:00 2022: (:jsonrpc "2.0" :id 30 :method "textDocument/documentHighlight" :params (:textDocument (:uri "file:///Users/northyear/Downloads/test/test.rmd") :position (:line 12 :character 7)))

Backtrace (mandatory, unless no error message seen or heard):

no backtrace, as this is not a error Minimum Reproducible Example (mandatory)

minimal emacs config

;;; minimal-ess-eglot.el -- lexical-binding: t; --

(require 'package) (setq package-user-dir "~/Downloads/emacs-package-dir")

(setq package-list '(ess polymode poly-R eglot)) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-initialize)

(unless package-archive-contents (package-refresh-contents))

(dolist (package package-list) (unless (package-installed-p package) (package-install package)))

(add-hook 'ess-r-mode-hook #'eglot-ensure)

Here's how I suggest you structure your recipe:

  1. How is Emacs started?

emacs -Q -nw -l /path/to/minimal-config.el

  1. Where does the language server executable live in your machine and how should it be installed?

/usr/local/bin/R via official R installer (or just R-base and R-base-dev for apt-get, say) and install languageserver via R -e 'install.packages("languageserver")'

  1. What project files are needed to demonstrate the problem? Please

say there is a test.rmd located at any .git project root

---title: 'test rmd'author: 'author'date: '12/14/2021'output: bookdown::pdf_document2:---



test = 10
for (i in 1:100) {
    print(i)
}

another_test = function(i) {
    if (i > 0) {
        print(i)
    } else {
        for (i in 1:i) {
            print(i + 5)
        }
    }
}

   1. How is Emacs operated/configured *before* you invoke Eglot?

emacs -Q -nw -l /path/to/minimal-config.el

   1.

   How is Emacs operated *after* you invoke Eglot
   2.

   What actions must be taken for the problem to manifest itself?

move point to a source code block (lines between three backquotes marker),
and feel obvious lag (hang emacs) for few seconds for the first time
entering a code block,
and after entering the block, typing some characters may feel laggy at
random(occasionally)

   1. What is the expected behaviour?

smooth typing experince, smooth moving cursor experience

   1. What is the observed behaviour?

feel obvious lag (hang emacs) for few seconds for the first time entering
a code block,
and after entering the block, typing some characters may feel laggy at
random( more frequent than occasionally)

—
Reply to this email directly, view it on GitHub
<https://github.com/joaotavora/eglot/issues/1085>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC6PQZNOKRWFBCQVKBOW3TWD5L4XANCNFSM6AAAAAARIU6GJQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
milanglacier commented 1 year ago

Hi! I tried poly-org to edit source block within org. And I find that the performance is okay when trying to edit python code block within org. But editing with R block in org is still laggy.

joaotavora commented 1 year ago

Hi! I tried poly-org to edit source block within org. And I find that the performance is okay when trying to edit python code block within org. But editing with R block in org is still laggy

Why did you replace poly-R with poly-org to start working with Python?? That's quite odd: i would expect some kind of poly-python instead.

At any rate, I'd say the problem can't really be pinned to Eglot, but to these "poly" mixed modes, which i am not acquainted with.

Also, can you try this without eglot-ensure but with M-x eglot instead?

milanglacier commented 1 year ago

poly-r adds support for some markup language format usually connected with R (rmarkdown (.rmd), sweave (.rnw), etc), it's nothing about the programming language.

The mechanism behind poly-mode is, it automatically switches the major mode depending on your point, so if your point is inside a code block, your buffer is switched to the major mode associated with the language of the code block.

I tried M-x eglot, and surprisingly, I find the performance becomes ok when trying to edit r code block too. Interesting... Do you recommend (add-hook 'ess-r-mode-hook #'eglot) instead of eglot-ensure for automatically starting lsp?

joaotavora commented 1 year ago

tried M-x eglot, and surprisingly, I find the performance becomes ok when trying to edit r code block too.

OK, marking this "workaround" then.

Do you recommend (add-hook 'ess-r-mode-hook #'eglot) instead of eglot-ensure for automatically starting lsp?

No, I recommend that even less then using eglot-ensure. You should only use eglot-ensure once you are confident that M-x eglot works fine and smoothly. You should not automatically resort to eglot-ensure.

You problem (though it remains to be analysed) may be that poly-thing are somehow creating many file buffers and starting many eglot connections.

milanglacier commented 1 year ago

Okay, I will also submit an issue to polymode to see what happens there

milanglacier commented 1 year ago

poly-r adds support for some markup language format usually connected with R (rmarkdown (.rmd), sweave (.rnw), etc), it's nothing about the programming language.

The mechanism behind poly-mode is, it automatically switches the major mode depending on your point, so if your point is inside a code block, your buffer is switched to the major mode associated with the language of the code block.

I tried M-x eglot, and surprisingly, I find the performance becomes ok when trying to edit r code block too. Interesting... Do you recommend (add-hook 'ess-r-mode-hook #'eglot) instead of eglot-ensure for automatically starting lsp?

Update: I find that calling M-x eglot in a .R file and then switch to a RMD file, entering a R code block still hangs emacs for several seconds.

Diver deeper, I find that the function causing the hang is imenu-update-menubar, so a temporary workaround is just (menu-bar-mode -1) which will disable menu bar and imenu-update-menubar will not be called

zhenhua-wang commented 1 year ago

Diver deeper, I find that the function causing the hang is imenu-update-menubar, so a temporary workaround is just (menu-bar-mode -1) which will disable menu bar and imenu-update-menubar will not be called

This seems to be related with this issue. Rlanguageserver cannot handle incomplete codes, which causes imenu to hang. Their author suggest that "The plugin (eglot) should be inspecting the outline (document symbols) asynchronously to avoid blocking the user."

REditorSupport/languageserver#558

milanglacier commented 1 year ago

Diver deeper, I find that the function causing the hang is imenu-update-menubar, so a temporary workaround is just (menu-bar-mode -1) which will disable menu bar and imenu-update-menubar will not be called

This seems to be related with this issue. Rlanguageserver cannot handle incomplete codes, which causes imenu to hang. Their author suggest that "The plugin (eglot) should be inspecting the outline (document symbols) asynchronously to avoid blocking the user."

REditorSupport/languageserver#558

This may be or may not be the issue. If a plain .R file is opened, then there's no hang. The hang only happens in poly-mode, i.e opening a .rmd switch point to a code block. I think Rlanguageserver can handle .rmd file natively. So from the lsp server side, the different behavior when treating .r and .rmd is shouldn't be expected.

ParetoOptimalDev commented 1 year ago

(eglot) should be inspecting the outline (document symbols) asynchronously to avoid blocking the user.

This may be or may not be the issue. If a plain .R file is opened, then there's no hang.

This could be because there's not a need for asynchronicity without polymode presumably opening many buffers.

Their author suggest that "The plugin (eglot) should be inspecting the outline (document symbols) asynchronously to avoid blocking the user."

I've seen comments like this from many lsp server contributors and it feels like that means they will continue developing server features that assume clients are totally async.

joaotavora commented 1 year ago

Eglot is async except in those cases where it doesn't make any sense.

So too make sense of this issue, someone has to provide concrete evidence of things, like a reproducible recipe that demonstrates the problem. Guesswork brings little reward. And vague statements like "Eglot should be more async" are kind of useless.

joaotavora commented 1 year ago

I've recently reproduced a problem with as complex setup like this one using Docker. If someone provides a docker image or dockerfile, it'll speed up analysis for sure.