Skip to content

Commit

Permalink
Switch from std/asyncdispatch to chronos (#28)
Browse files Browse the repository at this point in the history
* Added chronos patch to enable 0 timeout poll
* Updated wasm3 dependency
* Add patch for npeg codegen to fix missing gcsafe
* Add timeout to poll
* Clamp negative line/columns when converting to points
  • Loading branch information
Nimaoth authored Oct 6, 2024
1 parent bd260e6 commit 56b5789
Show file tree
Hide file tree
Showing 96 changed files with 10,942 additions and 8,611 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and test the editor
on:
# Runs on pushes targeting the default branch
push:
branches: ["main", "rope-crdt"]
branches: ["main", "chronos"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -76,11 +76,11 @@ jobs:
run: PATH=/github/home/.nimble/bin:$PATH nimble setup

# linux builds
- run: PATH=/github/home/.nimble/bin:$PATH nimble buildRemoteWorkspaceHost
- run: PATH=/github/home/.nimble/bin:$PATH nimble buildLspWs
- run: nim c --out:ast -D:enableGui=false -D:enableTerminal=true --app:console -D:forceLogToFile --passC:-std=gnu11 -d:exposeScriptingApi -D:isCI -D:isCINimbleCached=${{steps.cache-nimble.outputs.cache-hit}} src/desktop_main.nim
- run: nim c --out:astg -D:enableGui=true -D:enableTerminal=false --app:gui -D:forceLogToFile --passC:-std=gnu11 -d:exposeScriptingApi -D:isCI -D:isCINimbleCached=${{steps.cache-nimble.outputs.cache-hit}} src/desktop_main.nim
- run: nim c --out:ast-musl -D:enableGui=false -D:enableTerminal=true --app:console -d:musl -d:nimWasmtimeBuildMusl -D:forceLogToFile --passC:-std=gnu11 -d:exposeScriptingApi -D:isCI -D:isCINimbleCached=${{steps.cache-nimble.outputs.cache-hit}} src/desktop_main.nim
#- run: PATH=/github/home/.nimble/bin:$PATH nimble buildRemoteWorkspaceHost
#- run: PATH=/github/home/.nimble/bin:$PATH nimble buildLspWs

# create release packages
- run: PATH=/github/home/.nimble/bin:$PATH nim ./tools/package_release.nims -l
Expand Down Expand Up @@ -141,8 +141,8 @@ jobs:
# windows builds
- run: nim c --out:ast.exe -D:enableGui=false -D:enableTerminal=true --app:console -D:forceLogToFile --passC:-std=gnu11 -d:exposeScriptingApi -D:isCI -D:isCINimbleCached=${{steps.cache-nimble.outputs.cache-hit}} src/desktop_main.nim
- run: nim c --out:astg.exe -D:enableGui=true -D:enableTerminal=false --app:gui -D:forceLogToFile --passC:-std=gnu11 -d:exposeScriptingApi -D:isCI -D:isCINimbleCached=${{steps.cache-nimble.outputs.cache-hit}} src/desktop_main.nim
- run: nimble buildRemoteWorkspaceHostWindows
- run: nimble buildLspWsWindows
#- run: nimble buildRemoteWorkspaceHostWindows
#- run: nimble buildLspWsWindows

# create release packages
- run: nim ./tools/package_release.nims -w
Expand Down
17 changes: 15 additions & 2 deletions config.nims
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This is required for LSP to work with this file and not show tons of errros
when defined(nimsuggest):
import system/nimscript

switch("path", "$nim")
switch("path", "scripting")
switch("path", "src")
Expand Down Expand Up @@ -33,10 +37,12 @@ switch("linetrace", "off")
# required for actual builds, but for lsp this should be off to improve performance because it doesn't need to generate as many functions
# switch("d", "exposeScriptingApi")

switch("d", "npegGcsafe=true")

switch("d", "enableGui=true")
switch("d", "enableTerminal=true")
switch("d", "enableNimscript=true")
# switch("d", "enableAst=true")
switch("d", "enableNimscript=false")
switch("d", "enableAst=false")


# uncomment to see logs in the console
Expand Down Expand Up @@ -81,6 +87,9 @@ when defined(windows):
else:
switch("d", "nimWasmtimeStatic=true")

# results prints a ton of hints, silence them
switch("d", "resultsGenericsOpenSymWorkaroundHint=false")

when defined(musl):
var muslGcc = findExe("musl-gcc")
# muslGcc = "/home/nimaoth/musl/musl/bin/musl-gcc"
Expand All @@ -98,6 +107,10 @@ else:
when defined(enableSysFatalStackTrace):
patchFile("stdlib", "fatal", "patches/fatal")
patchFile("stdlib", "excpt", "patches/excpt")
patchFile("stdlib", "jsonutils", "src/misc/myjsonutils")
patchFile("stdlib", "tables", "patches/tables") # Patch tables.nim to remove exceptions
patchFile("chronos", "asyncengine", "patches/asyncengine") # Patch this to enable 0 timeout poll
patchFile("npeg", "codegen", "patches/codegen") # Patch this for proper gcsafety

# switches for debugging
# switch("d", "wasm3EnableStrace2")
Expand Down
4 changes: 2 additions & 2 deletions config/keybindings_normal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import misc/[event, id, timer]

{.used.}

proc setModeChangedHandler*(handler: proc(editor: TextDocumentEditor, oldMode: string, newMode: string)) =
proc setModeChangedHandler*(handler: proc(editor: TextDocumentEditor, oldMode: string, newMode: string) {.gcsafe, raises: [].}) =
let modeChangedHandler = getOption("editor.text.mode-changed-handler", "")
if modeChangedHandler != "":
onEditorModeChanged.unsubscribe(parseId(modeChangedHandler))
let id = onEditorModeChanged.subscribe proc(arg: auto) =
let id = onEditorModeChanged.subscribe proc(arg: auto) {.gcsafe, raises: [].} =
# infof"onEditorModeChanged: {arg.editor}, {arg.oldMode}, {arg.newMode}"
if arg.editor.isTextEditor(editor) and not editor.isRunningSavedCommands:
handler(editor, arg.oldMode, arg.newMode)
Expand Down
2 changes: 1 addition & 1 deletion config/keybindings_vim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ proc loadVimKeybindings*() {.expose("load-vim-keybindings").} =
setOption "editor.text.cursor.wide.visual-line", true
setOption "editor.text.cursor.movement.visual-line", "last"

setModeChangedHandler proc(editor, oldMode, newMode: auto) =
setModeChangedHandler proc(editor, oldMode, newMode: auto) {.gcsafe, raises: [].} =
if newMode == "":
editor.setMode "normal"
return
Expand Down
Binary file modified config/wasm/harpoon.wasm
Binary file not shown.
Binary file modified config/wasm/keybindings_plugin.wasm
Binary file not shown.
Binary file modified config/wasm/vscode_config_plugin.wasm
Binary file not shown.
9 changes: 5 additions & 4 deletions nev.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ requires "patty >= 0.3.5"
requires "nimclipboard >= 0.1.2"
requires "npeg >= 0.12.0"
requires "asynctools#a1a17d0"
# requires "results >= 0.4.0" # todo: use that at some point?
# requires "chronos >= 4.0.2" # todo: switch to this at some point
requires "stew >= 0.1.0"
requires "results >= 0.5.0"
requires "chronos >= 4.0.3"
requires "https://github.com/Nimaoth/ws >= 0.5.0"
requires "https://github.com/Nimaoth/windy >= 0.0.2"
requires "https://github.com/Nimaoth/wasm3 >= 0.1.13"
requires "https://github.com/Nimaoth/wasm3 >= 0.1.14"
requires "https://github.com/Nimaoth/lrucache.nim >= 1.1.4"
requires "https://github.com/Nimaoth/boxy >= 0.4.2"
requires "https://github.com/Nimaoth/nimscripter >= 1.0.21"
requires "https://github.com/Nimaoth/nimtreesitter-api >= 0.1.15"
requires "https://github.com/Nimaoth/nimwasmtime >= 0.1.7"
requires "https://github.com/Nimaoth/nimsumtree >= 0.3.3"
requires "https://github.com/Nimaoth/nimsumtree >= 0.3.5"

# Use this to include all treesitter languages (takes longer to download)
requires "https://github.com/Nimaoth/nimtreesitter >= 0.1.6"
Expand Down
87 changes: 81 additions & 6 deletions nimble.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@
"sha1": "3f7096335282f45ebab49b939b20a1ed52cdec31"
}
},
"unittest2": {
"version": "0.2.2",
"vcsRevision": "e96f3215030cbfa13abc2f5827069b6f8ba87e38",
"url": "https://github.com/status-im/nim-unittest2",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "6ac7f7ea74df812a25be5d6d36a59d23789eb508"
}
},
"bearssl": {
"version": "0.2.5",
"vcsRevision": "667b40440a53a58e9f922e29e20818720c62d9ac",
"url": "https://github.com/status-im/nim-bearssl",
"downloadMethod": "git",
"dependencies": [
"unittest2"
],
"checksums": {
"sha1": "550e6f9321b85de53bba9c0ffab9c95ffbe12ab3"
}
},
"bitty": {
"version": "0.1.4",
"vcsRevision": "cde1af08ab96536239cc737cbd9217ee284e4e03",
Expand Down Expand Up @@ -161,6 +183,59 @@
"sha1": "1954eb89cc353cf2a4e54804d38d5a1e72f3c98e"
}
},
"results": {
"version": "0.5.0",
"vcsRevision": "57b2392ad69849e3e2d02b74a8a0feee2c3d9570",
"url": "https://github.com/arnetheduck/nim-results",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "901e2ed088160fdcb8fdf3b315ce62baedc3f7ba"
}
},
"stew": {
"version": "0.1.0",
"vcsRevision": "41f48efee97ac688fc48d40280c8d45d340cc46d",
"url": "https://github.com/status-im/nim-stew",
"downloadMethod": "git",
"dependencies": [
"results",
"unittest2"
],
"checksums": {
"sha1": "d5679ef5f2116cb211b007d9df78668d5fc79ea8"
}
},
"httputils": {
"version": "0.3.0",
"vcsRevision": "e8fc71aee15203a852f6321e4dd8d87517502847",
"url": "https://github.com/status-im/nim-http-utils",
"downloadMethod": "git",
"dependencies": [
"stew",
"results",
"unittest2"
],
"checksums": {
"sha1": "9f48d0dfe6d3c0c7183c3a7261162ce9cb1d69d1"
}
},
"chronos": {
"version": "4.0.3",
"vcsRevision": "c04576d829b8a0a1b12baaa8bc92037501b3a4a0",
"url": "https://github.com/status-im/nim-chronos",
"downloadMethod": "git",
"dependencies": [
"results",
"stew",
"bearssl",
"httputils",
"unittest2"
],
"checksums": {
"sha1": "ba179f34b0513ebd1615076f07b61e2e217bd228"
}
},
"fusion": {
"version": "1.2",
"vcsRevision": "0b0a0273b8df860cd54e3fcca7bb4c617244ac77",
Expand Down Expand Up @@ -272,13 +347,13 @@
}
},
"nimsumtree": {
"version": "0.3.3",
"vcsRevision": "c8bfe3f925f7b838e21ab89afe8c79d4dc81b40c",
"version": "0.3.5",
"vcsRevision": "da06e6314415f8fef69f45114ab4e508270b73fe",
"url": "https://github.com/Nimaoth/nimsumtree",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "b1759d77e6635209fced7887006a57998c2dcb29"
"sha1": "d61463035dc623240070a01d70a9e050d6f333a7"
}
},
"nimtreesitter": {
Expand Down Expand Up @@ -357,15 +432,15 @@
}
},
"wasm3": {
"version": "0.1.13",
"vcsRevision": "621461f9c660fafe837f52762731571d68ae61c8",
"version": "0.1.14",
"vcsRevision": "6dfb94c735eecd0219f9aeecba9ad4c9349b942a",
"url": "https://github.com/Nimaoth/wasm3",
"downloadMethod": "git",
"dependencies": [
"micros"
],
"checksums": {
"sha1": "67b06dbf41e45be74755c1ea47216c4251aee40c"
"sha1": "f602a174feb50a4a5f57e0ad4ffc5ef7f9ecf149"
}
},
"ws": {
Expand Down
Loading

0 comments on commit 56b5789

Please sign in to comment.