From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 08 15:32:12 2024 Received: (at submit) by debbugs.gnu.org; 8 Mar 2024 20:32:12 +0000 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 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 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 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 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== From: Sebastian Poeplau To: bug-gnu-emacs@gnu.org Subject: Missing imenu entries with eglot Date: Fri, 08 Mar 2024 21:01:24 +0100 Message-ID: <87frx0ze5n.fsf@mailbox.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 08 16:46:03 2024 Received: (at 69657) by debbugs.gnu.org; 8 Mar 2024 21:46:03 +0000 Received: from localhost ([127.0.0.1]:59808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rii2V-0002c5-2K for submit@debbugs.gnu.org; Fri, 08 Mar 2024 16:46:03 -0500 Received: from mail-lj1-f179.google.com ([209.85.208.179]:56713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rii2S-0002ba-MC for 69657@debbugs.gnu.org; Fri, 08 Mar 2024 16:46:01 -0500 Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d27184197cso31457841fa.1 for <69657@debbugs.gnu.org>; Fri, 08 Mar 2024 13:45:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709934262; x=1710539062; darn=debbugs.gnu.org; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=YJ5xQn4LUGH8+WDU1Qu37CehJJ6XW/CQmyQdxu1xjk8=; b=cvmZs5zzYpONdDA09BR5r6ohJ1s4clNNpmT/fJLLfKboqPL31jRFYl4RXqcKFvwJtD Vx30L2iu4wJa0qxpuaSqw1FSZGxOAiCbUGRI6/UARBae1LIS4lMvFot/d+n+BwwNnSCE RXZ3IjGXVBq8UPATgBO5JYyk+xPcFA6nUSN9MhbKWKjVjDfM3xRd63P+NrDDLBMZf9u4 lD3J+/08+A21F926ookUBouaiksO2pIox7OIP0Xr1q71pen7Z380UaSrp2Xi31LAXKzl R7s3vGSnWXGSc3ul1ptgXpU17/BwiSUn2jDLs72OGqA0dvQbDjZK5+Vx7a6wluux+yhT ZsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709934262; x=1710539062; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YJ5xQn4LUGH8+WDU1Qu37CehJJ6XW/CQmyQdxu1xjk8=; b=Jf0jz9BHcGuaGTkVmnZxMpN5AKvjPvabu15/JEHGxxTOAkShkdKU2TIo0H5jJkZeeu VtF05j6GNkgzK+1pe3oe+FXhKfaVobdL5FYjeHWWwLY/oVo1Ge58+woyqKdclVbdUINm xjc30dTfUFQB+/lBwq/hwTQN79eAafL9D+Xq9BcKckzXRZTDdSHhAKt8SAPRziJM+fCS oBq//GtiCtVbtLDrKl2we1fzfyWDdKTc2YsxSPsXG+Ugn1vO6f2eqZxOQ0RiQopZbVDw I963u2erWjp9n13Xy3FTcuI0KDV3tBDv2VJVavA/DTbVUN0gaaSvTzYc5jHVEEM+Rq8b tpNA== X-Gm-Message-State: AOJu0YyKcQT57WKHSmOtMQGV/HEmajKHwO5NkBFEZofdkZJpTVlXn7XA bwCdFNIa94G1q5HyG6AodgiXUTFVapZTIgeFaImXsJL8V786y5VpShCqveRO X-Google-Smtp-Source: AGHT+IEoJeAnl8uFEbLAIFemnlzwCvb5ngxKQ0wW9mPE1vPbaH5WSjJtC4AzvkTzr4PstyFeuhiF3w== X-Received: by 2002:a2e:9357:0:b0:2d2:a2f5:5970 with SMTP id m23-20020a2e9357000000b002d2a2f55970mr318871ljh.27.1709934261272; Fri, 08 Mar 2024 13:44:21 -0800 (PST) Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu. [213.222.160.137]) by smtp.gmail.com with ESMTPSA id x1-20020a056402414100b005683b6d8809sm66832eda.19.2024.03.08.13.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 13:44:20 -0800 (PST) From: Felician Nemeth To: Sebastian Poeplau Subject: Re: bug#69657: Missing imenu entries with eglot References: <87frx0ze5n.fsf@mailbox.org> Date: Fri, 08 Mar 2024 22:44:19 +0100 In-Reply-To: <87frx0ze5n.fsf@mailbox.org> (Sebastian Poeplau via's message of "Fri, 08 Mar 2024 21:01:24 +0100") Message-ID: <87a5n8s8jw.fsf@betli.tmit.bme.hu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEWOdXElERN7LDLZs6/l 0dDQq6TepMcqAAACW0lEQVQ4jWWSzY7bMAyEaSm6mypylxjkroTRvUW8d9lavf+r7NDOZotWQHzg lyGHP0Sn5ed9qKrLWWIWos9/QJWIeCSywPNTd/AE0LtwFj7A+3WT5PwfeBrQKcsBnkfwVcNySWQr 3i34XN6gRNgis/v4uwSKHCD9lPitB0Aq9BHfHX4cgsI7cJJfLdZg/4bbCzoRmkD9MsagQSBDedZi CgNxkVSJmSOStTBUBKkywEnEoZzbwWj+ACiVJkF6pOpak2PMCqkMYDpaw+gatLR8atMOrB3JGzmm 3rSQo+tkxU+UAbhQSgtslULhsXKk6+IyQ1QTzeQB0MzjlpkCEUCeUdviWrwBcxVqpZjP+v0MYPA0 aq2rvIEZe4GRM0v+9QIB03rsABVSk5y+Mz3LSzExtJLlCCO6dV1uzDQFTBad+gO0TqqL9XE8x4ek +orvYiMJgzC8e+r6TqaPaK6QyqVNvoHtsRrooQ6tTi4vgaSkd8wIikodB3B0iIk58avsDdYNajpS bSKJ+mQnipGszB6zW4lGgsOkKHE2RWVcBpwhaIv3BYIAu3WsnC7YYKLRchp6w8fRGZIWiZuFsVai 7gbcUcJEhiDZ3K1+uzZvBlfaEO8oH4MLu6/hrKVM7QpQcIXJFuC1XjfbfKRxNslk94l9cYcEihV2 HWyNDQAXaLsvnrSyp7HaQhrAn13V6/XW11nh0XINBOEAV+tHK4EvAGNGvEwc0eZw8Vyr56imYEsV sOW9jxm/yb9AH1ufqGMviIK7A0Tc/723oM3tJ4HTOu9gDr3ftbdkxfdjsUv5AqWKwyfCYo5WAAAA AElFTkSuQmCC MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 69657 Cc: 69657@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > 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. How do you invoke imenu? If I type M-x imenu-add-menubar-index RET, then I cannot select "Foo" as you wrote above. However, if I apply the patch, the menu looks exactly the same. On the other hand, the patch seems to ruin breadcrumb-mode: putting the point after "{}", the breadcrumb header line shows: "dir/test.cpp: Class > Foo" instead of the original "dir/test.cpp: Class > Foo > bar". $ clangd --version Debian clangd version 14.0.6 Features: linux+grpc From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 08 22:13:55 2024 Received: (at 69657) by debbugs.gnu.org; 9 Mar 2024 03:13:55 +0000 Received: from localhost ([127.0.0.1]:60014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rin9h-0002bH-Mv for submit@debbugs.gnu.org; Fri, 08 Mar 2024 22:13:55 -0500 Received: from mout-p-202.mailbox.org ([80.241.56.172]:52400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1riisg-00045r-67 for 69657@debbugs.gnu.org; Fri, 08 Mar 2024 17:40:01 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4Ts1L01DLJz9spM; Fri, 8 Mar 2024 23:38:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1709937528; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YPz9PBEVXINbfhsQFhkZu7IS48haGKKwyAmNGJmlRmo=; b=O9QeUoV/viO9yXXQ4bRkPxsWheHsfdL/OCNI/Ka6TZSXEUCDRUDS1WL+ThOblqDliZsTbC GEZxl41djV1Gk5QP8b1mNk/luJA2zNsgNMUQzBQCq7Bc4a6QbhRRf3FLKYSrDKtjp0y/9x J6JsavUcquKC7f8h3vU8JIZcOAHk1M9NaWtOGGpJV/XkrTrpt4egw0bfgtBF86obMU3kIv win6M4INWEr3Q1OZf4Dx/4WFquGWyp4+GoCTZYy/nPvn9Rp4qmUmbzB47JUUuUPnBDTwyq cSW0DXsnSizmt7sg0shCn3FeG7VsqAtnU08cEfAJoFkJjQANMOP+twkHuEadVw== References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> From: Sebastian Poeplau To: Felician Nemeth Subject: Re: bug#69657: Missing imenu entries with eglot Date: Fri, 08 Mar 2024 23:28:26 +0100 In-reply-to: <87a5n8s8jw.fsf@betli.tmit.bme.hu> Message-ID: <87bk7oz6vc.fsf@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain X-MBO-RS-META: qocwwqgu3tqafzjb3kg6erx8737fm6n3 X-MBO-RS-ID: df0f2ab9927de61c4a3 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69657 X-Mailman-Approved-At: Fri, 08 Mar 2024 22:13:44 -0500 Cc: 69657@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > How do you invoke imenu? I did M-x imenu, although I should add that I normally use consult-imenu, which presents a flattened menu. That's also what I wrote the patch for. > If I type M-x imenu-add-menubar-index RET, then I cannot select "Foo" > as you wrote above. However, if I apply the patch, the menu looks > exactly the same. Indeed, it seems that for regular imenu the patch doesn't make a difference (presumably because both the category and the symbol have the same name). I had tested that the entry for "Foo" is absent, but I guess i should have verified that it shows up with the patch. In any case, for users of consult-imenu (and possibly others) there's a benefit, also in terms of consistency with language servers that use SymbolInformation. > On the other hand, the patch seems to ruin breadcrumb-mode: putting > the point after "{}", the breadcrumb header line shows: "dir/test.cpp: > Class > Foo" instead of the original "dir/test.cpp: Class > Foo > > bar". If you move point _after_ "{}", you're outside of method "bar", aren't you? Doesn't that mean the breadcrumb header is correct now and was wrong before? > $ clangd --version > Debian clangd version 14.0.6 > Features: linux+grpc I tested with clangd 15 from the Ubuntu repositories and clangd 17 from the repositories maintained by the LLVM project (for Ubuntu and Debian). But I don't think this is a matter of clangd versions; for the record, this is the textDocument/documentSymbol response I'm getting for the example in my original message: { "id": 5, "jsonrpc": "2.0", "result": [ { "children": [ { "detail": "void ()", "kind": 6, "name": "bar", "range": { "end": { "character": 15, "line": 1 }, "start": { "character": 2, "line": 1 } }, "selectionRange": { "end": { "character": 10, "line": 1 }, "start": { "character": 7, "line": 1 } } } ], "detail": "class", "kind": 5, "name": "Foo", "range": { "end": { "character": 1, "line": 2 }, "start": { "character": 0, "line": 0 } }, "selectionRange": { "end": { "character": 9, "line": 0 }, "start": { "character": 6, "line": 0 } } } ] } From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 09 11:21:55 2024 Received: (at 69657) by debbugs.gnu.org; 9 Mar 2024 16:21:56 +0000 Received: from localhost ([127.0.0.1]:34687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rizSN-0002wf-IZ for submit@debbugs.gnu.org; Sat, 09 Mar 2024 11:21:55 -0500 Received: from mail-ej1-f44.google.com ([209.85.218.44]:46191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rizSK-0002wS-V9 for 69657@debbugs.gnu.org; Sat, 09 Mar 2024 11:21:53 -0500 Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a45bdf6e9c2so363736066b.0 for <69657@debbugs.gnu.org>; Sat, 09 Mar 2024 08:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710001214; x=1710606014; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Kgzsvs8jhrLTiQFKFIHZoTw+5YxMWjSF4qDtsfUOBq8=; b=CxPWI6ASpx/ST1ZMqZ0T21x2Zbh25wY8sdng9SUQWewcNeZ8wDbxWeaVQCsYpQmrRX PSkpi6H+YR7u0oQ1HMeCfpLD2Uq3PNnOt61peAdxwJ/B23kPFDdEwEraOe7rM1W0YN5T mJn0UwoQPwWI1r3VIGSqclsZ2XT9i51m2vvxTZNPoG9qCbUWgs8un0Lw1eqa8WY9mKYf ySN63NG73xxcTsggFyJQ20tdwZY6D2w4rLU7Wm5aP0fZC+z2usglKAbZGM/djGg8VxxF Of/3Yi9jK/+H0CSQfFylMAqrc6agOinHMmX+2d3X2zmJ/HZtwcOe+cg9pUFKi2FjxwoB j++Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710001214; x=1710606014; h=content-transfer-encoding:mime-version:face:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Kgzsvs8jhrLTiQFKFIHZoTw+5YxMWjSF4qDtsfUOBq8=; b=FTgtPppl7XLWmc6bPaBmW0z1xeyrUUYHyH7GMutwHaWMz+NWmcT2dJNED7l9tSWH+3 DicUonbBypNvsmAckzozDyOStoDfhQ/tgz8HIJHs35K88/DnpQ7tltWVbsnvfWcYwRSJ BMUGAcTrjIN88DL4p9MQKR7tpslmKmjxQvFM/SkbYv1a30uZejEttxUumjSJZE73ZnYx 0ji2R0TgdNhucsx5j4yH7ravSgbCH6jLHp/3IYiPxb3q2Pip9dwzQgVt1QX9+MJnCfkF cpEar7+wiCV44LMY4IrtfNXgnLnp7wtsFFBC/PJpb4IgX3aUvZEZCkJ4FuHP4kni6YfY 0HhQ== X-Gm-Message-State: AOJu0YxJA4DrGWwiUIV60RB5nJzYxJwb0nI3RlDWCzY/M+wPHSkYSnRi cMP3L/2o+GJDs9GeeDNAfYd9uawua1hGlDm6c3vhitrYs45e2CrY X-Google-Smtp-Source: AGHT+IHfGzEwPvDzBou3WzTGXeQVbvL1QFVtqprlcL51pDaNVBXrNb0PgZroaF6oC4S7EeLsPkIoZQ== X-Received: by 2002:a17:906:f215:b0:a45:b1cf:42f6 with SMTP id gt21-20020a170906f21500b00a45b1cf42f6mr1230587ejb.9.1710001214041; Sat, 09 Mar 2024 08:20:14 -0800 (PST) Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu. [213.222.160.137]) by smtp.gmail.com with ESMTPSA id j20-20020a170906411400b00a45c18345e0sm1028451ejk.163.2024.03.09.08.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 08:20:13 -0800 (PST) From: Felician Nemeth To: Sebastian Poeplau Subject: Re: bug#69657: Missing imenu entries with eglot References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> Date: Sat, 09 Mar 2024 17:20:12 +0100 In-Reply-To: <87bk7oz6vc.fsf@mailbox.org> (Sebastian Poeplau's message of "Fri, 08 Mar 2024 23:28:26 +0100") Message-ID: <87v85v1io3.fsf@betli.tmit.bme.hu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/ //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA AAAASUVORK5CYII= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 69657 Cc: 69657@debbugs.gnu.org, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) CC-ing Jo=C3=A3o, the maintainer of breadcrumb-mode. > I did M-x imenu, although I should add that I normally use > consult-imenu, which presents a flattened menu. That's also what I wrote > the patch for. Without the patch, I can jump to "bar" (M-x imenu RET Foo RET bar RET) and cannot jump to "Foo". With the patch, I can jump to "Foo" (M-x imenu RET Foo RET) and cannot jump to "bar". So the default / basic behavior has changed, but I don't think it is a definit improvement. >> On the other hand, the patch seems to ruin breadcrumb-mode: putting >> the point after "{}", the breadcrumb header line shows: "dir/test.cpp: >> Class > Foo" instead of the original "dir/test.cpp: Class > Foo > >> bar". > > If you move point _after_ "{}", you're outside of method "bar", aren't > you? Doesn't that mean the breadcrumb header is correct now and was > wrong before? This is the first time I use breadcrumb, so I don't really know what is the exact correct behaviour. But without the patch there are locations for with "bar" is present it the breadcrumb header, and with the patch there isn't any. Maybe this is a bug in breadcrumb, but applying the current version of the patch is going to ruin an existing feature. Additionally, with the patch, the *Completions* buffer shows: "3 possible completions: *Rescan* Foo". So maybe there is a bug in imenu as well, since it seems it cannot handle items having the same name. > for the record, this is the textDocument/documentSymbol response I'm > getting for the example in my original message: [...] This is what I get as well, so luckily the different clangd versions don't cause problems. ---- By the way, I haven't used consult before, but after a quick look at it, I think consult-imenu could use the breadcrumb-kind text properties to show additional information in its live preview mode. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 09 20:07:28 2024 Received: (at 69657) by debbugs.gnu.org; 10 Mar 2024 01:07:29 +0000 Received: from localhost ([127.0.0.1]:35016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rj7ey-000842-Jb for submit@debbugs.gnu.org; Sat, 09 Mar 2024 20:07:28 -0500 Received: from mail-lf1-f50.google.com ([209.85.167.50]:54703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rj7ev-00083n-Bh for 69657@debbugs.gnu.org; Sat, 09 Mar 2024 20:07:28 -0500 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5131c0691feso4407639e87.1 for <69657@debbugs.gnu.org>; Sat, 09 Mar 2024 17:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710032746; x=1710637546; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l03ABOgB1iBmt17n2yy5yh/dpTsws/uS/09bkJ44sS4=; b=GTW8hkNI3XuV5GRvHvy14/qtQ5YnPbJkh8YJb5Jhvp7T5a46A4UHwc6yOrs4GtgAFT k2CcRVSJ6Ttpu36BT2LuBTtrsPY3owiMrPmTn1IdR40VtrmxRkLCNE4nVFuig0F4tNjh 0J0RsKuqy3pB6PPwmgp6tX62b72MR7RVqzJFRiE/3m2mDdlQ5uKzcCsfcgCkVDXVB/96 lKRCSk5YE65Ajynui2d9scg6RUOQcaSWSYRdzNgV/IszoSIIaq013iRILE+vL3hCKrUV BXQoiK9f2c9QzbmrAmosKsDIplzieDnWH40n9GKp4HxJ3ubKPL/cktpxZTAwSv5mQAiS h8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710032746; x=1710637546; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l03ABOgB1iBmt17n2yy5yh/dpTsws/uS/09bkJ44sS4=; b=pRcWOIXdZrV02b4+gExDNdOav0RC5NyddgVZer0Ne+JbW/jdET2OLx11hB4kRvN8dC 2BiBesFELJQitVmtL9z695Tc4DGitQ2ttcQa0Vqv/6B92IBC1BwXfEUKAfKyJ2BIKe5S /O9nyl8aoLteCtsXSU6S53KzMEZdTMLD3prsNyTYgKtzgJdvOBrvG5dd07Sdw/K1Tb4h 0UJmPZO61uNozHjRRXbWEuvLjLREQz98IA0alvcLuM29RCgMpoHJbPTbSJNqhiYgld+9 afLKhoqCUsbX+wkJuBoqs6SRePhB8VEg6V/Azmxq3/SGsfCb3Bx/N7AUJJWs4Pjv9Rxj 5pYw== X-Forwarded-Encrypted: i=1; AJvYcCUSVYEboLx21J2zbpciggeRewDGE7LF9z/MRdzUBs3UGqpndgkS/7WzD4nHQN6raGy9mZpBAYMKNq6dTak1/dLQiZdEWKM= X-Gm-Message-State: AOJu0YzfwiFBXjIamHyWbuw+AiPRSP1hsnnozTWk2G4gzL9MgzLaHCrX sEUVSkGkCi4Ez5hbUXAEvgKKUeiCern+8QAglX1zL09Pr4C7OIgV6X9lNQH0ND/T2Nx7G3K016G pVwP3leWH7G7p604j+hS8X3bTtvo= X-Google-Smtp-Source: AGHT+IFAXqLuyEu2bjLxVAdiKFZAz481tx2glDPqPNGsy3T3jdYgleZuu4BaKpcG0kPGLuS/DsKu3hnre7hHB9gzsNo= X-Received: by 2002:a05:6512:2353:b0:512:fded:e674 with SMTP id p19-20020a056512235300b00512fdede674mr2185920lfu.61.1710032746085; Sat, 09 Mar 2024 17:05:46 -0800 (PST) MIME-Version: 1.0 References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> <87v85v1io3.fsf@betli.tmit.bme.hu> In-Reply-To: <87v85v1io3.fsf@betli.tmit.bme.hu> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 10 Mar 2024 01:05:34 +0000 Message-ID: Subject: Re: bug#69657: Missing imenu entries with eglot To: Felician Nemeth Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 69657 Cc: 69657@debbugs.gnu.org, Sebastian Poeplau X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sat, Mar 9, 2024 at 4:20=E2=80=AFPM Felician Nemeth wrote: > > CC-ing Jo=C3=A3o, the maintainer of breadcrumb-mode. I've made a file with class Foo { void bar() {} }; And the imenu--index-alist calculated by Eglot has what I think is the most sensible way to represent this within the ancient rigid limitations of that variable's format. ((#("Foo" 0 3 (breadcrumb-region (1 . 31) breadcrumb-kind "Class")) (#("bar" 0 3 (breadcrumb-region (15 . 28) breadcrumb-kind "Method")) . 15))) I understand Sebastian wants to see an extra top-evel ("Foo" . 1) there or something, but that leads to two entries with duplicate names and imenu just doesn't like that (if I apply the patch I just can't go to 'bar' with = M -x imenu), neither do some of its clients. This is way Eglot emits "breadcrumb"-friendly cookies to overcome imenu's limitations. Using breadcrumb i can jump to Foo and Foo > bar just fine (using `M-x breadcrumb-jump`). These cookies are innocuous to anyone else. But I guess if someone took th= e time to consecrate them as imenu things instead of breadcrumb things. Then others UIs could use them. Or someone could invent something much better than imenu and have Eglot write to that idk. Imenu is pretty cursed, but i= t's what was already there so I picked it. Anyway, if users don't like Eglot's imenu function, they can use something else. Eglot's imenu is different from c++-ts-mode, and afaik c++-ts-mode's= is already different from c++-mode's. I wouldn't install this patch though, teach other UIs about those optional cookies seems like a better deal that doesn't break stuff. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 10 13:01:53 2024 Received: (at 69657) by debbugs.gnu.org; 10 Mar 2024 17:01:54 +0000 Received: from localhost ([127.0.0.1]:37785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjMYb-0007Fw-4B for submit@debbugs.gnu.org; Sun, 10 Mar 2024 13:01:53 -0400 Received: from mout-p-201.mailbox.org ([80.241.56.171]:52372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjLzZ-000665-9x for 69657@debbugs.gnu.org; Sun, 10 Mar 2024 12:25:42 -0400 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-201.mailbox.org (Postfix) with ESMTPS id 4Tt4xB002hz9smL; Sun, 10 Mar 2024 17:24:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1710087870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nYK+h01rvXGjwyXNGwAq/t/4rwfP6BkDfVZbGnhVsl0=; b=nM6ky1aqbzySMPkC18AeosT5Bg6t59h3mKYsb2IbtO9nKZcTnbg3qW6cfeu9k03RbvvCi/ eCQs3edzz+f9KOS2JvRny9+GocBihIdgiuSX/Vgw2xtH/RwggCd5Zjl2p8LTg48f969R1A CZHS2fOHRhGB0IaQ19+2xndE87ft2iLSwmbHpoD+/sLJPLXSkpI6ExO+VwTUafQ4e6+rrr F9LAZDMLMP0GYzNJ2S7iIsAlnDPlyG3vKjnXbtBghG3WzPGocq5O0MFY31kB0vv0JL/rwe d6E16AmDpUQHTtw6tNalI4saSsVoCQNV2qwia/xwIGYa0opvBEY1WMIpEI9bVg== References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> <87v85v1io3.fsf@betli.tmit.bme.hu> From: Sebastian Poeplau To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#69657: Missing imenu entries with eglot Date: Sun, 10 Mar 2024 17:15:49 +0100 In-reply-to: Message-ID: <87jzmat5qe.fsf@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain X-MBO-RS-META: cq3uq4fkub8oi74a6ij7e14x14r11eha X-MBO-RS-ID: 2de65faf15db06da3b4 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69657 X-Mailman-Approved-At: Sun, 10 Mar 2024 13:01:52 -0400 Cc: 69657@debbugs.gnu.org, Felician Nemeth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I understand Sebastian wants to see an extra top-evel ("Foo" . 1) there > or something, but that leads to two entries with duplicate names and imenu > just doesn't like that (if I apply the patch I just can't go to 'bar' with M > -x imenu), neither do some of its clients. What about naming the separate entry differently, e.g., "Foo (top)"? I'll certainly look into using the breadcrumb metadata instead, but that doesn't help users of plain imenu. > This is way Eglot emits "breadcrumb"-friendly cookies to overcome imenu's > limitations. Using breadcrumb i can jump to Foo and Foo > bar just > fine (using > `M-x breadcrumb-jump`). Thanks for the hint, I didn't know about `breadcrumb-jump'; I'd only used the headline feature before. > Anyway, if users don't like Eglot's imenu function, they can use something > else. Eglot's imenu is different from c++-ts-mode, and afaik c++-ts-mode's is > already different from c++-mode's. I wouldn't install this patch though, > teach other UIs about those optional cookies seems like a better deal that > doesn't break stuff. I wonder why I did get separate entries in consult-imenu with pylsp though. I'll have to give it another look, but it seems to me that in this case (e.g., with SymbolInformation objects) eglot's imenu function returns data that (a) works with plain imenu and (b) gives me what I expect with consult-imenu. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 10 15:35:27 2024 Received: (at 69657) by debbugs.gnu.org; 10 Mar 2024 19:35:27 +0000 Received: from localhost ([127.0.0.1]:37922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjOxC-0002hA-Ns for submit@debbugs.gnu.org; Sun, 10 Mar 2024 15:35:27 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:57443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjOxA-0002gv-EQ for 69657@debbugs.gnu.org; Sun, 10 Mar 2024 15:35:25 -0400 Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d311081954so43090891fa.2 for <69657@debbugs.gnu.org>; Sun, 10 Mar 2024 12:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710099225; x=1710704025; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2b2KwsL8Zb8PRNAf2akkyyQUi4egOjSkHEe5Rf0Gip4=; b=E/o9v8iy5OBlCLBgDulNer4Sf8lHhbbBTQ9cd1LFUjDoSx8PXZKZjNGH55iMtUNswS 6cl4KYbip8hKYw4Ef0ezMquX4V9ONKdVsve5tXrXiMsFiRMlJQw250vsa5najZlhnqn7 JkYh7UtKimUJOx3fKlOhs9az56Lrs4U8SRXX11CqHSBArjpJ3Ljt9aRjNsnWgddNAFVZ K1KATseYfiaUCxuziCNiKiGTJqNya7lqDoTrhC8q0D58N5U2h0fLR9A14xnYMbEACOtL lnfqMNSn+FVTwupiS1GF5B4HqHMVNGKxAqxMRGjeD1dxyeu1cAB2KZBzxMPepqe/iaeW xirw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710099225; x=1710704025; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2b2KwsL8Zb8PRNAf2akkyyQUi4egOjSkHEe5Rf0Gip4=; b=nGH3NCaLWF1c+8JnpbXuW9IjiLqjMTc3CasN5QDe7DkAfTP3C5n74IwPwYnbr74KtV lybbO7oXHwYN7+o19GhziITZdM9IP/q5qDV5VbnyQUSqHWw6R7Gji5xtb41y6Pp7SArp 8ADB20yYuzRM7iwNwthEReSNKrVcrOAj12kFLjdRFSnl8lGtSJ7T3mzpBzGn9NOqECPU 2AsjIUIZVIok9YCJ3oDlBsZUQPNt4yPW1z8GTDzDDvOTgqZwmj99HWB+EQNPrY127QX9 bCvsr8HCg7ZulFHpUc0iLf6/L7HsBKwk8osXrGPgvrVhFe/NexUaRY2OydsDX9rq7F8V EwlQ== X-Forwarded-Encrypted: i=1; AJvYcCXnA1YFFthRmQmLuxOHV/YsiiyAQB6aSfuH9K79iekubs/o12tHD95cXSlPvxHvM5Ye2gmzR8j26G3MkdpY2oCDzXkSLjw= X-Gm-Message-State: AOJu0Yzquzayv5ZHWI9dSBLIDW2W4ZPoywXIobvkcde7Y1uC3cyy6IsU bZZKG862S7JBopPao4ZRx29JQzkqRuhtxfi8ZIXp3HKn9GZY4qYFniZYJgPj5qjLPrErlo+Pb1w Uic0+3+YRARaN7AWLvJmPujC/tO4= X-Google-Smtp-Source: AGHT+IEuIhc2hDBYDYLOTmak48Lihu25tsaAdcKEvikgbWz6qWmd41PzP1G96vfRwfv0Fla7QEBgLGQ/PHxMkDkf79c= X-Received: by 2002:a2e:8ece:0:b0:2d4:2e12:93fa with SMTP id e14-20020a2e8ece000000b002d42e1293famr2104093ljl.3.1710099224674; Sun, 10 Mar 2024 12:33:44 -0700 (PDT) MIME-Version: 1.0 References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> <87v85v1io3.fsf@betli.tmit.bme.hu> <87jzmat5qe.fsf@mailbox.org> <87frwxuc1w.fsf@mailbox.org> In-Reply-To: <87frwxuc1w.fsf@mailbox.org> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Sun, 10 Mar 2024 19:33:58 +0000 Message-ID: Subject: Re: bug#69657: Missing imenu entries with eglot To: Sebastian Poeplau Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 69657 Cc: 69657@debbugs.gnu.org, Felician Nemeth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sun, Mar 10, 2024 at 7:22=E2=80=AFPM Sebastian Poeplau wrote: > Here's the return value of eglot-imenu with pylsp: > > ((#1=3D"Class" > (#("Foo" 0 3 (breadcrumb-kind #1# breadcrumb-region (1 . 44))) . 1)) > (#2=3D"Method" > ("Foo" (#("bar" 0 3 (breadcrumb-kind #2# breadcrumb-region (16 . 44)= )) . 16)))) > For completeness, this is pylsp's response to > textDocument/documentSymbol: See https://microsoft.github.io/language-server-protocol/specifications/lsp= /3.17/specification/#textDocument_documentSymbol pylsp does this because it is old, it uses SymbolInformation. clangd and most other servers use DocumentSymbol[] which is not only much more powerful and logical for represting a file's AST but also doesn't lend itself well to that structure of categorization, which is rather useless except for the fact that it makes leaves out of AST non-leaves. The problems are in Imenu. You should rather lobby for a better imenu structure (which will be hard to do fully backward compatibly will all existing UIs -- except if you use the string properties trick that Eglot/breadcrumb use as I explained) You could also lobby for a brand new imenu replacement in Emacs. Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 10 22:46:24 2024 Received: (at 69657) by debbugs.gnu.org; 11 Mar 2024 02:46:24 +0000 Received: from localhost ([127.0.0.1]:38223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjVgB-0005Lq-EG for submit@debbugs.gnu.org; Sun, 10 Mar 2024 22:46:24 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:39190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rjOlS-0002Nv-G6 for 69657@debbugs.gnu.org; Sun, 10 Mar 2024 15:23:20 -0400 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 4Tt8tj1LWZz9sq4; Sun, 10 Mar 2024 20:22:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1710098557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Fd8MSf9A7rnlD/DPorGeXUN+aKKhyABVy0gdUgRGfV8=; b=UmDq5CIADAwBrsETWdducvM3uEklwbKOEz0uMvIgDz6i3N+27cb4v3nvN57EAP1qxLuj0m /YN55M8f9Islk2wa3m2K5EksdV37kafBnXvuGgdIB+Z8Dvemlqt8GZCyI4S8AgH5qXyR7t gEPb1mWZHGsX4WvylXUZBXblwxyMQ9yqT5cc4ZoXidGNiJ2yh9eAWPjBLQxc1GYRXE3z0m 7T6/4RidjYnX1Ews4BVmXXHfZFpcv2jmd7I46mUY3SV6kqVYqpSYiTJvk2EgBOPp7h23ZK n9CERK3ZWuo2k6KGeyNsNIufY2Rd/v9l8Imf2LzG0hJ/RdDDCUupDN8970UOPA== References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> <87v85v1io3.fsf@betli.tmit.bme.hu> <87jzmat5qe.fsf@mailbox.org> From: Sebastian Poeplau To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#69657: Missing imenu entries with eglot Date: Sun, 10 Mar 2024 20:15:04 +0100 In-reply-to: <87jzmat5qe.fsf@mailbox.org> Message-ID: <87frwxuc1w.fsf@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain X-MBO-RS-META: p3txumroh7jcx7zwg866mf7a4xng81k1 X-MBO-RS-ID: 97c55910d12e2fa5fd4 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69657 X-Mailman-Approved-At: Sun, 10 Mar 2024 22:46:17 -0400 Cc: 69657@debbugs.gnu.org, Felician Nemeth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > I wonder why I did get separate entries in consult-imenu with pylsp > though. I'll have to give it another look, but it seems to me that in > this case (e.g., with SymbolInformation objects) eglot's imenu function > returns data that (a) works with plain imenu and (b) gives me what I > expect with consult-imenu. Here's the return value of eglot-imenu with pylsp: ((#1="Class" (#("Foo" 0 3 (breadcrumb-kind #1# breadcrumb-region (1 . 44))) . 1)) (#2="Method" ("Foo" (#("bar" 0 3 (breadcrumb-kind #2# breadcrumb-region (16 . 44))) . 16)))) The Python code I used is the following: class Foo: def bar(self): pass Like I said before, in this case I would consider the behavior of plain imenu, consult-imenu, and which-function-mode as correct, even though they don't use the breadcrumb annotations. I can jump to both the class and the method, and outside the method which-function-mode tells me that I'm in Foo. Maybe we could make eglot produce something similar for the data from clangd... For completeness, this is pylsp's response to textDocument/documentSymbol: { "jsonrpc": "2.0", "id": 21, "result": [ { "name": "Foo", "containerName": null, "location": { "uri": "file:///tmp/test.py", "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 3, "character": 0 } } }, "kind": 5 }, { "name": "bar", "containerName": "Foo", "location": { "uri": "file:///tmp/test.py", "range": { "start": { "line": 1, "character": 4 }, "end": { "line": 3, "character": 0 } } }, "kind": 6 } ] } From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 17 07:40:14 2024 Received: (at 69657) by debbugs.gnu.org; 17 Mar 2024 11:40:14 +0000 Received: from localhost ([127.0.0.1]:57703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlos9-0004pG-De for submit@debbugs.gnu.org; Sun, 17 Mar 2024 07:40:14 -0400 Received: from mout-p-201.mailbox.org ([80.241.56.171]:60638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlobz-0001f1-Jr for 69657@debbugs.gnu.org; Sun, 17 Mar 2024 07:23:32 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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-201.mailbox.org (Postfix) with ESMTPS id 4TyFvn5LgFz9srv; Sun, 17 Mar 2024 12:22:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1710674565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ylmcWX2xfdPCOMZfyOd1Kfi8yImkpUz8rFulKP4MtOg=; b=ElbW03L2Q0tWV6r8K7jV/jqIXOZsZ0JYYDb6BwAbYv3jw+VkvYwC6n9md2MulZiiID9/NU tByQ0Xm2wfAd4sP268S9tsxsmLbmQ0y7x8E34DCsscPp1pOkiVkJznmFwMqT6Ug60u2RgZ BVWMWT2E3obFq3AR/3d/w7GxLPIzWEJjAbpZBaoDKxvR/HC99HPiWHvJnLM1004Iq/Cmsf yg9wZ+omkGx/wBDkukCHjoxXIlKuEt2cFPKNAZvgNf3+xiBSxgUZiXvLirtj92bw9wrc1Y vKLHSQK52BhYRxDZSyxletOv7ADNX9OKfN79RYl+KlE8n3ai1kpwnEIv/eEYvg== References: <87frx0ze5n.fsf@mailbox.org> <87a5n8s8jw.fsf@betli.tmit.bme.hu> <87bk7oz6vc.fsf@mailbox.org> <87v85v1io3.fsf@betli.tmit.bme.hu> <87jzmat5qe.fsf@mailbox.org> <87frwxuc1w.fsf@mailbox.org> From: Sebastian Poeplau To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#69657: Missing imenu entries with eglot Date: Sun, 17 Mar 2024 12:04:07 +0100 In-reply-to: Message-ID: <87bk7dt858.fsf@mailbox.org> MIME-Version: 1.0 Content-Type: text/plain X-MBO-RS-META: yupqooe5rq3qtyf7n8ndmzudhbnqu5hd X-MBO-RS-ID: 665cb7b48bd606ac1a6 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 69657 X-Mailman-Approved-At: Sun, 17 Mar 2024 07:40:11 -0400 Cc: 69657@debbugs.gnu.org, Felician Nemeth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > The problems are in Imenu. > > You should rather lobby for a better imenu structure (which will be > hard to do fully backward compatibly will all existing UIs -- except if > you use the string properties trick that Eglot/breadcrumb use as > I explained) You could also lobby for a brand new imenu replacement > in Emacs. I've been thinking about this. A "brand new imenu replacement" sounds like something that would be hard to get adoption for. So, assuming that we wanted to change the imenu structure to something that works better for representing ASTs, I think there are two somewhat related problems: (1) how to represent the AST internally, and (2) how to show it to the user. 1. The current representation in `imenu--index-alist', as you said, has the problem that it doesn't allow position information on inner nodes; also, additional metadata like the category has to be tagged on with text properties or other tricks. One could extend the existing structure. For example, leaves could become lists (name beg end category) with everything but NAME and BEG being optional, or something like that; inner nodes could optionally have the same format instead of being just strings. I don't see how to much such a change in a way that wouldn't break existing UIs, but maybe one could find a way that at least makes it easy for them to support the new structure (e.g., by providing helper functions in imenu.el, which could also facilitate future changes in `imenu--index-alist'). I guess while changing the structure one could try to optimize it for the use cases of existing UIs. Breadcrumb, for example, probably needs an efficient means of computing the most specific node corresponding to a buffer position, as well as the path down from the root to that node, and the list of its sibling nodes. 2. A menu structure like the one offered by M-x imenu or `imenu-add-menubar-index' makes it difficult to jump to inner nodes. The best I can think of is an entry labeled "(top)" or something like that underneath each leave node with a position; in my earlier example, the "Foo" menu entry would then expand to a list of two sub-entries, "(top)" and "bar". Alternative UIs probably have much better ways to display the information (such as the entry in consult-imenu that I was originally looking for). Even if this sounds like a nice improvement, I wonder about the compatibility issue. Do you think such a patch would even be considered?