oxalica / nil

NIx Language server, an incremental analysis assistant for writing in Nix.
Apache License 2.0
1.39k stars 43 forks source link

Highlight breaks after certain amount of lines #154

Open frankitox opened 1 week ago

frankitox commented 1 week ago

Hi! I'm using nil via vim + neovim/nvim-lspconfig. It's working pretty well, but once in a while I try to use :lua vim.lsp.buf.document_highlight() which highlights the variable that's on the cursor. This works in simple code, but the more complex it gets, the less likely I'll see all the references. Here's two examples that differ in only one line:

image image

{ config, lib, rycee-lib, ... }:

let
  pepe = x: lib.mkMerge [
    {
      extensions = [
        config.nur.repos.rycee.firefox-addons.ublock-origin
        config.nur.repos.rycee.firefox-addons.darkreader
        config.nur.repos.bandithedoge.firefoxAddons.imagus
        # https://addons.mozilla.org/en-US/firefox/addon/art-project/
        # https://addons.mozilla.org/en-US/firefox/addon/shortkeys/
        # istilldontcareaboutcookies-1.1.1
        (rycee-lib.buildFirefoxXpiAddon {
          meta = with lib;
            {
              homepage = "https://github.com/reblws/tab-search/";
              description = "Easy tab search & management. Get a keyboard-accessible search interface for managing your tabs.";
              mozPermissions = [
                "tabs"
                "activeTab"
                "storage"
                "sessions"
                "bookmarks"
                "history"
              ];
              platforms = platforms.all;
            };
        })
      ];
    }
  ];
in
{
  programs = (pepe { });
}
oxalica commented 2 days ago

I think this is expected since Document Highlight is more like a quick fuzzy glance for all related code. If the variable is defined hundreds lines above the usage, you cannot highlight it anyway because it's out of the screen.

You can always use precise "Goto Definition" and/or "References" to get a complete list.