Skip to content

Commit 46f4934

Browse files
authored
Updates and ci (#1)
* Upgrades and CI * sgh
1 parent 538804d commit 46f4934

8 files changed

Lines changed: 79 additions & 36 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
strategy:
7+
fail-fast: false
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: actions/setup-java@v3
12+
with:
13+
distribution: 'temurin'
14+
java-version: '17'
15+
16+
- uses: VirtusLab/scala-cli-setup@main
17+
18+
- name: CI
19+
run: make all
20+

.scalafmt.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version = "3.5.8"
2+
runner.dialect = scala3
3+
rewrite.scala3.insertEndMarkerMinLines = 10
4+
rewrite.scala3.removeOptionalBraces = true
5+
rewrite.scala3.convertToNewSyntax = true
6+
align.preset = more
7+
8+
fileOverride {
9+
"glob:**.sbt" {
10+
runner.dialect = scala212source3
11+
}
12+
13+
"glob:**/project/**.*" {
14+
runner.dialect = scala212source3
15+
}
16+
}

lsp.server.scala renamed to LSP.scala

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
//> using lib "tech.neander::langoustine-lsp::0.0.6"
2-
//> using lib "tech.neander::jsonrpclib-fs2::0.0.2"
3-
//> using lib "co.fs2::fs2-io::3.2.11"
4-
51
import langoustine.lsp.*
62

7-
import requests.*
8-
import notifications as nt
9-
import structures.*
10-
import aliases.*
11-
import enumerations.*
12-
import json.*
13-
143
import cats.effect.*
154
import jsonrpclib.fs2.*
165

@@ -27,27 +16,44 @@ import cats.syntax.all.*
2716

2817
object LSP extends IOApp.Simple:
2918
import QuickmaffsLSP.{server, State}
19+
3020
def run =
31-
FS2Channel
32-
.lspCompliant[IO](
33-
byteStream = fs2.io.stdin(256),
34-
byteSink = fs2.io.stdout
35-
)
21+
FS2Channel[IO](2048, None)
3622
.evalTap { channel =>
3723
IO.ref(Map.empty[DocumentUri, State])
3824
.flatMap { state =>
3925
server(state).bind(channel)
4026
}
4127
}
42-
.flatMap(_.openStream)
43-
.evalMap(_ => IO.never)
28+
.flatMap(channel =>
29+
fs2.Stream
30+
.eval(IO.never) // running the server forever
31+
.concurrently(
32+
fs2.io
33+
.stdin[IO](512)
34+
.through(lsp.decodePayloads)
35+
.through(channel.input)
36+
)
37+
.concurrently(
38+
channel.output
39+
.through(lsp.encodePayloads)
40+
.through(fs2.io.stdout[IO])
41+
)
42+
)
4443
.compile
4544
.drain
45+
.guarantee(IO.consoleForIO.errorln("Terminating server"))
4646
end run
4747

4848
end LSP
4949

5050
object QuickmaffsLSP:
51+
import requests.*
52+
import structures.*
53+
import aliases.*
54+
import enumerations.*
55+
import json.*
56+
5157
enum State:
5258
case Empty
5359
case InvalidCode(err: QuickmaffsParser.ParsingError)
@@ -107,7 +113,7 @@ object QuickmaffsLSP:
107113
def recompile(uri: DocumentUri, back: Communicate[IO]) =
108114
def publish(vec: Vector[Diagnostic]) =
109115
back.notification(
110-
nt.textDocument.publishDiagnostics,
116+
textDocument.publishDiagnostics,
111117
PublishDiagnosticsParams(uri, diagnostics = vec)
112118
)
113119

@@ -161,11 +167,11 @@ object QuickmaffsLSP:
161167
case _ => None
162168
}
163169

164-
ImmutableLSPBuilder
170+
LSPBuilder
165171
.create[IO]
166172
.handleRequest(initialize) { (in, back) =>
167173
back.notification(
168-
nt.window.showMessage,
174+
window.showMessage,
169175
ShowMessageParams(
170176
message = "Hello from Quickmaffs",
171177
`type` = enumerations.MessageType.Info
@@ -192,10 +198,10 @@ object QuickmaffsLSP:
192198
)
193199
}
194200
}
195-
.handleNotification(nt.textDocument.didOpen) { (in, back) =>
201+
.handleNotification(textDocument.didOpen) { (in, back) =>
196202
recompile(in.textDocument.uri, back)
197203
}
198-
.handleNotification(nt.textDocument.didSave) { (in, back) =>
204+
.handleNotification(textDocument.didSave) { (in, back) =>
199205
recompile(in.textDocument.uri, back)
200206
}
201207
.handleRequest(textDocument.definition) { (in, back) =>

build.dependencies.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//> using lib "tech.neander::langoustine-lsp::0.0.7"
2+
//> using lib "tech.neander::jsonrpclib-fs2::0.0.3"
3+
//> using lib "co.fs2::fs2-io::3.2.11"
4+
//> using scala "3.1.3"
5+
//> using lib "org.typelevel::cats-parse::0.3.8"

examples/test.qmf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
worsts = (5 + 1)
2+
x = (worsts + 11)
3+
z = 17
4+
t = (x * 1)
5+
h = (x * (11 + worsts))
6+
hs = (x * (z + worsts))
7+
a = 11
8+
r = (x + a)
9+
File renamed without changes.

parser.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
//> using scala "3.1.2"
2-
//> using lib "org.typelevel::cats-parse::0.3.8"
3-
//> using plugin "org.polyvariant:::better-tostring:0.3.15"
4-
51
import cats.parse.Parser as P
62
import cats.parse.Parser0 as P0
73
import cats.parse.Caret

test.qmf

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)