machine_setup/ansible/roles/emacs/files/elisp/lang-go.el
2023-09-14 15:47:30 -04:00

34 lines
1.0 KiB
EmacsLisp

(require 'common-lsp)
(require 'util-tree-sitter)
(use-package go-ts-mode
:pin manual
:mode (
("\\.go\\'" . go-ts-mode)
("/go\\.mod\\'" . go-mod-ts-mode)
)
:commands (go-ts-mode go-mod-ts-mode)
:hook (
(go-ts-mode . (lambda ()
(when-linux
(eglot-ensure)
)
))
(go-mod-ts-mode . (lambda ()
(when-linux
(eglot-ensure)
)
))
;; (before-save . lsp-format-buffer)
)
:init
(add-to-list 'treesit-language-source-alist '(go "https://github.com/tree-sitter/tree-sitter-go"))
(add-to-list 'treesit-language-source-alist '(gomod "https://github.com/camdencheek/tree-sitter-go-mod"))
(unless (treesit-ready-p 'go) (treesit-install-language-grammar 'go))
(unless (treesit-ready-p 'gomod) (treesit-install-language-grammar 'gomod))
)
(provide 'lang-go)