Remove Rust code, delegate server to nuwiki-rs repo
Delete all Rust crates (crates/) and Cargo files. The nuwiki-ls binary is now built in the separate nuwiki-rs repository and downloaded at install time from the Gitea release assets, with a cargo build fallback that clones nuwiki-rs. Update all documentation to reflect the split repo layout.
This commit is contained in:
@@ -816,8 +816,7 @@ end
|
||||
-- the cursor visually mid-cell after columns expand. For insert-mode
|
||||
-- editing we replicate the alignment logic locally so we can realign
|
||||
-- *before* placing the cursor, all in a single `vim.schedule` tick.
|
||||
-- The algorithm matches `crates/nuwiki-lsp/src/commands.rs::ops::
|
||||
-- render_aligned_table`.
|
||||
-- The algorithm matches the LSP server's implementation in nuwiki-rs.
|
||||
|
||||
local function is_table_row(line)
|
||||
return line ~= nil and line:match('^%s*|.*|%s*$') ~= nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- lua/nuwiki/folding.lua — `foldexpr` fallback when the LSP isn't
|
||||
-- attached. Same heading-block model as the server-side `foldingRange`
|
||||
-- provider in `crates/nuwiki-lsp/src/folding.rs`, but driven from a
|
||||
-- provider in the nuwiki-rs LSP server, but driven from a
|
||||
-- pure regex over `getline()` so it works without a running server.
|
||||
--
|
||||
-- Activated by `setlocal foldmethod=expr foldexpr=v:lua.require'nuwiki.folding'.expr()`
|
||||
|
||||
+21
-13
@@ -2,9 +2,9 @@
|
||||
--
|
||||
-- Strategy:
|
||||
-- 1. Look for `bin/nuwiki-ls[.exe]` next to the plugin.
|
||||
-- 2. If missing or `g:nuwiki_build_from_source` is set, build with cargo.
|
||||
-- 3. Otherwise try to download a release asset for the current target.
|
||||
-- On failure, fall back to cargo.
|
||||
-- 2. If missing, download a release asset for the current target from
|
||||
-- nuwiki-rs.
|
||||
-- 3. On failure, fall back to cloning nuwiki-rs and building with cargo.
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -51,16 +51,30 @@ local function build_from_source(dest)
|
||||
return false
|
||||
end
|
||||
local root = plugin_root()
|
||||
vim.notify('nuwiki: building from source (cargo build --release) …', vim.log.levels.INFO)
|
||||
vim.notify('nuwiki: building nuwiki-ls from source (cargo build --release) …', vim.log.levels.INFO)
|
||||
local rs_repo = vim.fn.fnamemodify(root, ':h:h') .. '/nuwiki-rs'
|
||||
if not vim.uv then vim.uv = vim.loop end
|
||||
local rs_exists = vim.uv.fs_stat(rs_repo)
|
||||
if not rs_exists then
|
||||
vim.notify('nuwiki: cloning nuwiki-rs …', vim.log.levels.INFO)
|
||||
local _ = vim.fn.system({
|
||||
'git', 'clone', '--depth', '1',
|
||||
'https://code.gfran.co/gffranco/nuwiki-rs.git', rs_repo,
|
||||
})
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.notify('nuwiki: failed to clone nuwiki-rs', vim.log.levels.ERROR)
|
||||
return false
|
||||
end
|
||||
end
|
||||
local _ = vim.fn.system({
|
||||
'cargo', 'build', '--release', '-p', 'nuwiki-ls',
|
||||
'--manifest-path', root .. '/Cargo.toml',
|
||||
'--manifest-path', rs_repo .. '/Cargo.toml',
|
||||
})
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.notify('nuwiki: cargo build failed', vim.log.levels.ERROR)
|
||||
return false
|
||||
end
|
||||
local built = root .. '/target/release/nuwiki-ls' .. exe_suffix()
|
||||
local built = rs_repo .. '/target/release/nuwiki-ls' .. exe_suffix()
|
||||
vim.fn.system({ 'cp', built, dest })
|
||||
vim.fn.system({ 'chmod', '+x', dest })
|
||||
return vim.fn.executable(dest) == 1
|
||||
@@ -74,11 +88,8 @@ local function download_release(dest)
|
||||
if vim.fn.executable('curl') ~= 1 or vim.fn.executable('tar') ~= 1 then
|
||||
return false
|
||||
end
|
||||
-- Gitea serves the most recent release under the `latest` tag segment
|
||||
-- (`/releases/download/latest/<asset>`). Note this is NOT GitHub's
|
||||
-- `/releases/latest/download/<asset>` shape, which Gitea 404s.
|
||||
local url = string.format(
|
||||
'https://code.gfran.co/gffranco/nuwiki/releases/download/latest/nuwiki-ls-%s.tar.gz',
|
||||
'https://code.gfran.co/gffranco/nuwiki-rs/releases/download/latest/nuwiki-ls-%s.tar.gz',
|
||||
target
|
||||
)
|
||||
local archive = vim.fn.tempname() .. '.tar.gz'
|
||||
@@ -101,9 +112,6 @@ function M.install()
|
||||
local dest = M.expected_path()
|
||||
vim.fn.mkdir(vim.fn.fnamemodify(dest, ':h'), 'p')
|
||||
|
||||
if vim.g.nuwiki_build_from_source == 1 then
|
||||
return build_from_source(dest)
|
||||
end
|
||||
if download_release(dest) then
|
||||
vim.notify('nuwiki: installed ' .. dest, vim.log.levels.INFO)
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user