Skip to content

Commit

Permalink
Update injections format
Browse files Browse the repository at this point in the history
The old format was deprecated by neovim.
  • Loading branch information
stsewd committed Aug 25, 2023
1 parent ec53a6e commit bf48f58
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions after/queries/rst/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,79 @@

((directive
name: (type) @_type
body: (body (content) @rst))
body: (body (content) @injection.content))
(#any-of?
@_type
"toctree"
"versionadded" "versionchanged" "deprecated" "seealso" "centered" "hlist"
"glossary"
"index"
"productionlist"))
"productionlist")
(#set! injection.language "rst"))

((directive
name: (type) @_type
body: (body (arguments) @rst))
(#any-of? @_type "sectionauthor" "codeauthor"))
body: (body (arguments) @injection.content))
(#any-of? @_type "sectionauthor" "codeauthor")
(#set! injection.language "rst"))

;; Code highlight directives
((directive
name: (type) @_type
body: (body (arguments) @language (content) @content))
body: (body (arguments) @injection.language (content) @injection.content))
(#eq? @_type "highlight"))

;; Most directives from domains accept nested content
((directive
name: (type) @_type
body: (body (content) @rst))
(#match? @_type "^(py|c|cpp|js|rst):"))
body: (body (content) @injection.content))
(#match? @_type "^(py|c|cpp|js|rst):")
(#set! injection.language "rst"))

((directive
name: (type) @_type
body: (body (content) @rst))
(#any-of? @_type "default-domain" "option" "envar" "program" "describe" "object"))
body: (body (content) @injection.content))
(#any-of? @_type "default-domain" "option" "envar" "program" "describe" "object")
(#set! injection.language "rst"))

;; Directives from common extensions

;;; Sphinx docs
((directive
name: (type) @_type
body: (body (content) @rst))
(#eq? @_type "confval"))
body: (body (content) @injection.content))
(#eq? @_type "confval")
(#set! injection.language "rst"))

;;; sphinx-tabs
;;; https://github.com/executablebooks/sphinx-tabs
((directive
name: (type) @_type
body: (body (content) @rst))
(#any-of? @_type "tabs" "tab" "group-tab"))
body: (body (content) @injection.content))
(#any-of? @_type "tabs" "tab" "group-tab")
(#set! injection.language "rst"))

((directive
name: (type) @_type
body: (body (arguments) @language (content) @content))
body: (body (arguments) @injection.language (content) @injection.content))
(#eq? @_type "code-tab"))

;;; http domain
;;; https://sphinxcontrib-httpdomain.readthedocs.io/
((directive
name: (type) @_type
body: (body (content) @rst))
(#match? @_type "^(http):"))
body: (body (content) @injection.content))
(#match? @_type "^(http):")
(#set! injection.language "rst"))

((directive
name: (type) @_type
body: (body (arguments) @language (content) @content))
body: (body (arguments) @injection.language (content) @injection.content))
(#eq? @_type "sourcecode"))

;;; sphinx-prompt
;;; https://github.com/sbrunner/sphinx-prompt
((directive
name: (type) @_type
body: (body (arguments) @language (content) @content))
body: (body (arguments) @injection.language (content) @injection.content))
(#eq? @_type "prompt"))

0 comments on commit bf48f58

Please sign in to comment.