Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
199 stars 29 forks source link

Unable to format unsaved buffer marked as Racket language #113

Closed jryans closed 2 months ago

jryans commented 1 year ago

Steps to reproduce

  1. Open a new unsaved buffer
  2. Enter some Racket code
  3. Manually set the language of the buffer to Racket (if needed)
  4. Try to format with the "Format Document" command

Expected

The file should be formatted.

Actual

VS Code claims "There is no formatted for 'racket' files installed."

jryans commented 1 year ago

I believe this is happening because the extension provides the following document selector to the language server client:

https://github.com/Eugleo/magic-racket/blob/7aead209c0c48e1d99566b8aba7124f799afaed7/src/extension.ts#L41

The language server client then uses that to register support for various features (including formatting). The scheme: "file" portion only matches saved buffers, so that's probably the thing to change here.

The tricky part though is we may have some features that don't work for unsaved buffers (even if formatting can), and changing this global line would mark all language features as supported for unsaved buffers... Some testing is certainly needed before doing that.