From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alessandro Bertulli Newsgroups: gmane.emacs.help Subject: Xref/tags/lsp possible bug Date: Sat, 23 Apr 2022 14:17:03 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37013"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 23 14:18:21 2022 Return-path: Envelope-to: geh-help-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 1niEiS-0009Oj-Li for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 14:18:20 +0200 Original-Received: from localhost ([::1]:35072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niEiR-0004tU-5R for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 08:18:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niEhT-0004tJ-D9 for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 08:17:20 -0400 Original-Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]:44983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niEhQ-0007cv-PK for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 08:17:19 -0400 Original-Received: by mail-lj1-x229.google.com with SMTP id n17so12541351ljc.11 for ; Sat, 23 Apr 2022 05:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=8mQzSZagw+hB0CsqNOlhXqKIWGTTLTAkNkktEwl3dDs=; b=QVqQ5lPN49Vms4JM7ZkT/I2luISKGJBVygn9ABvcnUW2lgt3e4m9jx68sxtHg4qaXI e03rflY9Sq8qCT8g38ySEWlLnk6+assWvZ+ni6JOpTTTE5RF+Eskq8I8f26mjlAwwFZ4 KRh8fHpBs3y1SXaSFzcxzBPl6C1z/iZpiDzxGH3mnPQh36tg/9rAI7BPLwBATQh4YOHm nywhqAZprW7M1j5FEzu9AJw4gea7FZzWhin/QIchB+zA0Ue4HIdqc/si7yCt34dR0R40 RtWdDKLj+pcU2yG5HjPAswvG2VjYsxvNNuIJ2P5imz+/OanAg3DZiLgTOK4boqrOlY5c yaGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8mQzSZagw+hB0CsqNOlhXqKIWGTTLTAkNkktEwl3dDs=; b=WZE2+tdkwDVDqyt5y/aws6GuSpd7f7l47Flo/+xXCvZudv1X9MNycsUMk+P1/MrFzM XyK7jJfZ5FRTP3uovZq7elUGKuWKh1ATQJGi189Npc3VhU0KGgoEwTjdw+0bcwbIT0H9 wH/oFpX+ftCh7w/QPw9krU/CZ8uU+XkjdKHTRwGp299xCEBSP7z91P/pppRrkygWgmZm jZLx/3rVTwH8veSeFkGSlf78nXcUQ2Mz/FHidJHvXymwXXXy+6HbmIMbj8BI0ok9EfSM xDbxBuGfwto9Ct0ADvihMHWMlG7NSwi+wvFB8ip2nfxil1cILZPWfvyZbaysw8+0V+zy gXVg== X-Gm-Message-State: AOAM531SMeQpg9aY0P9hr+GPY5EeYez6pkMEhLloNs0FbZHo8mDVwBpI RSzHW3iBoqDvOwMsz7LM7DPePT8nIml8VBBmiAmHKYiAXNc= X-Google-Smtp-Source: ABdhPJzW+x4Uo/lxQpvC/zScrB0ZuHM7x1/SLA9GpOrZx1kTOi5iYg1fC2YLc8ikdv7D89CG1B0C/xeohl90FfFB2l4= X-Received: by 2002:a05:651c:234:b0:24d:ac46:ca7e with SMTP id z20-20020a05651c023400b0024dac46ca7emr5661861ljn.311.1650716234253; Sat, 23 Apr 2022 05:17:14 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=alessandro.bertulli96@gmail.com; helo=mail-lj1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136999 Archived-At: Hi all! I just stumbled upon a very strange behavior of Emacs, I don't know if it is a bug or an error of my configuration. Basically, I noticed two things: - First, when using LSP modes (both lsp-mode and eglot), the command xref-find-definitions only acts on the symbol under point. I explain: usually, in vanilla Emacs (emacs -q) if point is on a whitespace/not on a symbol, invoking the command (bound to M-.) will prompt you for an identifier to search for. However, when LSP is active, it directly searches for an empty symbol, for example reporting something similar to: "Symbol not found" (not the double space, which makes me think it searches for a symbol named ""). As I said, this happend both for lsp-mode and eglot, so maybe is a problem of xref? - Second, and minor: while I was investigating, I noticed that, depending on the loaded packages, when giving M-., xref sometimes asks for the symbol to search, sometimes it asks the TAGS table first. What package can be the problem? Do you think it is a bug of Emacs? Do you know a way to resolve? Thanks to all! ############ I report some useful infos: Emacs version: This is GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-04-20 lsp-mode version: 20220422.2059 xref version: 1.4.1 ########## Steps to reproduce: -First bug: - launch emacs -q - go on an C++ file - on a whitespace, give M-.. The prompt says "Find definition of: " - close and restart with the provided file (emacs -q --load file, see end of the mail) - go on the same C++ file - launch lsp-mode (M-x lsp) - on the same whitespace, give M-. The minibuffer says "Unable to find symbol in current document" (note the bouble space). In *Messages* buffer, the error is reported perfized with the string "user-error: ". - give M-x lsp-find-definition on the same whitespace. The minibuffer says: "LSP :: Not found for: " (note the space at the end). -Second bug: - launch emacs -q - go on a C++ file - on a whitespace, give M-. The prompt says "Find definitions of: " - close and restart with provided file (emacs -q --load file) - go on the same C++ file - on the same whitespace, give M-. The prompt says "Visit tags table (default TAGS): " - go on an elisp file, do the same, the prompt says "Find definitions of: " ############# Test init file (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(package-selected-packages '(helpful transient-dwim ivy projectile eglot magit lsp-ui flycheck which-key yasnippet-snippets yasnippet lsp-mode company)) ) ;;-------------- ;; Enable MELPA ;;------------- (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities` ;; and `package-pinned-packages`. Most users will not need or want to do this. ;;(add-to-list 'package-archives '("melpa-stable" . " https://stable.melpa.org/packages/") t) (package-initialize) (setq pkg-list '(helpful transient-dwim ivy projectile eglot magit lsp-ui flycheck which-key yasnippet-snippets yasnippet lsp-mode company)) (mapc (lambda (pkg) (unless (package-installed-p pkg) (package-install pkg)) (require pkg)) pkg-list) ;;------------ ;; Various ;;------------- (setq confirm-kill-emacs #'y-or-n-p) (tool-bar-mode 0) (global-flycheck-mode) (setq sentence-end-double-space nil) (show-paren-mode) ;;-------------- ;; Help - transient-dwim ;;-------------- (which-key-mode 1) (global-set-key (kbd "C-M-SPC") #'which-key-show-major-mode) (global-set-key (kbd "M-=") 'transient-dwim-dispatch) ;; Helpful --------------- (global-set-key (kbd "C-h f") #'helpful-callable) (global-set-key (kbd "C-h v") #'helpful-variable) (global-set-key (kbd "C-h k") #'helpful-key) (global-set-key (kbd "C-h M-.") #'helpful-at-point) ;;------------ ;; Ivy ;;---------- (ivy-mode 1) (setq ivy-use-virtual-buffers t) (setq ivy-count-format "(%d/%d) ") ;;----------------- ;; YASnippet ;;----------------- (require 'yasnippet) (yas-reload-all) (yas-global-mode) ;;-------------- ;;Projectile ;;------------------- (require 'projectile) (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) (projectile-mode +1) ;;------------------ ;; Eglot ;;------------------ (require 'eglot) ;;use flychech instead of flymake (add-to-list 'eglot-stay-out-of 'flymake) ;;suggested by the repo (define-key eglot-mode-map (kbd "C-c r") 'eglot-rename) (define-key eglot-mode-map (kbd "C-c o") 'eglot-code-action-organize-imports) (define-key eglot-mode-map (kbd "C-c h") 'eldoc) ;;---------------- ;; Language Server Protocol ;;-------------- (require 'lsp-mode) ;; apparently, this must be done before loading in any way lsp-mode (setq lsp-keymap-prefix "C-c l") (define-key lsp-mode-map (kbd "C-c l") lsp-command-map) ;; this must be called after to let which-key see the new prefix, think (add-hook 'lsp-mode-hook 'lsp-enable-which-key-integration) (define-key lsp-mode-map (kbd "M-RET") 'lsp-execute-code-action) ;;suggested by lsp-java doc (setq lsp-completion-enable-additional-text-edit nil) ;;copied from https://emacs-lsp.github.io/lsp-mode/tutorials/CPP-guide/ ;;probably is better (with-eval-after-load 'lsp-mode (add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration) (yas-global-mode)) ;; lsp-mode is not activated by default in the c++-hook so that ;; the second bug can also be reproduced. ;; However, if needed, uncomment this line ;; (add-hook 'c++-mode-hook 'lsp) ;;--------------- ;; lsp-ui ;;-------------- (eval-after-load 'lsp (eval-after-load 'lsp-ui (setq lsp-ui-sideline-show-hover t) )) ;;------------------- ;; Company (should be called after lsp-mode?) ;;------------------ (add-hook 'prog-mode-hook 'company-mode) (define-key prog-mode-map (kbd "C-M-i") 'company-complete) (eval-after-load 'comapny '(define-key company-mode-map (kbd "") 'company-complete)) (eval-after-load 'company '(define-key company-active-map (kbd "") 'company-complete)) (eval-after-load 'company '(add-to-list 'company-backends 'company-capf)) (setq company-minimum-prefix-length 1) (run-hooks 'after-init-hook)