helix icon indicating copy to clipboard operation
helix copied to clipboard

F# for Helix?

Open MarkuBu opened this issue 3 years ago • 4 comments

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 avatar Nov 30 '22 10:11 MarkuBu

@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

notmgsk avatar Nov 30 '22 13:11 notmgsk

I'm a F# beginner, so probably not

MarkuBu avatar Nov 30 '22 15:11 MarkuBu

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.

christianfosli avatar Dec 01 '22 05:12 christianfosli

That's not a good news :(

MarkuBu avatar Dec 03 '22 14:12 MarkuBu

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 :)

EluciusFTW avatar Jan 20 '23 06:01 EluciusFTW

Status update here for future contributors:

  • Linked PR (#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.

askreet avatar Feb 22 '23 12:02 askreet

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).

d4h0 avatar Feb 22 '23 12:02 d4h0

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 }

Eliemer avatar Feb 23 '23 17:02 Eliemer

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

d4h0 avatar Feb 23 '23 17:02 d4h0

Also interested in this.

varon avatar Mar 02 '23 16:03 varon

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

Eliemer avatar Mar 02 '23 18:03 Eliemer

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).

d4h0 avatar Mar 02 '23 18:03 d4h0

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"

Eliemer avatar Mar 03 '23 16:03 Eliemer

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.

varon avatar Jun 30 '23 21:06 varon

🍾

varon avatar Jul 17 '23 07:07 varon