FG42/lib/extensions/go/init.el

37 lines
1.0 KiB
EmacsLisp
Raw Normal View History

;;; 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."
(lsp-register-custom-settings
'(("gopls.completeUnimported" t t)
("gopls.staticcheck" t t)))
(lsp)
2020-02-23 17:56:58 +00:00
(with-ability yas
(yas-minor-mode-on))
(setq-local company-backends '(company-capf company-dabbrev company-dabbrev-code))
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t)
(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
(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))
(add-hook 'go-mode-hook 'fg42-go-hook))
(provide 'extensions/go/init)
;;; init ends here.