denoland / vscode_deno

Visual Studio Code plugin for Deno
https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
MIT License
1.5k stars 146 forks source link

Configuring Formatting Without Enabling Other Language Tools #1212

Closed harrysolovay closed 3 days ago

harrysolovay commented 4 days ago

I'd like to use Deno's formatter with VSCode + my Node project. Unfortunately, when I create a deno.json with my preferred formatting configuration, Deno overrides the default TS language server. If I specify exclude: ["."] to disable the language server for my project files, the formatting no longer applies to any of the files. I'm wondering if there's a way to utilize the Deno formatter without enabling the language server? I'd also be partial to doing this within the .vscode/settings.json to avoid need of the deno.json file.

{
  "deno.fmt": {
    "lineWidth": 100,
    "proseWrap": "always",
    "semiColons": false
  }
}

This would break usage of the deno fmt command. So perhaps there could also be a --vscode-settings flag to tell Deno's fmt command to look inside of the .vscode/settings.json for the configuration.

Thoughts?

bartlomieju commented 3 days ago

@nayeemrmn please take a look - I believe this should be possible with just VSCode settings to enable Deno as a default formatter

nayeemrmn commented 3 days ago

Using the formatter requires starting the language server and syncing docs with it. Instead, you should use https://marketplace.visualstudio.com/items?itemName=dprint.dprint which is the library deno fmt uses.

harrysolovay commented 3 days ago

I've been using dprint, but I see the latest Deno release has a sql formatter baked in. I've been using dprint-plugin-exec to trigger sql-formatter, but it's a little laggy. I'd prefer to use deno fmt now that it supports sql (even though it's technically unstable). I know it's nothing mission critical, but I believe this should be doable (using tools of the Deno toolchain independently of one another).

bartlomieju commented 3 days ago

@harrysolovay FYI deno fmt SQL support is based on https://github.com/shssoichiro/sqlformat-rs - it should be fairly straightforward to create a dprint plugin for it.

Unfortunately we don't have bandwidth at this point to maintain a completely different VSCode plugin that would allow us to only run deno fmt instead of spawning the whole language server.

harrysolovay commented 3 days ago

Makes sense. Thank you for your consideration!