Skip to content

Commit

Permalink
better completions
Browse files Browse the repository at this point in the history
  • Loading branch information
goswinr committed Oct 19, 2024
1 parent 5a323cd commit fc66b3d
Show file tree
Hide file tree
Showing 27 changed files with 984 additions and 720 deletions.
11 changes: 4 additions & 7 deletions FeshHosting.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<!-- <TargetFramework>net472</TargetFramework> -->
<TargetFrameworks>net472;net7.0-windows</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">NETFRAMEWORK</DefineConstants>
<!-- <RuntimeIdentifier>win-x64</RuntimeIdentifier> -->
Expand All @@ -24,14 +23,12 @@
<Product>Fesh</Product>
<PackageId>Fesh</PackageId>

<Version>0.12.0</Version>
<AssemblyVersion>0.12.0</AssemblyVersion>
<FileVersion>0.12.0</FileVersion>
<Version>0.13.0</Version>
<AssemblyVersion>0.13.0</AssemblyVersion>
<FileVersion>0.13.0</FileVersion>

<PackageReleaseNotes>
- add check for updates on startup
- fix version number in Title
- enable cancellation of running code in net48 and net8.0
- catch fsi startup errors
</PackageReleaseNotes>

<Authors>GoswinR</Authors>
Expand Down
44 changes: 22 additions & 22 deletions FeshStandalone.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,35 @@
<!-- Project Sdk= WinDesktop for WPF, it is also needed so that resources work with dotnet build, 'WindowsDesktop' must be included when building for net472 and net6.0-->
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">NETFRAMEWORK</DefineConstants>
<RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
<Configurations>Release</Configurations>

<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms> <!--inherited from Avalonedit ?-->
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
<!-- <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers> -->
<DefineConstants Condition="'$(TargetFramework)' == 'net472'">NETFRAMEWORK</DefineConstants>

<LangVersion>preview</LangVersion> <!-- to enable indexing from end via ^ -->

<!--<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<!-- the resulting 200 MB exe fails to load FSharp.Core correctly -->
<!-- <PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishReadyToRun>true</PublishReadyToRun>
doesn't work ?, long build times ? -->
<DebugType>embedded</DebugType> -->

<NeutralLanguage>en</NeutralLanguage>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <!-- <SatelliteResourceLanguages> to only have the English resources-->
<GenerateDocumentationFile>true</GenerateDocumentationFile> <!-- <GenerateDocumentationFile> just in case the editor itself gets referenced from a script-->
<FSharpCoreIncludeDocFileInOutput>true</FSharpCoreIncludeDocFileInOutput> <!-- <FSharpCoreIncludeDocFileInOutput> does not work when used in visual studio? only dotnet sdk ?-->
<FSharpCoreIncludeDocFileInOutput>true</FSharpCoreIncludeDocFileInOutput> <!-- doesn't seem to work -->

<RootNamespace>Fesh</RootNamespace>
<AssemblyName>Fesh</AssemblyName>
<AssemblyTitle>Fesh</AssemblyTitle>
<Title>Fesh</Title>
<Product>Fesh</Product>

<Version>0.12.0</Version>
<AssemblyVersion>0.12.0</AssemblyVersion>
<FileVersion>0.12.0</FileVersion>
<Version>0.13.0</Version>
<AssemblyVersion>0.13.0</AssemblyVersion>
<FileVersion>0.13.0</FileVersion>

<Company>Goswin Rothenthal</Company> <!-- <Company> shows up on file preview on fesh.exe in windows file explorer-->
<Authors>GoswinR</Authors>
Expand All @@ -42,26 +41,26 @@
<ApplicationIcon>Media/logo.ico</ApplicationIcon>
<Win32Resource>Media/logo.res</Win32Resource> <!-- Win32Resource for Application Icon in explorer-->

<Configurations>Release</Configurations>

<OutputPath>bin/standalone</OutputPath>
<!-- <RestoreAdditionalProjectSources>../AvalonEditB/AvalonEditB/bin/Release/</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectSources>../AvalonLog/bin/Release/</RestoreAdditionalProjectSources> -->

