Skip to content

Neovim plugin plugin to provide syntax highlighting for Hygen templates

Notifications You must be signed in to change notification settings

Hdoc1509/hygen.nvim

Repository files navigation

hygen.nvim

Neovim plugin that integrates tree-sitter-hygen-template to provide syntax highlighting for Hygen templates.

Hygen template with Markdown parser injected

Hygen template with Markdown parser injected

Features

  • Syntax highlighting for Hygen templates.
  • Dynamic parser injection based on file extension (see dynamic injection)

Requirements

Install

{
  {
    -- tree-sitter stuff
    "nvim-treesitter/nvim-treesitter",
    dependencies = {
      -- latest commit
      "Hdoc1509/hygen.nvim",
      -- specific release
      -- { "Hdoc1509/hygen.nvim", tag = "vX.X.X"  },
      -- { "Hdoc1509/hygen.nvim", version = "X.X.X"  },
    },
    config = function()
      -- NOTE: call this before calling `nvim-treesitter.configs.setup()`
      require("hygen.tree-sitter").setup()

      require("nvim-treesitter.configs").setup({
        ensure_installed = {
          -- other parsers
          "bash", -- optional
          "embedded_template", -- required
          "javascript", -- optional
          "hygen_template", -- required
        },
        -- other options
      })
    end,
  },
  {
    -- nvim-web-devicons stuff
    "nvim-tree/nvim-web-devicons",
    dependencies = {
      -- latest commit
      "Hdoc1509/hygen.nvim",
      -- specific release
      -- { "Hdoc1509/hygen.nvim", tag = "vX.X.X"  },
      -- { "Hdoc1509/hygen.nvim", version = "X.X.X"  },
    },
    config = function()
      require("nvim-web-devicons").setup({})
      require("hygen.web-devicons").setup()
    end,
  }
}
-- tree-sitter stuff
use {
  "nvim-treesitter/nvim-treesitter",
  requires = {
      -- latest commit
      "Hdoc1509/hygen.nvim",
      -- specific release
      -- { "Hdoc1509/hygen.nvim", tag = "vX.X.X"  },
  },
  config = function()
    -- NOTE: call this before calling `nvim-treesitter.configs.setup()`
    require("hygen.tree-sitter").setup()

    require("nvim-treesitter.configs").setup({
      ensure_installed = {
        -- other parsers
        "bash", -- optional
        "embedded_template", -- required
        "javascript", -- optional
        "hygen_template", -- required
      },
      -- other options
    })
  end,
}

-- nvim-web-devicons stuff
use {
  "nvim-tree/nvim-web-devicons",
  requires = {
      -- latest commit
      "Hdoc1509/hygen.nvim",
      -- specific release
      -- { "Hdoc1509/hygen.nvim", tag = "vX.X.X"  },
  },
  config = function()
    require("nvim-web-devicons").setup({})
    require("hygen.web-devicons").setup()
  end,
}

Filetype

This plugin will set filetype to hygen to all files that match the name pattern <file-name>.(ext).hygen.

Note

See file name pattern convention of tree-sitter-hygen-template for more information.

Dynamic injection

Dynamic injection is applied to template body, based on file extension.

Target parser to inject will be extracted from file.(ext).hygen.

Note

See dynamic injection of tree-sitter-hygen-template for more information.

file.ts.hygen

Hygen template with typescript parser injected

file.astro.hygen

Hygen template with astro parser injected

file.json.hygen

Hygen template with json parser injected

Updates

This plugin will follow changes of tree-sitter-hygen-template: