(java-ts-mode "{" "}" "/[*/]" nil nil)
(js-mode "{" "}" "/[*/]" nil)
(js-ts-mode "{" "}" "/[*/]" nil)
- (lua-ts-mode "{\\|\\[\\[" "}\\|\\]\\]" "--" nil)
(mhtml-mode "{\\|<[^/>]*?" "}\\|</[^/>]*[^/]>" "<!--" mhtml-forward nil)
;; Add more support here.
)
(rx (or "function_declaration" "function_definition")))
(setq-local treesit-thing-settings
`((lua
- (function ,(rx (or "function_declaration"
- "function_definition")))
+ (function (or "function_declaration"
+ "function_definition"))
(keyword ,(regexp-opt lua-ts--keywords 'symbols))
- (loop-statement ,(rx (or "do_statement"
- "for_statement"
- "repeat_statement"
- "while_statement")))
+ (loop-statement (or "do_statement"
+ "for_statement"
+ "repeat_statement"
+ "while_statement"))
(sentence (or function
loop-statement
- ,(rx (or "assignment_statement"
- "comment"
- "field"
- "function_call"
- "if_statement"
- "return_statement"
- "variable_declaration"))))
+ comment
+ "assignment_statement"
+ "field"
+ "function_call"
+ "if_statement"
+ "return_statement"
+ "variable_declaration"))
(sexp (or function
keyword
loop-statement
- ,(rx (or "arguments"
- "parameters"
- "parenthesized_expression"
- "string"
- "table_constructor"))))
- (text "comment"))))
+ "arguments"
+ "parameters"
+ "parenthesized_expression"
+ "string"
+ "table_constructor"))
+ (list (or function
+ loop-statement
+ "arguments"
+ "parameters"
+ "table_constructor"
+ "parenthesized_expression"
+ ,(rx bos "if_statement" eos)))
+ (text (or comment "string"))
+ (comment ,(rx bos "comment" eos)))))
;; Imenu/Outline/Which-function.
(setq-local treesit-simple-imenu-settings
(require 'ert)
(require 'ert-font-lock)
(require 'ert-x)
+(require 'hideshow)
(require 'treesit)
(require 'which-func)
(should (equal "f" (which-function)))
(which-function-mode -1)))
+(ert-deftest lua-ts-test-hideshow ()
+ (skip-unless (treesit-ready-p 'lua t))
+ (with-temp-buffer
+ (insert-file-contents (ert-resource-file "hide-show.lua"))
+ (lua-ts-mode)
+ (hs-minor-mode)
+ (hs-hide-all)
+ (should (= 11 (length (overlays-in (point-min) (point-max)))))
+ (hs-show-all)
+ (should (= 0 (length (overlays-in (point-min) (point-max)))))
+ (hs-minor-mode -1)))
+
(provide 'lua-ts-mode-tests)
;;; lua-ts-mode-tests.el ends here