<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags> <!-- 1182: warn on unused variables -->
</PropertyGroup>

<ItemGroup>

<PackageReference Update="FSharp.Core" Version="8.0.400" />
<PackageReference Update="FSharp.Core" Version="8.0.400" GeneratePathProperty="true"/>
<PackageReference Include="FSharp.Compiler.Service" Version="43.8.400" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />

<PackageReference Include="Fittings" Version="0.6.0" />
<PackageReference Include="AvalonLog" Version="0.14.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
<!-- https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets -->

<!--this reference is needed for tooling only, it might not be installed on host PC. (running the netFramework version) see also https://github.com/fsprojects/IfSharp/issues/213 -->
<PackageReference Include="NETStandard.Library" Version="2.0.3" GeneratePathProperty="true" />

<!--this reference is needed for tooling only, it might not be installed on host PC. (running the .NET Framework version) see also https://github.com/fsprojects/IfSharp/issues/213 -->
<PackageReference Include="NETStandard.Library" Version="2.0.3" Condition="'$(TargetFramework)' == 'net472'" GeneratePathProperty="true" /> <!-- Generated PathProperty will be 'PkgNETStandard_Library' -->
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -141,11 +140,12 @@
<Target Name="CopyFilesOverAfterBuild" BeforeTargets="AfterBuild">

<!--netstandard dll is needed for editor tooling only, copy it because it might not be installed on host PC . see also https://github.com/fsprojects/IfSharp/issues/213 -->
<Copy SourceFiles="$(PkgNETStandard_Library)/build/netstandard2.0/ref/netstandard.dll" DestinationFiles="$(TargetDir)netstandard.dll" ContinueOnError="false" />
<Copy SourceFiles="$(PkgNETStandard_Library)/build/netstandard2.0/ref/netstandard.xml" DestinationFiles="$(TargetDir)netstandard.xml" ContinueOnError="false" />
<Copy SourceFiles="$(PkgNETStandard_Library)/build/netstandard2.0/ref/netstandard.dll" DestinationFiles="$(TargetDir)netstandard.dll" ContinueOnError="false" Condition="'$(TargetFramework)' == 'net472'"/>
<Copy SourceFiles="$(PkgNETStandard_Library)/build/netstandard2.0/ref/netstandard.xml" DestinationFiles="$(TargetDir)netstandard.xml" ContinueOnError="false" Condition="'$(TargetFramework)' == 'net472'"/>

<!--FSharp.Core.xml because <FSharpCoreIncludeDocFileInOutput> does not seem to work add it explicitly: -->
<Copy SourceFiles="$(PkgFSharp_Core)/lib/netstandard2.0/FSharp.Core.xml" DestinationFiles="$(TargetDir)FSharp.Core.xml" ContinueOnError="false" />

