this post was submitted on 16 Nov 2023
1 points (100.0% liked)

Emacs

342 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 2 years ago
MODERATORS
top 7 comments
sorted by: hot top controversial new old
[–] edkolev@alien.top 1 points 2 years ago

I use go-ts-mode on a daily basis!

When I switched to go-ts-mode I found a missing feature - so I contributed it! Here it is:

"Extend go-ts-mode with command to add docstring to function"

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f0971f94fe42224b4d85bb8b6188d5d805689ddf

I've done similar contributions - I encourage you do to the same if there's a feature that you need

https://git.savannah.gnu.org/cgit/emacs.git/log/?qt=author&q=Evgeni+Kolev

[–] cradlemann@alien.top 1 points 2 years ago (1 children)

You setup looks not so optimal. Here is mine

(use-package go-mode
  :ensure t
  :mode "\\.go\\'"
  :preface
  (defun vd/go-lsp-start()
               (add-hook 'before-save-hook #'lsp-format-buffer t t)
               (add-hook 'before-save-hook #'lsp-organize-imports t t)
               (lsp-deferred)
               )
  :hook
  (go-ts-mode . vd/go-lsp-start)
  :bind
  (:map go-ts-mode-map
        ("RET" . newline-and-indent)
        ("M-RET" . newline)
        )
  :config
  (add-to-list 'exec-path "~/.local/bin")
  (setq lsp-go-analyses '(
                          (nilness . t)
                          (shadow . t)
                          (unusedwrite . t)
                          (fieldalignment . t)
                                       )
        lsp-go-codelenses '(
                          (test . t)
                          (tidy . t)
                          (upgrade_dependency . t)
                          (vendor . t)
                          (run_govulncheck . t)
                                       )
        )
)

(use-package go-tag
  :ensure t
)

(use-package godoctor
  :ensure t
)
[–] 404cn@alien.top 1 points 2 years ago (1 children)

It's wired after I config go-ts-indent-offset to 4, the indent after } and ) still indent 8 spaces(I think it's from electric-indent-mode), and content after treesit-check-indent also use 8 spaces, but bind RET to newline-and-indent is a workaround for me now, thanks.

[–] 404cn@alien.top 1 points 2 years ago (1 children)

Sorry, but after type ( it still indent current line to 8 space(not RET), I'm going to report a bug to emacs devel.

[–] cradlemann@alien.top 1 points 2 years ago

It works fine with (electric-indent-mode -1) and

  :custom
  (go-ts-mode-indent-offset 4)
[–] mekeor@alien.top 1 points 2 years ago

Does anybody else have problems with go-ts-mode, especially when invoking fill-paragraph in a comment?

[–] maksim77@alien.top 1 points 2 years ago

I may be wrong, but placing the (add-to-list 'treesit-language-source-alist blocks in the :init section will cause an error if you just place the entire use-package construct in an empty config. After all, at the init stage these alists are not there yet.