Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ For live updates on Fresh, [follow me on X](https://x.com/TheNoamLewis).
### Bug Fixes

* **LSP diagnostic fixes**: the gutter marker, `F8` target, hover, and panel now shift with inserted/deleted lines instead of freezing at the pre-edit position until the next save (#2602); and dismissing a hover popup no longer drops an unrelated error from the status bar, gutter, and `F8` navigation (#2601).
* **Rust LSP Reduced Memory mode**: hover and Go to Definition no longer silently fail on macro names and inside macro arguments (e.g. a call inside `println!(...)`/`format!(...)`); the mode was disabling proc-macro expansion, which rust-analyzer also uses to resolve identifiers inside macro invocations. Proc-macro expansion now stays on in Reduced mode (#2598).
* **LSP Rename keeps focus** - a cross-file F2 rename no longer jumps you to the definition's file at a stale cursor position (#2599).
* **LSP now pulls diagnostics from every server** configured for a language, not just the first - e.g. both `ruff` and `ty` for Python now stay live (#2615, reported by @ak24watch).
* **Format Buffer respects the selection** - with an active selection and a server that supports range formatting, only the selected range is formatted instead of silently reformatting the whole file (#2605).
Expand Down
2 changes: 1 addition & 1 deletion crates/fresh-editor/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
"enable": false
},
"procMacro": {
"enable": false
"enable": true
},
"cargo": {
"buildScripts": {
Expand Down
16 changes: 13 additions & 3 deletions crates/fresh-editor/plugins/rust-lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,23 @@ editor.on("action_popup_result", (data) => {
// Reduced-memory init options for rust-analyzer:
// - checkOnSave: false - disables cargo check on every save (#1 cause of slowdowns)
// - cachePriming.enable: false - no background indexing of entire crate graph
// - procMacro.enable: false - no proc-macro expansion (saves CPU/RAM)
// - cargo.buildScripts.enable: false - no build.rs
// - cargo.autoreload: false - manual reload only
//
// procMacro stays ENABLED on purpose. rust-analyzer resolves identifiers
// *inside* a macro invocation's arguments (and the macro name itself)
// through macro expansion, so turning procMacro off silently kills hover
// and Go to Definition for the macro name and everything inside its args —
// including built-in macros like println!/format!/assert!, which are among
// the most common cursor positions in real Rust code. Losing navigation
// there makes the editor look randomly broken, which is not the intent of a
// memory mode. Proc-macro expansion is comparatively cheap next to
// checkOnSave/cachePriming, and the process limits below still cap RAM/CPU.
// See issue #2598.
const REDUCED_MEMORY_INIT_OPTIONS = {
checkOnSave: false,
cachePriming: { enable: false },
procMacro: { enable: false },
procMacro: { enable: true },
cargo: {
buildScripts: { enable: false },
autoreload: false,
Expand Down Expand Up @@ -258,7 +268,7 @@ editor.on("action_popup_result", (data) => {
processLimits: REDUCED_MEMORY_PROCESS_LIMITS,
});
editor.restartLspForLanguage("rust");
editor.setStatus("Rust LSP: Reduced Memory mode — checkOnSave, procMacro, cachePriming disabled");
editor.setStatus("Rust LSP: Reduced Memory mode — checkOnSave, cachePriming, buildScripts disabled (macro navigation kept)");
break;

case "dismiss":
Expand Down
4 changes: 3 additions & 1 deletion docs/features/lsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ Some LSP servers expect a different `languageId` than Fresh's internal language

### Rust LSP Mode Switching

Use "Switch Rust Analyzer Mode" from the command palette to toggle between Full and Reduced Memory modes for rust-analyzer.
Use **Rust LSP: Configure Mode** from the command palette to toggle between Full and Reduced Memory modes for rust-analyzer.

**Reduced Memory** mode restarts rust-analyzer with `checkOnSave`, `cachePriming`, and `cargo.buildScripts` disabled, plus 50% RAM / 90% CPU process limits. Proc-macro expansion stays enabled so hover and Go to Definition keep working on macro names and on symbols inside macro arguments (e.g. a call inside `println!(...)`); disabling it silently breaks that navigation. **Full** mode restores rust-analyzer's defaults with no process limits.

## Configuring Language Detection via Settings UI

Expand Down