diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ad0ff31 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,167 @@ +name: Release + +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + version: + description: "Version to build (e.g., 0.1.0)" + required: true + type: string + dry_run: + description: "Dry run (build but don't create release)" + required: false + type: boolean + default: true + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + name: Build ${{ matrix.artifact_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + artifact_name: linux-x86_64 + ffi_ext: so + - os: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + artifact_name: linux-aarch64 + ffi_ext: so + - os: macos-13 + target: x86_64-apple-darwin + artifact_name: macos-x86_64 + ffi_ext: dylib + - os: macos-14 + target: aarch64-apple-darwin + artifact_name: macos-aarch64 + ffi_ext: dylib + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Determine version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=v${{ inputs.version }}" >> $GITHUB_OUTPUT + echo "Using manual version: v${{ inputs.version }}" + else + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + echo "Using tag version: ${GITHUB_REF#refs/tags/}" + fi + + - name: Verify version matches Cargo.toml + run: | + CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/') + BUILD_VERSION=${{ steps.version.outputs.VERSION }} + BUILD_VERSION=${BUILD_VERSION#v} # Strip v prefix + echo "Cargo.toml version: $CARGO_VERSION" + echo "Build version: $BUILD_VERSION" + if [ "$CARGO_VERSION" != "$BUILD_VERSION" ]; then + echo "::error::Version mismatch! Cargo.toml has $CARGO_VERSION but building v$BUILD_VERSION" + exit 1 + fi + echo "Version check passed" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} + + - name: Install dependencies (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libluajit-5.1-dev libclang-dev pkg-config + + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: | + brew install luajit pkg-config + + - name: Build release + run: cargo build --release --target ${{ matrix.target }} + + - name: Create artifact directory + run: | + mkdir -p artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }} + + - name: Copy binaries to artifact directory + run: | + cp target/${{ matrix.target }}/release/penview artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/ + cp target/${{ matrix.target }}/release/libwebsocket_ffi.${{ matrix.ffi_ext }} artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/websocket_ffi.so + echo "${{ steps.version.outputs.VERSION }}" > artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}/VERSION + + - name: Create tarball + run: | + cd artifact + tar -czvf penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}.tar.gz penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }} + path: artifact/penview-${{ steps.version.outputs.VERSION }}-${{ matrix.artifact_name }}.tar.gz + + release: + name: Create Release + needs: build + runs-on: ubuntu-latest + if: ${{ github.event_name == 'push' || !inputs.dry_run }} + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Determine version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=v${{ inputs.version }}" >> $GITHUB_OUTPUT + else + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + fi + + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Collect tarballs + run: | + mkdir -p release + find artifacts -name "*.tar.gz" -exec cp {} release/ \; + ls -la release/ + + - name: Generate checksums + run: | + cd release + sha256sum *.tar.gz > SHA256SUMS.txt + cat SHA256SUMS.txt + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: penview ${{ steps.version.outputs.VERSION }} + draft: false + prerelease: false + generate_release_notes: true + files: | + release/*.tar.gz + release/SHA256SUMS.txt diff --git a/.gitignore b/.gitignore index 2fd9cc6..7220046 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target +/bin rust/websocket-ffi/lua/ diff --git a/Cargo.lock b/Cargo.lock index c236891..fa1ec46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -277,9 +277,9 @@ checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "cc" -version = "1.2.48" +version = "1.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c481bdbf0ed3b892f6f806287d72acd515b352a4ec27a208489b8c1bc839633a" +checksum = "90583009037521a116abf44494efecd645ba48b6622457080f080b85544e2215" dependencies = [ "find-msvc-tools", "shlex", diff --git a/Cargo.toml b/Cargo.toml index 78e20cc..d9cbc55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,42 @@ members = [ "rust/penview", "rust/websocket-ffi", ] + +[workspace.package] +version = "0.1.0" +edition = "2024" +authors = ["Rahul Garg "] +readme = "README.md" +license = "MIT" +repository = "https://github.com/vihu/penview.nvim" +homepage = "https://github.com/vihu/penview.nvim" + +[workspace.dependencies] +anyhow = "1" +askama = "0.14" +axum = { version = "0.8", features = ["ws"] } +base64 = "0.22.0" +clap = { version = "4", features = ["derive"] } +futures-channel = "0.3" +futures-util = "0.3" +inquire = "0.9" +mime_guess = "2" +lazy_static = "1.4.0" +log = "0.4" +log4rs = { version = "1.4", features = ["file_appender"] } +log-panics = "2" +notify = "8" +mlua = "0.9.7" +nvim-oxi = { version = "0.4.2", features = ["neovim-0-9", "libuv", "mlua"] } +open = "5" +parking_lot = "0.12" +pulldown-cmark = "0.13" +resolve-path = "0.1.0" +serde = { version = "1", features = ["derive"] } +serde_json = "1" +tokio = { version = "1", features = ["full"] } +tokio-tungstenite = { version = "0.21.0", features = [] } +tracing = "0.1" +tracing-subscriber = "0.3" +url = "2" +uuid = { version = "1", features = [ "v4", "fast-rng", "macro-diagnostics" ] } diff --git a/README.md b/README.md index 03235ec..f4eed82 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,21 @@ Real-time Markdown preview for Neovim with GitHub Flavored Markdown styling. ## Requirements - Neovim 0.9+ -- Rust toolchain (for building) +- curl (for downloading pre-compiled binaries) +- Rust toolchain (only if building from source) ## Installation -### lazy.nvim +### lazy.nvim (recommended) + +Pre-compiled binaries are automatically downloaded for Linux and macOS (x86_64 and aarch64): ```lua { "vihu/penview.nvim", - build = "make build", + build = function() + require("penview.build").install() + end, ft = "markdown", config = function() require("penview").setup({ @@ -43,6 +48,51 @@ Real-time Markdown preview for Neovim with GitHub Flavored Markdown styling. } ``` +### packer.nvim + +```lua +use { + "vihu/penview.nvim", + run = function() + require("penview.build").install() + end, + config = function() + require("penview").setup({ + browser = "firefox", + }) + end, +} +``` + +### vim-plug + +```vim +Plug 'vihu/penview.nvim', { 'do': ':lua require("penview.build").install()' } + +" In your init.vim or after/plugin: +lua require("penview").setup({ browser = "firefox" }) +``` + +### Building from source + +If pre-compiled binaries are unavailable for your platform, or you prefer to build from source: + +```lua +-- lazy.nvim +{ + "vihu/penview.nvim", + build = "make build", -- Requires Rust toolchain + -- ... +} +``` + +Build dependencies: + +- Rust toolchain (stable) +- libluajit (libluajit-5.1-dev on Debian/Ubuntu) +- libclang-dev +- pkg-config + ## Usage 1. Open a markdown file diff --git a/lua/penview/build.lua b/lua/penview/build.lua new file mode 100644 index 0000000..9acccbd --- /dev/null +++ b/lua/penview/build.lua @@ -0,0 +1,404 @@ +-- penview build module +-- Downloads pre-compiled binaries or falls back to source compilation + +local M = {} + +-- GitHub repository for releases +M.repo = "vihu/penview.nvim" + +-- Get the plugin's root directory +local function get_plugin_root() + local source = debug.getinfo(1, "S").source:sub(2) + return vim.fn.fnamemodify(source, ":h:h:h") +end + +-- Detect current platform and architecture +function M.get_platform() + local uname = vim.loop.os_uname() + local os_name = uname.sysname:lower() + local arch = uname.machine + + -- Normalize OS name + if os_name == "darwin" then + os_name = "macos" + elseif os_name:match("linux") then + os_name = "linux" + else + return nil, nil, "Unsupported OS: " .. os_name + end + + -- Normalize architecture + if arch == "arm64" then + arch = "aarch64" + elseif arch == "x86_64" or arch == "amd64" then + arch = "x86_64" + else + return nil, nil, "Unsupported architecture: " .. arch + end + + return os_name, arch, nil +end + +-- Get the latest release version from GitHub +local function get_latest_version(callback) + local url = string.format("https://api.github.com/repos/%s/releases/latest", M.repo) + + vim.system({ "curl", "-sL", url }, { text = true }, function(result) + if result.code ~= 0 then + callback(nil, "Failed to fetch latest release: " .. (result.stderr or "unknown error")) + return + end + + local ok, data = pcall(vim.json.decode, result.stdout) + if not ok or not data or not data.tag_name then + callback(nil, "Failed to parse release info") + return + end + + callback(data.tag_name, nil) + end) +end + +-- Construct download URL for a specific version and platform +function M.get_download_url(version, os_name, arch) + local filename = string.format("penview-%s-%s-%s.tar.gz", version, os_name, arch) + return string.format("https://github.com/%s/releases/download/%s/%s", M.repo, version, filename) +end + +-- Download file to destination +local function download_file(url, dest, callback) + vim.system({ "curl", "-sL", "-o", dest, url }, {}, function(result) + if result.code ~= 0 then + callback(false, "Download failed: " .. (result.stderr or "unknown error")) + return + end + callback(true, nil) + end) +end + +-- Get checksums file URL for a version +function M.get_checksums_url(version) + return string.format("https://github.com/%s/releases/download/%s/SHA256SUMS.txt", M.repo, version) +end + +-- Verify SHA256 checksum of a file +local function verify_checksum(file_path, expected_checksum, callback) + -- Use sha256sum on Linux, shasum -a 256 on macOS + local cmd + local uname = vim.loop.os_uname().sysname:lower() + if uname == "darwin" then + cmd = { "shasum", "-a", "256", file_path } + else + cmd = { "sha256sum", file_path } + end + + vim.system(cmd, { text = true }, function(result) + if result.code ~= 0 then + callback(false, "Failed to compute checksum: " .. (result.stderr or "unknown error")) + return + end + + -- Both sha256sum and shasum output format: "checksum filename" + local computed = result.stdout:match("^(%x+)") + if not computed then + callback(false, "Failed to parse checksum output") + return + end + + if computed:lower() == expected_checksum:lower() then + callback(true, nil) + else + callback(false, string.format("Checksum mismatch: expected %s, got %s", expected_checksum, computed)) + end + end) +end + +-- Parse SHA256SUMS.txt and find checksum for a specific file +local function parse_checksums(checksums_content, filename) + for line in checksums_content:gmatch("[^\r\n]+") do + -- Format: "checksum filename" (two spaces) + local checksum, name = line:match("^(%x+)%s+(.+)$") + if checksum and name and name:match(vim.pesc(filename) .. "$") then + return checksum + end + end + return nil +end + +-- Extract tarball to destination directory +local function extract_tarball(tarball_path, dest_dir, callback) + -- Create destination directory + vim.fn.mkdir(dest_dir, "p") + + -- Extract with --strip-components=1 to avoid nested directory + vim.system({ "tar", "-xzf", tarball_path, "-C", dest_dir, "--strip-components=1" }, {}, function(result) + if result.code ~= 0 then + callback(false, "Extraction failed: " .. (result.stderr or "unknown error")) + return + end + + -- Make binary executable + local binary = dest_dir .. "/penview" + vim.system({ "chmod", "+x", binary }, {}, function(chmod_result) + if chmod_result.code ~= 0 then + callback(false, "Failed to set executable permission") + return + end + callback(true, nil) + end) + end) +end + +-- Get installed version from VERSION file +function M.get_installed_version() + local root = get_plugin_root() + local version_file = root .. "/bin/VERSION" + local f = io.open(version_file, "r") + if f then + local version = f:read("*l") + f:close() + return version + end + return nil +end + +-- Check if pre-compiled binaries exist +function M.binaries_exist() + local root = get_plugin_root() + local binary = root .. "/bin/penview" + local ffi = root .. "/bin/websocket_ffi.so" + return vim.fn.filereadable(binary) == 1 and vim.fn.filereadable(ffi) == 1 +end + +-- Install pre-compiled binaries +function M.install(opts) + opts = opts or {} + local force = opts.force or false + local root = get_plugin_root() + local bin_dir = root .. "/bin" + + -- Check if already installed + if not force and M.binaries_exist() then + local version = M.get_installed_version() + print("[penview] Binaries already installed" .. (version and (" (" .. version .. ")") or "")) + return true + end + + -- Detect platform + local os_name, arch, err = M.get_platform() + if err then + print("[penview] " .. err) + print("[penview] Falling back to source compilation...") + return M.build_from_source() + end + + print(string.format("[penview] Detected platform: %s-%s", os_name, arch)) + print("[penview] Fetching latest release...") + + -- Get latest version and download (synchronous for plugin manager compatibility) + local version = nil + local version_err = nil + local done = false + + get_latest_version(function(v, e) + version = v + version_err = e + done = true + end) + + -- Wait for async operation (with timeout) + local timeout = 30000 -- 30 seconds + local start = vim.loop.now() + while not done and (vim.loop.now() - start) < timeout do + vim.wait(100, function() + return done + end, 100) + end + + if version_err or not version then + print("[penview] " .. (version_err or "Timeout fetching release")) + print("[penview] Falling back to source compilation...") + return M.build_from_source() + end + + print("[penview] Latest version: " .. version) + + -- Download + local url = M.get_download_url(version, os_name, arch) + local tmp_file = vim.fn.tempname() .. ".tar.gz" + + print("[penview] Downloading from: " .. url) + + local download_ok = nil + local download_err = nil + done = false + + download_file(url, tmp_file, function(ok, e) + download_ok = ok + download_err = e + done = true + end) + + start = vim.loop.now() + while not done and (vim.loop.now() - start) < timeout do + vim.wait(100, function() + return done + end, 100) + end + + if not download_ok then + print("[penview] " .. (download_err or "Download timeout")) + print("[penview] Falling back to source compilation...") + os.remove(tmp_file) + return M.build_from_source() + end + + print("[penview] Download complete, verifying checksum...") + + -- Download checksums file + local checksums_url = M.get_checksums_url(version) + local checksums_content = nil + local checksums_err = nil + done = false + + vim.system({ "curl", "-sL", checksums_url }, { text = true }, function(result) + if result.code ~= 0 then + checksums_err = "Failed to download checksums: " .. (result.stderr or "unknown error") + else + checksums_content = result.stdout + end + done = true + end) + + start = vim.loop.now() + while not done and (vim.loop.now() - start) < timeout do + vim.wait(100, function() + return done + end, 100) + end + + if checksums_err or not checksums_content then + print("[penview] [WARN] " .. (checksums_err or "Timeout downloading checksums")) + print("[penview] [WARN] Skipping checksum verification") + else + -- Parse checksums and find expected checksum for our file + local tarball_name = string.format("penview-%s-%s-%s.tar.gz", version, os_name, arch) + local expected_checksum = parse_checksums(checksums_content, tarball_name) + + if not expected_checksum then + print("[penview] [WARN] Checksum not found for " .. tarball_name) + print("[penview] [WARN] Skipping checksum verification") + else + -- Verify checksum + local verify_ok = nil + local verify_err = nil + done = false + + verify_checksum(tmp_file, expected_checksum, function(ok, e) + verify_ok = ok + verify_err = e + done = true + end) + + start = vim.loop.now() + while not done and (vim.loop.now() - start) < timeout do + vim.wait(100, function() + return done + end, 100) + end + + if not verify_ok then + print("[penview] [ERROR] " .. (verify_err or "Checksum verification timeout")) + print("[penview] Falling back to source compilation...") + os.remove(tmp_file) + return M.build_from_source() + end + + print("[penview] Checksum verified") + end + end + + print("[penview] Extracting...") + + -- Extract + local extract_ok = nil + local extract_err = nil + done = false + + extract_tarball(tmp_file, bin_dir, function(ok, e) + extract_ok = ok + extract_err = e + done = true + end) + + start = vim.loop.now() + while not done and (vim.loop.now() - start) < timeout do + vim.wait(100, function() + return done + end, 100) + end + + -- Cleanup temp file + os.remove(tmp_file) + + if not extract_ok then + print("[penview] " .. (extract_err or "Extraction timeout")) + print("[penview] Falling back to source compilation...") + return M.build_from_source() + end + + -- Create lua/ subdirectory in bin/ for runtimepath compatibility + -- Neovim looks for lua/ subdirectory when resolving require() + local ffi_src = bin_dir .. "/websocket_ffi.so" + local ffi_lua_dir = bin_dir .. "/lua" + vim.fn.mkdir(ffi_lua_dir, "p") + vim.fn.system({ "cp", ffi_src, ffi_lua_dir .. "/websocket_ffi.so" }) + + print("[penview] [OK] Installation complete (" .. version .. ")") + return true +end + +-- Build from source using make +function M.build_from_source() + local root = get_plugin_root() + + -- Check for cargo + if vim.fn.executable("cargo") ~= 1 then + print("[penview] [ERROR] Rust toolchain not found") + print("[penview] Install Rust from https://rustup.rs/ and try again") + return false + end + + print("[penview] Building from source (this may take a while)...") + + local result = vim.fn.system({ "make", "-C", root, "build" }) + if vim.v.shell_error ~= 0 then + print("[penview] [ERROR] Build failed:") + print(result) + return false + end + + print("[penview] [OK] Build complete") + return true +end + +-- Update to latest version +function M.update() + local current = M.get_installed_version() + if current then + print("[penview] Current version: " .. current) + end + return M.install({ force = true }) +end + +-- Clean installed binaries +function M.clean() + local root = get_plugin_root() + local bin_dir = root .. "/bin" + if vim.fn.isdirectory(bin_dir) == 1 then + vim.fn.delete(bin_dir, "rf") + print("[penview] Cleaned bin/ directory") + end +end + +return M diff --git a/lua/penview/init.lua b/lua/penview/init.lua index 7440ac2..839f10b 100644 --- a/lua/penview/init.lua +++ b/lua/penview/init.lua @@ -15,10 +15,19 @@ end -- Get the path to the penview binary local function get_binary_path() local root = get_plugin_root() - local binary = root .. "/target/release/penview" - if vim.fn.executable(binary) == 1 then - return binary + + -- Check pre-compiled binary first + local precompiled = root .. "/bin/penview" + if vim.fn.executable(precompiled) == 1 then + return precompiled + end + + -- Check source-built binary + local source_built = root .. "/target/release/penview" + if vim.fn.executable(source_built) == 1 then + return source_built end + -- Fallback to PATH if vim.fn.executable("penview") == 1 then return "penview" diff --git a/lua/penview/websocket/init.lua b/lua/penview/websocket/init.lua index 217c769..0f57a5b 100644 --- a/lua/penview/websocket/init.lua +++ b/lua/penview/websocket/init.lua @@ -5,7 +5,20 @@ function M.setup(opts) -- Find penview plugin root (lua/penview/websocket/init.lua -> plugin root) local current_path = debug.getinfo(1).source:match("@?(.*/)") or "" local plugin_root = vim.fn.fnamemodify(current_path, ":h:h:h:h") - vim.opt.runtimepath:append(plugin_root .. "/rust/websocket-ffi") + + -- Check for FFI library locations in order of preference: + -- 1. Pre-compiled in bin/lua/ + -- 2. Source-built in rust/websocket-ffi/lua/ + local precompiled_path = plugin_root .. "/bin" + local source_path = plugin_root .. "/rust/websocket-ffi" + + if vim.fn.filereadable(precompiled_path .. "/lua/websocket_ffi.so") == 1 then + vim.opt.runtimepath:append(precompiled_path) + else + -- Fall back to source-built location (also used by make build) + vim.opt.runtimepath:append(source_path) + end + _G["_WEBSOCKET_NVIM"] = { clients = { callbacks = {}, diff --git a/rust/penview/Cargo.toml b/rust/penview/Cargo.toml index 06da466..421cefe 100644 --- a/rust/penview/Cargo.toml +++ b/rust/penview/Cargo.toml @@ -1,23 +1,26 @@ [package] name = "penview" -version = "0.1.0" -edition = "2024" +version.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true [dependencies] -anyhow = "1" -askama = "0.14" -axum = { version = "0.8", features = ["ws"] } -base64 = "0.22.0" -clap = { version = "4", features = ["derive"] } -inquire = "0.9" -mime_guess = "2" -notify = "8" -open = "5" -pulldown-cmark = "0.13" -resolve-path = "0.1.0" -serde = { version = "1", features = ["derive"] } -serde_json = "1" -tokio = { version = "1", features = ["full"] } -tracing = "0.1" -tracing-subscriber = "0.3" -url = "2" +anyhow.workspace = true +askama.workspace = true +axum.workspace = true +base64.workspace = true +clap.workspace = true +inquire.workspace = true +mime_guess.workspace = true +notify.workspace = true +open.workspace = true +pulldown-cmark.workspace = true +resolve-path.workspace = true +serde.workspace = true +serde_json.workspace = true +tokio.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true +url.workspace = true diff --git a/rust/websocket-ffi/Cargo.toml b/rust/websocket-ffi/Cargo.toml index 88a94e7..d97ef57 100644 --- a/rust/websocket-ffi/Cargo.toml +++ b/rust/websocket-ffi/Cargo.toml @@ -1,27 +1,26 @@ [package] name = "websocket-ffi" -version = "0.1.0" -edition = "2021" +version.workspace = true +edition.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true [lib] crate-type = ["cdylib"] [dependencies] -nvim-oxi = { version = "0.4.2", features = ["neovim-0-9", "libuv", "mlua"] } -serde = "1.0.201" -tokio = { version = "1.37.0", features = ["full"] } -tokio-tungstenite = { version = "0.21.0", features = [] } -lazy_static = "1.4.0" -parking_lot = "0.12.2" -uuid = { version = "1.8.0", features = [ - "v4", # Lets you generate random UUIDs - "fast-rng", # Use a faster (but still sufficiently random) RNG - "macro-diagnostics", # Enable better diagnostics for compile-time UUIDs -] } -mlua = "0.9.7" -url = "2.5.0" -futures-util = "0.3.30" -futures-channel = "0.3.30" -log = "0.4.21" -log4rs = { version = "1.3.0", features = ["file_appender"] } -log-panics = "2.1.0" \ No newline at end of file +futures-channel.workspace = true +futures-util.workspace = true +log.workspace = true +log4rs.workspace = true +log-panics.workspace = true +lazy_static.workspace = true +mlua.workspace = true +nvim-oxi.workspace = true +parking_lot.workspace = true +serde.workspace = true +tokio.workspace = true +tokio-tungstenite.workspace = true +url.workspace = true +uuid.workspace = true diff --git a/rust/websocket-ffi/src/client/ffi.rs b/rust/websocket-ffi/src/client/ffi.rs index e61e42a..7298903 100644 --- a/rust/websocket-ffi/src/client/ffi.rs +++ b/rust/websocket-ffi/src/client/ffi.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use nvim_oxi::{Dictionary, Function, Object}; use uuid::Uuid; -use super::WebsocketClient; use super::WEBSOCKET_CLIENT_REGISTRY; +use super::WebsocketClient; pub fn websocket_client_ffi() -> Dictionary { Dictionary::from_iter([ diff --git a/rust/websocket-ffi/src/client/inbound_event.rs b/rust/websocket-ffi/src/client/inbound_event.rs index 73f4871..f786e09 100644 --- a/rust/websocket-ffi/src/client/inbound_event.rs +++ b/rust/websocket-ffi/src/client/inbound_event.rs @@ -1,8 +1,8 @@ use std::error::Error; use mlua::prelude::*; -use nvim_oxi::conversion::ToObject; use nvim_oxi::Object; +use nvim_oxi::conversion::ToObject; #[derive(Clone, Debug)] pub enum WebsocketClientError { diff --git a/rust/websocket-ffi/src/lib.rs b/rust/websocket-ffi/src/lib.rs index f0fabae..d6c1c51 100644 --- a/rust/websocket-ffi/src/lib.rs +++ b/rust/websocket-ffi/src/lib.rs @@ -1,5 +1,3 @@ -use std::env; - use lazy_static::lazy_static; use log::{self}; use log4rs::{ @@ -19,8 +17,6 @@ lazy_static! { #[nvim_oxi::module] fn websocket_ffi() -> nvim_oxi::Result { - env::set_var("RUST_BACKTRACE", "1"); - let file_appender = FileAppender::builder() // Pattern: https://docs.rs/log4rs/*/log4rs/encode/pattern/index.html .encoder(Box::new(PatternEncoder::new( diff --git a/rust/websocket-ffi/src/server/ffi.rs b/rust/websocket-ffi/src/server/ffi.rs index c7aa804..d1b04af 100644 --- a/rust/websocket-ffi/src/server/ffi.rs +++ b/rust/websocket-ffi/src/server/ffi.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, ops::Deref}; use nvim_oxi::{Dictionary, Function, Object}; use uuid::Uuid; -use super::{WebsocketServer, WebsocketServerClient, WEBSOCKET_SERVER_REGISTRY}; +use super::{WEBSOCKET_SERVER_REGISTRY, WebsocketServer, WebsocketServerClient}; pub fn websocket_server_ffi() -> Dictionary { Dictionary::from_iter([ diff --git a/rust/websocket-ffi/src/server/inbound_event.rs b/rust/websocket-ffi/src/server/inbound_event.rs index ab4d4b5..1c952e1 100644 --- a/rust/websocket-ffi/src/server/inbound_event.rs +++ b/rust/websocket-ffi/src/server/inbound_event.rs @@ -1,6 +1,6 @@ use mlua::prelude::{IntoLua, Lua, LuaResult, LuaValue}; -use nvim_oxi::conversion::ToObject; use nvim_oxi::Object; +use nvim_oxi::conversion::ToObject; use uuid::Uuid; #[derive(Clone)]