From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Eglot "inlay hints" landed Date: Wed, 22 Feb 2023 19:42:00 +0000 Message-ID: <87356xv65z.fsf_-_@gmail.com> References: <83edqqaf8c.fsf@gnu.org> <2B284D77-97DF-4B3E-89FB-13F0CA93D240@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8508"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Dimitri Belopopsky , Chinmay Dalal , Po Lu , Eli Zaretskii To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 22 20:41:11 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pUuzH-00024y-RX for ged-emacs-devel@m.gmane-mx.org; Wed, 22 Feb 2023 20:41:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuyW-0006QP-1G; Wed, 22 Feb 2023 14:40:24 -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 1pUuyQ-0006Pv-CD for emacs-devel@gnu.org; Wed, 22 Feb 2023 14:40:18 -0500 Original-Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuyK-0006dm-Sd; Wed, 22 Feb 2023 14:40:16 -0500 Original-Received: by mail-wr1-x432.google.com with SMTP id r7so8699339wrz.6; Wed, 22 Feb 2023 11:40:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding: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=8cc68m7mFJddnIIzWDHv/E85mOwCmVfPFJkfxUeh+vU=; b=dxiraFxKX7dgEG3D7W/aDroyS46v+d8xGWoD+rkO1ogOAQcD3vzCquxv5it1G3uZtl yUTRVve89vPga7yY04a2ynSzT/BhNljIdlwKPtYmXuCdeqrBZ/k2hb4AIHx91Yiz8poc 4xjSBWM55qE7USxV4iTmJLizwaXMJGihQEwKXrpuVV75dLPvQjGBxpCCihc1nw/4mMRc XIjiPaujsmQDb+sbQ/jjviIBwlGVV4X6b0KtlQbadhFHvpOjUMo+67an8TWS9rgqCzJv tHVsk6tYGCcEUBiYbVwMAtTRTg1Rk9UJ2NQTrNV6BYNjZORzDy+/VaTo1kcMMdPDoCGJ UxUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=8cc68m7mFJddnIIzWDHv/E85mOwCmVfPFJkfxUeh+vU=; b=KpJwA8xDyeucVsqgpJGiy78e4Ds29JzBpRNLwZIx3azJLD8ONEHLQUZY8j0DnHQKWF WXxcUynBMGSMIpWK2k2hTvaF47XAl9GHnBqFaq27qywj0w3MHjG14KT2aGHZGF8D7LQj K8GmAIWj9b7KkSbj8OjIXRUx7DGhcI6NJLKwcxhiuFmDzUYVKVNVcXBDJnwQgisgr86J xOEoufhrDUAx3sv+C5eYfNR27+94fpU2PsKDyKTCaFtmojUhXx73gzTLE/wLgLn9o5OV Qz0pISakfHiynfUpOSlNWAFaWZtdgI+8PJ1qGeTxOoZSLdAK73ATufbIdXAoT6q2BbLx Xy6w== X-Gm-Message-State: AO0yUKXrUWrDZy4GX3Zeb4q/e07DFi2mj5flT2u38Kf/8KsZOko9HXQ+ p0rgVjYaNsgM6pYwgnQxOEZzg0BdU3A= X-Google-Smtp-Source: AK7set84Xfdn5nfNjGu8xnsScunymTl0uWusPRRHtru0Q0KQRXF6wVWIaSaoGiG54d/KRhuu8BVF/Q== X-Received: by 2002:a5d:47c9:0:b0:2bf:bf05:85ac with SMTP id o9-20020a5d47c9000000b002bfbf0585acmr7954408wrc.23.1677094808679; Wed, 22 Feb 2023 11:40:08 -0800 (PST) Original-Received: from krug ([87.196.72.142]) by smtp.gmail.com with ESMTPSA id z3-20020adff1c3000000b002c559def236sm6388572wro.57.2023.02.22.11.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 11:40:08 -0800 (PST) In-Reply-To: (Dimitri Belopopsky's message of "Tue, 21 Feb 2023 19:42:19 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=joaotavora@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303687 Archived-At: I've just landed Eglot "inlay hints" on lisp/progmodes/eglot.el in the emacs-29 branch. It's a feature that some users (including me) were looking for for some time. Inlay hints are small text annotations to specific parts of the whole buffer, not unlike diagnostics, but designed to help readability instead of indicating problems. For example, a C++ LSP server can serve hints about positional parameter names in function calls and a variable's automatically deduced type. Emacs can display these hints in many little 0-length overlays with an 'before-string property, thus helping the user remember those types and parameter names. Since inlay hints are potentially a large amount of data to request from the LSP server, the implementation strives to be as parsimonious as possible with these requests. So, by default, inlay hints are only requested for the visible portions of the buffer across windows showing this buffer. This is done by leveraging the 'window-scroll-functions' variable, making for a reasonably complex implementation involving per-window timers. When scrolling a window, it may take a short amount of time for inlay hints to "pop in". The new user variable 'eglot-lazy-inlay-hints' can be used to exert some control over this. Specifically, if the variable's value is set to 'nil', then inlay hints are greedily fetched for the whole buffer every time a change occurs. This is a much simpler mode of operation which may avoid problems, but is also likely much slower in large buffers. Also, because the inlay feature is probably visually suprising to some, it is turned OFF by default, which is not the usual practice of Eglot (at least not when the necessary infrastructure is present). This decision may be changed soon. Here's a good one-liner for enabling it by default in every Eglot-managed buffer: (add-hook 'eglot-managed-mode-hook #'eglot-inlay-hints-mode) I haven't tested inlay hints extensively across many LSP servers, so I would appreciate any testing, both for functional edge cases and regarding performance. There are possibly more optimization oportunities in the "lazy" mode of operation, like more aggressively deleting buffer overlays that are not in visible parts of the buffer. Though I ended up writing this one from scratch, I want to thank Dimitry Bolopopsky and Chinmay Dala for suggestions and early patches. Jo=C3=A3o