From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sebastian Poeplau via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69657: Missing imenu entries with eglot Date: Fri, 08 Mar 2024 21:01:24 +0100 Message-ID: <87frx0ze5n.fsf@mailbox.org> Reply-To: Sebastian Poeplau 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="30482"; mail-complaints-to="usenet@ciao.gmane.io" To: 69657@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 08 21:33:14 2024 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 1rigu1-0007kT-DO for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 08 Mar 2024 21:33:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rigtk-0007fe-JG; Fri, 08 Mar 2024 15:32:58 -0500 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 1rigtK-0007Y8-S4 for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 15:32:37 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rigtK-0004ky-3i for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 15:32:30 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rigtq-00039M-6b for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 15:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Sebastian Poeplau Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Mar 2024 20:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69657 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170992993211992 (code B ref -1); Fri, 08 Mar 2024 20:33:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Mar 2024 20:32:12 +0000 Original-Received: from localhost ([127.0.0.1]:59709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rigt0-00037K-TH for submit@debbugs.gnu.org; Fri, 08 Mar 2024 15:32:12 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rigQ2-0002B6-FM for submit@debbugs.gnu.org; Fri, 08 Mar 2024 15:02:17 -0500 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 1rigPU-000800-Vo for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 15:01:41 -0500 Original-Received: from mout-p-202.mailbox.org ([2001:67c:2050:0:465::202]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from ) id 1rigPS-0007a9-K8 for bug-gnu-emacs@gnu.org; Fri, 08 Mar 2024 15:01:40 -0500 Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4TrxrV24M3z9sSV for ; Fri, 8 Mar 2024 21:01:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1709928090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=G5Ic7Q6x1tFTmh7lQXcqraxdmh1b0VW3AyIAWYm/Zpo=; b=Kj8KyB0zMd7kbBr9tgcxT2MjKr4mFXUgHmR5d26xoB+/Q0s2Te6g5cwl8PCzrwdx4bYbj8 aFwRs6ski0rlPykCZuXJEP9dfGqD5tPKlE3zWSd6qWraYpYZuEHTPxjpec10KChOaAme0H thyB2zk6e1JUcjztF4WsAOMDWhgr2uE5Ijbc3xeyYa7O3mP/8hhkImoRGSw3QUhgkKpBmE bqbSt0DVkO4AWUxLHxOAq5xOyi93BZnUQo6WXXKs29YL03b1ixm3/A2pOX18MF989YlaTu J55SszqPdYTPxYt6kTnus/nRGa6UjTmqHag3IRYeEp8StkI0Tm8Cgw/zdcUdtg== X-MBO-RS-ID: 9ead0157ce2e62f9060 X-MBO-RS-META: 9t4zy4g5oipa4h6bffr9uz3ax71b5hsu Received-SPF: pass client-ip=2001:67c:2050:0:465::202; envelope-from=sebastian.poeplau@mailbox.org; helo=mout-p-202.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 08 Mar 2024 15:32:09 -0500 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:281269 Archived-At: --=-=-= Content-Type: text/plain For language servers that reply to the textDocument/documentSymbol request with instances of DocumentSymbol rather than SymbolInformation, eglot's imenu builder omits symbols containing other symbols. This applies to eglot 1.17 from ELPA as well as the version in Emacs master as of today. You can use clangd to reproduce the problem: 1. Put this code in a C++ source file, e.g., test.cpp: class Foo { void bar() {} }; 2. Start eglot with clangd. 3. Invoke imenu; there will be a single entry "bar", nested under "Foo". In particular, there is no entry that lets you jump to Foo. This is inconsistent with how eglot handles language servers that return SymbolInformation (e.g., pylsp), and I would argue that it's not what users expect. The attached patch fixes the behavior by inserting a dedicated entry for each symbol in addition to entries for its children. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Eglot-include-containers-in-imenu.patch >From 953372f4cb1eea435a21a66e72226c7b2a6be51b Mon Sep 17 00:00:00 2001 From: Sebastian Poeplau Date: Fri, 8 Mar 2024 16:29:25 +0100 Subject: [PATCH] Eglot: include containers in imenu When the language server provides symbols as instances of DocumentSymbol, eglot now includes containers (i.e., symbols with children) in the imenu listing. This is consistent with eglot's behavior when symbols are given as SymbolInformation objects. * lisp/progmodes/eglot.el (eglot--imenu-DocumentSymbol): Include an entry for symbols with children. --- lisp/progmodes/eglot.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index f341428cac3..87366811efd 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3454,10 +3454,13 @@ for which LSP on-type-formatting should be requested." 'breadcrumb-region reg 'breadcrumb-kind kind))) (if (seq-empty-p children) - (cons name (car reg)) - (cons name - (mapcar (lambda (c) (apply #'dfs c)) children)))))) - (mapcar (lambda (s) (apply #'dfs s)) res))) + (list (cons name (car reg))) + (list (cons name (car reg)) + (cons name + (mapcan (lambda (c) + (apply #'dfs c)) + children))))))) + (mapcan (lambda (s) (apply #'dfs s)) res))) (cl-defun eglot-imenu () "Eglot's `imenu-create-index-function'. -- 2.43.2 --=-=-=--