From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#62116: RFE: eglot: support window.showDocument LSP RPC Date: Fri, 12 May 2023 01:54:07 +0100 Message-ID: <871qjm5pzk.fsf@gmail.com> References: <87jzznxx8f.fsf@gmail.com> <83fsabwhpg.fsf@gnu.org> <87v8j7vy48.fsf@gmail.com> <83r0tuv62t.fsf@gnu.org> <874jp8gu8a.fsf@betli.tmit.bme.hu> <838re3jowg.fsf@gnu.org> <87ttwqsow9.fsf@gmail.com> <87ttwpbpaj.fsf@betli.tmit.bme.hu> <875y93arek.fsf@betli.tmit.bme.hu> <87h6sla14k.fsf@betli.tmit.bme.hu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2029"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: sebastian.poeplau@mailbox.org, adonovan@google.com, 62116@debbugs.gnu.org To: Felician Nemeth Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 12 02:53:38 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pxH2P-0000OE-5N for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 May 2023 02:53:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxH1v-00038Z-Op; Thu, 11 May 2023 20:53:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pxH1r-000387-BV for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 20:53:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pxH1q-0003YS-2a for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 20:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pxH1p-000693-Vo for bug-gnu-emacs@gnu.org; Thu, 11 May 2023 20:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 May 2023 00:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62116-submit@debbugs.gnu.org id=B62116.168385272323533 (code B ref 62116); Fri, 12 May 2023 00:53:01 +0000 Original-Received: (at 62116) by debbugs.gnu.org; 12 May 2023 00:52:03 +0000 Original-Received: from localhost ([127.0.0.1]:53661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxH0s-00067S-H8 for submit@debbugs.gnu.org; Thu, 11 May 2023 20:52:02 -0400 Original-Received: from mail-wm1-f41.google.com ([209.85.128.41]:62952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxH0p-00066u-Ep for 62116@debbugs.gnu.org; Thu, 11 May 2023 20:52:00 -0400 Original-Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-3f315735514so303544205e9.1 for <62116@debbugs.gnu.org>; Thu, 11 May 2023 17:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683852713; x=1686444713; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=LQ/Z3gPzmt6/ucl7HwhUUNnj8ZLpekUh+yV6Zoypm6w=; b=QdbNUvI/ozv1s7v2AGyf37ElRdFxOrakrmWyjPdPdldoLY/HjgRdk97NoXAwbNmAr0 sRLSXWTimRR+YQdOvMQa/elZdYvurcAWn2vUfIsaumuTRvbTpXZ+TqiV5EQdtuZycUsd 9VegaYsTMtnj7m4x9sXCPP7kwslFyg2HF6ICtjgTwTWXYdG3wCrwMsG8kb1VCytVuQKe EVpr3S+Z6iSJub1Co5McPeV0jKYWcV2xALoVSrxrISdXgGqnqRT4v4aMElEuz0DtIhAa LPUUBLF5SZ0QNyZjens+j8hjoDhcPiNfFwKypaiFm78i9yc5QF9iFnyRA/H6vY4pTSZi gYKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683852713; x=1686444713; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LQ/Z3gPzmt6/ucl7HwhUUNnj8ZLpekUh+yV6Zoypm6w=; b=iie0yMaFMuWPylD4YD64WmezS2WYPqCEFY4IeUZWouIU6dy1Hnc+ogOX0V4Pyjhrcb Aul6LrGPvc+5XqPx64QzEwGcHV9ic7Yi8lcPQU3b6OEVeCccxIYsMGW++fezHUGW5d+3 KXT2G/kkoCRWqlsA7PMNply9AHfO0kincvhx5CxRJ2EMMXKhj3IMmSjKTLsmZWEVMr3K d3nFIswfd/OITmnKdl/0zE4Vp+TQsCheAiwi+bJvTgbvUkScgAK5ZKOPLNYy6sNK2qot fDp7GPdTdykoUCwZDow8WQPiMjGvJX8w9qABabSq4Q8TF8irSZG5iblaU1scLAkDCHCs gFOw== X-Gm-Message-State: AC+VfDyKNcpsdmqlCOVKwd4mOIHhrhAI7j+bUPZlpQm5v+nWm8ofUyCi ICiCcCxhxAazzlQrC0jNji4= X-Google-Smtp-Source: ACHHUZ5sbolGxY4whJESpxMvcOFQdG3RKciwrcySIqibbGivJ3ZRcHwPNMY9fSDb+YEPlljcr4Qtiw== X-Received: by 2002:a5d:6144:0:b0:307:c6b2:4f0b with SMTP id y4-20020a5d6144000000b00307c6b24f0bmr2976191wrt.29.1683852713144; Thu, 11 May 2023 17:51:53 -0700 (PDT) Original-Received: from krug (87-196-72-49.net.novis.pt. [87.196.72.49]) by smtp.gmail.com with ESMTPSA id n16-20020a5d67d0000000b002fae7408544sm21912996wrw.108.2023.05.11.17.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 17:51:52 -0700 (PDT) In-Reply-To: <87h6sla14k.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Tue, 09 May 2023 19:03:07 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261597 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Felician Nemeth writes: > Jo=C3=A3o T=C3=A1vora writes: > >>> Since it advances the status quo, can this be merged? If not, how >>> should we proceed? >> >> Haven't looked at it, but I'd say yes. However, Alan Donovan >> has replied recently, with a recipe showcasing his particular >> use case. I dont' have time to try it right now, but if you >> could try his recipe/use case with your solution, it would be >> great. > > It requires to patch and recompile gopls, which would be too much effort > for me, unfortunately. I've now followed Alan's recipe and played around a bit with this. Starting from your version, I came up with this simpler patch. I was about to push it, but let's hear your opinions first (though we can always push and tweak it later). Jo=C3=A3o --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Eglot-support-window-showRequest.patch Content-Transfer-Encoding: quoted-printable >From 1acbbc188a7c43063f9d6a4d25e3d854052cc956 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Felici=3DC3=3DA1n=3D20N=3DC3=3DA9meth?=3D Date: Fri, 12 May 2023 01:50:05 +0100 Subject: [PATCH] Eglot: support window/showRequest (bug#62116) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jo=C3=A3o T=C3=A1vora * lisp/progmodes/eglot.el (eglot-client-capabilities): Advertise window/showDocument. (eglot-handle-request window/showDocument): New handler. --- lisp/progmodes/eglot.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 66d893a14b5..291ae9b83d9 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -845,7 +845,8 @@ eglot-client-capabilities `(:valueSet [,@(mapcar #'car eglot--tag-faces)]))) - :window `(:workDoneProgress t) + :window `(:showDocument (:support t) + :workDoneProgress t) :general (list :positionEncodings ["utf-32" "utf-8" "utf-16"]) :experimental eglot--{}))) =20 @@ -2366,6 +2367,27 @@ eglot-handle-request "Handle server request workspace/workspaceFolders." (eglot-workspace-folders server)) =20 +(cl-defmethod eglot-handle-request + (_server (_method (eql window/showDocument)) &key + uri external takeFocus selection) + "Handle request window/showDocument." + (if (eq external t) (browse-url uri) + (let* (;; requests run with a let-bound `eglot--cached-server', + ;; but when finding files from handlers, this fools + ;; `eglot--maybe-activate-editing-mode'. + (eglot--cached-server nil)) + (with-current-buffer (find-file-noselect (eglot--uri-to-path uri)) + (cond (takeFocus + (pop-to-buffer (current-buffer)) + (select-frame-set-input-focus (selected-frame))) + ((display-buffer (current-buffer)))) + (when selection + (eglot--widening + (pcase-let ((`(,beg . ,end) (eglot--range-region selection))) + (goto-char beg) + (pulse-momentary-highlight-region beg end 'highlight))))))) + '(:success t)) + (defun eglot--TextDocumentIdentifier () "Compute TextDocumentIdentifier object for current buffer." `(:uri ,(eglot--path-to-uri (or buffer-file-name --=20 2.39.2 --=-=-=--