-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
25 lines (19 loc) · 901 Bytes
/
init.lua
File metadata and controls
25 lines (19 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local grammar_path = vim.fn.system("nix build .#tree-sitter-grammar --no-link --print-out-paths 2>/dev/null"):gsub("%s+$", "")
if vim.v.shell_error ~= 0 or grammar_path == "" then
vim.notify("sol: failed to build tree-sitter grammar via nix", vim.log.levels.ERROR)
return
end
vim.filetype.add({ extension = { sol = "sol" } })
local runtime_dir = vim.fn.stdpath("data") .. "/sol-treesitter"
vim.fn.mkdir(runtime_dir .. "/parser", "p")
vim.fn.mkdir(runtime_dir .. "/queries/sol", "p")
vim.uv.fs_copyfile(grammar_path .. "/parser", runtime_dir .. "/parser/sol.so")
local query_src = vim.fn.getcwd() .. "/tree-sitter/queries/highlights.scm"
vim.uv.fs_copyfile(query_src, runtime_dir .. "/queries/sol/highlights.scm")
vim.opt.runtimepath:prepend(runtime_dir)
vim.api.nvim_create_autocmd("FileType", {
pattern = "sol",
callback = function(ev)
vim.treesitter.start(ev.buf, "sol")
end,
})