mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-22 21:04:53 +01:00
feat(lua): alternative getters, annotations
also cleaned up features a bit and updated annotations oh and run CI too once
This commit is contained in:
parent
5cf6c4d4eb
commit
cd1fc21df7
6 changed files with 29 additions and 22 deletions
1
.github/workflows/lua.yml
vendored
1
.github/workflows/lua.yml
vendored
|
@ -4,6 +4,7 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- stable
|
||||
- dev
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
|
|
@ -72,8 +72,9 @@ rust = [] # used for ci matrix
|
|||
java = ["lazy_static", "jni", "tracing-subscriber"]
|
||||
js = ["napi-build", "tracing-subscriber", "napi", "napi-derive"]
|
||||
py = ["pyo3", "tracing-subscriber", "pyo3-build-config"]
|
||||
lua = ["mlua-codemp-patch", "tracing-subscriber", "lazy_static", "serialize", "mlua-codemp-patch/lua54"]
|
||||
luajit = ["mlua-codemp-patch", "tracing-subscriber", "lazy_static", "serialize", "mlua-codemp-patch/luajit"]
|
||||
lua = ["mlua-codemp-patch", "tracing-subscriber", "lazy_static", "serialize"]
|
||||
lua54 =["lua", "mlua-codemp-patch/lua54"]
|
||||
luajit = ["lua", "mlua-codemp-patch/luajit"]
|
||||
|
||||
|
||||
[package.metadata.docs.rs] # enabled features when building on docs.rs
|
||||
|
|
31
dist/lua/annotations.lua
vendored
31
dist/lua/annotations.lua
vendored
|
@ -121,14 +121,14 @@ local Workspace = {}
|
|||
---@async
|
||||
---@nodiscard
|
||||
---create a new empty buffer
|
||||
function Workspace:create_buffer(path) end
|
||||
function Workspace:create(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to delete
|
||||
---@return NilPromise
|
||||
---@async
|
||||
---@nodiscard
|
||||
---delete buffer from workspace
|
||||
function Workspace:delete_buffer(path) end
|
||||
function Workspace:delete(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to get
|
||||
---@return BufferController?
|
||||
|
@ -140,15 +140,15 @@ function Workspace:get_buffer(path) end
|
|||
---@async
|
||||
---@nodiscard
|
||||
---attach to a remote buffer, synching content and changes and returning its controller
|
||||
function Workspace:attach_buffer(path) end
|
||||
function Workspace:attach(path) end
|
||||
|
||||
---@param path string relative path ("name") of buffer to detach from
|
||||
---@return boolean
|
||||
---detach from an active buffer, closing all streams. returns false if buffer was no longer active
|
||||
function Workspace:detach_buffer(path) end
|
||||
function Workspace:detach(path) end
|
||||
|
||||
---@param filter? string apply a filter to the return elements
|
||||
---@param strict boolean whether to strictly match or just check whether it starts with it
|
||||
---@param strict? boolean whether to strictly match or just check whether it starts with it
|
||||
---@return string[]
|
||||
---return the list of available buffers in this workspace, as relative paths from workspace root
|
||||
function Workspace:filetree(filter, strict) end
|
||||
|
@ -184,10 +184,14 @@ local BufferController = {}
|
|||
|
||||
---@class TextChange
|
||||
---@field content string text content of change
|
||||
---@field first integer start index of change
|
||||
---@field last integer end index of change
|
||||
---@field start integer start index of change
|
||||
---@field finish integer end index of change
|
||||
---@field hash integer? optional hash of text buffer after this change, for sync checks
|
||||
---@field apply fun(self: TextChange, other: string): string apply this text change to a string
|
||||
local TextChange = {}
|
||||
|
||||
---@param other string text to apply change to
|
||||
---apply this text change to a string, returning the result
|
||||
function TextChange:apply(other) end
|
||||
|
||||
---@param change TextChange text change to broadcast
|
||||
---@return NilPromise
|
||||
|
@ -238,16 +242,11 @@ function BufferController:content() end
|
|||
---handle to a workspace's cursor channel, allowing send/recv operations
|
||||
local CursorController = {}
|
||||
|
||||
---@class RowCol
|
||||
---@field row integer row number
|
||||
---@field col integer column number
|
||||
---row and column tuple
|
||||
|
||||
---@class Cursor
|
||||
---@field user string? id of user owning this cursor
|
||||
---@field buffer string relative path ("name") of buffer on which this cursor is
|
||||
---@field start RowCol cursor start position
|
||||
---@field finish RowCol cursor end position
|
||||
---@field start [integer, integer] cursor start position
|
||||
---@field finish [integer, integer] cursor end position
|
||||
---a cursor position
|
||||
|
||||
---@param cursor Cursor cursor event to broadcast
|
||||
|
@ -297,7 +296,7 @@ function CursorController:callback(cb) end
|
|||
---@field port integer | nil port to connect to, default 50053
|
||||
---@field tls boolean | nil enable or disable tls, default true
|
||||
|
||||
---@class (exact) Codemp
|
||||
---@class Codemp
|
||||
---the codemp shared library
|
||||
local Codemp = {}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ pub struct TextChange {
|
|||
/// Range start of text change, as char indexes in buffer previous state.
|
||||
pub start: u32,
|
||||
/// Range end of text change, as char indexes in buffer previous state.
|
||||
#[cfg_attr(feature = "serialize", serde(alias = "finish"))] // Lua uses `end` as keyword
|
||||
pub end: u32,
|
||||
/// New content of text inside span.
|
||||
pub content: String,
|
||||
|
|
|
@ -13,6 +13,7 @@ pub struct Cursor {
|
|||
/// Cursor start position in buffer, as 0-indexed row-column tuple.
|
||||
pub start: (i32, i32),
|
||||
/// Cursor end position in buffer, as 0-indexed row-column tuple.
|
||||
#[cfg_attr(feature = "serialize", serde(alias = "finish"))] // Lua uses `end` as keyword
|
||||
pub end: (i32, i32),
|
||||
/// Path of buffer this cursor is on.
|
||||
pub buffer: String,
|
||||
|
|
|
@ -294,8 +294,8 @@ impl LuaUserData for CodempWorkspace {
|
|||
// Ok(())
|
||||
// });
|
||||
|
||||
methods.add_method("filetree", |_, this, (filter, strict,):(Option<String>, bool,)|
|
||||
Ok(this.filetree(filter.as_deref(), strict))
|
||||
methods.add_method("filetree", |_, this, (filter, strict,):(Option<String>, Option<bool>,)|
|
||||
Ok(this.filetree(filter.as_deref(), strict.unwrap_or(false)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -359,6 +359,8 @@ impl LuaUserData for Cursor {
|
|||
fields.add_field_method_get("user", |_, this| Ok(this.user.clone()));
|
||||
fields.add_field_method_get("buffer", |_, this| Ok(this.buffer.clone()));
|
||||
fields.add_field_method_get("start", |_, this| Ok(RowCol::from(this.start)));
|
||||
fields.add_field_method_get("end", |_, this| Ok(RowCol::from(this.end)));
|
||||
// add a 'finish' accessor too because in Lua 'end' is reserved
|
||||
fields.add_field_method_get("finish", |_, this| Ok(RowCol::from(this.end)));
|
||||
}
|
||||
}
|
||||
|
@ -414,9 +416,11 @@ from_lua_serde! { CodempTextChange }
|
|||
impl LuaUserData for CodempTextChange {
|
||||
fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F) {
|
||||
fields.add_field_method_get("content", |_, this| Ok(this.content.clone()));
|
||||
fields.add_field_method_get("first", |_, this| Ok(this.start));
|
||||
fields.add_field_method_get("last", |_, this| Ok(this.end));
|
||||
fields.add_field_method_get("start", |_, this| Ok(this.start));
|
||||
fields.add_field_method_get("end", |_, this| Ok(this.end));
|
||||
fields.add_field_method_get("hash", |_, this| Ok(this.hash));
|
||||
// add a 'finish' accessor too because in Lua 'end' is reserved
|
||||
fields.add_field_method_get("finish", |_, this| Ok(this.end));
|
||||
}
|
||||
|
||||
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M) {
|
||||
|
|
Loading…
Reference in a new issue