[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tramp and conversion of \r\n into \n
From: |
Michael Albinus |
Subject: |
Re: Tramp and conversion of \r\n into \n |
Date: |
Wed, 16 Dec 2020 16:34:38 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
APEL Martin <Martin.APEL@3ds.com> writes:
> Hi Michael,
Hi Martin,
> 6. Now try to open the main.cpp file on the remote machine in Emacs on
> the local machine. This should trigger the start of clangd via
> lsp-mode. If the error occurs, the modeline shows 'clangd starting'
> forever.
Well, I don't belive it is eol conversion. With some more stderr
redirection, I could see that the local process sends
--8<---------------cut here---------------start------------->8---
Content-Length: 2134
{"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath":"/home/albinus/tmp/minicpp","clientInfo":{"name":"emacs","version":"GNU
Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo
version 1.16.0)\n of
2020-12-15"},"rootUri":"file:///home/albinus/tmp/minicpp","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"]},"applyEdit":true,"symbol":{"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]}},"executeCommand":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":true},"documentSymbol":{"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]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"snippetSupport":false,"documentationFormat":["markdown"],"resolveAdditionalTextEditsSupport":true},"contextSupport":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"hover":{"contentFormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true}},"window":{"workDoneProgress":true}},"initializationOptions":null,"workDoneToken":"1"},"id":1}
--8<---------------cut here---------------end--------------->8---
Both on the remote side, running "clangd --log=verbose", we see only
--8<---------------cut here---------------start------------->8---
I[16:18:53.667] Ubuntu clangd version 11.0.0-2
I[16:18:53.667] PID: 269465
I[16:18:53.667] Working directory: /home/albinus/tmp/minicpp
I[16:18:53.667] argv[0]: clangd
I[16:18:53.667] argv[1]: --log=verbose
V[16:18:53.667] User config file is /home/albinus/.config/clangd/config.yaml
I[16:18:53.667] Starting LSP over stdin/stdout
V[16:18:53.668] <<<
{"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath":"/home/albinus/tmp/minicpp","clientInfo":{"name":"emacs","version":"GNU
Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo
version 1.16.0)\n of
2020-12-15"},"rootUri":"file:///home/albinus/tmp/minicpp","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"]},"applyEdit":true,"symbol":{"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]}},"executeCommand":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":true},"documentSymbol":{"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]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"snippetSupport":false,"documentationFormat":["markdown"],"resolveAdditionalTextEditsSupport":true},"contextSupport":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"hover":{"contentFormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true}},"window":{"workDoneProgress":true}},"initializationOptions":null,"workDoneToken":"1"},"id":1
E[16:18:53.668] JSON parse error: [3:2132, byte=2134]: Expected , or } after
object property
--8<---------------cut here---------------end--------------->8---
That is, both the Content-Length header is missing as well as the final "}".
This is strange. I've tried to debug lsp-mode.el, but it is an 8200+
lines monster, and not documented well. However, lsp-tramp-connection
uses start-file-process-shell-command, which means several shell calls
in between. So I have rewritten this to the following code:
--8<---------------cut here---------------start------------->8---
(defun lsp-tramp-connection (local-command &optional generate-error-file-fn)
"Create LSP stdio connection named name.
LOCAL-COMMAND is either list of strings, string or function which
returns the command to execute."
;; Force a direct asynchronous process.
(add-to-list 'tramp-connection-properties
(list (regexp-quote (file-remote-p default-directory))
"direct-async-process" t))
(list :connect (lambda (filter sentinel name environment-fn)
(let* ((final-command (lsp-resolve-final-function
local-command))
(_stderr (or (when generate-error-file-fn
(funcall generate-error-file-fn name))
(format "/tmp/%s-%s-stderr" name
(cl-incf lsp--stderr-index))))
(process-name (generate-new-buffer-name name))
(process-environment
(lsp--compute-process-environment environment-fn))
(proc (make-process
:name process-name
:buffer (format "*%s*" process-name)
:command final-command
:connection-type 'pipe
:coding 'no-conversion
:noquery t
:filter filter
:sentinel sentinel
:file-handler t)))
(cons proc proc)))
:test? (lambda () (-> local-command lsp-resolve-final-function
lsp-server-present?))))
--8<---------------cut here---------------end--------------->8---
With this, your test scenario works fine for me. Could you check how it
fits in your environment?
One disadvantage is, that direct asynch processes work only with the
upcoming Tramp 2.5 (that's already in Emacs master), and it works only
if the asynchronous process does not require password handling. The
latter is true, if your ssh authentication is based on keys, or if you
use Tramp's control master arguments (enabled by default).
> Hope this helps,
>
> Martin
Best regards, Michael.
- RE: Tramp and conversion of \r\n into \n, (continued)
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/11
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/11
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/11
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/11
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/13
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/15
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/15
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/15
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/15
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/16
- Re: Tramp and conversion of \r\n into \n,
Michael Albinus <=
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/16
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/17
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/17
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/18
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/18
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/18
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/18
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/18
- Re: Tramp and conversion of \r\n into \n, Michael Albinus, 2020/12/18
- RE: Tramp and conversion of \r\n into \n, APEL Martin, 2020/12/18