Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: package for luarocks #356

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua",
cpath = "./.luarocks/lib/lua/5.1/?.so",
lua = "nlua",
},
default = {
verbose = true,
},
tests = {
verbose = true,
},
}
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Makefile]
indent_style = tab
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
48 changes: 48 additions & 0 deletions .github/rockspec.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
local git_ref = '$git_ref'
local modrev = '$modrev'
local specrev = '$specrev'

local repo_url = '$repo_url'

rockspec_format = '3.0'
package = '$package'
version = modrev ..'-'.. specrev

description = {
summary = '$summary',
detailed = $detailed_description,
labels = $labels,
homepage = '$homepage',
$license
}

dependencies = {
'lua == 5.1',
}

build_dependencies = {
'luarocks-build-rust-mlua',
}

test_dependencies = {
'nlua',
}

source = {
url = repo_url .. '/archive/' .. git_ref .. '.zip',
dir = '$repo_name-' .. '$archive_dir_suffix',
}

build = {
type = 'rust-mlua',
modules = {
'blink_cmp_fuzzy',
},
install = {
lua = {
['blink-cmp.init'] = 'lua/blink-cmp.lua',
},
},
default_features = false,
features = { 'lua51' },
}
31 changes: 31 additions & 0 deletions .github/workflows/luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to luarocks

on:
push:
tags:
- 'v*'
release:
types: [published]
pull_request: # Will test a local install without uploading to luarocks.org
workflow_dispatch: # Allow triggering manually

jobs:
luarocks-upload:
runs-on: ubuntu-latest
name: Publish to luarocks
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
toolchain: nightly
- name: LuaRocks upload
uses: nvim-neorocks/luarocks-tag-release@v7
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
with:
name: blink.cmp
summary: "Performant, batteries-included completion plugin for Neovim"
template: .github/rockspec.template
5 changes: 4 additions & 1 deletion .github/workflows/nix-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Test Nix Build

on:
push:
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -18,4 +21,4 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build with Nix
run: nix build .#blink-cmp
run: nix build .#blink-cmp -Lv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dual/
result
.direnv
.devenv
.luarocks
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ version = "0.1.0"
edition = "2021"

[lib]
path = "lua/blink/cmp/fuzzy/lib.rs"
crate-type = ["cdylib"]

[features]
default = ["luajit"]
luajit = ["mlua/luajit"]
lua51 = ["mlua/lua51"]

[dependencies]
regex = "1.10.5"
lazy_static = "1.5.0"
frizbee = { git = "https://github.com/saghen/frizbee" }
serde = { version = "1.0.204", features = ["derive"] }
heed = "0.20.3"
mlua = { version = "0.10.0", features = ["module", "luajit"] }
mlua = { version = "0.10.0", features = ["module"] }
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
./test.sh
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@

## Installation

> [!NOTE]
>
> `lazy.nvim` (with luarocks enabled) and `rocks.nvim` will configure luarocks
> to fetch a pre-built package with the fuzzy binary included.
> If you are using a platform for which there are no pre-built packages,
> luarocks needs a [nightly rust toolchain](https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust)
> to build the fuzzy binary.

`lazy.nvim`

```lua
Expand All @@ -36,9 +44,11 @@
-- optional: provides snippets for the snippet source
dependencies = 'rafamadriz/friendly-snippets',

-- use a release tag to download pre-built binaries
-- recommended: use a release tag for stable releases and prebuilt binaries, when not using luarocks
version = 'v0.*',
-- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust

-- optionally: build from source, when not using luarocks
-- (requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust)
-- build = 'cargo build --release',
-- If you use nix, you can build from source using latest nightly rust with:
-- build = 'nix run .#build-plugin',
Expand Down Expand Up @@ -94,6 +104,12 @@
}
```

`rocks.nvim`

```vim
:Rocks install blink.cmp
```

<details>
<summary><strong>mini.deps</strong></summary>

Expand Down Expand Up @@ -327,14 +343,10 @@ MiniDeps.add({
download = true,
-- When downloading a prebuilt binary, force the downloader to resolve this version. If this is unset
-- then the downloader will attempt to infer the version from the checked out git tag (if any).
--
-- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking.
force_version = nil,
-- When downloading a prebuilt binary, force the downloader to use this system triple. If this is unset
-- then the downloader will attempt to infer the system triple from `jit.os` and `jit.arch`.
-- Check the latest release for all available system triples
--
-- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking.
force_system_triple = nil,
},
},
Expand Down Expand Up @@ -612,7 +624,7 @@ The plugin use a 4 stage pipeline: trigger -> sources -> fuzzy -> render

**Sources:** Provides a common interface for and merges the results of completion, trigger character, resolution of additional information and cancellation. Some sources are builtin: `LSP`, `buffer`, `path`, `snippets`

**Fuzzy:** Rust <-> Lua FFI which performs both filtering and sorting of the items
**Fuzzy:** Native Lua library written in Rust, which performs both filtering and sorting of the items

&nbsp;&nbsp;&nbsp;&nbsp;**Filtering:** The fuzzy matching uses smith-waterman, same as FZF, but implemented in SIMD for ~6x the performance of FZF (TODO: add benchmarks). Due to the SIMD's performance, the prefiltering phase on FZF was dropped to allow for typos. Similar to fzy/fzf, additional points are given to prefix matches, characters with capitals (to promote camelCase/PascalCase first char matching) and matches after delimiters (to promote snake_case first char matching)

Expand Down
45 changes: 45 additions & 0 deletions blink.cmp-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
local MODREV, SPECREV = 'scm', '-1'
rockspec_format = '3.0'
package = 'blink.cmp'
version = MODREV .. SPECREV

description = {
summary = 'Performant, batteries-included completion plugin for Neovim',
labels = { 'neovim' },
homepage = 'https://github.com/Saghen/blink.cmp',
license = 'MIT',
}

source = {
url = 'https://github.com/Saghen/blink.cmp/archive/v' .. MODREV .. '.zip',
}

if MODREV == 'scm' then source = {
url = 'git://github.com/Saghen/blink.cmp',
} end

dependencies = {
'lua == 5.1',
}

test_dependencies = {
'nlua', -- neovim lua interpreter
}

build_dependencies = {
'luarocks-build-rust-mlua',
}

build = {
type = 'rust-mlua',
modules = {
'blink_cmp_fuzzy',
},
install = {
lua = {
['blink-cmp.init'] = 'lua/blink-cmp.lua',
},
},
default_features = false,
features = { 'lua51' },
}
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading