glean-lsp

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info Package maintainers For package maintainers and hackage trustees Candidates glean-lsp is a generic LSP server that provides a minimal set of LSP features using Glean data. A Glean-based LSP is particularly suited for navigating very large codebases, where it wouldn't be practical to use a traditional language service that parses all the source files on the fly. The Glean LSP server works for any language supported by Glean and Glass, and currently provides the following LSP features: More features may be added in the future. The LSP server is purely static, in that it will not re-index the source files if they are edited. To update the Glean data, currently you have to manually re-run the indexer yourself. This can be done without restarting VS Code or the LSP server, though. cabal install glean-lsp First index your source code into a Glean DB. This will be something like where See the Glean manual for any language-specific options that you might need. To use this LSP server with VS Code you need a generic LSP client such as Generic LSP Client (v2). Using that client, add the following to .vscode/settings.json where Now if you open this workspace in VS Code and open one of the source files that was indexed, you should have go-to-definition and the other features available. Clone a copy of React: Start a Glean server: If you don't have Flow installed: Index the code into a DB called react/0: Put the following into /tmp/react/.vscode/settings: Start VS Code, and open the folder react that you cloned. You probably want to disable the built-in TypeScript extensions to avoid conflicts: Ctrl-Shift-X and filter on built-in extensions (Show Built-in Extensions in the ... dropdown), then disable the extensions for TypeScript for this workspace only. Now open a .js file, and you should have navigation features provided by glean-lsp: try right-click and "Go to Definition" or "Go to References". Check that the Outline view is populated. Try symbol search with Ctrl-T. In the "Output" pane, select the output for the LSP client in the dropdown on the right to see the debugging output. A common problem is the file paths not matching up, which will result in the LSP server starting up and appearing to be working, but go-to-definition just doesn't work. Make sure that in the Glean DB the file paths are all relative to the root of the workspace. To check this you can open the DB in the shell and query for src.File _. For example when I look at my DB stackage/1 which contains all the Haskell packages in Stackage: Check that the paths look reasonable. If not, you may need to use language-specific options to get the indexer to generate the right paths. If the paths look OK, things should work to the extent that support for the language is implemented in Glean's codemarkup layer and the Glass server. Some languages might be missing certain features, but the basics should work for most languages. If you're still having trouble try raising an issue on the Glean issue tracker or asking on Discord, details of which are in Glean's README.


License
BSD-3-Clause
Install
cabal install glean-lsp-0.1.0.0

Documentation

CI Glean demo Docker image

Glean

Glean home | Documentation

Glean is a system for working with facts about source code. You can use it for:

  • Collecting and storing detailed information about code structure. Glean is designed around an efficient storage model that enables storing information about code at scale.

  • Querying information about code, to power tools and experiences from online IDE features to offline code analysis.

Status

Glean is pre-release software. There are many rough edges; there are limited language indexers available initially; the build system is not as smooth as we would like. However, we want to make it available for you to experiment with and contribute to.

We'd love to hear feedback! If you run into problems or have suggestions please file an issue.

Language coverage

There is currently full support for:

We also support the SCIP or LSIF code indexing formats, for:

Custom indexers for these languages exist but aren't in the open source release yet; we hope to make these available in the future:

  • Python
  • Java
  • Kotlin
  • Erlang
  • Thrift
  • Buck and Bazel
  • C#

License

Glean is licensed under a BSD LICENSE.

Contributing

We'd love to have your help developing Glean. Please submit pull requests on github, and note that we need contributors to sign the Contributor license agreement before we can accept your pull request.

Style guide: for Haskell code, we use hlint to check for style issues. Lines wrap at 80 columns. Code should be -Wall clean. For C++, code should compile with Clang or GCC.

How to contact the Glean team

Building

See Building Glean.

Docker demo

For demo of the react codebase with hyperlinks powered by glean run docker run -ti -p8888:8888 ghcr.io/facebookincubator/glean/demo

Try out on your own codebase with a .flowconfig by running docker run -ti -p8888:8888 -v __YOUR_CODE_DIR__:/glean_demo/code ghcr.io/facebookincubator/glean/demo

Play round using the glean binaries in a shell by running docker run -ti -p8888:8888 ghcr.io/facebookincubator/glean/demo shell