From 11844dde81c41bded54f2383b57f8eef406f2736 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 1 Jul 2023 11:08:06 +0200 Subject: feat(treesitter): bundle markdown parser and queries (#22481) * bundle split Markdown parser from https://github.com/MDeiml/tree-sitter-markdown * add queries from https://github.com/nvim-treesitter/nvim-treesitter/tree/main * upstream `#trim!` and `#inject-language!` directives Co-authored-by: dundargoc --- runtime/doc/news.txt | 5 ++++- runtime/doc/treesitter.txt | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) (limited to 'runtime/doc') diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 0a9b926b7f..5ee9cb7a14 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -101,6 +101,8 @@ The following new APIs and features were added. • Implemented LSP inlay hints: |vim.lsp.inlay_hint()| https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint +• Bundled Markdown parser for treesitter highlighting and folding. + ============================================================================== CHANGED FEATURES *news-changed* @@ -120,7 +122,8 @@ The following changes to existing APIs or features add new behavior. • Automatic linting of treesitter query files (see |ft-query-plugin|). Can be disabled via: >lua vim.g.query_lint_on = {} -< • Enabled treesitter highlighting for treesitter query files. +< + • Enabled treesitter highlighting for treesitter query files. • The `workspace/didChangeWatchedFiles` LSP client capability is now enabled by default. diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 28ab3ecd8e..7539417197 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -292,7 +292,39 @@ The following directives are built in: Example: >query ((identifier) @constant (#offset! @constant 0 1 0 -1)) < + `gsub!` *treesitter-directive-gsub!* + Transforms the content of the node using a Lua pattern. This will set + a new `metadata[capture_id].text`. + Parameters: ~ + {capture_id} + {pattern} + + Example: >query + (#gsub! @_node ".*%.(.*)" "%1") +< + `trim!` *treesitter-directive-trim!* + Trim blank lines from the end of the node. This will set a new + `metadata[capture_id].range`. + + Parameters: ~ + {capture_id} + + Example: >query + (#inject-language! @_lang) +< + `inject-language!` *treesitter-directive-inject-language!* + Set the injection language from the node text, interpreted first as a + language name, then (if a parser is not found) a filetype. Custom + aliases can be added via |vim.treesitter.language.register()|. This + will set a new `metadata[capture_id]['injection.language']`. + + Parameters: ~ + {capture_id} + + Example: >query + (#inject-language! @_lang) +< Further directives can be added via |vim.treesitter.query.add_directive()|. Use |vim.treesitter.query.list_directives()| to list all available directives. -- cgit