Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F# for Helix? #4943

Closed
MarkuBu opened this issue Nov 30, 2022 · 15 comments · Fixed by #7619
Closed

F# for Helix? #4943

MarkuBu opened this issue Nov 30, 2022 · 15 comments · Fixed by #7619
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@MarkuBu
Copy link

MarkuBu commented Nov 30, 2022

I wonder why there is no support for F# in Helix until now. Is there any plan to add F# to Helix in the near future?

@MarkuBu MarkuBu added the C-enhancement Category: Improvements label Nov 30, 2022
@notmgsk
Copy link

notmgsk commented Nov 30, 2022

@MarkuBu There will be F# support when someone decides they want to add it. Maybe that person is you? https://docs.helix-editor.com/guides/adding_languages.html

@MarkuBu
Copy link
Author

MarkuBu commented Nov 30, 2022

I'm a F# beginner, so probably not

@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Nov 30, 2022
@archseer archseer added the E-good-first-issue Call for participation: Issues suitable for new contributors label Nov 30, 2022
@christianfosli
Copy link

It seems there is no finished F# tree-sitter grammar (https://github.com/baronfel/tree-sitter-fsharp is very WIP), so I guess it's hard to get syntax highlights.

@MarkuBu
Copy link
Author

MarkuBu commented Dec 3, 2022

That's not a good news :(

@EluciusFTW
Copy link

This is sad, I just found Helix, and love it out of the box, but fsharp syntax highlighting is mandatory for me. Hope it will be added soon :)

@askreet
Copy link
Contributor

askreet commented Feb 22, 2023

