2020-02-23 05:34:35 +00:00
|
|
|
;;; go-init --- The entry point for golang extension
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defun fg42-go-hook ()
|
2020-02-23 19:44:15 +00:00
|
|
|
;; move to action
|
2020-02-23 18:27:41 +00:00
|
|
|
"Set's up emacs hooks and turn necessary modes on."
|
2020-11-11 12:32:40 +00:00
|
|
|
(lsp-register-custom-settings
|
|
|
|
'(("gopls.completeUnimported" t t)
|
|
|
|
("gopls.staticcheck" t t)))
|
2021-03-02 21:23:38 +00:00
|
|
|
(setq lsp-headerline-breadcrumb-enable nil)
|
2020-02-23 05:34:35 +00:00
|
|
|
(lsp)
|
2020-02-23 17:56:58 +00:00
|
|
|
(with-ability yas
|
2020-08-08 11:30:36 +01:00
|
|
|
(yas-minor-mode-on))
|
|
|
|
(setq-local company-backends '(company-capf company-dabbrev company-dabbrev-code))
|
2020-02-23 05:34:35 +00:00
|
|
|
(add-hook 'before-save-hook #'lsp-format-buffer t t)
|
|
|
|
(add-hook 'before-save-hook #'lsp-organize-imports t t)
|
2021-03-02 21:23:38 +00:00
|
|
|
;; (add-hook 'before-save-hook #'eglot-format t t)
|
|
|
|
;; (add-hook 'before-save-hook #' t t)
|
|
|
|
|
2020-02-23 05:34:35 +00:00
|
|
|
(local-set-key (kbd "M-.") #'godef-jump)
|
|
|
|
(local-set-key (kbd "M-*") 'pop-tag-mark))
|
|
|
|
|
|
|
|
|
2020-02-23 14:11:32 +00:00
|
|
|
|
2020-02-23 18:27:41 +00:00
|
|
|
(defun go-path ()
|
|
|
|
"Gets gopath from OS env."
|
|
|
|
(exec-path-from-shell-copy-env "GOPATH"))
|
|
|
|
(defun go-path-binary ()
|
|
|
|
"Gets Go binaries path."
|
|
|
|
(concat (go-path) "/bin"))
|
2020-02-23 16:27:37 +00:00
|
|
|
|
2020-02-23 05:34:35 +00:00
|
|
|
(defun extensions/go-initialize ()
|
2020-02-23 18:27:41 +00:00
|
|
|
"Initialize Golang extension."
|
2020-02-23 18:09:37 +00:00
|
|
|
(exec-path-from-shell-initialize)
|
2020-02-23 14:11:32 +00:00
|
|
|
(add-to-list 'exec-path (go-path-binary))
|
2020-02-23 05:34:35 +00:00
|
|
|
(add-hook 'go-mode-hook 'fg42-go-hook))
|
|
|
|
|
|
|
|
(provide 'extensions/go/init)
|
|
|
|
;;; init ends here.
|