Skip to content

avoid having to open many files in large projects for (e.g.) textDocument/references #1155

Closed

Description

The context of this request is a project that has:

  1. Many O(100k) files.
  2. To facilitate this, is (partially) backed by a remote filesystem.

Though the problem is also apparently for projects with O(1k) files and many references and a local fs, just less so.

There exists an LSP implementation that can deal with such large projects, it has knowledge of all the relevant files. When calling something like textDocument/references in this project (editor use: Neovim 0.5.x with builtin nvim-lsp), a list is displayed with the resulting references (called the quicklist). The format is like this:

  1 caller.1.go|6 col 6| lib.CalledVeryOften()                                                                                                                                                                                                                                            
  2 caller.10.go|6 col 6| lib.CalledVeryOften()                                                                                                                                                                                                                                           
  3 caller.100.go|6 col 6| lib.CalledVeryOften()                                                                                                                                                                                                                                          
  4 caller.11.go|6 col 6| lib.CalledVeryOften()                                                                                                                                                                                                                                           
  5 caller.12.go|6 col 6| lib.CalledVeryOften()   
  ...

The template is <filename>|<lnum> col <col>|<text>. It is user-friendly to include the text because it can already give a hint about:

  • The arguments used (though in this example there are none).
  • The import alias used, if any.
  • Post-line comments.

Unfortunately, the textDocument/references response only contains a Location but not the line itself. So the editor has to open all files, potentially translate UTF-16 code units to whatever encoding it is using and read the line, in order to display the line.

This is quite expensive, as noted in neovim/neovim#13359.

A workaround would be to stop displaying the line snippet. That would regrettably not be as user-friendly. But I'm wondering if some thought on this had been spent on mitigating this latency/resource issue, perhaps by optionally returning the snippet in the response?

Activity

  1. dbaeumer commented on Dec 1, 2020

    @dbaeumer
    Member

    I am folding the issue with #396 with ask for similar support and we should have one solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions