From d2e45f35c3b6607b7d9da373902837acd02fcd4a Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Wed, 18 Oct 2023 23:55:39 +0100 Subject: [PATCH] workflow: Create workflow for capturing neovim capabilities --- .github/workflows/capabilities-nvim.yml | 42 +++++++++++++++++++++++++ scripts/nvim-capabilities.lua | 21 +++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/capabilities-nvim.yml create mode 100644 scripts/nvim-capabilities.lua diff --git a/.github/workflows/capabilities-nvim.yml b/.github/workflows/capabilities-nvim.yml new file mode 100644 index 0000000..11985ab --- /dev/null +++ b/.github/workflows/capabilities-nvim.yml @@ -0,0 +1,42 @@ +name: Neovim Capabilities +on: + workflow_dispatch: + inputs: + version: + description: 'Version to capture capabilities for' + required: true + type: string + +jobs: + capture: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - run: | + gh release download ${{ inputs.version }} -p '*.appimage' -R neovim/neovim + ls -l + + chmod +x nvim.appimage + ./nvim.appimage -l scripts/nvim-capabilities.lua + + mv neovim_v*.json lib/pytest-lsp/pytest_lsp/clients/ + ls -l + + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + + git checkout -b neovim-${{ inputs.version }}-capabilities + git add lib/pytest-lsp/pytest_lsp/clients/ + git commit -m "Add client capabilities for Neovim ${{ inputs.version }}" + git push -u origin neovim-${{ inputs.version }}-capabilities + + gh pr create --base develop --fill + name: Capture Neovim Capailities + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/nvim-capabilities.lua b/scripts/nvim-capabilities.lua new file mode 100644 index 0000000..47b6e44 --- /dev/null +++ b/scripts/nvim-capabilities.lua @@ -0,0 +1,21 @@ +-- Dump the client capabilities for this version of neovim. +local version_info = vim.version() +local version = string.format('%d.%d.%d', version_info.major, version_info.minor, version_info.patch) + +local params = { + clientInfo = { + name = 'Neovim', + version = version, + }, + capabilities = vim.lsp.protocol.make_client_capabilities(), +} + +local json = vim.json.encode(params) +local bufnr = vim.api.nvim_create_buf(true, false) +vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { json }) + +vim.api.nvim_buf_call(bufnr, function() + vim.cmd(string.format(':w neovim_v%s.json', version)) + vim.cmd('.!python -m json.tool %') + vim.cmd(':w') +end)