Commit graph

602 commits

Author SHA1 Message Date
claytonrcarter
1f4c9b9427
language: Update block_comment and documentation comment (#34861)
As suggested in https://github.com/zed-industries/zed/pull/34418, this
proposes various changes to language configs to make block comments and
doc-block-style comments more similar. In doing so, it introduces some
breaking changes into the extension schema.

This change is needed to support the changes I'm working on in #34418,
to be able to support `rewrap` in block comments like `/* really long
comment ... */`. As is, we can do this in C-style doc-block comments (eg
`/** ... */`) because of the config in `documentation`, but we can't do
this in regular block comments because we lack the info about what the
line prefix and indentation should be.

And while I was here, I did various other clean-ups, many of which feel
nice but are optional.

I would love special attention on the changes to the schema, version and
related changes; I'm totally unfamiliar with that part of Zed.

**Summary of changes**
- break: changes type of `block_comment` to same type as
`documentation_comment` (**this is the important change**)
- break: rename `documentation` to `documentation_comment` (optional,
but improves consistency w/ `line_comments` and `block_comment`)
- break/refactor?: removes some whitespace in the declaration of
`block_comment` delimiters (optional, may break things, need input; some
langs had no spaces, others did)
- refactor: change `tab_size` from `NonZeroU32` to just a `u32` (some
block comments don't seem to need/want indent past the initial
delimiter, so we need this be 0 sometimes)
- refactor: moves the `documentation_comment` declarations to appear
next to `block_comment`, rearranges the order of the fields in the TOML
for `documentation_comment`, rename backing `struct` (all optional)

**Future scope**
I believe that this will also allow us to extend regular block comments
on newline – as we do doc-block comments – but I haven't looked into
this yet. (eg, in JS try pressing enter in both of these: `/* */` and
`/** */`; the latter should extend w/ a `*` prefixed line, while the
former does not.)

Release Notes:

- BREAKING CHANGE: update extension schema version from 1 to 2, change
format of `block_comment` and rename `documentation_comment`

/cc @smitbarmase
2025-07-23 20:38:52 +05:30
Ben Kunkle
7c1040bc93
keymap_ui: Auto complete action arguments (#34785)
Supersedes: #34242

Creates an `ActionArgumentsEditor` that implements the required logic to
have a JSON language server run when editing keybinds so that there is
auto-complete for action arguments.

This is the first time action argument schemas are required by
themselves rather than inlined in the keymap schema. Rather than add all
action schemas to the configuration options we send to the JSON LSP on
startup, this PR implements support for the
`vscode-json-language-server` extension to the LSP whereby the server
will request the client (Zed) to resolve URLs with URI schemes it does
not recognize, in our case `zed://`. This limits the impact on the size
of the configuration options to ~1KB as we send URLs for the language
server to resolve on demand rather than the schema itself. My
understanding is that this is how VSCode handles JSON schemas as well. I
plan to investigate converting the rest of our schema generation logic
to this method in a follow up PR.

Co-Authored-By: Cole <cole@zed.dev>

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-07-20 16:24:17 -04:00
Vitaly Slobodin
0ffd93774c
Fix Tailwind support for HTML/ERB files (#34743)
Closes #27118
Closes #34165

Fix a small issue after we landed
https://github.com/zed-extensions/ruby/pull/113+ where we introduced
`HTML/ERB` and `YAML/ERB` language IDs to improve user experience. Sorry
about that. Thanks!

Release Notes:

- N/A
2025-07-19 11:06:35 -04:00
Lukas Spiss
fd05f17fa7
go: Support raw string subtest names (#34636)
Currently, we're not able to run Go sub-tests that have a raw string
(e.g. we're using multi-line names a lot) via the UI. I added the
changes that are needed, plus a handful of tests to cover the basics.

Quick comparison:

Before:
<img width="901" height="370" alt="before"
src="https://github.com/user-attachments/assets/4e5cadeb-9a0c-49e2-b976-2223e1010f85"
/>



After:
<img width="901" height="505" alt="after"
src="https://github.com/user-attachments/assets/994fc69b-f720-488c-a14b-853a3ca2f53c"
/>


Release Notes:

- Added support for Go subtest runner with raw string names
2025-07-18 13:38:18 +02:00
Arseny Kapoulkine
00097df0d5
Improve C/C++ indentation flow for single statement blocks (#34549)
Before this, indentation did not automatically increase after
if/for/while/do/else statements in C++, and only increased after if/for
in C. This led to Zed using last line logic when inserting lines *after*
the indented statement, as well as not indenting the statement itself,
resulting in irregular indentation during typing.

Just adding indentation (similar to C) creates a new problem: now if a
scope is started with a brace on a new line, that brace is indented.
Thus we need to deindent it.

Using else_clause in the indent guide results in the else statement
being indented forward as well, so we need to deindent that too.

Note: the most significant issue for me is the one where indentation
jumps forward when inserting lines after indented lines. Unfortunately,
it appears that fixing that issue requires all of these other changes. I
would have preferred a simpler fix, but I'm not sure if disabling last
line behavior for C/C++ is appropriate as it probably breaks something
else, like cases where the file is incomplete and the statements can't
be parsed properly.

Editing flow before this change:

[Screencast From 2025-07-16
08-31-36.webm](https://github.com/user-attachments/assets/3dea86c5-47bd-47c2-aee8-b0aa613948e6)

Editing flow after this change:

[Screencast From 2025-07-16
08-35-36.webm](https://github.com/user-attachments/assets/7ef23e60-1ee3-49fd-90f9-d53f909ca674)

(note: the "else" snippet is completely breaking the flow here, but I
think that comes from clangd by default? Unfortunately I haven't found a
way to disable it cleanly but that is a separate problem that happens
right now too.)

Release Notes:

- Improve indentation during typing for C/C++ around if/for/while/do
blocks
2025-07-18 12:24:20 +02:00
Umesh Yadav
b4dc7f8a8a
debugger: Add support for running test methods with function receiver in Go (#34613)
![CleanShot 2025-07-17 at 16 35
10](https://github.com/user-attachments/assets/bad794fb-198e-40a1-958c-6ff30a0a4e53)


Closes #33759

Release Notes:

- debugger: Add support for running test methods with function receiver
in Go

Signed-off-by: Umesh Yadav <git@umesh.dev>
2025-07-17 17:44:40 +02:00
Ben Kunkle
58807f0dd2
keymap_ui: Create language for Zed keybind context (#34558)
Closes #ISSUE

Creates a new language in the languages crate for the DSL used in Zed
keybinding context. Previously, keybind context was highlighted as Rust
in the keymap UI due to the expression syntax of Rust matching that of
the context DSL, however, this had the side effect of highlighting upper
case contexts (e.g. `Editor`) however Rust types would be highlighted
based on the theme. By extracting only the necessary pieces of the Rust
language `highlights.scm`, `brackets.scm`, and `config.toml`, and
continuing to use the Rust grammar, we get a better result across
different themes

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-07-16 17:00:47 +00:00
Brian Donovan
6f9e052edb
languages: Add JS/TS generator functions to outline (#34388)
Functions like `function* iterateElements() {}` would not show up in the
editor's navigation outline. With this change, they do.

| **Before** | **After**
|-|-|
|<img width="453" height="280" alt="Screenshot 2025-07-13 at 4 58 22 PM"
src="https://github.com/user-attachments/assets/822f0774-bda2-4855-a6dd-80ba82fffaf3"
/>|<img width="564" height="373" alt="Screenshot 2025-07-13 at 4 58
55 PM"
src="https://github.com/user-attachments/assets/f4f6b84f-cd26-49b7-923b-724860eb18ad"
/>|

Note that I decided to use Zed's agent assistance features to do this PR
as a sort of test run. I don't normally code with an AI assistant, but
figured it might be good in this case since I'm unfamiliar with the
codebase. I must say I was fairly impressed. All the changes in this PR
were done by Claude Sonnet 4, though I have done a manual review to
ensure the changes look sane and tested the changes by running the
re-built `zed` binary with a toy project.

Closes #21631

Release Notes:

- Fixed JS/TS outlines to show generator functions.
2025-07-14 07:26:17 -05:00
Umesh Yadav
cf1ce1beed
languages: Fix ESLint diagnostics not getting shown (#33814)
Closes #33442

Release Notes:

- Resolved an issue where the ESLint language server returned an empty
string for the CodeDescription.href field in diagnostics, leading to
missing diagnostics in editor.
2025-07-14 13:48:56 +03:00
Smit Barmase
38febed02d
languages: Fix detents case line after typing : in Python (#34017)
Closes #34002

`decrease_indent_patterns` should only contain mapping which are at same
indent level with each other, which is not true for `match` and `case`
mapping.

Caused in https://github.com/zed-industries/zed/pull/33370

Release Notes:

- N/A
2025-07-07 22:41:29 +05:30
Cole Miller
955580dae6
Adjust Go outline query for method definition to avoid pesky whitespace (#33971)
Closes #33951 

There's an adjustment that kicks in to extend `name_ranges` when we
capture more than one `@name` for an outline `@item`. That was happening
here because we captured both the parameter name for the method receiver
and the name of the method as `@name`. It seems like only the second one
should have that annotation.

Release Notes:

- Fixed extraneous leading space in `$ZED_SYMBOL` when used with Go
methods.
2025-07-07 09:51:30 -04:00
Smit Barmase
6b456ede49
languages: Fix string override to match just string_fragment part of template_string (#33997)
Closes #33703

`template_string` consists of `template_substitution` and
`string_fragment` chunks. `template_substitution` should not be
considered a string.

```ts
const variable = `this is a string_fragment but ${this.is.template_substitution}`;
```

Release Notes:

- Fixed auto-complete not showing on typing `.` character in template
literal string in JavaScript and TypeScript files.
2025-07-07 11:45:54 +05:30
Michael Sloan
ed7552d3e3
Default `#[schemars(deny_unknown_fields)] for json-language-server schemas (#33883)
Followup to #33678, doing the same thing for all JSON Schema files
provided to json-language-server

Release Notes:

* Added warnings for unknown fields when editing `tasks.json` /
`snippets.json`.
2025-07-04 00:57:43 +00:00
Richard Feldman
03ca2f4d2b
Fix yaml comment indent (#33882)
Closes #33761

The problem was that in the indentation regex we were treating lines
that had `:` in them as requiring an indent on the next line, even if
that `:` was inside a comment.

Release Notes:

- Fixed YAML indentation for lines containing comments with `:` in them
2025-07-03 23:57:57 +00:00
Cole Miller
e224da8522
Disambiguate package.json tasks by parent directory as needed (#33798)
Closes #33701, cc @afgomez 

Release Notes:

- Added the parent directory to the label as needed to disambiguate
tasks from package.json
2025-07-02 16:37:36 -04:00
Piotr Osiewicz
4cc06bfb4e
debugger: Fix wrong cwd in Rust tests (#33788)
This commit introduces a new task variable RUST_MANIFEST_DIRNAME which
points at the parent directory of the manifest for the current package.
Previously we were running `cargo test` inside of parent dir of a
currently focused source file, which happened to work with non-debug
stuff (as `cargo test` itself fixed cwd for us), but that no longer
works with debug scenarios - they are compiled separately and so we no
longer have cargo doing the heavy lifting for us

Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>

Closes #33751

Release Notes:

- debugger: Fixed wrong cwd in automatically-generated Rust test debug
sessions

Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-07-02 17:36:35 +00:00
Peter Tripp
274f2e90da
Add support for more python operators (#33720)
Closes: https://github.com/zed-industries/zed/issues/33683

| Before | After |
| - | - |
| <img width="571" alt="Screenshot 2025-07-01 at 11 42 56"
src="https://github.com/user-attachments/assets/5ef79304-37bb-42a1-8891-d19a55a5095e"
/> | <img width="592" alt="Screenshot 2025-07-01 at 11 44 45"
src="https://github.com/user-attachments/assets/f28aa2a8-6306-4294-86e1-8f089f57b825"
/> |

Release Notes:

- python: Properly highlight additional operators ("&=", "<<=", ">>=",
"@=", "^=" and "|=")
2025-07-01 12:12:46 -04:00
Umesh Yadav
6e9c6c5684
git_ui: Fix list in git commit message (#33409)
Follow up: #32114

Closes #33274

Use the new support for language-specific rewrap_prefixes added in
https://github.com/zed-industries/zed/pull/33702.

Release Notes:

- Fix git commit message line break getting stripped after committing.

---------

Signed-off-by: Umesh Yadav <git@umesh.dev>
2025-07-01 08:05:08 -04:00
Smit Barmase
3151b5efc1
languages: Fix ( wouldn’t autocomplete when . is preceded by it in Markdown (#33705)
Closes #5092

Release Notes:

- Fixed issue where `(` wouldn’t autocomplete when `.` is preceded by it
in Markdown.
2025-07-01 16:51:46 +05:30
Smit Barmase
8fb3199a84
editor: Improve rewrap of markdown lists, todos, and block quotes (#33702)
Closes #19644 #18151

Now, rewrapping markdown lists (unordered, ordered, and to-do lists) and
block quotes wrap them separately, without merging them together.
Additionally, it correctly indents subsequent lines.

With this input: 

```md
1. This is a list item that is short.
2. This list item is a bit longer because I want to see if it wraps correctly after a rewrap operation in Zed. What do you think?
3. another short item
```

Output would be:

```md
1. This is a list item that is short.
2. This list item is a bit longer because I want to see if it wraps correctly
   after a rewrap operation in Zed. What do you think?
3. another short item
```

Instead of:

```md
1. This is a list item that is short. 2. This list item is a bit longer because 
I want to see if it wraps correctly after a rewrap operation in Zed. What 
do you think? 3. another short item
```

Release Notes:

- Improved rewrap for markdown lists, todos, and block quotes.
2025-07-01 15:34:39 +05:30
Michael Sloan
c74ecb4654
Warn about unknown fields when editing settings json (#33678)
Closes #30017

* While generating the settings JSON schema, defaults all schema
definitions to reject unknown fields via `additionalProperties: false`.

* Uses `unevaluatedProperties: false` at the top level to check fields
that remain after the settings field names + release stage override
field names.

* Changes json schema version from `draft07` to `draft_2019_09` to have
support for `unevaluatedProperties`.

Release Notes:

- Added warnings for unknown fields when editing `settings.json`.
2025-06-30 23:34:25 +00:00
Michael Sloan
5fafab6e52
Migrate to schemars version 1.0 (#33635)
The major change in schemars 1.0 is that now schemas are represented as
plain json values instead of specialized datatypes. This allows for more
concise construction and manipulation.

This change also improves how settings schemas are generated. Each top
level settings type was being generated as a full root schema including
the definitions it references, and then these were merged. This meant
generating all shared definitions multiple times, and might have bugs in
cases where there are two types with the same names.

Now instead the schemar generator's `definitions` are built up as they
normally are and the `Settings` trait no longer has a special
`json_schema` method. To handle types that have schema that vary at
runtime (`FontFamilyName`, `ThemeName`, etc), values of
`ParameterizedJsonSchema` are collected by `inventory`, and the schema
definitions for these types are replaced.

To help check that this doesn't break anything, I tried to minimize the
overall [schema
diff](https://gist.github.com/mgsloan/1de549def20399d6f37943a3c1583ee7)
with some patches to make the order more consistent + schemas also
sorted with `jq -S .`. A skim of the diff shows that the diffs come
from:

* `enum: ["value"]` turning into `const: "value"`
* Differences in handling of newlines for "description"
* Schemas for generic types no longer including the parameter name, now
all disambiguation is with numeric suffixes
* Enums now using `oneOf` instead of `anyOf`.

Release Notes:

- N/A
2025-06-30 21:07:28 +00:00
Kirill Bulatov
6e77e8405b
Revert "languages: Bump ESLint LSP server to version 3.0.10 (#32717)" (#33659)
This reverts commit 1edaeebae5.

Based on an elevated number of ESLint-related issues, reverting the
upgrade.
Many people upvoted the issues and did not share any repro details, so
cannot be certain what's more broken: seems relatively generic as
related to *.ts ESLint configs.

Checked the revert on 2 projects from the issues below:

Closes https://github.com/zed-industries/zed/issues/33425

With https://github.com/adamhl8/zed-33425 as an example repo: there,
both eslint configurations worked for me when I stopped Zed and opened a
project.
Somehow, switching various Zed's with different vscode-eslint package
versions, eventually I get
`Error: Cannot find module
'~/.local/share/zed/languages/eslint/vscode-eslint-3.0.10/vscode-eslint/server/out/eslintServer.js'`-ish
error.

Not very related to issues with newer vscode-eslint integration, but
worth mentioning as is related to the package updates.


Closes https://github.com/zed-industries/zed/issues/33648

With a good example of
https://github.com/florian-lackner365/zed-eslint-bug monorepo project.
The monorepo part seems not to be related, but somehow,
`eslint.config.js` is involved as the newer vscode-eslint fails to find
a config.
Works well with the older vscode-eslint.

Release Notes:

- Downgraded to vscode-eslint-2.4.4 as a ESLint language server
2025-06-30 15:19:00 +00:00
Smit Barmase
d09c7eb317
language: Add context-aware decrease indent for Python (#33370)
Closes #33238, follow-up to
https://github.com/zed-industries/zed/pull/29625.

Changes:

- Removed `significant_indentation`, which was the way to introduce
indentation scoping in languages like Python. However, it turned out to
be unnecessarily complicated to define and maintain.
- Introduced `decrease_indent_patterns`, which takes a `pattern` keyword
to automatically outdent and `valid_after` keywords to treat as valid
code points to snap to. The outdent happens to the most recent
`valid_after` keyword that also has less or equal indentation than the
currently typed keyword.

Fixes:

1. In Python, typing `except`, `finally`, `else`, and so on now
automatically indents intelligently based on the context in which it
appears. For instance:

```py
try:
    if a == 1:
        try:
             b = 2
             ^  # <-- typing "except:" here would indent it to inner try block
```

but,

```py
try:
    if a == 1:
        try:
             b = 2
    ^  # <-- typing "except:" here would indent it to outer try block
```

2. Fixes comments not maintaining indent.

Release Notes:

- Improved auto outdent for Python while typing keywords like `except`,
`else`, `finally`, etc.
- Fixed the issue where comments in Python would not maintain their
indentation.
2025-06-26 11:11:03 +05:30
Anthony Eid
fc1fc264ec
debugger: Generate inline values based on debugger.scm file (#33081)
## Context

To support inline values a language will have to implement their own
provider trait that walks through tree sitter nodes. This is overly
complicated, hard to accurately implement for each language, and lacks
proper extension support.

This PR switches to a singular inline provider that uses a language's
`debugger.scm` query field to capture variables and scopes. The inline
provider is able to use this information to generate inlays that take
scope into account and work with any language that defines a debugger
query file.

### Todos
- [x] Implement a utility test function to easily test inline values
- [x] Generate inline values based on captures
- [x] Reimplement Python, Rust, and Go support
- [x] Take scope into account when iterating through variable captures
- [x] Add tests for Go inline values
- [x] Remove old inline provider code and trait implementations

Release Notes:

- debugger: Generate inline values based on a language debugger.scm file
2025-06-24 18:24:43 +00:00
Smit Barmase
76e3136369
editor: Utilize filter_text from language server for filter_range (#33155)
Closes #33106

Instead of directly using `filter_text` in `StringMatchCandidate`, which
yields better results for fuzzy matching but messes up with highlighting
letters in bold, as `positions` list generated by fuzzy crate are now of
`filter_text` and not `label` shown to the user.

This PR fixes it by keeping use of `filter_range` in
`StringMatchCandidate`, which is range w.r.t to `label` shown to user.
And actually generating this `filter_range` at source by using
`filter_range` if exists.

- [x] Tests

Release Notes:

- Fixed issue where incorrect letters are marked as bold in completions.
2025-06-21 19:47:16 +05:30
Cole Miller
0b228ad12c
debugger: Fix issues with debugging scripts from package.json (#32995)
- [x] Pass in cwd
- [x] Use the appropriate package manager
- [x] Don't mix up package.json and composer.json

Release Notes:

- debugger: Fixed wrong arguments being passed to the DAP when debugging
scripts from package.json.
2025-06-19 14:33:24 +00:00
Piotr Osiewicz
99215f7660
debugger: Run debug scenarios from package.json (#32958)
Release Notes:

- New session modal for a debugger will now show tasks from package.json
as debuggable scenarios

---------

Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
2025-06-18 20:04:25 +02:00
Cole Miller
2f52e2d285
debugger: Fix a few issues with JS debugging (#32918)
- Don't assume all located tasks come from our test runnables
- Run tests from the right working directory
- Scope forking behavior customization for jest and vitest more tightly,
to just our test runnables
- Standardize on `$PACKAGE_MANAGER exec -- $TEST_LIBRARY ...` to fix
runnables not working with npm

Release Notes:

- Debugger Beta: Fixed issues with debugging tasks from package.json and
test runnables.
2025-06-18 10:37:09 -04:00
Finn Evers
a391d67366
supermaven_api: Ensure downloaded Supermaven binary has executable permissions set (#32576)
Closes #32068
Closes #15653

Not entirely sure that it fixes the latter issue, but I am fairly
certain given the comments in #32068 and the available logs in the
issue.

This PR fixes an issue where the Supermaven provider would not leave the
"Initializing" stage. This happened due to the downloaded binary missing
executable permissions. The change here ensures that freshly downloaded
binaries as well as existing binaries downloaded by Zed have executable
permissions set. I decided on also adding this for the latter since
existing downloads would continue to be broken and Supermaven does not
seem to change versions often given the logs provided by users.


While I was at it, I also added a `make_file_executable` to the util
crate mirroring the method of the `zed_extensions_api` and refactored
existing usages where possible to use that method instead. This makes
the code slightly more readable in my opinion, yet adds a method to
non-unix systems that practically does nothing. I can revert this should
that be preferred.


Release Notes:

- Fixed an issue where the Supermaven completion provider would not
leave the "Initializing" stage.

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2025-06-17 14:39:45 +00:00
Umesh Yadav
1edaeebae5
languages: Bump ESLint LSP server to version 3.0.10 (#32717)
Testing project: https://github.com/imumesh18/zed-testing

I have attached the logs from the eslint lsp server. Confirming that we
are indeed calling `textDocument/diagnostic` and we are receiving the
error response as well from lsp. Please check the attached log for it.

<details>
<summary>Server Log</summary>

```

// Send:
{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"":{"validate":"on","rulesCustomizations":[],"run":"onType","nodePath":null,"workingDirectory":{"mode":"auto"},"workspaceFolder":{"uri":"/Users/umesh/code/zed-testing","name":"zed-testing"},"problems":{},"codeActionOnSave":{"enable":true},"codeAction":{"disableRuleComment":{"enable":true,"location":"separateLine"},"showDocumentation":{"enable":true}},"useFlatConfig":true}}}}

// Receive:
{"jsonrpc":"2.0","id":6,"method":"workspace/diagnostic/refresh"}

// Send:
{"jsonrpc":"2.0","id":6,"result":null}

// Send:
{"jsonrpc":"2.0","id":8,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":9,"character":3},"end":{"line":9,"character":3}},"context":{"diagnostics":[],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":7,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","section":""}]}}

// Send:
{"jsonrpc":"2.0","id":7,"result":[{"validate":"on","rulesCustomizations":[],"run":"onType","nodePath":null,"workingDirectory":{"mode":"auto"},"workspaceFolder":{"uri":"/Users/umesh/code/zed-testing","name":"zed-testing"},"problems":{},"codeActionOnSave":{"enable":true},"codeAction":{"disableRuleComment":{"enable":true,"location":"separateLine"},"showDocumentation":{"enable":true}},"useFlatConfig":true}]}

// Receive:
{"jsonrpc":"2.0","id":8,"result":[]}

// Send:
{"jsonrpc":"2.0","id":9,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":12,"character":20},"end":{"line":12,"character":20}},"context":{"diagnostics":[],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":9,"result":[]}

// Send:
{"jsonrpc":"2.0","id":10,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":11,"character":37},"end":{"line":11,"character":37}},"context":{"diagnostics":[],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":10,"result":[]}

// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"}}}

// Send:
{"jsonrpc":"2.0","id":11,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":3,"character":0},"end":{"line":14,"character":0}},"context":{"diagnostics":[{"range":{"start":{"line":4,"character":8},"end":{"line":4,"character":22}},"severity":1,"code":"@typescript-eslint/no-unused-vars","source":"eslint","message":"'unusedVariable' is assigned a value but never used."},{"range":{"start":{"line":4,"character":8},"end":{"line":4,"character":22}},"severity":4,"code":6133,"source":"ts","message":"'unusedVariable' is declared but its value is never read."},{"range":{"start":{"line":7,"character":6},"end":{"line":7,"character":14}},"severity":1,"code":2367,"source":"ts","message":"This comparison appears to be unintentional because the types 'number' and 'string' have no overlap."},{"range":{"start":{"line":13,"character":2},"end":{"line":13,"character":52}},"severity":1,"code":"no-var","source":"eslint","message":"Unexpected var, use let or const instead."},{"range":{"start":{"line":13,"character":6},"end":{"line":13,"character":22}},"severity":1,"code":"@typescript-eslint/no-unused-vars","source":"eslint","message":"'oldStyleVariable' is assigned a value but never used."},{"range":{"start":{"line":13,"character":6},"end":{"line":13,"character":22}},"severity":4,"code":6133,"source":"ts","message":"'oldStyleVariable' is declared but its value is never read."}],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":11,"result":[{"title":"Disable @typescript-eslint/no-unused-vars for this line","command":{"title":"Disable @typescript-eslint/no-unused-vars for this line","command":"eslint.applyDisableLine","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Disable @typescript-eslint/no-unused-vars for the entire file","command":{"title":"Disable @typescript-eslint/no-unused-vars for the entire file","command":"eslint.applyDisableFile","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Show documentation for @typescript-eslint/no-unused-vars","command":{"title":"Show documentation for @typescript-eslint/no-unused-vars","command":"eslint.openRuleDoc","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Fix this no-var problem","command":{"title":"Fix this no-var problem","command":"eslint.applySingleFix","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"no-var"}]},"kind":"quickfix","diagnostics":[{"message":"Unexpected var, use let or const instead.","severity":1,"source":"eslint","range":{"start":{"line":13,"character":2},"end":{"line":13,"character":52}},"code":"no-var","codeDescription":{"href":"https://eslint.org/docs/latest/rules/no-var"}}],"isPreferred":true},{"title":"Disable no-var for this line","command":{"title":"Disable no-var for this line","command":"eslint.applyDisableLine","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Disable no-var for the entire file","command":{"title":"Disable no-var for the entire file","command":"eslint.applyDisableFile","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Show documentation for no-var","command":{"title":"Show documentation for no-var","command":"eslint.openRuleDoc","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Fix all auto-fixable problems","command":{"title":"Fix all auto-fixable problems","command":"eslint.applyAllFixes","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":0}]},"kind":"quickfix"}]}

// Send:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":1},"contentChanges":[{"range":{"start":{"line":3,"character":2},"end":{"line":3,"character":2}},"text":"// "},{"range":{"start":{"line":4,"character":2},"end":{"line":4,"character":2}},"text":"// "},{"range":{"start":{"line":6,"character":2},"end":{"line":6,"character":2}},"text":"// "},{"range":{"start":{"line":7,"character":2},"end":{"line":7,"character":2}},"text":"// "},{"range":{"start":{"line":8,"character":2},"end":{"line":8,"character":2}},"text":"// "},{"range":{"start":{"line":9,"character":2},"end":{"line":9,"character":2}},"text":"// "},{"range":{"start":{"line":11,"character":2},"end":{"line":11,"character":2}},"text":"// "},{"range":{"start":{"line":12,"character":2},"end":{"line":12,"character":2}},"text":"// "},{"range":{"start":{"line":13,"character":2},"end":{"line":13,"character":2}},"text":"// "}]}}

// Send:
{"jsonrpc":"2.0","id":12,"method":"textDocument/diagnostic","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"identifier":"eslint","previousResultId":null}}

// Receive:
{"jsonrpc":"2.0","method":"eslint/status","params":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","state":1,"validationTime":18}}

// Receive:
{"jsonrpc":"2.0","id":12,"result":{"kind":"full","items":[]}}

// Send:
{"jsonrpc":"2.0","id":13,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":3,"character":0},"end":{"line":14,"character":0}},"context":{"diagnostics":[{"range":{"start":{"line":4,"character":11},"end":{"line":4,"character":25}},"severity":4,"code":6133,"source":"ts","message":"'unusedVariable' is declared but its value is never read."},{"range":{"start":{"line":7,"character":9},"end":{"line":7,"character":17}},"severity":1,"code":2367,"source":"ts","message":"This comparison appears to be unintentional because the types 'number' and 'string' have no overlap."},{"range":{"start":{"line":13,"character":9},"end":{"line":13,"character":25}},"severity":4,"code":6133,"source":"ts","message":"'oldStyleVariable' is declared but its value is never read."}],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":13,"result":[]}

// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"}}}

// Send:
{"jsonrpc":"2.0","id":14,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":13,"character":7},"end":{"line":13,"character":7}},"context":{"diagnostics":[],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":14,"result":[]}

// Send:
{"jsonrpc":"2.0","id":15,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":3,"character":0},"end":{"line":14,"character":0}},"context":{"diagnostics":[],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":15,"result":[]}

// Send:
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2},"contentChanges":[{"range":{"start":{"line":3,"character":2},"end":{"line":3,"character":5}},"text":""},{"range":{"start":{"line":4,"character":2},"end":{"line":4,"character":5}},"text":""},{"range":{"start":{"line":6,"character":2},"end":{"line":6,"character":5}},"text":""},{"range":{"start":{"line":7,"character":2},"end":{"line":7,"character":5}},"text":""},{"range":{"start":{"line":8,"character":2},"end":{"line":8,"character":5}},"text":""},{"range":{"start":{"line":9,"character":2},"end":{"line":9,"character":5}},"text":""},{"range":{"start":{"line":11,"character":2},"end":{"line":11,"character":5}},"text":""},{"range":{"start":{"line":12,"character":2},"end":{"line":12,"character":5}},"text":""},{"range":{"start":{"line":13,"character":2},"end":{"line":13,"character":5}},"text":""}]}}

// Send:
{"jsonrpc":"2.0","id":16,"method":"textDocument/diagnostic","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"identifier":"eslint","previousResultId":null}}

// Receive:
{"jsonrpc":"2.0","method":"eslint/status","params":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","state":1,"validationTime":15}}

// Receive:
{"jsonrpc":"2.0","id":16,"result":{"kind":"full","items":[{"message":"'unusedVariable' is assigned a value but never used.","severity":1,"source":"eslint","range":{"start":{"line":4,"character":8},"end":{"line":4,"character":22}},"code":"@typescript-eslint/no-unused-vars","codeDescription":{"href":"https://typescript-eslint.io/rules/no-unused-vars"}},{"message":"Unexpected var, use let or const instead.","severity":1,"source":"eslint","range":{"start":{"line":13,"character":2},"end":{"line":13,"character":52}},"code":"no-var","codeDescription":{"href":"https://eslint.org/docs/latest/rules/no-var"}},{"message":"'oldStyleVariable' is assigned a value but never used.","severity":1,"source":"eslint","range":{"start":{"line":13,"character":6},"end":{"line":13,"character":22}},"code":"@typescript-eslint/no-unused-vars","codeDescription":{"href":"https://typescript-eslint.io/rules/no-unused-vars"}}]}}

// Send:
{"jsonrpc":"2.0","id":17,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"},"range":{"start":{"line":3,"character":0},"end":{"line":14,"character":0}},"context":{"diagnostics":[{"range":{"start":{"line":4,"character":8},"end":{"line":4,"character":22}},"severity":1,"code":"@typescript-eslint/no-unused-vars","source":"eslint","message":"'unusedVariable' is assigned a value but never used."},{"range":{"start":{"line":13,"character":2},"end":{"line":13,"character":52}},"severity":1,"code":"no-var","source":"eslint","message":"Unexpected var, use let or const instead."},{"range":{"start":{"line":13,"character":6},"end":{"line":13,"character":22}},"severity":1,"code":"@typescript-eslint/no-unused-vars","source":"eslint","message":"'oldStyleVariable' is assigned a value but never used."}],"only":["quickfix","source.fixAll.eslint"]}}}

// Receive:
{"jsonrpc":"2.0","id":17,"result":[{"title":"Disable @typescript-eslint/no-unused-vars for this line","command":{"title":"Disable @typescript-eslint/no-unused-vars for this line","command":"eslint.applyDisableLine","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Disable @typescript-eslint/no-unused-vars for the entire file","command":{"title":"Disable @typescript-eslint/no-unused-vars for the entire file","command":"eslint.applyDisableFile","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Show documentation for @typescript-eslint/no-unused-vars","command":{"title":"Show documentation for @typescript-eslint/no-unused-vars","command":"eslint.openRuleDoc","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"@typescript-eslint/no-unused-vars"}]},"kind":"quickfix"},{"title":"Fix this no-var problem","command":{"title":"Fix this no-var problem","command":"eslint.applySingleFix","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"no-var"}]},"kind":"quickfix","diagnostics":[{"message":"Unexpected var, use let or const instead.","severity":1,"source":"eslint","range":{"start":{"line":13,"character":2},"end":{"line":13,"character":52}},"code":"no-var","codeDescription":{"href":"https://eslint.org/docs/latest/rules/no-var"}}],"isPreferred":true},{"title":"Disable no-var for this line","command":{"title":"Disable no-var for this line","command":"eslint.applyDisableLine","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Disable no-var for the entire file","command":{"title":"Disable no-var for the entire file","command":"eslint.applyDisableFile","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Show documentation for no-var","command":{"title":"Show documentation for no-var","command":"eslint.openRuleDoc","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2,"ruleId":"no-var"}]},"kind":"quickfix"},{"title":"Fix all auto-fixable problems","command":{"title":"Fix all auto-fixable problems","command":"eslint.applyAllFixes","arguments":[{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx","version":2}]},"kind":"quickfix"}]}

// Send:
{"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///Users/umesh/code/zed-testing/src/app/page.tsx"}}}
```

</details>

Release Notes:

- Bump ESLint LSP server to version 3.0.10
2025-06-14 01:20:38 +03:00
Cole Miller
bcd79331b9
debugger: Fix running JS tests when worktree root and package root do not coincide (#32644)
- construct the correct path to the test library based on the location
of package.json
- run scripts from the package root where they were defined
- run tests in the directory of the defining file

Release Notes:

- Debugger Beta: fixed running JS tests when the worktree root is above
the location of package.json.

---------

Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-06-13 05:03:07 +00:00
Alexander
83eb6ffe1e
Apply TypeScript test improvements to tsx files (#32477)
relates-to: #32467
relates-to: #31499

Release Notes:

- N/A
2025-06-11 20:23:16 +02:00
Cole Miller
06f7d791b7
debugger: Fix a couple of issues with vitest (#32543)
- Pass the right test name filter
- Limit the number of forks used by the testing pool in the spirit of
#32473

Release Notes:

- Debugger Beta: switched to running vitest tests serially when
debugging.
2025-06-11 10:36:23 -04:00
Smit Barmase
fc4ca346be
editor: Adjust scope for prefer label for snippet workaround (#32515)
Closes #32159

This PR refines the scope to match just the function name with **the
type argument** instead of the whole call expression.

Matching to whole call expression prevented methods from expanding
inside the function argument. For example, `const foo =
bar(someMethod(2)^);` instead of `const foo = bar(someMethod^)`;

Follow-up for https://github.com/zed-industries/zed/pull/30312,
https://github.com/zed-industries/zed/pull/30351. Mistakenly regressed
since https://github.com/zed-industries/zed/pull/31872 when we stopped
receiving `insert_range` for this particular case and fallback to
`replace_range`.

Release Notes:

- Fixed issue where code completion in TypeScript function arguments
sometimes omitted the dot separator, for example resulting in
`NumberparseInt` instead of `Number.parseInt(string)`.

---------

Co-authored-by: Michael Sloan <michael@zed.dev>
Co-authored-by: Michael Sloan <mgsloan@gmail.com>
2025-06-11 10:38:39 +05:30
Kirill Bulatov
9c513223c4
Add initial package.json scripts task autodetection (#32497)
Now, every JS/TS-related file will get their package.json script
contents added as tasks:

<img width="1020" alt="image"
src="https://github.com/user-attachments/assets/5bf80f80-fd72-4ba8-8ccf-418872895a25"
/>

To achieve that, `fn associated_tasks` from the `ContextProvider` was
made asynchronous and the related code adjusted.

Release Notes:

- Added initial `package.json` scripts task autodetection

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
2025-06-10 22:16:27 +00:00
Cole Miller
71d5c57119
debugger: Specify runtimeExecutable in output of node locator (#32464)
This appears to fix some cases where we fail to launch JS tests under
the debugger.

Release Notes:

- N/A (node locator is still gated)

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-06-10 20:42:55 +00:00
Alexander
9334e152b4
Allow identifiers in TypeScript/JavaScript test names (#32467)
Current behavior (not detected as runnable):

<img width="1105" alt="image"
src="https://github.com/user-attachments/assets/7d3b7936-43d8-4645-bbbb-e81ed5f9b35a"
/>

New behavior:



https://github.com/user-attachments/assets/524e2a56-cb30-4dc0-98ec-b34b510015e0

Release Notes:

- Improved detection of runnable TypeScript/JavaScript test cases when
they contain identifier
2025-06-10 18:00:42 +02:00
Alexander
6fe58a2c4e
Allow to run dynamic TypeScript and JavaScript tests (#31499)
First of all thank you for such a fast editor!

I realized that the existing support for detecting runnable test cases
for typescript/javascript is not full. Meanwhile I can run most of test
by pressing "run button":

<img width="713" alt="image"
src="https://github.com/user-attachments/assets/e8bb1cb1-f0a5-4eb1-b9a6-7188a9fa47ae"
/>

I can't run dynamic tests:

<img width="703" alt="image"
src="https://github.com/user-attachments/assets/d7eef1bc-e99a-4f05-9d62-ec49b8194959"
/>

I was curious whether I can improve it on my own and created this pr. I
edited schemas and added minor changes in `TaskTemplate` to allow to
replace '%s' with regexp pattern, so it can match test cases:

<img width="772" alt="image"
src="https://github.com/user-attachments/assets/db3a6fe0-ad90-4853-8e98-4215e41dfe88"
/>

Release Notes:

- Allow to run dynamic TypeScript/JavaScript tests

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2025-06-09 12:13:25 +02:00
chbk
9e5f89dc26
Improve CSS syntax highlighting (#25326)
Release Notes:

  - Improved CSS syntax highlighting

| Zed 0.174.6 | With this PR |
| --- | --- |
| ![css_0 174
6](https://github.com/user-attachments/assets/d069f20e-5f1f-4d03-a010-81ba4b61b3a0)
|
![css_pr](https://github.com/user-attachments/assets/36463ef1-2ead-421d-9825-bd359e7677ab)
|

- `|`: `operator`
- `and`, `or`, `not`, `only`: `operator` -> `keyword.operator`, as
defined in other languages
- `id_name`, `class_name`: `property`/`attribute` -> `selector`, not a
property name. [CSS
reference](https://www.w3.org/TR/selectors-3/#class-html)
- `namespace_name`: `property` -> `namespace`, not a property name
- `property_name`: `constant` -> `property`, like `feature_name` already
defined
- `(keyword_query)`: `property`, similar to `feature_name`. [CSS
reference](https://www.w3.org/TR/mediaqueries-3/#media1)
- `keyword_query`: `constant.builtin`, [CSS
reference](https://www.w3.org/TR/mediaqueries-3/#media0)
- `plain_value`, `keyframes_name`: `constant.builtin`, [CSS
reference](https://www.w3.org/TR/css-values-3/#value-defs)
- `unit`: `type` -> `type.unit`,
[Atom](9e4afce058/grammars/tree-sitter-css.cson (L73))
and [VS
Code](336801752d/extensions/css/syntaxes/css.tmLanguage.json (L1393))
also have a `unit` scope for this. [CSS
reference](https://www.w3.org/TR/css3-values/#dimensions)


```css
@media (keyword_query) and keyword_query {}
@supports (feature_name: plain_value) {}
@namespace namespace_name url("string");
namespace_name|tag_name {}
@keyframes keyframes_name {
  to {
    top: 200unit;
    color: #c01045;
  }
}
tag_name::before,
#id_name:nth-child(even),
.class_name[attribute_name=plain_value] {
  property_name: 2em 1.2em;
  --variable: rgb(250, 0, 0);
  color: var(--variable);
  animation: keyframes_name 5s plain_value;
}
```
2025-06-06 17:14:32 -04:00
chbk
3da1de2a48
Add JSDoc scope (#29476)
This is a small PR that adds a `.jsdoc` scope to JSDoc tokens, just like
[JSX](3fdbc3090d/crates/languages/src/javascript/highlights.scm (L239))
has a specific scope.
This effectively allows differentiating between JavaScript keywords and
JSDoc tags in comments.

Release Notes:

  - Add scope for JSDoc
2025-06-06 08:31:59 -04:00
Julia Ryan
f62d76159b
Fix matching braces in jsx/tsx tags (#32196)
Closes #27998

Also fixed an issue where jumping back from closing to opening tags
didn't work in javascript due to missing brackets in our tree-sitter
query.

Release Notes:

- N/A

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-06-05 18:10:22 -07:00
Peter Tripp
ae210eced8
Fix aggressive indent in shell scripts (#31973)
Closes: https://github.com/zed-industries/zed/issues/31774

Release Notes:

- N/A

Co-authored-by: Ben Kunkle <ben.kunkle@gmail.com>
2025-06-03 10:50:58 -04:00
Thiago Pacheco
3e6435eddc
Fix Python virtual environment detection (#31934)
# Fix Python Virtual Environment Detection in Zed

## Problem

Zed was not properly detecting Python virtual environments when a
project didn't contain a `pyrightconfig.json` file. This caused Pyright
(the Python language server) to report `reportMissingImports` errors for
packages installed in virtual environments, even though the virtual
environment was correctly set up and worked fine in other editors.

The issue was that while Zed's `PythonToolchainProvider` correctly
detected virtual environments, this information wasn't being
communicated to Pyright in a format it could understand.

## Root Cause

The main issue was in how Zed communicated virtual environment
configuration to Pyright through the Language Server Protocol (LSP).
When Pyright requests workspace configuration, it expects virtual
environment settings (`venvPath` and `venv`) at the root level of the
configuration object - the same format used in `pyrightconfig.json`
files. However, Zed was attempting to place these settings in various
nested locations that Pyright wasn't checking.

## Solution

The fix involves several coordinated changes to ensure Pyright receives
virtual environment configuration in all the ways it might expect:

### 1. Enhanced Workspace Configuration (`workspace_configuration`
method)
- When a virtual environment is detected, Zed now sets `venvPath` and
`venv` at the root level of the configuration object, matching the exact
format of a `pyrightconfig.json` file
- Uses relative path `"."` when the virtual environment is located in
the workspace root
- Also sets `python.pythonPath` and `python.defaultInterpreterPath` for
compatibility with different Pyright versions

### 2. Environment Variables for All Language Server Binaries
- Updated `check_if_user_installed`, `fetch_server_binary`,
`check_if_version_installed`, and `cached_server_binary` methods to
include shell environment variables
- This ensures environment variables like `VIRTUAL_ENV` are available to
Pyright, helping with automatic virtual environment detection

### 3. Initialization Options
- Added minimal initialization options to enable Pyright's automatic
path searching and import completion features
- Sets `autoSearchPaths: true` and `useLibraryCodeForTypes: true` to
improve Pyright's ability to find packages

## Key Changes

The workspace configuration now properly formats virtual environment
configuration:
- Root level: `venvPath` and `venv` (matches pyrightconfig.json format)
- Python section: `pythonPath` and `defaultInterpreterPath` for
interpreter paths

## Impact

- Users no longer need to create a `pyrightconfig.json` file for virtual
environment detection
- Python projects with virtual environments in standard locations
(`.venv`, `venv`, etc.) will work out of the box
- Import resolution for packages installed in virtual environments now
works correctly
- Maintains compatibility with manual `pyrightconfig.json` configuration
for complex setups

## Testing

The changes were tested with Python projects using virtual environments
without `pyrightconfig.json` files. Pyright now correctly resolves
imports from packages installed in the virtual environment, eliminating
the `reportMissingImports` errors.

## Release Notes

- Fixed Python virtual environment detection when no
`pyrightconfig.json` is present
- Pyright now correctly resolves imports from packages installed in
virtual environments (`.venv`, `venv`, etc.)
- Python projects with virtual environments no longer show false
`reportMissingImports` errors
- Improved Python development experience with automatic virtual
environment configuration

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2025-06-03 16:35:13 +02:00
Piotr Osiewicz
9dd18e5ee1
python: Re-land usage of source file path in toolchain picker (#31893)
This reverts commit 1e55e88c18.

Closes #ISSUE

Release Notes:

- Python toolchain selector now uses path to the closest pyproject.toml
as a basis for picking a toolchain. All files under the same
pyproject.toml (in filesystem hierarchy) will share a single virtual
environment. It is possible to have multiple Python virtual environments
selected for disjoint parts of the same project.
2025-06-02 16:29:06 +00:00
Thiago Pacheco
aacbb9c2f4
python: Respect picked toolchain (when it's not at the root) when running tests (#31150)
# Fix Python venv Detection for Test Runner
## Problem
Zed’s Python test runner was not reliably detecting and activating the
project’s Python virtual environment (.venv or venv), causing it to
default to the system Python. This led to issues such as missing
dependencies (e.g., pytest) when running tests.
## Solution
Project Root Awareness: The Python context provider now receives the
project root path, ensuring venv detection always starts from the
project root rather than the test file’s directory.
Robust venv Activation: The test runner now correctly detects and
activates the Python interpreter from .venv or venv in the project root,
setting VIRTUAL_ENV and updating PATH as needed.
Minimal Impact: The change is limited in scope, affecting only the
necessary code paths for Python test runner venv detection. No broad
architectural changes were made.
## Additional Improvements
Updated trait and function signatures to thread the project root path
where needed.
Cleaned up linter warnings and unused code.
## Result
Python tests now reliably run using the project’s virtual environment,
matching the behavior of other IDEs and ensuring all dependencies are
available.

Release Notes:

- Fixed Python tasks always running with a toolchain selected for the
root of a workspace.

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2025-06-02 15:29:34 +02:00
Umesh Yadav
32214abb64
Improve TypeScript shebang detection (#31437)
Closes #13981

Release Notes:

- Improved TypeScript shebang detection
2025-05-30 16:11:13 -04:00
Kirill Bulatov
1e83022f03
Add a JS/TS debug locator (#31769)
With this, a semi-working debug session is possible from the JS/TS
gutter tasks:


https://github.com/user-attachments/assets/8db6ed29-b44a-4314-ae8b-a8213291bffc

For now, available in debug builds only as a base to improve on later on
the DAP front.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
2025-05-30 17:15:42 +00:00
Kirill Bulatov
2abc5893c1
Improve TypeScript task detection (#31711)
Parses project's package.json to better detect Jasmine, Jest, Vitest and
Mocha and `test`, `build` scripts presence.
Also tries to detect `pnpm` and `npx` as test runners, falls back to
`npm`.


https://github.com/user-attachments/assets/112d3d8b-8daa-4ba5-8cb5-2f483036bd98

Release Notes:

- Improved TypeScript task detection
2025-05-29 20:51:20 +00:00
Piotr Osiewicz
83135e98e6
Introduce $ZED_CUSTOM_PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW to work around (#31685)
Follow up to #31674 

Release Notes:

- N/A

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2025-05-29 13:44:55 +00:00