From 3e589723b255be6dff229b7e847f3722f49eb0bf Mon Sep 17 00:00:00 2001 From: Gerard Vermeulen Date: Tue, 25 Apr 2023 20:56:10 +0200 Subject: [PATCH] Start to play with Go, Gopls, and `go-ts-mode' --- README.org | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 10931db..188ebf9 100644 --- a/README.org +++ b/README.org @@ -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)]]