Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2019 19:21
What would you like to do?
Emacs LSP & yasnippet config
;;; go-config.el --- Summary
;;; Commentary:
;;; Code:
(setenv "GOPATH" "/home/sean/Code/Go")
(use-package go-mode
:ensure t
:defer t
:mode "\\.go\\'"
:bind (:map go-mode-map
("C-c i" . go-goto-imports)
("C-c C-r" . go-remove-unused-imports)
("C-c C-t" . go-test-current-file)
("M-." . godef-jump))
(add-hook 'before-save-hook 'gofmt-before-save)
(use-package dap-go)
(use-package godoc
:bind (:map go-mode-map ("C-c C-k" . godoc-at-point)))
(use-package go-add-tags
:ensure t
:bind (:map go-mode-map ("C-c '" . go-add-tags))
:commands go-add-tags)
(use-package go-eldoc
:ensure t
(add-hook 'go-mode-hook 'go-eldoc-setup))
(use-package helm-go-package
:ensure t
(substitute-key-definition 'go-import-add 'helm-go-package go-mode-map))
(use-package go-playground
:ensure t)
(use-package go-direx
:ensure t
:bind (:map go-mode-map
("C-c C-j" . go-direx-pop-to-buffer))))
(provide 'go-config)
;;; go-config.el ends here
;;; lsp-config.el --- Summary
;;; Commentary:
;;; Code:
(message "Loading lsp config")
(use-package lsp-mode
:ensure t
:commands lsp
:defer t
:hook (go-mode . lsp)
(setq lsp-eldoc-enable-hover t
lsp-eldoc-enable-signature-help t
lsp-eldoc-prefer-signature-help t
lsp-response-timeout 5)
(unless (executable-find "/home/sean/Code/Go/bin/gopls")
(user-error "Go LSP server is not on PATH\n"))
(add-hook 'prog-mode-hook #'lsp)
(setq lsp-prefer-flymake :none))
(use-package lsp-ui
:ensure t
:defer t
:commands lsp-ui-mode
(setq lsp-ui-doc-enable nil
lsp-ui-doc-max-width 70
lsp-ui-peek-enable t
lsp-ui-peek-always-show nil
lsp-ui-sideline-enable nil))
(use-package company-lsp
:ensure t
:defer t
:commands company-lsp
(push 'company-lsp company-backends))
(provide 'lsp-config)
;;; lsp-config.el ends here
;;; yasnippet-config -- Summary
;;; Commentary:
;;; Code:
(message "Loading yasnippet config")
(use-package yasnippet
:ensure t
:diminish yas-minor-mode
:bind (:map yas-minor-mode-map
("C-c C-e" . yas-expand))
(add-hook 'prog-mode-hook #'yas-minor-mode)
;;(yas-global-mode 1)
(setq yas-prompt-functions '(yas-dropdown-prompt
(provide 'yasnippet-config)
;;; yasnippet-config.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment