feat(nvim): integrate typst

This commit is contained in:
Price Hiller 2024-01-07 00:57:45 -06:00
parent faf51c679a
commit 9d8089a6a7
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
4 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,79 @@
;; 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) @text.math

View File

@ -429,6 +429,7 @@ return {
"vimls",
"marksman",
"asm_lsp",
"typst_lsp"
}) do
lspconfig[server].setup(server_opts)
end

View File

@ -126,6 +126,17 @@ return {
"RRethy/nvim-treesitter-endwise",
},
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" },

View File

@ -0,0 +1,7 @@
return {
{
"chomosuke/typst-preview.nvim",
ft = "typst",
build = function() require("typst-preview").update() end,
}
}