mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-02 14:53:38 -05:00
refactor(lua): DRY tree-sitter config
This commit is contained in:
@@ -7,22 +7,23 @@
|
|||||||
;;
|
;;
|
||||||
;;; Major modes
|
;;; Major modes
|
||||||
|
|
||||||
|
(defun +lua-common-config (mode)
|
||||||
|
(set-lookup-handlers! mode :documentation 'lua-search-documentation)
|
||||||
|
(set-electric! mode :words '("else" "end"))
|
||||||
|
(set-repl-handler! mode #'+lua/open-repl)
|
||||||
|
(set-company-backend! mode '(company-lua company-yasnippet))
|
||||||
|
(when (modulep! +lsp)
|
||||||
|
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append)
|
||||||
|
(when (modulep! :tools lsp +eglot)
|
||||||
|
(set-eglot-client! mode (+lua-generate-lsp-server-command)))))
|
||||||
|
|
||||||
|
|
||||||
(use-package! lua-mode
|
(use-package! lua-mode
|
||||||
:interpreter "\\<lua\\(?:jit\\)?"
|
:interpreter "\\<lua\\(?:jit\\)?"
|
||||||
:init
|
:init
|
||||||
;; lua-indent-level defaults to 3 otherwise. Madness.
|
(setq lua-indent-level 2) ; default is 3; madness!
|
||||||
(setq lua-indent-level 2)
|
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
|
(+lua-common-config 'lua-mode))
|
||||||
(set-electric! 'lua-mode :words '("else" "end"))
|
|
||||||
(set-repl-handler! 'lua-mode #'+lua/open-repl)
|
|
||||||
(set-company-backend! 'lua-mode '(company-lua company-yasnippet))
|
|
||||||
|
|
||||||
(when (modulep! +lsp)
|
|
||||||
(add-hook 'lua-mode-local-vars-hook #'lsp! 'append)
|
|
||||||
(when (modulep! :tools lsp +eglot)
|
|
||||||
(set-eglot-client! 'lua-mode (+lua-generate-lsp-server-command)))))
|
|
||||||
|
|
||||||
|
|
||||||
(use-package! lua-ts-mode
|
(use-package! lua-ts-mode
|
||||||
@@ -32,15 +33,7 @@
|
|||||||
:init
|
:init
|
||||||
(set-tree-sitter! 'lua-mode 'lua-ts-mode 'lua)
|
(set-tree-sitter! 'lua-mode 'lua-ts-mode 'lua)
|
||||||
:config
|
:config
|
||||||
(set-lookup-handlers! 'lua-ts-mode :documentation 'lua-search-documentation)
|
(+lua-common-config 'lua-ts-mode))
|
||||||
(set-electric! 'lua-ts-mode :words '("else" "end"))
|
|
||||||
(set-repl-handler! 'lua-ts-mode #'+lua/open-repl)
|
|
||||||
(set-company-backend! 'lua-ts-mode '(company-lua company-yasnippet))
|
|
||||||
|
|
||||||
(when (modulep! +lsp)
|
|
||||||
(add-hook 'lua-ts-mode-local-vars-hook #'lsp! 'append)
|
|
||||||
(when (modulep! :tools lsp +eglot)
|
|
||||||
(set-eglot-client! 'lua-ts-mode (+lua-generate-lsp-server-command)))))
|
|
||||||
|
|
||||||
|
|
||||||
(use-package! moonscript
|
(use-package! moonscript
|
||||||
|
Reference in New Issue
Block a user