From 3d248a690fdd9f9652550506aead2e9c2da117e0 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 23 May 2024 23:43:09 +0200 Subject: [PATCH] feat: luarocks/rocks.nvim support --- .github/workflows/luarocks.yml | 31 ++++++++++++++++++++ .github/workflows/release-please.yml | 22 ++++++++++++++ .github/workflows/rockspec.template | 33 +++++++++++++++++++++ Makefile | 8 +++++ lua/zf.lua | 4 +++ telescope-zf-native.nvim-scm-1.rockspec | 39 +++++++++++++++++++++++++ 6 files changed, 137 insertions(+) create mode 100644 .github/workflows/luarocks.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/rockspec.template create mode 100644 Makefile create mode 100644 telescope-zf-native.nvim-scm-1.rockspec diff --git a/.github/workflows/luarocks.yml b/.github/workflows/luarocks.yml new file mode 100644 index 0000000..0b6864a --- /dev/null +++ b/.github/workflows/luarocks.yml @@ -0,0 +1,31 @@ +--- +name: Push to Luarocks + +on: + push: + tags: + - '*' + release: + types: + - created + pull_request: # Test luarocks install without publishing on PR + workflow_dispatch: + +jobs: + luarocks-upload: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to count the commits + - name: Get Version + run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV + - name: LuaRocks Upload + uses: nvim-neorocks/luarocks-tag-release@v6 + env: + LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} + with: + version: ${{ env.LUAROCKS_VERSION }} + dependencies: | + telescope.nvim + template: .github/workflows/rockspec.template diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..3de4364 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,22 @@ +--- +permissions: + contents: write + pull-requests: write + +name: Release Please + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v4 + with: + release-type: simple + token: ${{ secrets.PAT }} diff --git a/.github/workflows/rockspec.template b/.github/workflows/rockspec.template new file mode 100644 index 0000000..a7c0339 --- /dev/null +++ b/.github/workflows/rockspec.template @@ -0,0 +1,33 @@ +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', + labels = $labels, + homepage = '$homepage', + $license +} + +source = { + url = repo_url .. '/archive/' .. git_ref .. '.zip', + dir = '$repo_name-' .. '$archive_dir_suffix', +} + +build = { + type = 'make', + build_pass = false, + install_variables = { + INST_PREFIX='$(PREFIX)', + INST_BINDIR='$(BINDIR)', + INST_LIBDIR='$(LIBDIR)', + INST_LUADIR='$(LUADIR)', + INST_CONFDIR='$(CONFDIR)', + }, +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..febb9f3 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +build: + echo "Do nothing" + +install: + mkdir -p $(INST_LUADIR) + mkdir -p $(INST_LIBDIR) + cp -r lua/* $(INST_LUADIR) + cp -r lib/* $(INST_LIBDIR) diff --git a/lua/zf.lua b/lua/zf.lua index a8a9328..db7cc6a 100644 --- a/lua/zf.lua +++ b/lua/zf.lua @@ -14,6 +14,10 @@ M.get_path = function() ext = "so" end + local libzf_path = package.searchpath(string.format("libzf-%s-%s", os, arch), package.cpath) + if libzf_path then + return libzf_path + end local dirname = string.sub(debug.getinfo(1).source, 2, #"/zf.lua" * -1) return dirname .. string.format("../lib/libzf-%s-%s.%s", os, arch, ext) end diff --git a/telescope-zf-native.nvim-scm-1.rockspec b/telescope-zf-native.nvim-scm-1.rockspec new file mode 100644 index 0000000..84dd60a --- /dev/null +++ b/telescope-zf-native.nvim-scm-1.rockspec @@ -0,0 +1,39 @@ +local MODREV, SPECREV = 'scm', '-1' +rockspec_format = '3.0' +package = 'telescope-zf-native.nvim' +version = MODREV .. SPECREV + +description = { + summary = 'native telescope bindings to zf for sorting results', + labels = { 'neovim', 'plugin', 'telescope', 'zf' }, + homepage = 'https://github.com/natecraddock/telescope-zf-native.nvim', + license = 'MIT', +} + +dependencies = { + 'lua >= 5.1', + 'telescope.nvim', +} + +source = { + url = 'https://github.com/natecraddock/telescope-zf-native.nvim/archive/refs/tags/' .. MODREV .. '.zip', + dir = 'telescope-fzf-native.nvim-' .. MODREV +} + +if MODREV == 'scm' then + source = { + url = 'git://github.com/natecraddock/telescope-zf-native.nvim', + } +end + +build = { + type = 'make', + build_pass = false, + install_variables = { + INST_PREFIX='$(PREFIX)', + INST_BINDIR='$(BINDIR)', + INST_LIBDIR='$(LIBDIR)', + INST_LUADIR='$(LUADIR)', + INST_CONFDIR='$(CONFDIR)', + }, +}