<!--FSharp.Core.xml because <FSharpCoreIncludeDocFileInOutput>true</FSharpCoreIncludeDocFileInOutput> does not work in visual studio: -->
<!-- <Copy SourceFiles="$(PkgFSharp_Core)/lib/netstandard2.0/FSharp.Core.xml" DestinationFiles="$(TargetDir)FSharp.Core.xml" ContinueOnError="false" /> -->
<!-- <Copy SourceFiles="$(PkgFSharp_Compiler_Service)/lib/netstandard2.0/FSharp.Compiler.Service.xml" DestinationFiles="$(TargetDir)FSharp.Compiler.Service.xml" ContinueOnError="false" /> -->
<!-- <Copy SourceFiles="$(PkgAvalonLog)/lib/net472/AvalonLog.xml" DestinationFiles="$(TargetDir)AvalonLog.xml" ContinueOnError="false" /> -->
<!-- <Copy SourceFiles="$(PkgAvalonEditB)/lib/net472/AvalonEditB.xml" DestinationFiles="$(TargetDir)AvalonEditB.xml" ContinueOnError="false" /> -->
Expand Down
73 changes: 50 additions & 23 deletions Media/READMEnuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,92 @@
![code size](https://img.shields.io/github/languages/code-size/goswinr/Fesh.svg)
[![license](https://img.shields.io/github/license/goswinr/Fesh)](LICENSE)

Fesh is a Scripting Editor for F# on Windows.

![Screenshot](https://raw.githubusercontent.com/goswinr/Fesh/main/Media/screenshot1.png)
Fesh is a ***F***# ***E***ditor *& ***S***criptin*g ***H***ost.\
On Windows.

It is based on the excellent [AvalonEdit](https://github.com/goswinr/AvalonEditB).
The editor supports F# 8.0 and has modern IDE features like semantic syntax highlighting, type-info and autocomplete.
Unlike a typical F# REPL this editor has the input and the output in two separate windows.
Just [like Don Syme always wanted it](https://github.com/dotnet/fsharp/issues/2161#issuecomment-270465310). You can even color the output with [Fescher](https://www.nuget.org/packages/Fesher)!
It is designed for embedding F# as application scripting tool.\
But it works standalone just as well.

By using [FSharp.Compiler.Service](https://www.nuget.org/packages/FSharp.Compiler.Service/43.8.400) in the same process the Editor can easily be hosted in other apps to create an embedded application scripting tool.
This was in fact the primary motivation for creating this editor.
It is public since 2024. But I started prototyping it in 2017. I used it for scripting in Rhino3D professionally since 2019.
Initially I used the Tsunami F# editor, [see my talk on Louvre Abu Dhabi](https://www.youtube.com/watch?v=ZY-bvZZZZnE).
But it is no longer available.
![Screenshot](https://raw.githubusercontent.com/goswinr/Fesh/main/Media/screen2.png)

It is based on the excellent [AvalonEdit](https://github.com/goswinr/AvalonEditB), that is why it only works on Windows (for now).\
The editor supports F# 8.0 and has modern IDE features like semantic syntax highlighting, type-info and autocomplete.\
Unlike a typical F# REPL this editor has the input and the output in two separate windows.\
Just [like Don Syme always wanted it](https://github.com/dotnet/fsharp/issues/2161#issuecomment-270465310).\
You can even color the output with [Fescher](https://www.nuget.org/packages/Fesher).

Contrary to most F# editors, it uses [FSharp.Compiler.Service](https://www.nuget.org/packages/FSharp.Compiler.Service/43.8.400) in the same process as the UI.\
There is no separate language server or FSI process.\
Therefore, Fesh can easily be hosted in other apps to create an embedded application scripting tool.\
This was in fact the primary motivation for creating Fesh.\
It is public since 2024.\
But I started prototyping it in 2017. I used it for scripting in Rhino3D professionally since 2019.\
Initially I used the Tsunami F# editor, like seen in [my talk on the Louvre Abu Dhabi Dome](https://www.youtube.com/watch?v=ZY-bvZZZZnE).\
But it is no longer available. So I created Fesh.

For hosting there is the nuget package [Fesh](https://www.nuget.org/packages/Fesh/). See hosting examples
[Fesh.Rhino](https://github.com/goswinr/Fesh.Rhino) and [Fesh.Revit](https://github.com/goswinr/Fesh.Revit).

## How to install

### Standalone
Just download the from [Releases](https://github.com/goswinr/Fesh/releases).
to any location, **unblock** and run the Fesh.exe.

Or build from source with:
Build from the source with

```bash
dotnet build FeshStandalone.fsproj
```
or download the from [Releases](https://github.com/goswinr/Fesh/releases) to any location, **unblock** and run Fesh.exe.

### For hosting in another app
use the nuget package [Fesh](https://www.nuget.org/packages/Fesh/).\
Or, to build the Fesh nuget package run:

### for Hosting in another App
use the nuget package [Fesh](https://www.nuget.org/packages/Fesh/).
or, to build the Fesh nuget package run:
```bash
dotnet build FeshHosting.fsproj
```

## Features

### Syntax Highlighting
Initial static syntax highlighting is done via AvalonEdit's regex based highlighting.
See [SyntaxHighlightingFSharp.xshd](https://github.com/goswinr/Fesh/blob/main/Src/SyntaxHighlightingFSharp.xshd).
The F# Compiler Service provides additional semantic highlighting.
Initial static syntax highlighting is done via AvalonEdit's regex based highlighting.\
See [SyntaxHighlightingFSharp.xshd](https://github.com/goswinr/Fesh/blob/main/Src/SyntaxHighlightingFSharp.xshd).\
The F# Compiler Service provides additional semantic highlighting.\
If you want different colors go the menu: `About` -> `Open and watch SyntaxHighlighting in VS Code`.\
You wil see any changes upon every save in VS Code.\

### Auto complete
Auto complete works on enter and dot, also in middle of a word.
Auto complete works on enter and dot, also when typing in the middle of a word.

### Type info
The type info includes the inferred signature.
All of the xml docs and information about the containing assembly
The type info includes the inferred signature.\
All of the xml docs and information about the path of the containing assembly.

### Status bar
The statusbar at the bottom shows compiler error count, click on it to scroll to the first error.

### Selection highlighting
Selected text is highlighted in both code and output window. The count is shown in the status bar.

### Drag and drop
Drag any file or folder into the editor to get the full path as a string at the cursor position.\
For *.dlls it will be at the top and prefixed with `#r`.\
For *.fsx it will be at the top and prefixed with `#load`.

### Font
The default font is [Cascadia Mono](https://github.com/microsoft/cascadia-code).\
You can change it in the 'Settings.txt' file at `%APPDATA%\Local\Fesh\Settings.txt`.\
Or via the menu: `About` -> `Open Settings Folder`.


## Release notes

`0.13.0`
- fix crash on assembly load conflict
- faster completion window
- optional tracking of evaluated code via settings

`0.12.0`
- add check for updates on startup
- fix version number in Title
Expand All @@ -82,3 +108,4 @@ Selected text is highlighted in both code and output window. The count is shown
- first public release



Binary file added Media/screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 48 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,91 @@
![code size](https://img.shields.io/github/languages/code-size/goswinr/Fesh.svg)
[![license](https://img.shields.io/github/license/goswinr/Fesh)](LICENSE)

Fesh is a Scripting Editor for F# on Windows.
Designed for embedding F# as application scripting tool.
Fesh is a **<ins>F</ins># <ins>E</ins>ditor & <ins>S</ins>cripting <ins>H</ins>ost**.\
On Windows.

![Screenshot](https://raw.githubusercontent.com/goswinr/Fesh/main/Media/screenshot1.png)
It is designed for embedding F# as application scripting tool.\
But it works standalone just as well.

It is based on the excellent [AvalonEdit](https://github.com/goswinr/AvalonEditB).
The editor supports F# 8.0 and has modern IDE features like semantic syntax highlighting, type-info and autocomplete.
Unlike a typical F# REPL this editor has the input and the output in two separate windows.
Just [like Don Syme always wanted it](https://github.com/dotnet/fsharp/issues/2161#issuecomment-270465310). You can even color the output with [Fescher](https://www.nuget.org/packages/Fesher)!
![Screenshot](https://raw.githubusercontent.com/goswinr/Fesh/main/Media/screen2.png)

Contrary to most F# editors, it uses [FSharp.Compiler.Service](https://www.nuget.org/packages/FSharp.Compiler.Service/43.8.400) in the same process as the UI.
There is no separate language server or FSI process.
Therefore, Fesh can easily be hosted in other apps to create an embedded application scripting tool.
This was in fact the primary motivation for creating Fesh.
It is public since 2024. But I started prototyping it in 2017. I used it for scripting in Rhino3D professionally since 2019.
Initially I used the Tsunami F# editor, [see my talk on Louvre Abu Dhabi](https://www.youtube.com/watch?v=ZY-bvZZZZnE).
But it is no longer available.
It is based on the excellent [AvalonEdit](https://github.com/goswinr/AvalonEditB), that is why it only works on Windows (for now).\
The editor supports F# 8.0 and has modern IDE features like semantic syntax highlighting, type-info and autocomplete.\
Unlike a typical F# REPL this editor has the input and the output in two separate windows.\
Just [like Don Syme always wanted it](https://github.com/dotnet/fsharp/issues/2161#issuecomment-270465310).\
You can even color the output with [Fescher](https://www.nuget.org/packages/Fesher).

Contrary to most F# editors, it uses [FSharp.Compiler.Service](https://www.nuget.org/packages/FSharp.Compiler.Service/43.8.400) in the same process as the UI.\
There is no separate language server or FSI process.\
Therefore, Fesh can easily be hosted in other apps to create an embedded application scripting tool.\
This was in fact the primary motivation for creating Fesh.\
It is public since 2024.\
But I started prototyping it in 2017. I used it for scripting in Rhino3D professionally since 2019.\
Initially I used the Tsunami F# editor, like seen in [my talk on the Louvre Abu Dhabi Dome](https://www.youtube.com/watch?v=ZY-bvZZZZnE).\
But it is no longer available. So I created Fesh.

For hosting there is the nuget package [Fesh](https://www.nuget.org/packages/Fesh/). See hosting examples
[Fesh.Rhino](https://github.com/goswinr/Fesh.Rhino) and [Fesh.Revit](https://github.com/goswinr/Fesh.Revit).

## How to install

### Standalone
Just download the from [Releases](https://github.com/goswinr/Fesh/releases).
to any location, **unblock** and run the Fesh.exe.

Or build from source with:
Build from the source with

```bash
dotnet build FeshStandalone.fsproj
```
or download the from [Releases](https://github.com/goswinr/Fesh/releases) to any location, **unblock** and run Fesh.exe.

### For hosting in another app
use the nuget package [Fesh](https://www.nuget.org/packages/Fesh/).\
Or, to build the Fesh nuget package run:

### for Hosting in another App
use the nuget package [Fesh](https://www.nuget.org/packages/Fesh/).
or, to build the Fesh nuget package run:
```bash
dotnet build FeshHosting.fsproj
```

## Features

### Syntax Highlighting
Initial static syntax highlighting is done via AvalonEdit's regex based highlighting.
See [SyntaxHighlightingFSharp.xshd](https://github.com/goswinr/Fesh/blob/main/Src/SyntaxHighlightingFSharp.xshd).
The F# Compiler Service provides additional semantic highlighting.
Initial static syntax highlighting is done via AvalonEdit's regex based highlighting.\
See [SyntaxHighlightingFSharp.xshd](https://github.com/goswinr/Fesh/blob/main/Src/SyntaxHighlightingFSharp.xshd).\
The F# Compiler Service provides additional semantic highlighting.\
If you want different colors go the menu: `About` -> `Open and watch SyntaxHighlighting in VS Code`.\
You wil see any changes upon every save in VS Code.\

### Auto complete
Auto complete works on enter and dot, also in middle of a word.
Auto complete works on enter and dot, also when typing in the middle of a word.

### Type info
The type info includes the inferred signature.
All of the xml docs and information about the containing assembly
The type info includes the inferred signature.\
All of the xml docs and information about the path of the containing assembly.

### Status bar
The statusbar at the bottom shows compiler error count, click on it to scroll to the first error.

### Selection highlighting
Selected text is highlighted in both code and output window. The count is shown in the status bar.

### Drag and drop
Drag any file or folder into the editor to get the full path as a string at the cursor position.\
For *.dlls it will be at the top and prefixed with `#r`.\
For *.fsx it will be at the top and prefixed with `#load`.

### Font
The default font is [Cascadia Mono](https://github.com/microsoft/cascadia-code).\
You can change it in the 'Settings.txt' file at `%APPDATA%\Local\Fesh\Settings.txt`.\
Or via the menu: `About` -> `Open Settings Folder`.


## Release notes

`0.13.0`
- fix crash on assembly load conflict
- faster completion window
- optional tracking of evaluated code via settings

`0.12.0`
- add check for updates on startup
- fix version number in Title
Expand Down
4 changes: 4 additions & 0 deletions Src/Config/DefaultCode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ type DefaultCode (runContext:RunContext) =
match runContext.DefaultCode with
| Some dc -> dc
| None ->
"#r \"nuget: Fesher, 0.2.0\" // for printf with color"
""
"open System"
"open Fesher"
""
"Printfn.red \"Hello, Fesh!\""
""
""
]
Expand Down
Loading

0 comments on commit fc66b3d

Please sign in to comment.