zed icon indicating copy to clipboard operation
zed copied to clipboard

Deno support

Open clo4 opened this issue 3 years ago • 20 comments

Is your feature request related to a problem? Please describe. There's no way to use the Deno language server (deno lsp) which means Zed doesn't support most of my personal projects.

Describe the solution you'd like A way to configure the language server that gets used

Describe alternatives you've considered Currently the only alternative is use an editor that supports setting the language server, eg. vim/vscode

clo4 avatar Jun 20 '22 08:06 clo4

We have @slightknack working on allowing users to bring their own language servers.

nathansobo avatar Jun 20 '22 16:06 nathansobo

Is there an ETA on this?

NetOpWibby avatar Jul 23 '23 21:07 NetOpWibby

I think automatically switching to Deno's LSP if there's a deno.json or deno.jsonc in the root would be great. I'd hope there would be a configuration option outside of that, but this would be a great start. This is the only thing stopping me from moving to zed right now (I currently switch between Zed and Lapce depending on whether it's a Deno project or not)!

lino-levan avatar Sep 21 '23 17:09 lino-levan

A possibility to choose the LSP for each separate language in the settings perhaps? Like in VSC where you can enable to always use Deno LSP in TypeScript projects.

agorushkin avatar Nov 02 '23 04:11 agorushkin

2024 bump

NetOpWibby avatar Jan 13 '24 00:01 NetOpWibby

Not on the Zed team, but I can tell you this is important to them! After all, what’s a code editor if you can’t use it for what you want to use it for? But with the zed2/GPUI2 transition nearing completion, the focus is more around stability and polishing the codebase right now. So, this will get done, but there have been other priorities that needed to be addressed first.

clo4 avatar Jan 13 '24 08:01 clo4

@clo4 is right! Supporting things like Deno is hugely important to us, we just need to finish off this transition for GPUI2 and the open source checklist (soooo very close!). We will switch back to building big fun features after that, and you all can join us in building some features out too, if you'd like!

JosephTLyons avatar Jan 15 '24 03:01 JosephTLyons

@maxbrunsfeld I think we can close this now.

smorimoto avatar Jan 26 '24 13:01 smorimoto

It'd make more sense to close once the Deno feature is actually in the released app, no?

NetOpWibby avatar Jan 26 '24 15:01 NetOpWibby

Deno's LSP isn't fully integrated yet. Maybe we wait until we hit feature parity (or close) with vscode_deno?

lino-levan avatar Jan 26 '24 15:01 lino-levan

I'd wait until the feature has properly launched. Can't wait to start having better support for Deno, since I'm using Deno daily for my own projects.

Ducky07 avatar Jan 29 '24 10:01 Ducky07

This is available in Zed v0.121.0.

maxdeviant avatar Jan 31 '24 22:01 maxdeviant

SS 2024-01-31 at 3 03 45 PM

I'm still getting red squiggles on that version.

NetOpWibby avatar Jan 31 '24 23:01 NetOpWibby

@NetOpWibby

I'm still getting red squiggles on that version.

Deno is off by default.

I had to add "deno": { "enable": true } to my global settings. Adding it to the folder-specific settings did not work.

rotu avatar Feb 01 '24 04:02 rotu

SS 2024-02-01 at 7 23 54 PM

Okay I have that working but now I'm getting these errors for valid code. My import_map.json sets up these import paths.

NetOpWibby avatar Feb 02 '24 03:02 NetOpWibby

Okay I have that working but now I'm getting these errors for valid code. My import_map.json sets up these import paths.

You probably need to add that to your deno.json/deno.jsonc file.

You can either put it right in your deno.json:

{
  "imports": { "std/": "https://deno.land/[email protected]/" }
}

or use a separate import map file:

{
  "importMap": "import_map.json"
}

rotu avatar Feb 02 '24 04:02 rotu

I downloaded this pre release, then set ~/.config/zed/settings.json this:

{
  "theme": "One Dark",
  "vim_mode": true,
  "ui_font_size": 12,
  "buffer_font_size": 12,
  "deno": { "enable": true }
}

and refresh the zed, but the lsp didn't started at the LSP logs.

igorbrasileiro avatar Feb 02 '24 15:02 igorbrasileiro

@igorbrasileiro your setup works for me. You do have to quit and restart Zed after enabling Deno. Or run the "workspace: restart" command. The "editor: restart language server" command does not switch over from the typescript to the deno language server.

Also, in the "debug: language server logs" page, slightly confusingly there's a a dropdown at the top to choose between language servers. Is deno-language-server in that dropdown?

rotu avatar Feb 03 '24 03:02 rotu

@igorbrasileiro your setup works for me. You do have to quit and restart Zed after enabling Deno. Or run the "workspace: restart" command. The "editor: restart language server" command does not switch over from the typescript to the deno language server.

Also, in the "debug: language server logs" page, slightly confusingly there's a a dropdown at the top to choose between language servers. Is deno-language-server in that dropdown?

