straight.el based, shorter, simplified, more lsp-mode based

This commit is contained in:
Łukasz Pankowski 2022-03-10 23:14:58 +01:00
parent a3ad94031c
commit 75cf4b8c52
3 changed files with 365 additions and 1051 deletions

1175
init.el

File diff suppressed because it is too large Load Diff

157
old-go.el
View File

@ -1,157 +0,0 @@
;;; #### Old Go setup ####
;;; <div class="warning">
;;; This is my old Go setup, you may try the <a href="#go">new setup
;;; (above)</a> based (partially) on <a
;;; href="https://github.com/golang/go/wiki/gopls">gopls</a> if the
;;; new one does not work for you try this one.
;;; </div>
;;; I used the following setup for the [go-mode] in my `~/.emacs.d/init.el`. This
;;; adds syntax highlighting but without fontifing names of called
;;; functions, autocompletion and [eldoc] support, auto formatting of the
;;; code on save with adding of missing imports ([goimports]).
;;; It is quite long as I define two interactive functions:
;;; 1. `my-go-electric-brace` which is bind to `{` key and inserts an
;;; indented pair of braces (if previous character is a space,
;;; otherwise it inserts single opening brace),
;;; 2. `my-godoc-package` which is bind to `C-c P` key and display
;;; documentation for a package choosen from a list of installed
;;; packages.
;;; [go-mode]: https://github.com/dominikh/go-mode.el
;;; [eldoc]: http://emacswiki.org/emacs/ElDoc
;;; [goimports]: https://godoc.org/golang.org/x/tools/cmd/goimports
(defun my-go-electric-brace ()
"Insert an opening brace may be with the closing one.
If there is a space before the brace also adds new line with
properly indented closing brace and moves cursor to another line
inserted between the braces between the braces."
(interactive)
(insert "{")
(when (looking-back " {")
(newline)
(indent-according-to-mode)
(save-excursion
(newline)
(insert "}")
(indent-according-to-mode))))
(defun my-godoc-package ()
"Display godoc for given package (with completion)."
(interactive)
(godoc (ivy-read "Package: " (go-packages) :require-match t)))
(use-package flycheck
:defer)
(use-package go-eldoc
:defer)
(use-package company-go
:defer)
(use-package go-guru
:after go-mode)
(use-package go-mode
:init
(setq gofmt-command "goimports" ; use goimports instead of gofmt
go-fontify-function-calls nil ; fontifing names of called
; functions is too much for me
company-idle-delay nil) ; avoid auto completion popup, use TAB
; to show it
:bind
(:map go-mode-map
("M-." . go-guru-definition)
("C-c d" . godoc-at-point)
("C-c g" . godoc)
("C-c h" . go-guru-hl-identifier)
("C-c P" . my-godoc-package)
("{" . my-go-electric-brace)
("C-i" . company-indent-or-complete-common)
("C-M-i" . company-indent-or-complete-common))
:config
;; run gofmt/goimports when saving the file
(add-hook 'before-save-hook #'gofmt-before-save)
(defun my-go-mode-hook-fn ()
(go-eldoc-setup)
(set (make-local-variable 'company-backends) '(company-go))
(company-mode)
(smartparens-mode 1)
(flycheck-mode 1)
(setq imenu-generic-expression
'(("type" "^type *\\([^ \t\n\r\f]*\\)" 1)
("func" "^func *\\(.*\\) {" 1))))
(add-hook 'go-mode-hook #'my-go-mode-hook-fn))
;; Go/speedbar integration
(eval-after-load 'speedbar
'(speedbar-add-supported-extension ".go"))
;;; Now, in go buffers you can use `M-.` to jump to the definition of
;;; the identifier at point (use `M-,` to jump back as for normal tags
;;; in Emacs 25.1) and you can also use `C-c C-d` for a short
;;; description of the identifier at point (actually it is constantly
;;; displayed in the mode line by enabled Go [eldoc] support). You can
;;; use `C-c d` for a longer description of the identifier at point.
;;; For this to work you have to
;;; 1. Install [from MELPA](#add-melpa-package-list) the following Emacs
;;; packages: [go-mode], [company-go], [go-eldoc], and [go-guru].
;;; 2. Install Go compiler. Under Debian you may install `golang` package
;;; (but in Debian 10 Buster it is 1.11 compared to the current 1.14,
;;; so you may consider
;;; [downloading the current version of Go](https://golang.org/dl/)). Otherwise
;;; search for the package for your system or
;;; see [Getting started](https://golang.org/doc/install).
;;; 3. Install [godef](https://godoc.org/github.com/rogpeppe/godef)
;;; with
;;; ```
;;; $ go get github.com/rogpeppe/godef
;;; ```
;;; 4. Install [goimports] which can be installed from Debian package
;;; `golang-go.tools` or with
;;; ```
;;; $ go get golang.org/x/tools/cmd/goimports
;;; ```
;;; 5. Install [gocode](https://github.com/stamblerre/gocode) (a fork
;;; with Go modules support) which can be installed with
;;; ```
;;; $ go get -u github.com/stamblerre/gocode
;;; ```
;;; 6. Install [guru](https://godoc.org/golang.org/x/tools/cmd/guru)
;;; with
;;; ```
;;; $ go get golang.org/x/tools/cmd/guru
;;; ```
;;; 7. Add your `$GOPATH/bin` to your `PATH` environment variable (or copy
;;; the `godef`, `goimports`, `gocode`, and `guru` executables from
;;; `$GOPATH/bin` to some directory which is in your `PATH`).
;;; See also
;;; [Writing Go in Emacs](http://dominik.honnef.co/posts/2013/03/writing_go_in_emacs/)
;;; for more info.
;;; [company-go]: https://melpa.org/#/company-go
;;; [go-eldoc]: https://melpa.org/#/go-eldoc
;;; [go-guru]: https://melpa.org/#/go-guru

View File

@ -0,0 +1,84 @@
(("Emacs-D-Mode" . "199743df55c6bfce3cdb08405bd8519768c8dfa9")
("ace-jump-mode" . "8351e2df4fbbeb2a4003f2fb39f46d33803f3dac")
("ace-window" . "0577c426a9833ab107bab46c60d1885c611b2fb9")
("all-the-icons-dired" . "147ed0dfd1034a686795a08dc63e2c293128597e")
("all-the-icons-ivy-rich" . "328047e1b107baa1f7df3c706000a1ec9e8f51db")
("all-the-icons.el" . "2c963ebb75f211d2f7ac3d2db5f4a9ee2f3e27da")
("apropospriate-theme" . "1761bf480cd62859e452ca492b69f09024bb308a")
("avy" . "ba5f035be33693d1a136a5cbeedb24327f551a92")
("bui.el" . "f3a137628e112a91910fd33c0cff0948fa58d470")
("cfrs" . "f3a21f237b2a54e6b9f8a420a9da42b4f0a63121")
("company-mode" . "5e4cff936ea5e4365b799990e902b4a279f21bb4")
("ctrlf" . "38b5e94bf718eeea0b880a78ed52926dec89fea9")
("dap-mode" . "6933fca0b53ea5d2d65a0545e5a4ae6424d32e9b")
("dart-mode" . "3bac14200f9f8f8fcebc383087572da5c3823c34")
("dash.el" . "da167c51e9fd167a48d06c7c0ee8e3ac7abd9718")
("devdocs.el" . "cdc1a7cc3f05235883ffb098fe1c5a8963ed06e2")
("diff-hl" . "4a08b02afec1fc6b1e84de46cc34f75f6c9c3bcc")
("dired-hacks" . "7c0ef09d57a80068a11edc74c3568e5ead5cc15a")
("dired-sidebar" . "3635a36f4b4febc8e79e18a0684c8d031adffd92")
("el-get" . "9353309744e4f8a7c9b1adf22ec99536fb2146b0")
("elisp-refs" . "8f84280997d8b233d66fb9958a34b46078c58b03")
("emacs-ansible" . "d89ac0ee57742cca0f0e0a3453d9dcc521575690")
("emacs-faff-theme" . "f1a1cf6c900cccc2b189d49ed6bc4557cfb1593b")
("emacs-htmlize" . "dd27bc3f26efd728f2b1f01f9e4ac4f61f2ffbf9")
("emacs-libvterm" . "a940dd2ee8a82684860e320c0f6d5e15d31d916f")
("emacs-which-key" . "1217db8c6356659e67b35dedd9f5f260c06f6e99")
("emacsmirror-mirror" . "641994eed3590a39a778431a16758c2c041963a9")
("epl" . "78ab7a85c08222cd15582a298a364774e3282ce6")
("f.el" . "50af874cd19042f17c8686813d52569b1025c76a")
("flycheck" . "784f184cdd9f9cb4e3dbb997c09d93e954142842")
("git-messenger" . "eade986ef529aa2dac6944ad61b18de55cee0b76")
("git-timemachine" . "3381797bcbf906b18dff654a2361032d2d01b4a3")
("gnu-elpa-mirror" . "b9591336dc6ece42784901c4c00dded50be415fa")
("go-mode.el" . "3273fcece5d9ab7edd4f15b2d6bce61f4e5a0666")
("goto-chg" . "278cd3e6d5107693aa2bb33189ca503f22f227d0")
("helpful" . "67cdd1030b3022d3dc4da2297f55349da57cde01")
("ht.el" . "c4c1be487d6ecb353d07881526db05d7fc90ea87")
("hydra" . "9e9e00cb240ea1903ffd36a54956b3902c379d29")
("ivy-rich" . "600b8183ed0be8668dcc548cc2c8cb94b001363b")
("ivy-yasnippet" . "83402d91b4eba5307f71884a72df8e11cc6a994e")
("kotlin-mode" . "3e0c34087ba4965a8bf08d3f27325f0a1e631bfb")
("let-alist" . "592553db5929b54db40af0df90c5add0aaca045b")
("lsp-dart" . "40aa90d8ad0ec6d5f9682e135eefb794b675dc9a")
("lsp-mode" . "ec57aab424b881ead7a8cf7af977ca4db4bc04d8")
("lsp-treemacs" . "72d367757a89453a712f6ba1df9b6e789ece2bbd")
("lsp-ui" . "21ce926eedd41ef305c2d89412506ce59b1a7eac")
("magit" . "10b5407131d4299ca9ed038a23a3a41bcaac14fc")
("markdown-mode" . "521658eb32e456681592443e04ae507c3a59ed07")
("melpa" . "144364ae1ab127dd4e630a848741eb561e00ab24")
("meson-mode" . "1a2e2abb098c9288c2cdb3affbad76edd98abf59")
("multiple-cursors.el" . "8a60fc7ef0ae6e5ca089a7c95264cd0ae83e7274")
("pfuture" . "bde5b06795e3e35bfb2bba4c34b538d506a0856e")
("pkg-info" . "76ba7415480687d05a4353b27fea2ae02b8d9d61")
("popup-el" . "37a04117ac83b3ed24a2cba894443a32795c2f1a")
("posframe" . "c91d4d53fa479ceb604071008ce0a901770eff57")
("prescient.el" . "3dbcef387502d309d130a518a18d48cd2f0e15b7")
("project" . "4fe1eec8035969d59ab461eb1674343378182a0b")
("rainbow-mode" . "949166cc0146bc9fabf74ce70c1c4a097f4cffd4")
("restclient.el" . "9e2cfa86529133eba6c9ef53794be182f15e4c21")
("rich-minority" . "a03e693f6f9232cf75363aaaf1cb041f21675c19")
("rust-mode" . "26ecc903c50b2ffd289bbe981f9ad03626fc0057")
("rustic" . "f4b5c288af2a9833a104bc54850ddabe3996b8be")
("s.el" . "08661efb075d1c6b4fa812184c1e5e90c08795a9")
("smart-mode-line" . "abcb0ab6f7110a03d6c7428bae67cf8731496433")
("smartparens" . "37f77bf2e2199be9fe27e981317b02cfd0e8c70e")
("spinner" . "34905eae12a236753fa88abc831eff1e41e8576e")
("straight.el" . "af5437f2afd00936c883124d6d3098721c2d306c")
("swiper" . "c97ea72285f2428ed61b519269274d27f2b695f9")
("transient" . "45ef6df3fbc7f4fc87fd0db20b48334f61b521e0")
("treemacs" . "b18a05b1f62074a40e6011d83cd4c92cbee040dd")
("typescript.el" . "88f317f0b6aef8f8d232e912fdbc679799580c56")
("use-package" . "a7422fb8ab1baee19adb2717b5b47b9c3812a84c")
("vala-mode" . "d696a8177e94c81ea557ad364a3b3dcc3abbc50f")
("web-mode" . "f70277774a725e177774cc81ecbd228792cd6656")
("windswap" . "1a334f6543e0a30c55ea1e6071e9732d948f9e4b")
("with-editor" . "f514f23258af67a10fc8e1c431bfe94702b6e65b")
("ws-butler" . "e3a38d93e01014cd47bf5af4924459bd145fd7c4")
("xref" . "2cc73a20741be0e6eb698060a0e14f2cdf3953a7")
("xterm-color" . "1a4012854c69a5cdaeb5a73d2ad705011892fca3")
("yaml-mode" . "535273d5a1eb76999d20afbcf4d9f056d8ffd2da")
("yasnippet" . "5cbdbf0d2015540c59ed8ee0fcf4788effdf75b6")
("yasnippet-snippets" . "b7c09f1ad7e1a62da6f6042bfaa2b26d111c7e81")
("zenburn-emacs" . "cef1e26146c1b8b32fc5ce346f2cfa9861eb67d4"))
:beta