Add: x12 AST

This commit is contained in:
2026-04-22 12:16:06 -05:00
parent 0c59342399
commit 92e6109ab6
6 changed files with 64 additions and 28 deletions
-1
View File
@@ -1 +0,0 @@
plugin/
+46
View File
@@ -0,0 +1,46 @@
-- Configure nvim-treesitter with defaults
require("nvim-treesitter").setup()
-- Register the custom x12 parser for the nvim-treesitter main branch API
vim.api.nvim_create_autocmd("User", {
pattern = "TSUpdate",
callback = function()
require("nvim-treesitter.parsers").x12 = {
install_info = {
url = "https://github.com/hugginsio/tree-sitter-x12",
files = {"src/parser.c"},
branch = "main",
generate_requires_npm = false,
requires_generate_from_grammar = false
},
filetype = "x12"
}
end
})
-- Explicitly trigger installation for the required parsers
require("nvim-treesitter").install({"bash", "c", "c_sharp", "diff", "go", "html", "javascript", "jsdoc", "json", "lua",
"luadoc", "luap", "markdown", "markdown_inline", "python", "query", "regex", "toml",
"tsx", "typescript", "vim", "vimdoc", "xml", "yaml", "x12"})
-- Automatically enable treesitter features for all buffers
local ts_group = vim.api.nvim_create_augroup("TreesitterStart", {
clear = true
})
vim.api.nvim_create_autocmd("FileType", {
group = ts_group,
callback = function(args)
-- Bypass treesitter if the file exceeds 200 MiB
local max_filesize = 200 * 1024 * 1024
local filepath = vim.api.nvim_buf_get_name(args.buf)
local ok, stats = pcall(vim.uv.fs_stat, filepath)
if ok and stats and stats.size > max_filesize then
return
end
-- Start treesitter highlighting
-- Using pcall prevents errors if a parser is missing for the current filetype
pcall(vim.treesitter.start, args.buf)
end
})
-27
View File
@@ -1,27 +0,0 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "javascript", "typescript", "go", "rust", "c", "lua", "vim", "vimdoc", "query" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (or "all")
-- ignore_install = { "javascript" },
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
highlight = {
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}
+7
View File
@@ -0,0 +1,7 @@
-- Register custom filetypes for EDI documents
vim.filetype.add({
extension = {
edi = "x12",
dat = "x12"
}
})
+1
View File
@@ -1,4 +1,5 @@
require("cole.remap")
require("cole.set")
require("cole.filetype")
require("cole.lazy")
+10
View File
@@ -0,0 +1,10 @@
(segment_header) @keyword
[
(element_separator)
(component_element_separator)
(segment_separator)
] @comment
(alphanumeric) @string
(numeric) @number