-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathpyrope.lua
More file actions
58 lines (56 loc) · 2.2 KB
/
Copy pathpyrope.lua
File metadata and controls
58 lines (56 loc) · 2.2 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- Pyrope syntax highlighting for Neovim via nvim-treesitter (main branch).
--
-- Drop this file into your lazy.nvim plugins directory, e.g.
-- ~/.config/nvim/lua/plugins/pyrope.lua
-- After restarting Neovim, run `:TSInstall pyrope` once.
--
-- For local grammar development, replace the url/branch below with a path:
-- install_info = {
-- path = vim.fn.expand("~/projs/tree-sitter-pyrope"),
-- queries = "queries",
-- },
-- Register the parser. nvim-treesitter's main branch reloads its parser table
-- from disk on every install/update (wiping runtime registrations) and re-fires
-- the `User TSUpdate` event so out-of-tree parsers can re-register. Registering
-- on that event -- not once at startup -- is what avoids the error
-- "skipping unsupported language: pyrope".
local function register_pyrope()
require("nvim-treesitter.parsers").pyrope = {
install_info = {
url = "https://github.com/masc-ucsc/tree-sitter-pyrope",
branch = "main",
queries = "queries", -- installs this repo's queries/*.scm automatically
},
}
end
return {
{
"nvim-treesitter/nvim-treesitter",
init = function()
vim.filetype.add({ extension = { prp = "pyrope" } })
vim.api.nvim_create_autocmd("User", {
pattern = "TSUpdate", -- fired by nvim-treesitter before every install/update
callback = register_pyrope,
})
-- Pyrope uses C-style comments (`//` and `/* */`); set commentstring so
-- `gc`/`gcc` commenting works (otherwise: "Option 'commentstring' is empty").
vim.api.nvim_create_autocmd("FileType", {
pattern = "pyrope",
callback = function(args)
vim.bo.commentstring = "// %s"
vim.lsp.start({
name = "livehd",
cmd = { "prplsp" }, -- on $PATH; falls back to `lgshell` outside a checkout
-- launch in the file's dir so prplsp detects an enclosing livehd checkout
cmd_cwd = vim.fn.fnamemodify(args.file, ":h"),
root_dir = vim.fn.getcwd(),
})
end,
})
end,
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "pyrope" })
end,
},
}