jdtsmith / eglot-booster

Boost eglot using lsp-booster
GNU General Public License v3.0
152 stars 3 forks source link

Tramp support? #6

Closed ileixe closed 6 months ago

ileixe commented 6 months ago

Hi, thanks for great package.

I wonder this package works in tramp env. I got error below in Message buffer

Tramp: Opening connection EGLOT (furiosa-hal2/(rust-mode rust-ts-mode)) for ubuntu@yan-cpu-0 using kubectl...done
[jsonrpc] (warning) Invalid JSON: (invalid token near '#' <callback> 1 1 1) #[0 "\316\317\320\321\322\323\324\300\325\326\301\327\330\331\332\333\334&\6\302\300F\335\302\300D\336\337\340\305D\302\300\306\301\341\307\342\303$\257\6\343\300\344\300\345\300\346\300\347\350\351\352\301\307\353\354\303$F\355\305\356\300\357\360\300\361\300\362\300\363\300\364\300\365\300\366\300\367\300\370\371\301\372!D\373\300\374\300\257\^V\375\300\376\300\377\300\201@\0\302\300D\201A\0\201B\0\201C\0\300\201D\0\201E\0\300D\201F\0\300\201G\0\201H\0\201I\0\300D\201J\0\201K\0\301\201L\0\201M\0\201N\0\201O\0\201P\0\310\201Q\0\201R\0\201S\0\201T\0\201U\0\201V\0\201W\0\201X\0\311\201Y\0\201Z\0\201[\0\201\134\0\201]\0&\^T\201^\0\301\201_\0\201`\0\201a\0\201b\0\201c\0\201d\0\201e\0\311\201f\0\201g\0\201h\0\201i\0\201j\0\201k\0\201l\0\201m\0\201n\0\201o\0\201p\0\201q\0\310\201r\0\201s\0\201t\0\201u\0\201v\0\201w\0\201x\0\201y\0\201z\0\201{\0\201|\0\201}\0\201~\0\201\d\0\201\200\0\201\201\0\201\202\0\201\203\0\201\204\0\201\205\0\201\206\0\201\207\0\201\210\0\201\211\0\201\212\0\201\213\0\201\214\0\201\215\0\201\216\0\201\217\0\201\220\0\201\221\0&5F\201\222\0\300\257\6\201\223\0\306\301\303\201\224\0\201\225\0#D\201\226\0\201\227\0\201\230\0\201\231\0\300\201\232\0\201\233\0\257\6\201\234\0\300\201\235\0\201\236\0\201\237\0\201\240\0\301\312\313\201\241\0\314\304F\315\304F\312\313\201\242\0\314\201\243\0F\315\304F\42DD\201\244\0\201\245\0\300\201\246\0\300FF\201\247\0\300\2574\201\250\0\201\251\0\201\252\0\201\253\0\201\254\0FF\257\6\207" [t vector :resolveProvider "(" "file" :json-false :triggerCharacters "." "attribute" "macro" :pattern :glob :matches :scheme :id 1 :jsonrpc "2.0" :result :capabilities :callHierarchyProvider :codeActionProvider :codeActionKinds "" "quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" :codeLensProvider :completionProvider :completionItem :labelDetailsSupport ":" "'" :declarationProvider :definitionProvider :documentFormattingProvider :documentHighlightProvider :documentOnTypeFormattingProvider :firstTriggerCharacter "=" :moreTriggerCharacter ">" "{" :documentRangeFormattingProvider :documentSymbolProvider :experimental :externalDocs :hoverRange :joinLines :matchingBrace :moveItem :onEnter :openCargoToml :parentModule :runnables :kinds "cargo" :ssr :workspaceSymbolScopeKindFiltering :foldingRangeProvider :hoverProvider :implementationProvider :inlayHintProvider :positionEncoding "utf-32" :referencesProvider :renameProvider :prepareProvider :selectionRangeProvider :semanticTokensProvider :full :delta :legend :tokenModifiers "documentation" "declaration" "static" "defaultLibrary" "async" "callable" "constant" "consuming" "controlFlow" "crateRoot" "injected" "intraDocLink" "library" "mutable" "public" "reference" "trait" "unsafe" :tokenTypes "comment" "decorator" "enumMember" "enum" "function" "interface" "keyword" "method" "namespace" "number" "operator" "parameter" "property" "string" "struct" "typeParameter" "variable" "angle" "arithmetic" "attributeBracket" "bitwise" "boolean" "brace" "bracket" "builtinAttribute" "builtinType" "character" "colon" "comma" "comparison" "constParameter" "derive" "deriveHelper" "dot" "escapeSequence" "invalidEscapeSequence" "formatSpecifier" "generic" "label" "lifetime" "logical" "macroBang" "parenthesis" "punctuation" "selfKeyword" "selfTypeKeyword" "semicolon" "typeAlias" "toolModule" "union" "unresolvedReference" :range :signatureHelpProvider "," "<" :textDocumentSync :change 2 :openClose :save nil :typeDefinitionProvider :workspace :fileOperations :willRename :filters "**/*.rs" "**" "folder" :workspaceFolders :changeNotifications :supported :workspaceSymbolProvider :serverInfo :name "rust-analyzer" :version "1.78.0-nightly (2bf78d1 2024-02-18)"] 115]

and eglot log buffer nothing appeared

[stderr]  [2024-03-12T06:42:56Z INFO  emacs_lsp_booster::app] Running server "rust-analyzer"
[stderr]  [2024-03-12T06:42:56Z INFO  emacs_lsp_booster::app] Will convert server json to bytecode! bytecode options: BytecodeOptions { object_type: Plist, null_value: Nil, false_value: Keyword("json-false") }

Can you give me any guidance? I don't have any customization for eglot itself.

Thanks.

jdtsmith commented 6 months ago

I don't know but I see no reason why it shouldn't. Do you have the wrapper installed on the remote end? You might open an issue with emacs-lsp-booster to get their input.

ileixe commented 6 months ago

I have wrapper on the remote end.

(defun eglot-booster--jsonrpc--json-read (old-fn &rest args)
  "Try to parse bytecode instead of json."
  (or
   (when (equal (following-char) ?#)
     (let ((bytecode (read (current-buffer))))
       (when (byte-code-function-p bytecode)
         (funcall bytecode))))
   (apply old-fn args)))

;; (defun eglot-booster--jsonrpc--json-read (orig-func)
;;   "Read JSON or bytecode, wrapping the ORIG-FUNC JSON reader."
;;   (if eglot-booster-boosted ; local to process-buffer

;;       (or (and (= (following-char) ?#)
;;                (let ((bytecode (read (current-buffer))))
;;                  (when (byte-code-function-p bytecode)
;;                    (funcall bytecode))))
;;           (funcall orig-func))
;;     ;; Not in a boosted process, fallback
;;     (funcall orig-func)))

It's weird in that I can run eglot successfully with the function that original repo has.

jdtsmith commented 6 months ago

Can you change to your *EGLOT ... output* buffer (note the leading space) and in there C-h v eglot-booster-boosted? What is the value there?

ileixe commented 6 months ago
eglot-booster-boosted is a variable defined in ‘eglot-booster.el’.

Its value is nil

Not documented as a variable.

After adding leading space *ELOGT ... output* , its changed to nil. Do you have any clue?

jdtsmith commented 6 months ago

I have pushed caee55e, which attempts to handle tramp remote commands (which are typically starting /bin/sh) correctly. Let me know if that works for you (works here).

ileixe commented 6 months ago

Works like a charm! Thanks for quick response.