Skip to content

Commit

Permalink
Replace file content representation with rope crdt (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth authored Sep 24, 2024
1 parent 9058941 commit bd260e6
Show file tree
Hide file tree
Showing 50 changed files with 1,919 additions and 1,480 deletions.
1 change: 1 addition & 0 deletions config/default_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ proc loadDefaultKeybindings*(clearExisting: bool = false) {.expose("load-default
addCommand "editor", "<LEADER>gp", "explore-current-file-directory"
addCommand "editor", "<LEADER>gs", "search-global-interactive"
addCommand "editor", "<LEADER>gk", "browse-keybinds"
addCommand "editor", "<LEADER>gn", "open-last-editor"
addCommandBlock "editor", "<LEADER>log":
logs(scrollToBottom = true)
nextView()
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.
1 change: 1 addition & 0 deletions nev.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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"

# Use this to include all treesitter languages (takes longer to download)
requires "https://github.com/Nimaoth/nimtreesitter >= 0.1.6"
Expand Down
10 changes: 10 additions & 0 deletions nimble.lock
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@
"sha1": "dfe09fbcf8040027630301c43b4dbe9d9f0fab4d"
}
},
"nimsumtree": {
"version": "0.3.3",
"vcsRevision": "c8bfe3f925f7b838e21ab89afe8c79d4dc81b40c",
"url": "https://github.com/Nimaoth/nimsumtree",
"downloadMethod": "git",
"dependencies": [],
"checksums": {
"sha1": "b1759d77e6635209fced7887006a57998c2dcb29"
}
},
"nimtreesitter": {
"version": "0.1.6",
"vcsRevision": "8e0af3c1efecfd624a169790d29a8b5e0b11edd6",
Expand Down
4 changes: 4 additions & 0 deletions patches/fatal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ else:
when defined(enableSysFatalStackTrace) and not defined(wasm):
writeStackTrace2()
##### patch end
when defined(sysFatalInt3):
asm "int3"
raise (ref exceptn)(msg: message)

func sysFatal(exceptn: typedesc[Defect], message, arg: string) {.inline, noreturn.} =
##### patch begin - I want that stacktrace
when defined(enableSysFatalStackTrace) and not defined(wasm):
writeStackTrace2()
##### patch end
when defined(sysFatalInt3):
asm "int3"
raise (ref exceptn)(msg: message & arg)

{.pop.}
31 changes: 31 additions & 0 deletions scripting/collab_api_wasm.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import std/[json, options]
import scripting_api, misc/myjsonutils

## This file is auto generated, don't modify.


proc collab_connectCollaborator_void_int_wasm(arg: cstring): cstring {.importc.}
proc connectCollaborator*(port: int = 6969) =
var argsJson = newJArray()
argsJson.add block:
when int is JsonNode:
port
else:
port.toJson()
let argsJsonString = $argsJson
let res {.used.} = collab_connectCollaborator_void_int_wasm(
argsJsonString.cstring)


proc collab_hostCollaborator_void_int_wasm(arg: cstring): cstring {.importc.}
proc hostCollaborator*(port: int = 6969) =
var argsJson = newJArray()
argsJson.add block:
when int is JsonNode:
port
else:
port.toJson()
let argsJsonString = $argsJson
let res {.used.} = collab_hostCollaborator_void_int_wasm(
argsJsonString.cstring)

4 changes: 4 additions & 0 deletions scripting/editor_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ proc browseKeybinds*(preview: bool = true; scaleX: float = 0.9;
scaleY: float = 0.8; previewScale: float = 0.4) =
editor_browseKeybinds_void_App_bool_float_float_float_impl(preview, scaleX,
scaleY, previewScale)
proc connectCollaborator*(port: int = 6969) =
editor_connectCollaborator_void_App_int_impl(port)
proc hostCollaborator*(port: int = 6969) =
editor_hostCollaborator_void_App_int_impl(port)
proc chooseFile*(preview: bool = true; scaleX: float = 0.8; scaleY: float = 0.8;
previewScale: float = 0.5) =
## Opens a file dialog which shows all files in the currently open workspaces
Expand Down
67 changes: 17 additions & 50 deletions scripting/editor_text_api_wasm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,20 @@ proc selectParentTs*(self: TextDocumentEditor; selection: Selection;
argsJsonString.cstring)


proc editor_text_printTreesitterMemoryUsage_void_TextDocumentEditor_wasm(
arg: cstring): cstring {.importc.}
proc printTreesitterMemoryUsage*(self: TextDocumentEditor) =
var argsJson = newJArray()
argsJson.add block:
when TextDocumentEditor is JsonNode:
self
else:
self.toJson()
let argsJsonString = $argsJson
let res {.used.} = editor_text_printTreesitterMemoryUsage_void_TextDocumentEditor_wasm(
argsJsonString.cstring)


proc editor_text_printTreesitterTree_void_TextDocumentEditor_wasm(arg: cstring): cstring {.
importc.}
proc printTreesitterTree*(self: TextDocumentEditor) =
Expand Down Expand Up @@ -1392,25 +1406,6 @@ proc addNextCheckpoint*(self: TextDocumentEditor; checkpoint: string) =
argsJsonString.cstring)


proc editor_text_printUndoHistory_void_TextDocumentEditor_int_wasm(arg: cstring): cstring {.
importc.}
proc printUndoHistory*(self: TextDocumentEditor; max: int = 50) =
var argsJson = newJArray()
argsJson.add block:
when TextDocumentEditor is JsonNode:
self
else:
self.toJson()
argsJson.add block:
when int is JsonNode:
max
else:
max.toJson()
let argsJsonString = $argsJson
let res {.used.} = editor_text_printUndoHistory_void_TextDocumentEditor_int_wasm(
argsJsonString.cstring)


proc editor_text_copy_void_TextDocumentEditor_string_bool_wasm(arg: cstring): cstring {.
importc.}
proc copy*(self: TextDocumentEditor; register: string = "";
Expand Down Expand Up @@ -1438,7 +1433,7 @@ proc copy*(self: TextDocumentEditor; register: string = "";

proc editor_text_paste_void_TextDocumentEditor_string_bool_wasm(arg: cstring): cstring {.
importc.}
proc paste*(self: TextDocumentEditor; register: string = "";
proc paste*(self: TextDocumentEditor; registerName: string = "";
inclusiveEnd: bool = false) =
var argsJson = newJArray()
argsJson.add block:
Expand All @@ -1448,9 +1443,9 @@ proc paste*(self: TextDocumentEditor; register: string = "";
self.toJson()
argsJson.add block:
when string is JsonNode:
register
registerName
else:
register.toJson()
registerName.toJson()
argsJson.add block:
when bool is JsonNode:
inclusiveEnd
Expand Down Expand Up @@ -3441,34 +3436,6 @@ proc clearDiagnostics*(self: TextDocumentEditor) =
argsJsonString.cstring)


proc editor_text_updateDiagnosticsForCurrent_void_TextDocumentEditor_wasm(
arg: cstring): cstring {.importc.}
proc updateDiagnosticsForCurrent*(self: TextDocumentEditor) =
var argsJson = newJArray()
argsJson.add block:
when TextDocumentEditor is JsonNode:
self
else:
self.toJson()
let argsJsonString = $argsJson
let res {.used.} = editor_text_updateDiagnosticsForCurrent_void_TextDocumentEditor_wasm(
argsJsonString.cstring)


proc editor_text_showDiagnosticsForCurrent_void_TextDocumentEditor_wasm(
arg: cstring): cstring {.importc.}
proc showDiagnosticsForCurrent*(self: TextDocumentEditor) =
var argsJson = newJArray()
argsJson.add block:
when TextDocumentEditor is JsonNode:
self
else:
self.toJson()
let argsJsonString = $argsJson
let res {.used.} = editor_text_showDiagnosticsForCurrent_void_TextDocumentEditor_wasm(
argsJsonString.cstring)


proc editor_text_setReadOnly_void_TextDocumentEditor_bool_wasm(arg: cstring): cstring {.
importc.}
proc setReadOnly*(self: TextDocumentEditor; readOnly: bool) =
Expand Down
6 changes: 6 additions & 0 deletions scripting/plugin_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ export scripting_api

## This file is auto generated, don't modify.

when defined(wasm):
import collab_api_wasm
export collab_api_wasm
else:
import collab_api
export collab_api
when defined(wasm):
import debugger_api_wasm
export debugger_api_wasm
Expand Down
4 changes: 4 additions & 0 deletions scripting/plugin_api_internal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ proc editor_browseKeybinds_void_App_bool_float_float_float_impl*(
preview: bool = true; scaleX: float = 0.9; scaleY: float = 0.8;
previewScale: float = 0.4) =
discard
proc editor_connectCollaborator_void_App_int_impl*(port: int = 6969) =
discard
proc editor_hostCollaborator_void_App_int_impl*(port: int = 6969) =
discard
proc editor_chooseFile_void_App_bool_float_float_float_impl*(
preview: bool = true; scaleX: float = 0.8; scaleY: float = 0.8;
previewScale: float = 0.5) =
Expand Down
Loading

0 comments on commit bd260e6

Please sign in to comment.