Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy resolve lnum/col in quickfix items #20783

Open
mfussenegger opened this issue Oct 23, 2022 · 1 comment
Open

Lazy resolve lnum/col in quickfix items #20783

mfussenegger opened this issue Oct 23, 2022 · 1 comment
Labels
enhancement feature request performance issues reporting performance problems
Milestone

Comments

@mfussenegger
Copy link
Member

mfussenegger commented Oct 23, 2022

Feature already in Vim?

Afaik no

Feature description

Problem

Currently it is necessary to provide the lnum and col (+ _end variants) eagerly when setting quickfix items. Calculating the position can be expensive. E.g for LSP it would be useful if resolving those values could be done lazy/ad-hoc and asynchronous when needed.

There would probably be a lot of BWC cases to consider, e.g. how this would work for existing uses of getqtflist.

Concrete use case:

Querying workspace symbols via LSP. In neovim this is currently exposed via the vim.lsp.buf.workspace_symbol function. Using this function queries LSP for the symbols and populates the quickfix list with the results. Users can then jump to the definition of a symbol via the quickfix list.

There are two problems:

  • The existing implementation ignores that the language server usually uses UTF-16 offsets. This could be fixed in the implementation, but would make it slower as we'd have to read the line for each position to convert utf-16 offset to byte indices. (We already do this in other places, which could also be changed to improve performance if it could be done lazy/as-needed)
  • They added a workspaceSymbol/resolve capability in 3.17.0 of the specification to allow language servers to defer the calculation of the position (because it can be expensive). You'd first list all items and only if the user selects one resolve its position. It's currently not possible to use a quickfix list to implement this. (Unless we'd eagerly resolve all symbols, but that defeats the purpose of the capability).

Alternative Solutions

  • Create and use a custom buffer/widget for the workspace symbol case
@mfussenegger mfussenegger added the enhancement feature request label Oct 23, 2022
@justinmk justinmk added this to the unplanned milestone Oct 24, 2022
@justinmk
Copy link
Member

Sounds like something Vim should do upstream. Quickfix is a complex interface that gets a lot of attention from upstream Vim, and not something we want to own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request performance issues reporting performance problems
Projects
None yet
Development

No branches or pull requests

2 participants