kenkangxgwe / lsp-wl

A Wolfram Language Server
MIT License
215 stars 22 forks source link

support for unicode #24

Open asukaminato0721 opened 4 years ago

asukaminato0721 commented 4 years ago

image

as the image shows, it will warning. But it did can run in .wls.

\[Alpha]=1
Print[\[Alpha]]

besides, I have tested that this can't run.

α=1;Print[α]

in .nb , α will be translated into \[Alpha] ,then do the following calculation.(But shown as α).

So here are some advice.

  1. in vs code, show \[Alpha] as α,but run it as itself.(But it's confusing that how to deal with the widith of this character)
  2. if users copy it to clipboard, automatically change it into α.But if use //CopyToClipboard//UsingFrontEnd,it's also hard to deal with.(Or maybe just ignore it?)
  3. if someone paste α into vscode, change it into \[Alpha] (but shown as α)

Maybe there can be a switch to open/close the "translate"? If some users really want to see \[Alpha].

kenkangxgwe commented 4 years ago

The warning here is not charming to me either. It comes from the Lint paclet. Maybe I can contact Brenton to see if he'd like to change the rule here.


besides, I have tested that this can't run.

image

Did you mean that it CAN run?


Thank you for the advice. Here are my two cents,

  1. Showing special character is a feature which better to be supported by the editor. Our language server should not assume that an editor supports Unicode display. There is a Pretty Symbols Mode extension for VSCode.

  2. Copying as Unicode Character is somehow tricky for LSP because the copy feature is not natively supported, thus the language server knows neither when you copy nor what you copy. What's more, copying into \[Alpha] is the default behavior of MMA (no matter what form you copy as). I do not mean it is good, but I would like to keep it as is for the time being.

  3. I may add a WillSaveTextDocumentParams handler to convert those Unicode characters that users input every time before the file is saved.

Thanks again for your feedback.

asukaminato0721 commented 4 years ago

what I mean is this: image

kenkangxgwe commented 4 years ago

That should be the problem of wolframscript. I can run it with

wolfram -script temp.wl
asukaminato0721 commented 4 years ago

Now I know what's the problem. XD If I change utf-8 to gbk (Just ignore the warning, because I find the solution here, but I have done it before , and don't want to repeat it.) image

Main reason is that, MS's cmd is gbk. Cpp will meet the same thing , too.

So there are some solutions:

  1. Convert encoding from utf-8 to gbk. But it will affect the existing Chinese.
  2. Change the system code to UTF-8. But some old softwares will meet trouble.
  3. Using English.

It is worth mentioning that, Python can handle this easily .

Gravifer commented 3 years ago

Main reason is that, MS's cmd is gbk. Cpp will meet the same thing , too.

@wuyudi I was wondering about this, and raised a question at SE-MMA. CMD in Win10 has default utf-8 encoding at least from 1903. I really wonder why Wolfram systems pickup the GBK codepage.

Gravifer commented 3 years ago

I think for the original feature request by @wuyudi, it may be convenient to construct a font with ligatures. I am just speaking off the top of my head, but we may just PR Wolfram-lang related features to Fira Code, e.g. [[⟶⟦ and so on. Of course, for arrows and so on this may be sufficient, while for Greek letters the widths are still an issue.

kenkangxgwe commented 3 years ago

I think for the original feature request by @wuyudi, it may be convenient to construct a font with ligatures.

See https://github.com/be5invis/Iosevka and the related issue https://github.com/be5invis/Iosevka/issues/680

I am just speaking off the top of my head, but we may just PR Wolfram-lang related features to Fira Code, e.g. [[⟶⟦ and so on.

]] is not possible to be ligatured. E.g. f[g[x]].