unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: APEL Martin <Martin.APEL@3ds.com>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Tramp and conversion of \r\n into \n
Date: Wed, 16 Dec 2020 16:34:38 +0100	[thread overview]
Message-ID: <87tuslzrw1.fsf@gmx.de> (raw)
In-Reply-To: <4f2b42e36d924f83883e120e601d40f7@3ds.com> (APEL Martin's message of "Fri, 11 Dec 2020 11:29:09 +0000")

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.



  parent reply	other threads:[~2020-12-16 15:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11  7:46 Tramp and conversion of \r\n into \n APEL Martin
2020-12-11  9:15 ` Michael Albinus
2020-12-11  9:59   ` APEL Martin
2020-12-11 10:26     ` Michael Albinus
2020-12-11 11:29       ` APEL Martin
2020-12-11 11:52         ` Michael Albinus
2020-12-13 16:04           ` Michael Albinus
2020-12-15 11:37         ` Michael Albinus
2020-12-15 12:45           ` APEL Martin
2020-12-15 14:37             ` Michael Albinus
2020-12-15 18:45               ` Michael Albinus
2020-12-16  6:44                 ` APEL Martin
2020-12-16 15:34         ` Michael Albinus [this message]
2020-12-16 15:55           ` APEL Martin
2020-12-17 11:35           ` APEL Martin
2020-12-17 12:50             ` Michael Albinus
2020-12-18  7:48               ` APEL Martin
2020-12-18 12:35                 ` Michael Albinus
2020-12-18 12:56                   ` APEL Martin
2020-12-18 13:04                     ` Michael Albinus
2020-12-18 14:54                       ` APEL Martin
2020-12-18 15:00                         ` Michael Albinus
2020-12-18 15:10                           ` APEL Martin
2020-12-18 15:18                             ` Michael Albinus
2020-12-22 14:57                             ` Michael Albinus
2021-01-07 11:13                               ` APEL Martin
2020-12-19  9:18             ` yyoncho
2020-12-19 16:48               ` Michael Albinus
2020-12-20 14:03                 ` Michael Albinus
2021-08-05  1:46                 ` Thomas Ross
2021-08-05  6:16                   ` Eli Zaretskii
2021-08-07  2:08                     ` Thomas Ross
2021-08-05 14:10                   ` Stefan Monnier
2021-08-05 15:40                     ` Michael Albinus
2021-08-05 16:25                       ` Stefan Monnier
2021-08-06  7:13                         ` Michael Albinus
2021-08-06 14:46                           ` Stefan Monnier
2021-08-07 13:51                             ` Michael Albinus
2021-08-07 22:04                               ` Stefan Monnier
2021-08-08  6:13                                 ` PTYs vs. pipes for subprocesses [was: Tramp and conversion of \r\n into \n] tomas
2021-08-08 14:25                                 ` Tramp and conversion of \r\n into \n Michael Albinus
2021-08-12 18:47                                   ` Michael Albinus
2021-08-13 12:16                                     ` Michael Albinus
2021-08-07  2:07                     ` Thomas Ross
2021-08-07 13:54                       ` Michael Albinus
2021-08-08 14:29                         ` Michael Albinus
  -- strict thread matches above, loose matches on Subject: below --
2020-12-09  7:34 yyoncho
2020-12-10 13:44 ` Michael Albinus
2020-12-11 14:11   ` yyoncho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuslzrw1.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=Martin.APEL@3ds.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).