llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.1k stars 11.6k forks source link

[clangd] Clangd's #include CodeCompletion could use a fuzzier finder across '/' #109735

Open torshepherd opened 3 hours ago

torshepherd commented 3 hours ago

Clangd's CodeCompletion for #includes currently does a fuzzy match but not across /. For example,


#include "cl // at the end here within llvm codebase, clangd will suggest "clang/"
#include "Expr.h // clangd can't figure this one out
#include "clASExpr.h // clangd can't figure this one out

There are two issues with this: 1) folders don't make sense for includes, and 2) you have to find which folder you want to include from before moving on to the next fuzzy part of the path.

In contrast, the vscode native file picker ctrl-p with clASExpr or with Expr finds clang/AST/Expr.h as expected.

There are two ways we could improve the clangd file completion experience:

  1. Allow autocompletes to skip directory levels, so that Expr.h finds clang/AST/Expr.h
  2. Allow fuzziness across /, so clASExpr.h finds clang/AST/Expr.h
llvmbot commented 3 hours ago

@llvm/issue-subscribers-clangd

Author: Tor Shepherd (torshepherd)

Clangd's CodeCompletion for `#include`s currently does a fuzzy match but not across `/`. For example, ```cpp #include "cl // at the end here within llvm codebase, clangd will suggest "clang/" #include "Expr.h // clangd can't figure this one out #include "clASExpr.h // clangd can't figure this one out ``` There are two issues with this: 1) folders don't make sense for includes, and 2) you have to find which folder you want to include from before moving on to the next fuzzy part of the path. In contrast, the vscode native file picker `ctrl-p` with `clASExpr` or with `Expr` finds `clang/AST/Expr.h` as expected. There are two ways we could improve the clangd file completion experience: 1. Allow autocompletes to skip directory levels, so that `Expr.h` finds `clang/AST/Expr.h` 2. Allow fuzziness across `/`, so `clASExpr.h` finds `clang/AST/Expr.h`