refactor(nvim): use typst grammar from nvim-treesitter upstream
This commit is contained in:
parent
e1e757c3ae
commit
48ac528567
@ -1,11 +1,10 @@
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.api.nvim_set_hl(
|
||||
0,
|
||||
"@text.title.typst",
|
||||
"@markup.heading.typst",
|
||||
vim.tbl_deep_extend(
|
||||
"force",
|
||||
vim.api.nvim_get_hl(0, { name = "@text.title.typst", link = false }),
|
||||
vim.api.nvim_get_hl(0, { name = "@markup.heading", link = false }),
|
||||
{ underline = true, bold = true }
|
||||
)
|
||||
)
|
||||
vim.api.nvim_set_hl(0, "@text.emph.typst", { link = "@text.emphasis" })
|
||||
|
@ -1,80 +0,0 @@
|
||||
;; extends
|
||||
;; All scopes: comments
|
||||
(comment) @comment @spell
|
||||
|
||||
;; Code
|
||||
;; punctuation
|
||||
["#"] @punctuation.special
|
||||
[":" ";" ","] @punctuation.delimiter
|
||||
["(" ")" "{" "}"] @punctuation.bracket
|
||||
;; TODO: context blocks?
|
||||
[ "[" "]" ] @punctuation.bracket
|
||||
;; operators
|
||||
[
|
||||
"-"
|
||||
"+"
|
||||
"*"
|
||||
"/"
|
||||
|
||||
"=="
|
||||
"!="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
|
||||
"="
|
||||
|
||||
"in"
|
||||
"and"
|
||||
"or"
|
||||
"not"
|
||||
] @operator
|
||||
;; keywords
|
||||
[ "import" "include" ] @include
|
||||
[ "let" "set" "show" ] @keyword
|
||||
;; control flow
|
||||
[ "for" "while" "break" "continue" ] @repeat
|
||||
[ "if" "else" ] @conditional
|
||||
;; special case: #for (ident) in (expr)
|
||||
(for "in" @repeat)
|
||||
;; type literals
|
||||
(number) @number
|
||||
(string) @string
|
||||
(bool) @boolean
|
||||
;; identifiers
|
||||
(builtin) @namespace
|
||||
(ident) @identifier
|
||||
;; name-value pairs
|
||||
(tagged
|
||||
field: (ident)) @field
|
||||
;; function definitions, calls, etc.
|
||||
;; TODO: support for functions such as #calc.cos, tree view appears as
|
||||
;; (call)
|
||||
;; item: (field)
|
||||
;; (builtin)
|
||||
; field: (ident)
|
||||
(call
|
||||
item: (builtin)) @function.builtin
|
||||
(call
|
||||
item: (ident)) @function.call
|
||||
|
||||
;; Text
|
||||
(heading) @text.title
|
||||
(text) @text
|
||||
(strong) @text.strong
|
||||
(emph) @text.emph
|
||||
(url) @text.uri
|
||||
;; code blocks
|
||||
(raw_span) @text.literal
|
||||
(raw_span
|
||||
(blob)) @text.literal
|
||||
(raw_blck) @text.literal
|
||||
(raw_blck
|
||||
(blob)) @text.literal.block
|
||||
;; refs and labels
|
||||
(label) @text.reference
|
||||
(ref) @text.reference
|
||||
|
||||
;; Math
|
||||
(math) @markup.math
|
@ -1,6 +0,0 @@
|
||||
(raw_blck
|
||||
(blob) @injection.shebang @injection.content)
|
||||
|
||||
(raw_blck
|
||||
lang: (ident) @injection.language
|
||||
(blob) @injection.content)
|
@ -131,22 +131,12 @@ return {
|
||||
})
|
||||
end,
|
||||
config = function()
|
||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
parser_config.typst = {
|
||||
install_info = {
|
||||
url = "https://github.com/uben0/tree-sitter-typst",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
branch = "master",
|
||||
generate_requires_npm = true,
|
||||
},
|
||||
maintainers = { "uben0" },
|
||||
experimental = true,
|
||||
}
|
||||
require("nvim-treesitter.configs").setup({
|
||||
auto_install = true,
|
||||
ignore_install = { "comment" },
|
||||
ensure_installed = {
|
||||
"org",
|
||||
"latex",
|
||||
"regex",
|
||||
"vim",
|
||||
"lua",
|
||||
|
Loading…
Reference in New Issue
Block a user