feat: improve tree-sitter syntax highlighting with named nodes
- Add aliases for keywords (VAR_INPUT, BEGIN, IF, etc.) as named nodes - Add aliases for built-in types (INT, BOOL, STRING, etc.) as type_builtin - Add aliases for constants (TRUE, FALSE) - Add aliases for operators (AND, OR, NOT, MOD) - Add prefix node for # variable prefix highlighting - Highlight FB instance names in calls - Highlight FB parameter names as properties - Update README with detailed syntax highlighting features - Update .gitignore for *.wasm files
This commit is contained in:
+31
-14
@@ -6,23 +6,40 @@ local M = {}
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- Add plugin to runtime path
|
||||
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/scl_lsp")
|
||||
|
||||
M.create_commands()
|
||||
|
||||
-- Treesitter parser config
|
||||
local has_ts, ts = pcall(require, "nvim-treesitter.parsers")
|
||||
if has_ts and ts.get_parser_configs then
|
||||
local ok, parser_config = pcall(ts.get_parser_configs)
|
||||
if ok and parser_config then
|
||||
parser_config.scl = {
|
||||
install_info = {
|
||||
files = { "src/parser.c" },
|
||||
generate_requires_npm = false,
|
||||
requires_generate_from_grammar = false,
|
||||
},
|
||||
filetype = "scl",
|
||||
}
|
||||
end
|
||||
-- Treesitter setup for Neovim 0.11+
|
||||
local function setup_treesitter()
|
||||
local lang = vim.treesitter.language
|
||||
local parser_path = "/home/lazar/dev/scl_lsp/src/parser.so"
|
||||
|
||||
-- Register the SCL language
|
||||
lang.add("scl", {
|
||||
path = parser_path,
|
||||
filetype = "scl",
|
||||
})
|
||||
end
|
||||
|
||||
pcall(setup_treesitter)
|
||||
|
||||
-- Install queries
|
||||
local queries_src = "/home/lazar/dev/scl_lsp/queries/highlights.scm"
|
||||
local queries_dest = vim.fn.stdpath("data") .. "/site/queries/scl/highlights.scm"
|
||||
if vim.fn.filereadable(queries_src) == 1 then
|
||||
vim.fn.mkdir(vim.fn.stdpath("data") .. "/site/queries/scl", "p")
|
||||
vim.fn.writefile(vim.fn.readfile(queries_src), queries_dest)
|
||||
end
|
||||
|
||||
-- Enable treesitter manually for SCL files - bypass LazyVim
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "scl",
|
||||
callback = function(args)
|
||||
vim.treesitter.start(args.buf, "scl")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Register blink.cmp source
|
||||
if opts.cmp then
|
||||
|
||||
Reference in New Issue
Block a user