mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
feat(go): add treesit support
This commit is contained in:
@ -3,19 +3,16 @@
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(after! go-mode
|
||||
(set-docsets! 'go-mode "Go")
|
||||
(set-repl-handler! 'go-mode #'gorepl-run)
|
||||
(set-lookup-handlers! 'go-mode
|
||||
(defun +go-common-config (mode)
|
||||
(set-docsets! mode "Go")
|
||||
(set-repl-handler! mode #'gorepl-run)
|
||||
(set-lookup-handlers! mode
|
||||
:documentation #'godoc-at-point)
|
||||
|
||||
(when (modulep! +lsp)
|
||||
(add-hook 'go-mode-local-vars-hook #'lsp! 'append))
|
||||
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append))
|
||||
|
||||
(when (modulep! +tree-sitter)
|
||||
(add-hook 'go-mode-local-vars-hook #'tree-sitter! 'append))
|
||||
|
||||
(map! :map go-mode-map
|
||||
(map! :map ,(symbol-value (intern (format "%s-map" mode)))
|
||||
:localleader
|
||||
"a" #'go-tag-add
|
||||
"d" #'go-tag-remove
|
||||
@ -47,10 +44,28 @@
|
||||
"a" #'+go/bench-all))))
|
||||
|
||||
|
||||
(after! go-mode
|
||||
(+go-common-config 'go-mode))
|
||||
|
||||
|
||||
(use-package! go-ts-mode
|
||||
:when (modulep! +tree-sitter)
|
||||
:when (fboundp 'go-ts-mode) ; 31.1+ only
|
||||
:defer t
|
||||
:init
|
||||
(set-tree-sitter! 'go-mode 'go-ts-mode
|
||||
'((go :url "https://github.com/tree-sitter/tree-sitter-go" :ref "v0.23.4")
|
||||
(gomod :url "https://github.com/camdencheek/tree-sitter-go-mod" :ref "v1.1.0")
|
||||
(gowork :url "https://github.com/omertuc/tree-sitter-go-work")))
|
||||
:config
|
||||
(+go-common-config 'go-ts-mode))
|
||||
|
||||
|
||||
(use-package! gorepl-mode
|
||||
:commands gorepl-run-load-current-file)
|
||||
|
||||
|
||||
(use-package! flycheck-golangci-lint
|
||||
:when (modulep! :checkers syntax -flymake)
|
||||
:hook (go-mode . flycheck-golangci-lint-setup))
|
||||
:hook (go-mode . flycheck-golangci-lint-setup)
|
||||
:hook (go-ts-mode . flycheck-golangci-lint-setup))
|
||||
|
@ -9,6 +9,10 @@
|
||||
(modulep! :tools tree-sitter))
|
||||
"This module requires (:tools tree-sitter)")
|
||||
|
||||
(assert! (or (not (modulep! +tree-sitter))
|
||||
(fboundp 'go-ts-mode))
|
||||
"Can't find `go-ts-mode'; Emacs 31.1+ is required")
|
||||
|
||||
(unless (executable-find "gore")
|
||||
(warn! "Couldn't find gore. REPL will not work"))
|
||||
|
||||
|
@ -43,8 +43,6 @@
|
||||
(commonlisp "https://github.com/tree-sitter-grammars/tree-sitter-commonlisp" nil nil nil nil)
|
||||
(css "https://github.com/tree-sitter/tree-sitter-css" nil nil nil nil)
|
||||
(dart "https://github.com/ast-grep/tree-sitter-dart" nil nil nil nil)
|
||||
(go "https://github.com/tree-sitter/tree-sitter-go" nil nil nil nil)
|
||||
(gomod "https://github.com/camdencheek/tree-sitter-go-mod" nil nil nil nil)
|
||||
(html "https://github.com/tree-sitter/tree-sitter-html" nil nil nil nil)
|
||||
(java "https://github.com/tree-sitter/tree-sitter-java" nil nil nil nil)
|
||||
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src" nil nil)
|
||||
|
Reference in New Issue
Block a user