Start to play with Go, Gopls, and `go-ts-mode'

This commit is contained in:
Gerard Vermeulen 2023-04-25 20:56:10 +02:00
parent d1a0628fcd
commit 3e589723b2
1 changed files with 9 additions and 2 deletions

View File

@ -376,6 +376,8 @@ the contents of packages and allows to update packages to the latest version.
#+begin_src emacs-lisp -n :results silent
(when (require 'treesit nil 'noerror)
(setopt
;; Set `tab-width' in `after-change-major-mode-hook' function too.
go-ts-mode-indent-offset 2
treesit-language-source-alist
'((bash "https://github.com/tree-sitter/tree-sitter-bash" "master" "src")
(c "https://github.com/tree-sitter/tree-sitter-c" "master" "src")
@ -383,7 +385,9 @@ the contents of packages and allows to update packages to the latest version.
(cpp "https://github.com/tree-sitter/tree-sitter-cpp" "master" "src")
(css "https://github.com/tree-sitter/tree-sitter-css" "master" "src")
(glsl "https://github.com/theHamsta/tree-sitter-glsl" "master" "src")
;; go-ts-mode requires libtree-sitter-go and libtree-sitter-gomode.
(go "https://github.com/tree-sitter/tree-sitter-go" "master" "src")
(gomod "https://github.com/camdencheek/tree-sitter-go-mod" "main" "src")
(html "https://github.com/tree-sitter/tree-sitter-html" "master" "src")
(java "https://github.com/tree-sitter/tree-sitter-java" "master" "src")
(javascript "https://github.com/tree-sitter/tree-sitter-javascript"
@ -405,8 +409,11 @@ the contents of packages and allows to update packages to the latest version.
"master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml" "master" "src")))
(add-to-list 'auto-mode-alist
`(,(rx ".py" (opt (any "iw")) eos) . python-ts-mode)))
(add-hook 'after-change-major-mode-hook
(defun on-go-ts-mode-hook ()
(when (derived-mode-p 'go-ts-mode 'go-mod-ts-mode)
(setq-local tab-width 2))))
(add-to-list 'auto-mode-alist `(,(rx ".go" eos) . go-ts-mode)))
#+end_src
* [[info:emacs#Faces][Text faces or styles (info)]]