Oh, thank you, yeah, after restar it worked. I thought it didn`t worked, but the delay was the deno lsp timeout

igorbrasileiro avatar Feb 03 '24 03:02 igorbrasileiro

I’d love to improve this. Anyone @ me if you want to pair on it. Why do we need a restart?

On Fri, Feb 2, 2024 at 8:16 PM Igor Brasileiro @.***> wrote:

@igorbrasileiro https://github.com/igorbrasileiro your setup works for me. You do have to quit and restart Zed after enabling Deno. Or run the "workspace: restart" command. The "editor: restart language server" command does not switch over from the typescript to the deno language server.

Also, in the "debug: language server logs" page, slightly confusingly there's a a dropdown at the top to choose between language servers. Is deno-language-server in that dropdown?

Oh, thank you, yeah, after restar it worked. I thought it didn`t worked, but the delay was the deno lsp timeout

— Reply to this email directly, view it on GitHub https://github.com/zed-industries/zed/issues/5361#issuecomment-1925037443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAN7MXDKNCGVK3ISQ5HHLYRWTX7AVCNFSM6AAAAABCJF56TSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGAZTONBUGM . You are receiving this because you commented.Message ID: @.***>

nathansobo avatar Feb 03 '24 03:02 nathansobo

Seems like we can close this issue now - there's probably a lot of low hanging fruit that can be fixed, but Deno support has landed in main. From this point it's going to be more useful to create issues for the individual things that don't work so it's easier to track what needs to get done.

clo4 avatar Feb 07 '24 07:02 clo4

I agree with @clo4, let's close this issue out in favor of new issues for further fixes / enhancements.

JosephTLyons avatar Feb 26 '24 06:02 JosephTLyons

It seems that the formatter doesn't use deno fmt yet. For now, I could use deno fmt by configuring it like below:

{
  "deno": { "enable": true },
  "format_on_save": "on",
  "formatter": {
    "external": {
      "command": "deno",
      "arguments": ["fmt", "-"]
    }
  }
}

dahlia avatar Feb 27 '24 03:02 dahlia

For a monorepo setup, is there a way to configure the formatter based on the file paths in the workspace settings? For example if 2 out of 5 packages use Deno

andreasvirkus avatar Mar 06 '24 06:03 andreasvirkus

Screenshot 2024-05-03 at 12 35 20

started to get squilly lines in the latest deno version

Screenshot 2024-05-03 at 12 35 52

this is in the stock-standard tutorial project for fresh

kewp avatar May 03 '24 04:05 kewp

Screenshot 2024-05-03 at 12 35 20 started to get squilly lines in the latest deno version Screenshot 2024-05-03 at 12 35 52 this is in the stock-standard tutorial project for fresh

If you show the diagnostics, the language server that reported is Typescript? I'm facing the same issue and the LS that's reporting is Typescript. The message:

typescript: Cannot find module 'deco/deps.ts' or its corresponding type declarations.

igorbrasileiro avatar May 03 '24 12:05 igorbrasileiro

yeah weird @igorbrasileiro not sure why it happened but some people on discord helped me out https://discord.com/channels/684898665143206084/684898665151594506/1235814362388889601

basically you need to install the deno plugin from zed (it's version 0.0.1 ... and only have like 150 installs) and then disable the built-in typescript server by changing your settings:

{
  "languages": {
    "TypeScript": {
      "language_servers": ["deno", "!typescript-language-server", "!eslint", "..."]
    },
    "TSX": {
      "language_servers": ["deno", "!typescript-language-server", "!eslint", "..."]
    }
  }
}

kewp avatar May 03 '24 13:05 kewp

Thanks for the tip @kewp – this had worked for a few weeks for me.

In the last few days, however, I’m getting TS errors all over my project 😢

ts: Cannot find name 'Deno'. (2304)

EDIT: obvisouly the moment I posted this I discovered that there’s a new language server for TS that needs to be explcicitely disabled called vtsls since #13140

{
  "languages": {
    "TypeScript": {
      "language_servers": [
        "deno",
        "!typescript-language-server",
+       "!vtsls",
        "!eslint",
        "..."
      ]
    },
  }
}

mxdvl avatar Jun 19 '24 08:06 mxdvl

hey @mxdvl yeah I'm also having issues, not with your fix but with monorepos ... I need to be able to tell Zed "please use this language server for this directory", much like @andreasvirkus mentioned ...

kewp avatar Jun 19 '24 14:06 kewp

I'm having issues when using dependencies from JSR image As you can see, the Deno plugin is loaded and working, but I cannot get type declarations. What is interesting is that import suggestions work.

Edit:

I can get some functionality working by specifying the LSP to use:

"languages": {
    "TypeScript": {
      "language_servers": [
        "deno"
      ]
    }
  }

However goto source always returns an empty document.

sachaw avatar Jun 29 '24 05:06 sachaw