-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env -S nvim -u NONE -U NONE -N -i NONE -l | ||
|
||
vim.opt.rtp:append(vim.fs.joinpath(vim.fn.getcwd(), "nvim-treesitter")) | ||
|
||
local parser_configs = require("nvim-treesitter.parsers").configs | ||
for lang, config in pairs(parser_configs) do | ||
config.lang = lang | ||
end | ||
local parser_map = vim.iter(parser_configs) | ||
:filter(function(config) | ||
return config.filetype ~= nil | ||
end) | ||
:fold({}, function(acc, config) | ||
acc[config.filetype] = config.lang | ||
return acc | ||
end) | ||
|
||
local mod = ([==[ | ||
---@mod rocks_treesitter.ft_parser_map | ||
---@brief [[ | ||
--- | ||
---This module is generated. Do not edit by hand! | ||
--- | ||
---@brief ]] | ||
return %s | ||
]==]):format(vim.inspect(parser_map)) | ||
|
||
io.write(mod) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
--- | ||
name: Update filetype -> parser mappings | ||
|
||
# Prevent concurrent auto-commits | ||
concurrency: | ||
group: update-filetype-parser-mappings | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- '.github/scripts/echo-nvim-ts-ft-maps.lua' | ||
- .github/workflows/update-ft-ts-maps.yml | ||
schedule: | ||
# Runs at midnight | ||
- cron: "0 0 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-filetype-parser-mappings: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: nvim-treesitter/nvim-treesitter | ||
path: nvim-treesitter | ||
ref: main | ||
- uses: rhysd/action-setup-vim@v1 | ||
with: | ||
neovim: true | ||
version: nightly | ||
- name: Update tree-sitter parsers JSON | ||
run: | | ||
./.github/scripts/echo-nvim-ts-ft-maps.lua > lua/rocks_treesitter/ft_parser_map.lua | ||
- name: commit | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "chore: update filetype -> parser map" | ||
file_pattern: "lua/rocks_treesitter/ft_parser_map.lua" |