Status update here for future contributors:

  • Linked PR (Add basic support for F# syntax highlighting. #6002) shows an example of getting started with this, with some good feedback on how to improve the highlight queries.
  • Tree-Sitter implementation for F# is still buggy, so we'll keep an eye on it's progress to see when a complete implementation is possible.
  • An LSP is also available and should be added at the same time.

@d4h0
Copy link

d4h0 commented Feb 22, 2023

After the F# tree-sitter implementation adds tree-sitter queries (which some plan to implement when the grammar stabilized), we should have everything to add F# support to Helix.

However, the language server currently seems to be broken. I've tried to use the LSP server with neovim, and it displays error messages on almost every cursor move.

Until that is fixed (or Helix enables a workaround), the F# language server is basically unusable.

For now, I switched to VSCode for F#. This seems to be by far the best solution at the moment (and isn't too bad in combination with the neovim extension for VSCode).

@Eliemer
Copy link

Eliemer commented Feb 23, 2023

This is pretty unofficial, but this is my working LSP config for using FSAC. Provides errors messages and jump to definition and other LSP stuff. The FSAC team is working, albeit slowly, on generalizing a lot of the endpoints that are Ionide (VSCode extension) specific.

dotnet tool -g fsautocomplete
[[language]]
name = "fsharp"
scope="source.fs"
roots = ["fsproj", "sln", ".git"]
injection-regex = "^fsharp$"
file-types = ["fs", "fsx", "fsi"]
comment-token = "//"
indent = { tab-width = 4, unit = " " }
auto-format = true
language-server = { command = "fsautocomplete", args = ["--verbose"] }
config = { AutomaticWorkspaceInit = true, FSharp.ExternalAutocomplete = true }

@d4h0
Copy link

d4h0 commented Feb 23, 2023

@Eliemer: And this doesn't result in error messages after most cursor moves, as I've mentioned above?

@varon
Copy link
Contributor

varon commented Mar 2, 2023

Also interested in this.

@Eliemer
Copy link

Eliemer commented Mar 2, 2023

Info:

helix 22.08
Windows 11
.NET 7.0.103
fsautocomplete 0.59.1 [[VERBOSE flag]]

I traversed through all the file, back and forth, up and down, then swapped (a + b) to (c + b) and received an error notification. Then reverted the change. This is how the log looks.

fib.fsx

let fibs =
    let rec f a b =
        seq {
            yield a
            yield! f b (a + b)
        }

    f 1 1 |> Seq.cache

Seq.take 12 fibs |> Seq.skip 8

image

log.txt

2023-03-02T13:10:20.596 helix_lsp::transport [ERROR] err <- "[13:10:20.596 INF] [LSP] TextDocumentSignatureHelp Request: {\"TextDocument\": {\"Uri\": \"file:///C:/Users/13617/Downloads/fib.fsx\", \"$type\": \"TextDocumentIdentifier\"}, \"Position\": {\"Line\": 3, \"Character\": 19, \"$type\": \"Position\"}, \"Context\": null, \"$type\": \"SignatureHelpParams\"}\r\n"
2023-03-02T13:10:20.597 helix_lsp::transport [ERROR] err <- "[13:10:20.597 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1547915854\r\n"
2023-03-02T13:10:20.597 helix_lsp::transport [ERROR] err <- "[13:10:20.597 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - got results - -1547915854\r\n"
2023-03-02T13:10:20.597 helix_lsp::transport [ERROR] err <- "[13:10:20.597 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1547915854 - cacheHit True\r\n"
2023-03-02T13:10:21.178 helix_lsp::transport [ERROR] err <- "[13:10:21.177 INF] [LSP] TextDocumentSignatureHelp Request: {\"TextDocument\": {\"Uri\": \"file:///C:/Users/13617/Downloads/fib.fsx\", \"$type\": \"TextDocumentIdentifier\"}, \"Position\": {\"Line\": 3, \"Character\": 18, \"$type\": \"Position\"}, \"Context\": null, \"$type\": \"SignatureHelpParams\"}\r\n"
2023-03-02T13:10:21.178 helix_lsp::transport [ERROR] err <- "[13:10:21.178 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1547915854\r\n"
2023-03-02T13:10:21.178 helix_lsp::transport [ERROR] err <- "[13:10:21.178 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - got results - -1547915854\r\n"
2023-03-02T13:10:21.178 helix_lsp::transport [ERROR] err <- "[13:10:21.178 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1547915854 - cacheHit True\r\n"
2023-03-02T13:10:21.178 helix_lsp::transport [ERROR] err <- "[13:10:21.178 INF] [LSP] TextDocumentDidChange Request: c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:21.442 helix_lsp::transport [ERROR] err <- "[13:10:21.442 INF] [LSP] ParseFile - Parsing c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:21.443 helix_lsp::transport [ERROR] err <- "[13:10:21.443 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-02T13:10:21.518 helix_lsp::transport [ERROR] err <- "[13:10:21.517 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-02T13:10:21.519 helix_lsp::transport [ERROR] err <- "[13:10:21.518 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx started\r\n"
2023-03-02T13:10:21.519 helix_lsp::transport [ERROR] err <- "[13:10:21.519 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx - []\r\n"
2023-03-02T13:10:21.519 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:21.520 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:21.520 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:21.522 helix_lsp::transport [ERROR] err <- "[13:10:21.522 INF] [LSP] SendDiag for file:///c%3A/Users/13617/Downloads/fib.fsx: 1 entries\r\n"
2023-03-02T13:10:21.612 helix_lsp::transport [ERROR] err <- "[13:10:21.612 INF] [LSP] TextDocumentDidChange Request: c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:21.875 helix_lsp::transport [ERROR] err <- "[13:10:21.874 INF] [LSP] ParseFile - Parsing c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:21.875 helix_lsp::transport [ERROR] err <- "[13:10:21.875 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-02T13:10:21.885 helix_lsp::transport [ERROR] err <- "[13:10:21.884 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-02T13:10:21.886 helix_lsp::transport [ERROR] err <- "[13:10:21.885 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx started\r\n"
2023-03-02T13:10:21.886 helix_lsp::transport [ERROR] err <- "[13:10:21.885 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx - []\r\n"
2023-03-02T13:10:21.886 helix_lsp::transport [ERROR] err <- "[13:10:21.886 INF] [LSP] SendDiag for file:///c%3A/Users/13617/Downloads/fib.fsx: 1 entries\r\n"
2023-03-02T13:10:21.887 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:21.888 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:21.888 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:25.841 helix_lsp::transport [ERROR] err <- "[13:10:25.841 INF] [LSP] TextDocumentDidChange Request: c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:25.841 helix_lsp::transport [ERROR] err <- "[13:10:25.841 INF] [LSP] TextDocumentSignatureHelp Request: {\"TextDocument\": {\"Uri\": \"file:///C:/Users/13617/Downloads/fib.fsx\", \"$type\": \"TextDocumentIdentifier\"}, \"Position\": {\"Line\": 3, \"Character\": 18, \"$type\": \"Position\"}, \"Context\": null, \"$type\": \"SignatureHelpParams\"}\r\n"
2023-03-02T13:10:25.841 helix_lsp::transport [ERROR] err <- "[13:10:25.841 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1884873199\r\n"
2023-03-02T13:10:25.842 helix_lsp::transport [ERROR] err <- "[13:10:25.841 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -1884873199 - cacheHit False\r\n"
2023-03-02T13:10:25.842 helix_lsp::transport [ERROR] err <- "[13:10:25.842 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-02T13:10:25.846 helix_lsp::transport [ERROR] err <- "[13:10:25.845 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-02T13:10:25.966 helix_lsp::transport [ERROR] err <- "[13:10:25.966 INF] [LSP] TextDocumentDidChange Request: c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:26.204 helix_lsp::transport [ERROR] err <- "[13:10:26.203 INF] [LSP] ParseFile - Parsing c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-02T13:10:26.204 helix_lsp::transport [ERROR] err <- "[13:10:26.204 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-02T13:10:26.207 helix_lsp::transport [ERROR] err <- "[13:10:26.207 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-02T13:10:26.207 helix_lsp::transport [ERROR] err <- "[13:10:26.207 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx started\r\n"
2023-03-02T13:10:26.207 helix_lsp::transport [ERROR] err <- "[13:10:26.207 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx - []\r\n"
2023-03-02T13:10:26.208 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:26.208 helix_lsp::transport [ERROR] err <- "[13:10:26.208 INF] [LSP] SendDiag for file:///c%3A/Users/13617/Downloads/fib.fsx: 0 entries\r\n"
2023-03-02T13:10:26.209 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-03-02T13:10:26.209 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled

@d4h0
Copy link

d4h0 commented Mar 2, 2023

Thanks, @Eliemer. This sounds like there are no error messages displayed in the UI of Helix (which is what happened in Neovim). Maybe the messages that are logged as received malformed notification from Language Server: Unhandled represent those errors, however this doesn't seem to happen often enough (in Neovim an error message was displayed after almost every cursor move).

@Eliemer
Copy link

Eliemer commented Mar 3, 2023

Theres still some dumb errors though. This happens when I introduce a newline at the start of the file. Results in an Async job failed: protocol error message.

2023-03-03T11:14:36.415 helix_lsp::transport [ERROR] <- InternalError: Index was outside the bounds of the array.
2023-03-03T11:14:36.605 helix_lsp::transport [ERROR] err <- "[11:14:36.605 INF] [LSP] TextDocumentDidChange Request: c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-03T11:14:36.608 helix_lsp::transport [ERROR] err <- "[11:14:36.607 INF] [LSP] TextDocumentSignatureHelp Request: {\"TextDocument\": {\"Uri\": \"file:///C:/Users/13617/Downloads/fib.fsx\", \"$type\": \"TextDocumentIdentifier\"}, \"Position\": {\"Line\": 0, \"Character\": 0, \"$type\": \"Position\"}, \"Context\": null, \"$type\": \"SignatureHelpParams\"}\r\n"
2023-03-03T11:14:36.608 helix_lsp::transport [ERROR] err <- "[11:14:36.608 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -315704538\r\n"
2023-03-03T11:14:36.608 helix_lsp::transport [ERROR] err <- "[11:14:36.608 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -315704538 - cacheHit False\r\n"
2023-03-03T11:14:36.608 helix_lsp::transport [ERROR] err <- "[11:14:36.608 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-03T11:14:36.613 helix_lsp::transport [ERROR] err <- "[11:14:36.613 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-03T11:14:36.614 helix_lsp::transport [ERROR] <- InternalError: Couldn't find previous non-whitespace char
2023-03-03T11:14:36.795 helix_lsp::transport [ERROR] err <- "[11:14:36.795 INF] [LSP] TextDocumentSignatureHelp Request: {\"TextDocument\": {\"Uri\": \"file:///C:/Users/13617/Downloads/fib.fsx\", \"$type\": \"TextDocumentIdentifier\"}, \"Position\": {\"Line\": 0, \"Character\": 0, \"$type\": \"Position\"}, \"Context\": null, \"$type\": \"SignatureHelpParams\"}\r\n"
2023-03-03T11:14:36.795 helix_lsp::transport [ERROR] err <- "[11:14:36.795 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -315704538\r\n"
2023-03-03T11:14:36.795 helix_lsp::transport [ERROR] err <- "[11:14:36.795 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - got results - -315704538\r\n"
2023-03-03T11:14:36.795 helix_lsp::transport [ERROR] err <- "[11:14:36.795 INF] [Checker] TryGetRecentCheckResultsForFile - \"c:\\Users\\13617\\Downloads\\fib.fsx\" - -315704538 - cacheHit True\r\n"
2023-03-03T11:14:36.796 helix_lsp::transport [ERROR] <- InternalError: Couldn't find previous non-whitespace char
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [LSP] ParseFile - Parsing c:\\Users\\13617\\Downloads\\fib.fsx\r\n"
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\"\r\n"
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [Checker] ParseAndCheckFileInProject - \"c:\\Users\\13617\\Downloads\\fib.fsx\" completed successfully\r\n"
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx started\r\n"
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [Commands] Test Detection of c:\\Users\\13617\\Downloads\\fib.fsx - []\r\n"
2023-03-03T11:14:36.864 helix_lsp::transport [ERROR] err <- "[11:14:36.864 INF] [LSP] SendDiag for file:///c%3A/Users/13617/Downloads/fib.fsx: 0 entries\r\n"

@varon
Copy link
Contributor

varon commented Jun 30, 2023

Bump on this.

Was able to try out the config of Eliemer. using FsAutoComplete v0.6.0 This worked as an LSP with some silly errors and bad log messages, but was largely usable in some quick testing.

We're still going to need highlighting as a requirement, so https://github.com/Nsidorenco/tree-sitter-fsharp might be worth a look again if someone wants to give that a try in the current version and report back.

@the-mikedavis the-mikedavis linked a pull request Jul 13, 2023 that will close this issue
@varon
Copy link
Contributor

varon commented Jul 17, 2023

🍾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
10 participants