Commit graph

468 commits

Author SHA1 Message Date
Smit Barmase
33fc1f4af2
languages: Fix JS/TS imports not showing correct suggestions after using period (#27235)
Closes #21728

This PR improves autocomplete for imports for all kinds of javascript
and typescript files.

Adds `.` as `completion_query_characters` which will make it act like
word for auto completion context. This allows capturing compete
`format.` as query.

Before:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/849fb342-db73-48e7-a9d8-93f0e5a14b58"
/>

After:
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/e3ac3272-3217-4bcd-857f-4a83afc5980e"
/>

Release Notes:

- Improved autocomplete suggestions for JavaScript and TypeScript
imports.
2025-03-21 15:13:31 +05:30
Kirill Bulatov
5bef32f3ed
When determining Python task context, do not consider worktree-less files as an error (#27183)
Makes Python plugin to output


![image](https://github.com/user-attachments/assets/4960bc48-21b7-4392-82b9-18bfd1dd9cd0)

for standalone Python files now, instead of nothing as now.

Before the change, no task context was created for the standalone file
due to `VariableName::RelativeFile` lookup considered as an error.
Now, Zed continues and constructs whatever possible context instead.

That `pytest` task seems odd, as the logic fixed here needs a relative
path (hence, a worktree) to consider unit tests.
We do not have variables at the moment the associated tasks are queried
for:


14920ab910/crates/languages/src/python.rs (L359-L363)


14920ab910/crates/languages/src/python.rs (L417-L446)

so we cannot filter this the same way the PR does.
Maybe, we can use a `VariableName::RelativeFile` instead of
`VariableName::File` there?

Release Notes:

- Show tasks from Python plugin for standalone files
2025-03-20 12:44:07 +00:00
Smit Barmase
23e8519057
Add completion_query_characters in language (#27175)
Closes #18581

Now characters for completing query and word characters, which are
responsible for selecting words by double clicking or navigating, are
different. This fixes a bunch of things:

For settings.json, this improves completions to treat the whole string
as a completion query, instead of just the last word. We now added
"space" as a completion query character without it being a word
character.

For keymap.json, this improves selecting part of an action as the ":"
character is only a completion character and not a word character. So,
completions would still trigger on ":" and query capture will treat ":"
as a word, but for actions like selections and navigation, ":" will be
treated as punctuation.

Before:
Unnecessary related suggestions as query is only the last word which is
"d".
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/8199a715-7521-49dd-948b-e6aaed04c488"
/>

Double clicking `ToggleFold` selects the whole action:
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/c7f91a6b-06d5-45b6-9d59-61a1b2deda71"
/>

After:
Now query is "one d" and it shows only matched ones.
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/1455dfbc-9906-42e8-b8aa-b3f551194ca2"
/>

Double clicking `ToggleFold` only selects part of the action, which is
more refined behavior.
<img width="300" alt="image"
src="https://github.com/user-attachments/assets/34b1c3c2-184f-402f-9dc8-73030a8c370f"
/>

Release Notes:

- Improved autocomplete suggestions in `settings.json`, now whole string
is queried instead of just last word of string, which filters out lot of
false positives.
- Improved selection of action in `keymap.json`, where now you can
double click to only select certain part of action, instead of selecting
whole action.

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-03-20 16:45:35 +05:30
Angelo Verlain Shema
c30fb5f1ec
Use shell script language for APKBUILD files (#27099)
`APKBUILD` files are similar to `PKGBUILD` used by arch linux, but are
used to build alpine linux packages:
https://wiki.alpinelinux.org/wiki/APKBUILD_Reference

Release Notes:

- Added recognition for `APKBUILD` files as "Shell Script".
2025-03-19 22:00:44 +00:00
Mikayla Maki
1aefa5178b
Move "async move" a few characters to the left in cx.spawn() (#26758)
This is the core change:
https://github.com/zed-industries/zed/pull/26758/files#diff-044302c0d57147af17e68a0009fee3e8dcdfb4f32c27a915e70cfa80e987f765R1052

TODO:
- [x] Use AsyncFn instead of Fn() -> Future in GPUI spawn methods
- [x] Implement it in the whole app
- [x] Implement it in the debugger 
- [x] Glance at the RPC crate, and see if those box future methods can
be switched over. Answer: It can't directly, as you can't make an
AsyncFn* into a trait object. There's ways around that, but they're all
more complex than just keeping the code as is.
- [ ] Fix platform specific code

Release Notes:

- N/A
2025-03-19 02:09:02 +00:00
Kirill Bulatov
959a024861
Omit json-language-server from the scope_opt_in_language_servers (#27023)
Follow-up of https://github.com/zed-industries/zed/pull/26574/files

After that PR, settings.json stopped giving completions when `"` was
typed as a key:

https://github.com/user-attachments/assets/5ff03863-024c-4c28-a7cd-8ef48a1695d8

This goes down to 


fb12863999/crates/language/src/language.rs (L1736-L1748)

which was empty before the PR, hence leading to lower `true` branch.
Now, when typing `"`, there's no scope according to 


fb12863999/crates/project/src/lsp_store.rs (L4529-L4532)

return result.

Removing `json-language-server` from `scope_opt_in_language_servers`
seems to preserve the `:` fix and restore the completions behavior.


Release Notes:

- N/A
2025-03-18 21:08:43 +00:00
Cole Miller
22b8662275
Fix syntax highlighting of git commit messages (#26988)
- Load syntax colors into commit message editors
- Fix name mismatches that were preventing the git commit grammar and
language config from being matched up

Release Notes:

- Fixed git commit messages not being syntax-highlighted
2025-03-18 18:18:56 +00:00
Remco Smits
41a60ffecf
Debugger implementation (#13433)
###  DISCLAIMER

> As of 6th March 2025, debugger is still in development. We plan to
merge it behind a staff-only feature flag for staff use only, followed
by non-public release and then finally a public one (akin to how Git
panel release was handled). This is done to ensure the best experience
when it gets released.

### END OF DISCLAIMER 

**The current state of the debugger implementation:**


https://github.com/user-attachments/assets/c4deff07-80dd-4dc6-ad2e-0c252a478fe9


https://github.com/user-attachments/assets/e1ed2345-b750-4bb6-9c97-50961b76904f

----

All the todo's are in the following channel, so it's easier to work on
this together:
https://zed.dev/channel/zed-debugger-11370

If you are on Linux, you can use the following command to join the
channel:
```cli
zed https://zed.dev/channel/zed-debugger-11370 
```

## Current Features

- Collab
  - Breakpoints
    - Sync when you (re)join a project
    - Sync when you add/remove a breakpoint
  - Sync active debug line
  - Stack frames
    - Click on stack frame
      - View variables that belong to the stack frame
      - Visit the source file
    - Restart stack frame (if adapter supports this)
  - Variables
  - Loaded sources
  - Modules
  - Controls
    - Continue
    - Step back
      - Stepping granularity (configurable)
    - Step into
      - Stepping granularity (configurable)
    - Step over
      - Stepping granularity (configurable)
    - Step out
      - Stepping granularity (configurable)
  - Debug console
- Breakpoints
  - Log breakpoints
  - line breakpoints
  - Persistent between zed sessions (configurable)
  - Multi buffer support
  - Toggle disable/enable all breakpoints
- Stack frames
  - Click on stack frame
    - View variables that belong to the stack frame
    - Visit the source file
    - Show collapsed stack frames
  - Restart stack frame (if adapter supports this)
- Loaded sources
  - View all used loaded sources if supported by adapter.
- Modules
  - View all used modules (if adapter supports this)
- Variables
  - Copy value
  - Copy name
  - Copy memory reference
  - Set value (if adapter supports this)
  - keyboard navigation
- Debug Console
  - See logs
  - View output that was sent from debug adapter
    - Output grouping
  - Evaluate code
    - Updates the variable list
    - Auto completion
- If not supported by adapter, we will show auto-completion for existing
variables
- Debug Terminal
- Run custom commands and change env values right inside your Zed
terminal
- Attach to process (if adapter supports this)
  - Process picker
- Controls
  - Continue
  - Step back
    - Stepping granularity (configurable)
  - Step into
    - Stepping granularity (configurable)
  - Step over
    - Stepping granularity (configurable)
  - Step out
    - Stepping granularity (configurable)
  - Disconnect
  - Restart
  - Stop
- Warning when a debug session exited without hitting any breakpoint
- Debug view to see Adapter/RPC log messages
- Testing
  - Fake debug adapter
    - Fake requests & events

---

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
Co-authored-by: Piotr <piotr@zed.dev>
2025-03-18 12:55:25 -04:00
Sheik Althaf
fdcacb3849
typescript: Add highlighting for Angular inline components (#26553)
Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Before
<img width="1004" alt="image"
src="https://github.com/user-attachments/assets/9a611e8d-e00e-4dc7-b4c9-bd76fec95525"
/>

After
<img width="936" alt="Image"
src="https://github.com/user-attachments/assets/b83d3309-1aab-492c-a2f1-c45cd19e6bcc"
/>
2025-03-18 09:27:48 +00:00
Max Brunsfeld
52567f4b72
Eliminate unnecessary macros in languages crate (#26813)
I vibe coded this in Zed, dawg.

This avoids a number of cases where we created multiple copies of the
same lsp adapter. Now we clone the Arcs.

Release Notes:

- N/A
2025-03-17 08:13:32 -07:00
Kirill Bulatov
8a31dcaeb0
Use textDocument/codeLens data in the actions menu when applicable #2 (#26848)
Re-applies what's been reverted in
https://github.com/zed-industries/zed/pull/26832 with an action-related
fix in
64b5d37d32

Before, actions were resolved only if `data` is present and either of
the possible fields is empty:

e842b4eade/crates/project/src/lsp_store.rs (L1632-L1633)

But Zed resolves completions and inlays once, unconditionally, and the
reverted PR applied the same strategy to actions.
That did not work despite the spec not forbidding `data`-less actions to
be resolved.

Soon, it starts to work due to
https://github.com/rust-lang/rust-analyzer/pull/19369 but it seems safer
to restore the original filtering code.

Code lens have no issues with `data`-less resolves:

220d913cbc/crates/rust-analyzer/src/handlers/request.rs (L1618-L1620)

so the same approach as completions and inlays is kept: resolve once.


Release Notes:

- N/A
2025-03-15 20:09:32 +00:00
Marshall Bowers
021d6584cc
Revert "Use textDocument/codeLens data in the actions menu when applicable (#26811)" (#26832)
This reverts commit b61171f152.

This PR reverts #26811, as it has broken `rust-analyzer` code actions.

With this commit reverted my code actions are working again. 

Release Notes:

- Community: Reverted https://github.com/zed-industries/zed/pull/26811.
2025-03-15 14:14:29 +00:00
Kirill Bulatov
b61171f152
Use textDocument/codeLens data in the actions menu when applicable (#26811)
Similar to how tasks are fetched via LSP, also queries for document's
code lens and filters the ones with the commands, supported in server
capabilities.

Whatever's left and applicable to the range given, is added to the
actions menu:


![image](https://github.com/user-attachments/assets/6161e87f-f4b4-4173-8bf9-30db5e94b1ce)

This way, Zed can get more actions to run, albeit neither r-a nor vtsls
seem to provide anything by default.

Currently, there are no plans to render code lens the way as in VSCode,
it's just the extra actions that are show in the menu.

------------------

As part of the attempts to use rust-analyzer LSP data about the
runnables, I've explored a way to get this data via standard LSP.

When particular experimental client capabilities are enabled (similar to
how clangd does this now), r-a starts to send back code lens with the
data needed to run a cargo command:

```
{"jsonrpc":"2.0","id":48,"result":{"range":{"start":{"line":0,"character":0},"end":{"line":98,"character":0}},"command":{"title":"▶︎ Run Tests","command":"rust-analyzer.runSingle","arguments":[{"label":"test-mod tests::ecparser","location":{"targetUri":"file:///Users/someonetoignore/work/ec4rs/src/tests/ecparser.rs","targetRange":{"start":{"line":0,"character":0},"end":{"line":98,"character":0}},"targetSelectionRange":{"start":{"line":0,"character":0},"end":{"line":98,"character":0}}},"kind":"cargo","args":{"environment":{"RUSTC_TOOLCHAIN":"/Users/someonetoignore/.rustup/toolchains/1.85-aarch64-apple-darwin"},"cwd":"/Users/someonetoignore/work/ec4rs","overrideCargo":null,"workspaceRoot":"/Users/someonetoignore/work/ec4rs","cargoArgs":["test","--package","ec4rs","--lib"],"executableArgs":["tests::ecparser","--show-output"]}}]}}}
```

This data is passed as is to VSCode task processor, registered in


60cd01864a/editors/code/src/main.ts (L195)

where it gets eventually executed as a VSCode's task, all handled by the
r-a's extension code.

rust-analyzer does not declare server capabilities for such tasks, and
has no `workspace/executeCommand` handle, and Zed needs an interactive
terminal output during the test runs, so we cannot ask rust-analyzer
more than these descriptions.

Given that Zed needs experimental capabilities set to get these lens:

60cd01864a/editors/code/src/client.ts (L318-L327)

and that the lens may contain other odd tasks (e.g. docs opening or
references lookup), a protocol extension to get runnables looks more
preferred than lens:
https://rust-analyzer.github.io/book/contributing/lsp-extensions.html#runnables

This PR does not include any work on this direction, limiting to the
general code lens support.

As a proof of concept, it's possible to get the lens and even attempt to
run it, to no avail:

![image](https://github.com/user-attachments/assets/56950880-d387-48f9-b865-727f97b5633b)


Release Notes:

- Used `textDocument/codeLens` data in the actions menu when applicable
2025-03-15 09:50:32 +02:00
Finn Evers
e9b4fa1465
rust: Follow-up fixes for attribute highlighting (#26172)
Closes #26124

This PR fixes some more cases of improper attribute highlights for rust.

In #25501 I tried to address the regression in highlighting rust
attributes which were introduced by #25333 . However, I failed to
properly check all cases of attribute highlights as shown in the linked
issue - really sorry for that! Thus, this is a follow-up fix aiming to
resolve the issues the previous PR did not cover.

The changes do not affect any highlighting shown in the [previous
PR](https://github.com/zed-industries/zed/pull/25501):

| `main` | <img width="719" alt="main-working"
src="https://github.com/user-attachments/assets/9aa0e611-7bda-4b50-9335-c87da4c38057"
/> |
| --- | --- |
| This PR | <img width="719" alt="PR-working"
src="https://github.com/user-attachments/assets/605b275c-1d68-4bd7-97c6-251d7614a7ed"
/> |

But resolves the mentioned regressions in the linked issue:

| `main` | <img width="371" alt="main_broken"
src="https://github.com/user-attachments/assets/ebbb47b7-7945-41e0-b030-2fe3f2198653"
/> |
| --- | --- |
| This PR | <img width="371" alt="PR_broken"
src="https://github.com/user-attachments/assets/fa97408b-e1d6-4d99-81c1-cfb8073961a4"
/> |

Again, sorry for not checking this more thoroughly.


Release Notes:

- Fixed attributes in Rust being improperly highlighted.

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-03-14 23:02:45 +00:00
KyleBarton
6bdd2cf7db
Consider the colon to be a word character when inside a string in JSON (#26574)
Partially addresses #25698

Part of why autocomplete suggestions for `keymap.json` aren't great is
because `:` is (correctly) considered a punctuation character, rather
than a word character, in JSON. But since `::` is part of the name of
zed commands, it means that the autocomplete context window loses
context after the user types colon:

Suggestion here is to use overrides for JSON and JSONC such that colon
is considered a word character when it's inside a string. This improves
the experience:

I believe this is more broadly correct anyway, since `:` loses it's
punctuation meaning when inside a string.

Hope this is helpful!

Release Notes:

- Improved autocomplete for keymap.json by treating `::` like word characters when inside a string.
2025-03-13 16:21:34 -04:00
Ben Kunkle
25f407baab
settings: Auto-update JSON schemas for settings when extensions are un/installed (#26633)
Because of #26562, it is now possible to subscribe to extension update
events within the LSP store, where we can then update the Schemas sent
to the JSON LSP resulting in dynamic updates to the auto-complete
suggestions and diagnostics in settings. Notably, this means newly
installed languages and (icon) themes will auto-complete correctly as
soon as the extension is installed.

Closes #15436

Release Notes:

- Fixed an issue where autocomplete suggestions and diagnostics for
languages and (icon) themes in settings would not update when the
extension with which they were added was installed or uninstalled
2025-03-13 16:50:07 +00:00
Kirill Bulatov
690f26cf8b
Disable clangd's inactiveRegions support (#26539)
Disables https://github.com/zed-industries/zed/pull/26146 until a better
way to add diagnostics is found.
Overall, the PR had made changes that are worth keeping instead of
reverting, such as finally extracting out r-a's language server logic
into an `_ext.rs` file.

Release Notes:

- N/A
2025-03-12 14:20:05 +00:00
Devzeth
84fe1bfe9b
Recognize ixx as part of the cpp suffix (#26333)
Adds "ixx" as path suffix to be recognized for c++. 

> ixx documentation
https://learn.microsoft.com/en-us/cpp/cpp/modules-cpp?view=msvc-

I've also added it to the icon file. 

Release Notes:

- N/A
2025-03-10 09:10:29 -05:00
Ben Kunkle
6de3ac3e17
Revert "Highlight super and this as keywords in JS/TS/TSX" (#26342)
Reverts zed-industries/zed#25135

This approach was not the best as explained in the response to the
original PR. Likely, the better approach is to create a newer specific
scope for these kinds of variables under the `@variable` prefix so that
themes can control these pseudo-keywords specifically
2025-03-09 16:11:37 +00:00
Naim A.
829ecda370
lsp: Add support for clangd's inactiveRegions extension (#26146)
Closes #13089 

Here we use `experimental` to advertise our support for
`inactiveRegions`. Note that clangd does not currently have a stable
release that reads the `experimental` object (PR
https://github.com/llvm/llvm-project/pull/116531), this can be tested
with one of clangd's recent "unstable snapshots" in their
[releases](https://github.com/clangd/clangd/releases).

Release Notes:

- Added support for clangd's `inactiveRegions` extension.

![Screen Recording 2025-03-05 at 22 39
58](https://github.com/user-attachments/assets/ceade8bd-4d8e-43c3-9520-ad44efa50d2f)

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2025-03-06 21:30:05 +00:00
Ben Kunkle
ff25fa24e7
Add support for auto-closing of JSX tags (#25681)
Closes #4271

Implemented by kicking of a task on the main thread at the end of
`Editor::handle_input` which waits for the buffer to be re-parsed before
checking if JSX tag completion possible based on the recent edits, and
if it is then it spawns a task on the background thread to generate the
edits to be auto-applied to the buffer

Release Notes:

- Added support for auto-closing of JSX tags

---------

Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: Max Brunsfeld <max@zed.dev>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Peter Tripp <peter@zed.dev>
2025-03-06 08:36:10 -06:00
Isac Ljung
db28b9bbde
Add typescript-language-server and vtsls to list of available language servers (#26046)
Add the typescript language severs as lsp adapters.
This would allow language extensions to use them.
For example using on vue files to be able to run the vue-language-server
in
[hybridMode](https://github.com/vuejs/language-tools?tab=readme-ov-file#hybrid-mode-configuration-requires-vuelanguage-server-version-200).

Release Notes:

- Added `vtsls` and `typescript-language-server` to the list of
available language servers.
2025-03-04 15:49:27 -05:00
Boris Vassilev
cbb535f5eb
Fix completion details on new clangd versions (#25405)
Fixes #16057

In newer versions of clangd, the switch labelDetailsSupport in the json
passed to the language server modifies the format of the returned json.
Zed handles well the old format, but misses the function parameters in
the new one. For example:
The old format looks like this:
```json
...
"label": " Window(int width, int height, const char *name, bool vsync, bool resizable)",
...
```
and with labelDetailsSupport = true:
```json
...
 "label": " Window",
 "labelDetails": {
     "detail": "(int width, int height, const char *name, bool vsync, bool resizable)"
 },
...
```
A simple solution is to just to not tell the language server that label
details are supported and force it to use the old format. This is a
dirty fix, but makes the completions behave like in the old versions of
clangd.

I do not know if this will break another language server. From what I've
found out most lsp-s do not depend on that setting and provide all
completion data either way. If not, this switch will need to be exposed
in a config or be at least lsp-dependant.

Lastly, I do not know Rust, maybe will need help to make a better fix
for the issue.

Release Notes:

- Fixed broken C++ completion suggestions
2025-03-04 14:30:03 +02:00
Finn Evers
042fc82e99
python: Fix and improve highlighting (#25813)
Closes #25803
Closes #25707 

This PR fixes the highlighting regression described in #25803 by fixing
the priorities of highlights as described in the [comment within the
file
itself](5b66ea1563/crates/languages/src/python/highlights.scm (L1)).
A nice side-effect of this is that scoped constants or other identifiers
are now also more accurately highlighted, as seen in the screenshots
below.

While I was at it, I also adressed the highlighting issue for default
typed idenfiers.

| This PR | <img width="575" alt="PR"
src="https://github.com/user-attachments/assets/aed5cdd0-c31a-4794-8128-376944fddd2d"
/> |
| --- | --- |
| Preview | <img width="575" alt="preview"
src="https://github.com/user-attachments/assets/ae3fad35-d436-472c-aff0-16508304ccf7"
/> |
| Stable | <img width="575" alt="stable"
src="https://github.com/user-attachments/assets/3836427c-f1cc-42ea-b1a7-8f5bbbadf210"
/> |

Release Notes:

- Fixed constants not being highlighted in Python-files.
- Improved Python-highlighting for default function arguments and scoped
identifiers.
2025-03-04 08:41:10 +01:00
Conrad Irwin
6faa7cd722
Fix regex search colors (#25962)
In #25005 we added regex syntax highlighting to search; but the existing
regex grammar highlighted every character as a string which was hard to
read.

This flips so that characters are not highlighted, and brackets, etc.
are.
<img width="346" alt="Screenshot 2025-03-03 at 14 39 35"
src="https://github.com/user-attachments/assets/f7d3ae9c-fb5c-45eb-a5e9-41a330fbe940"
/>


Release Notes:

- Fixed regex search box being overly green
2025-03-03 15:55:07 -07:00
Devzeth
e00d737196
Add constructor highlighting for JS/TS/TSX (#25207)
Closes #19267

Adds highlight field specifically for `constructor` in JS/TS/TSX so that
it can be highlighted as a different color than regular methods

Release Notes:

- N/A

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2025-03-02 00:43:51 +00:00
Peter Tripp
760d08711c
Update bundled JSON schemas (2025-02-28) (#25826)
Updated JSON schemas to
[SchemaStore/schemastore@b107b83](b107b83a50)
(2025-02-28)

-
[tsconfig.json](https://github.com/SchemaStore/schemastore/commits/master/src/schemas/json/tsconfig.json)
@
[b107b83](https://raw.githubusercontent.com/SchemaStore/schemastore/b107b83a50bad9ac06dd171201dc870901f92ca8/src/schemas/json/tsconfig.json)
-
[package.json](https://github.com/SchemaStore/schemastore/commits/master/src/schemas/json/package.json)
@
[b107b83](https://raw.githubusercontent.com/SchemaStore/schemastore/b107b83a50bad9ac06dd171201dc870901f92ca8/src/schemas/json/package.json)

Previously:
- https://github.com/zed-industries/zed/pull/20910

Release Notes:

- Updated bundled JSON schemas for package.json and tsconfig.json
2025-02-28 16:32:16 -05:00
Piotr Osiewicz
e4e758db3a
Rust 1.85 (#25272)
Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-02-28 18:33:35 +01:00
Piotr Osiewicz
b15aa5e018
rust: Fix test/doctest tasks showing up outside of tests (#25787)
Closes #ISSUE

Release Notes:

- Fixes Rust test tasks showing up outside of tests
2025-02-28 00:48:19 +01:00
Piotr Osiewicz
2e98bc17cb
lsp: Use available workspace folders in initialize params (#25753)
Closes https://github.com/zed-industries/zed/issues/25743
Closes https://github.com/biomejs/biome-zed/issues/73

Release Notes:

- Fixed issues with launching Svelte/Biome language servers
2025-02-27 16:45:59 +01:00
Piotr Osiewicz
c0b6d86c41
go: Do not fill out root_uri in initialization params to prevent stale notifications (#25644)
Closes #25381

Release Notes:

- N/A
2025-02-26 13:24:27 +01:00
Finn Evers
113c471bb0
rust: Restore and update attribute highlighting (#25501)
#25333 added broader highlighting for identifiers, which broke the
generic query for attribute queries, resulting in these being
highlighted the same as identifiers.

To accomodate for this change, this PR updates the attribute matches to
be more specific.

Additionally, path matches in scoped identifiers are no longer
highlighted as attributes, as seen in the comparison screenshot. Can
revert this if requested.

| Zed Preview | <img width="750" alt="preview"
src="https://github.com/user-attachments/assets/2cd2e830-f510-4adf-8ce9-c41ed6fb157c"
/> |
| --- | --- | 
| `main` | <img width="750" alt="main"
src="https://github.com/user-attachments/assets/cbe93186-9afd-4515-bc06-e519fd4ee6af"
/> |
| This PR | <img width="750" alt="pr"
src="https://github.com/user-attachments/assets/68270de8-e083-4fc6-a45e-25d3151acd87"
/> |

The generic match for `token_tree` is needed to recursively match
patterns like `#[cfg(any(test, feature = "test-support"))]` (or at least
I was unable to find a better query here). I tried to validate that this
does not break any other highlights and I believe it does not. However,
I might have still missed something.

Release Notes:

- N/A
2025-02-24 19:10:30 -05:00
Joseph T. Lyons
535ba75bc7
Do not indent on enter in python comments ending in colon (#25437)
Closes https://github.com/zed-industries/zed/issues/25416

Release Notes:

- Fixed a bug where indentation was applied when adding a newline to a
Python comment ending in `:`.
2025-02-24 04:11:22 +00:00
Coenen Benjamin
65f76e6f4d
Add support for --target-dir for Rust tasks (#24725)
This PR is an attempt to add support for `--target-dir` argument to
`cargo` commands when executing tasks with rust.
When using VSCode I was already using this trick to not block the
current binary compilation when I was trying a specific test. As it's a
different target directory it won't block the `cargo` commands I'm using
in my terminal.

I used the task variables to achieve this but I'm not sure it's the best
option to be honest. I didn't find any examples in your docs to see if
sometimes you had specific configuration for languages and tasks.

Let me know if this solution would be a good fit and if the
implementation is ok.

If so feel free to redirect me to an example I can reproduce to write a
unit test or so... And I will also update the docs.

Example of config:

```
{
  "languages": {
    "Rust": {
      "tasks": {
        "variables": {
          "RUST_TARGET_DIR": ".cargo_check"
        }
      }
    }
  }
}
```

it will run `cargo test -p XXX --target-dir .cargo-check`


Release Notes:

- Added support for `--target-dir` for Rust tasks

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
2025-02-23 11:05:07 +01:00
Arseny Kapoulkine
dabc35b257
Improve C++ highlighting for sized type specifiers (#25362)
For consistency, sized type specifiers should be highlighted the same
way as primitive types, to make sure 'unsigned', 'int' and 'unsigned
int' are all the same color. [A previous
change](https://github.com/zed-industries/zed/pull/18016) moved
primitive types from `@keyword` to `@type`, and this PR adjusts the
sized type specifier to follow suit.

Before this change:


![image](https://github.com/user-attachments/assets/d0982ced-882f-4477-b716-f07ac4a72170)

After this change:


![image](https://github.com/user-attachments/assets/2fb6a7e7-061b-46e1-a4e3-e906e1e87bd8)

Release Notes:

- Improved C++ syntax highlighting for sized type specifiers.
2025-02-21 16:57:57 -05:00
chbk
8f40bcc86c
Improve JavaScript and TypeScript syntax highlighting (#25328)
Release Notes:

  - Improved JavaScript and TypeScript syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/a64f0abf-3b4e-4369-80c5-1d1381c925fc)
|
![Image](https://github.com/user-attachments/assets/f8224243-f4ab-4af9-8dd8-5062dd7ea743)
|

- `regex_flags`: `keyword.regex`, see the [Regex
PR](https://github.com/zed-industries/zed/pull/25332) for other Regex
scopes
- `@`: `punctuation.special`, as in Python
- `jsx_text`: `text.jsx`
- `=`: `operator` -> `punctuation.jsx.delimiter`, `punctuation` as in
[VS
Code](0fe195613e/extensions/html/syntaxes/html.tmLanguage.json (L78))
and
[Atom](ee750a014a/grammars/tree-sitter-html.cson (L47))
- added `jsx` scope to target JSX tokens specifically

```javascript
/**
 * @keyword comment
 */
@log
class X {
  render() {
    return (
      <div jsx_attribute="value">
        <Input onKeyPress={super.bind(this)}/>
        jsx_text
      </div>
    );
  }
}
const IDENTIFIER = true
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 21:54:16 +00:00
chbk
3e75a661dd
Improve Rust syntax highlighting (#25333)
Release Notes:

  - Improved Rust syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/0ec56dd0-2c17-4b5f-98e3-0897cb4e0192)
|
![Image](https://github.com/user-attachments/assets/309de467-dd32-47e9-ac40-96334a20d5c3)
|

- `identifier`: `variable`

```rust
let identifier = true;
const IDENTIFIER: i32 = 3;
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 16:20:53 -05:00
chbk
59a153b2e1
Improve Python syntax highlighting (#25331)
Release Notes:

  - Improved Python syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/3d8830c9-23cd-437d-88a6-258bcfba5f50)
|
![Image](https://github.com/user-attachments/assets/fd34ca38-c105-4f27-9979-98ab8d616c51)
|

- `identifier`: `variable`
- `.`, `,`, `:`: `punctuation.delimiter`
- `@`: `operator`, for matrix multiplication

```python
class Mat(list):
  def __matmul__(self, b):
    ...
a, b = Mat(), Mat()
identifier = a @ b
IDENTIFIER = True
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 20:52:04 +00:00
chbk
144d8a1db6
Improve C and C++ syntax highlighting (#25325)
Release Notes:

  - Improved C and C++ syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/fa5bf2e0-c682-4e6a-ab64-bb873579d47c)
|
![Image](https://github.com/user-attachments/assets/dc980de9-cd6a-4b0b-8ddc-ac705f687910)
|

- `NULL`, `nullptr`: `constant` -> `constant.builtin`

```cpp
#include <stdbool.h>
int a[] = {true, false};
const int * IDENTIFIER = nullptr;
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 12:01:39 -05:00
chbk
7deceb62dc
Improve Go syntax highlighting (#25327)
Release Notes:

  - Improved Go syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/7f6113cb-0517-4ea7-a979-902a2373314e)
|
![Image](https://github.com/user-attachments/assets/0cf07ebc-c5bd-4269-af7a-49496305d265)
|

- `package_identifier`: `namespace`, language-agnostic scope for
modules, packages, namespaces
- `method_elem`: `function.method`
- `;` ,`.` ,`,` ,`:`: `punctuation.delimiter`

```go
package my_package
import (
  pkg "fmt"
)
type A interface {
  method_elem(foo int, bar float64) int
}
func main() {
  identifier := true
  const constant int = 3
  for i := 0; i <= 3; i++ {
    pkg.Println(identifier)
  }
}
```

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 11:32:14 -05:00
chbk
5e4bdbbcde
Improve JSON syntax highlighting (#25329)
Release Notes:

  - Improved JSON syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/46c8ae89-aca1-4756-b66c-78ccd8f3778d)
|
![Image](https://github.com/user-attachments/assets/3ba5e5db-1467-40d7-a502-2790feec8ad3)
|

- `null`: `constant` -> `constant.builtin`
- `,`, `:`: `punctuation.delimiter`

```json
{
  "property": null,
  "boolean": true
}
```
2025-02-21 15:59:32 +00:00
chbk
d0a0303428
Improve Bash syntax highlighting (#25324)
Release Notes:

  - Improved Bash syntax highlighting

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/ecff952a-c10c-447a-8a99-ebd4ac6d6936)
|
![Image](https://github.com/user-attachments/assets/37568a83-f32c-4d4c-bd9a-3ebbe9aa40ae)
|

- `string`: `string`
- `variable`: `property` -> `variable`
- `number`: `number`
- `regex`: `string.regex`
- `>&`, `>&-`, `:`, `//`, `/`, `%`, `%%`, `#`, `##`, `=`, `==`:
`operator`
- `-lt`, `-le`, `-gt`, `-ge`, `-eq`, `-ne`, `-z`, `-n`:
`keyword.operator`
- `;`: `punctuation.delimiter`
- `(`, `)`, `{`, `}`, `[`, `]`: `punctuation.bracket`
- `$`, `${ }`, `$( )`: `punctuation.special`, as defined in other
languages

```bash
variable=I\ like\ Zed
function my_function() {
  echo "Hello world, ${variable//regex/string}" > file
}
if [ $(uid) -lt 600 ]; then
  my_function;
  cat file | grep hello >&3
fi
```
2025-02-21 10:36:07 -05:00
Marshall Bowers
a4ade37a56
rust: Add raw to keyword list for syntax highlighting (#25342)
This PR adds support for syntax highlighting the `raw` keyword in Rust.

Release Notes:

- Added `raw` keyword to Rust language highlights (see the [Rust 1.82.0
announcement](https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html#native-syntax-for-creating-a-raw-pointer)).

Co-authored-by: everdrone <giorgiotropiano@gmail.com>
2025-02-21 15:28:30 +00:00
everdrone
1fb4620a90
Use @boolean for true and false in highlights (#25338)
Release Notes:

- Fixed issue where `true` and `false` were highlighted as constants,
ignoring the `boolean` highlight defined in themes.
  - This fix applies to: C, C++, Go, JSON, JSONC, Python, and Rust.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-21 15:26:52 +00:00
Coenen Benjamin
dff47a8436
rust: Add support for doctest runnables (#24806)
Screenshot:


![image](https://github.com/user-attachments/assets/0ac88029-76c1-4135-bef2-373636e3587d)

I would be happy to add tests if you point me to the right place to do
it please.

Release Notes:

- Added support for doc test in tasks for Rust

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
2025-02-21 10:57:09 +01:00
Cole Miller
274e70e81d
Fix cargo test task for tests module in lib.rs, main.rs, mod.rs (#25092)
Closes #19161

Release Notes:
- Fixed not being able to spawn the `cargo test` task for a `tests`
module in `lib.rs`, `main.rs`, or `mod.rs`
2025-02-20 20:28:34 +00:00
Finn Evers
f2b7d8a9c9
python: Properly check for Pyright language server in local environment (#24873)
Closes #24565 

As pointed out in
https://github.com/zed-industries/zed/issues/24565#issuecomment-2657822723
, the name for the Pyright language server is `pyright-langserver`, not
`pyright`. The latter is a CLI-tool as described in
https://microsoft.github.io/pyright/#/command-line which only provides
static type checking. It has neither LSP-capabilities nor a `--stdio`
argument. Thus, the error as shown in the linked issue appears.

I disagree with the fix as described in
https://github.com/zed-industries/zed/issues/24565#issuecomment-2657904208
, as it could only cause this error to reappear in rare scenarios where
Pyright, but not the Pyright language server is installed in a user's
environment. Just checking for `pyright-langserver` to be present in the
environment seems more straightforward here.

Release Notes:

- Python: Fixed Pyright failing to start when installed locally

Co-authored-by: Beniamin Zagan <47153906+beniaminzagan@users.noreply.github.com>
2025-02-20 10:43:04 -05:00
Matthew Penner
ffc7558a1d
Enable package-version-server lookup in PATH (#23849)
Release Notes:

- Added support for checking for `package-version-server` on the
`$PATH`.

---------

Signed-off-by: Matthew Penner <me@matthewp.io>
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-19 19:46:38 +00:00
Ben Kunkle
ebbc6a9752
Highlight super and this as keywords in JS/TS/TSX (#25135)
Closes #24951

We were highlighting both as `@variable.special` however, they are
_techinically_ keywords and other editors (VSCode/WebStorm) seem to
highlight them as keywords as well.

Release Notes:

- N/A
2025-02-19 05:53:16 +00:00
Ben Kunkle
bb600acaa1
Set base highlight for identifiers in go to variable highlight color (#25128)
Closes #24947 

Release Notes:

- N/A
2025-02-19 01:54:51 +00:00