machine_setup/ansible/roles/emacs/files/elisp/lang-go.el

34 lines
1.0 KiB
EmacsLisp
Raw Normal View History

2022-10-20 04:03:56 +00:00
(require 'common-lsp)
(require 'util-tree-sitter)
2023-05-27 19:39:09 +00:00
(use-package go-ts-mode
:pin manual
:mode (
("\\.go\\'" . go-ts-mode)
2023-09-14 19:47:30 +00:00
("/go\\.mod\\'" . go-mod-ts-mode)
2023-05-27 19:39:09 +00:00
)
2023-09-14 19:47:30 +00:00
:commands (go-ts-mode go-mod-ts-mode)
2022-10-20 04:03:56 +00:00
:hook (
2023-05-27 19:19:08 +00:00
(go-ts-mode . (lambda ()
(when-linux
(eglot-ensure)
)
2023-09-14 19:47:30 +00:00
))
(go-mod-ts-mode . (lambda ()
(when-linux
(eglot-ensure)
)
))
2022-10-20 04:03:56 +00:00
;; (before-save . lsp-format-buffer)
)
2023-05-27 19:19:08 +00:00
: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))
2022-10-20 04:03:56 +00:00
)
(provide 'lang-go)