fe8ee9c43a
feat: add the ability to limit the number of threads launched by `main_loop` ## Motivation `main_loop` defaults to launch as many threads as cpus in one machine. When developing on multi-core remote servers on multiple projects, this will lead to thousands of idle threads being created. This is very annoying when one wants check whether his program under developing is running correctly via `htop`. <img width="756" alt="image" src="https://user-images.githubusercontent.com/41831480/206656419-fa3f0dd2-e554-4f36-be1b-29d54739930c.png"> ## Contribution This patch introduce the configuration option `rust-analyzer.numThreads` to set the desired thread number used by the main thread pool. This should have no effects on the performance as not all threads are actually used. <img width="1325" alt="image" src="https://user-images.githubusercontent.com/41831480/206656834-fe625c4c-b993-4771-8a82-7427c297fd41.png"> ## Demonstration The following is a snippet of `lunarvim` configuration using my own build. ```lua vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" }) require("lvim.lsp.manager").setup("rust_analyzer", { cmd = { "env", "RA_LOG=debug", "RA_LOG_FILE=/tmp/ra-test.log", "/home/jlhu/Projects/rust-analyzer/target/debug/rust-analyzer", }, init_options = { numThreads = 4, }, settings = { cachePriming = { numThreads = 8, }, }, }) ``` ## Limitations The `numThreads` can only be modified via `initializationOptions` in early initialisation because everything has to wait until the thread pool starts including the dynamic settings modification support. The `numThreads` also does not reflect the end results of how many threads is actually created, because I have not yet tracked down everything that spawns threads. |
||
---|---|---|
.. | ||
src | ||
tests | ||
.eslintignore | ||
.eslintrc.js | ||
.gitignore | ||
.prettierignore | ||
.prettierrc.js | ||
.vscodeignore | ||
icon.png | ||
language-configuration.json | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
ra_syntax_tree.tmGrammar.json | ||
README.md | ||
tsconfig.eslint.json | ||
tsconfig.json |
rust-analyzer
This extension provides support for the Rust programming language.
It is recommended over and replaces rust-lang.rust
.
Features
- code completion with imports insertion
- go to definition, implementation, type definition
- find all references, workspace symbol search, symbol renaming
- types and documentation on hover
- inlay hints for types and parameter names
- semantic syntax highlighting
- a lot of assists (code actions)
- apply suggestions from errors
- ... and many more, check out the manual to see them all
Quick start
- Install rustup.
- Install the rust-analyzer extension.
Configuration
This extension provides configurations through VSCode's configuration settings. All configurations are under rust-analyzer.*
.
See the manual for more information on VSCode specific configurations.
Communication
For usage and troubleshooting requests, please use the "IDEs and Editors" category of the Rust forum.
Documentation
See rust-analyzer.github.io for more information.