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

28 lines
906 B
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)
("/go\\.mod\\'" . go-ts-mode)
)
2023-05-27 19:19:08 +00:00
:commands (go-mode go-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)
)
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 'major-mode-remap-alist '(go-mode . go-ts-mode))
(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)