Hdoc1509/gh-actions.nvim

github github
syntax
stars 6
issues 0
subscribers 0
forks 0
CREATED

UPDATED


gh-actions.nvim

Plugin that improves support for Github Actions files in Neovim.

Github Actions Expression syntax highlight

Features

Requirements

Install

lazy.nvim

{
  "nvim-treesitter/nvim-treesitter",
  branch = 'main',
  dependencies = { "Hdoc1509/gh-actions.nvim" },
  config = function()
    -- NOTE: register parser before installation
    require("gh-actions.tree-sitter").setup()

    require("nvim-treesitter").install({
      "gh_actions_expressions", -- required
      "gitignore", -- optional
      "json", -- optional
      "yaml", -- required
    })
  end,
}

packer.nvim

use({
  "nvim-treesitter/nvim-treesitter",
  branch = 'main',
  requires = { "Hdoc1509/gh-actions.nvim" },
  config = function()
    -- NOTE: register parser before installation
    require("gh-actions.tree-sitter").setup()

    require("nvim-treesitter").install({
      "gh_actions_expressions", -- required
      "gitignore", -- optional
      "json", -- optional
      "yaml", -- required
    })
  end,
})

Parser installation for previous nvim-treesitter versions

ensure_install of main branch

require("nvim-treesitter").setup({
  ensure_install = {
    "gh_actions_expressions", -- required
    "gitignore", -- optional
    "json", -- optional
    "yaml", -- required
  }
})

configs module of old master branch

require("nvim-treesitter.configs").setup({
  ensure_installed = {
    "gh_actions_expressions", -- required
    "gitignore", -- optional
    "json", -- optional
    "yaml", -- required
  }
})

is-gh-actions-file? predicate

Check if the buffer matches the pattern .github/workflows/*.ya?ml.

LSP configuration

The gh-actions.ts-query-ls module exports a configuration for ts_query_ls server in order to register the custom is-gh-actions-file? predicate used by this plugin.

[!NOTE] This is only needed if you will use the is-gh-actions-file? predicate in your queries.

nvim-lspconfig + neovim < 0.11

[!IMPORTANT] Be sure to set gh-actions.nvim as a dependency

local lspconfig = require('lspconfig')
local gh_actions = require('gh-actions.ts-query-ls')

lspconfig.ts_query_ls.setup(vim.tbl_deep_extend('force', {
  -- your settings
}, gh_actions.expressions))

vim.lsp.config + neovim >= 0.11

local gh_actions = require('gh-actions.ts-query-ls')

vim.lsp.config('ts_query_ls', vim.tbl_deep_extend('force', {
  -- your settings
}, gh_actions.expressions))
vim.lsp.enable('ts_query_ls')

<rtp>/lsp/ts_query_ls.lua + neovim >= 0.11

[!IMPORTANT] <rtp> is your runtimepath

local gh_actions = require('gh-actions.ts-query-ls')

return vim.tbl_deep_extend('force', {
  -- your settings
}, gh_actions.expressions)

Then, in your init.lua:

vim.lsp.enable('ts_query_ls')

Troubleshooting

[!IMPORTANT] Be sure to run :checkhealth vim.treesitter before checking the following errors.

Incompatible ABI version

If you found the following error:

- ERROR Parser "gh_actions_expressions" failed to load
  (path: .../gh_actions_expressions.so): ...: ABI version mismatch for
  .../gh_actions_expressions.so: supported between X and Y, found Z

[!NOTE] X and Y are the interval of ABI versions supported by neovim. Z is the ABI version that was used to develop the parser.

  1. Install the following tools:

  2. Add the from_grammar option to the setup function of the gh-actions.tree-sitter module:

    require("gh-actions.tree-sitter").setup({ from_grammar = true })
    
  3. Reload your neovim config.

  4. Run :TSInstall gh_actions_expressions to re-install the parser with the correct ABI version.

Errors not related to neovim

Check the Troubleshooting section of tree-sitter-gh-actions-expressions.

Updates

This plugin will follow changes of tree-sitter-gh-actions-expressions: