                           (agenda    . 5)
                           (projects  . 10))))
 
+;; Enable go-mode
+(use-package go-mode
+  :ensure t
+  :mode ("\\.go\\'" . go-mode))
+
+;; Set up before-save hooks to format buffer and add/delete imports.
+;; Make sure you don't have other gofmt/goimports hooks enabled.
+(defun lsp-go-install-save-hooks ()
+  (add-hook 'before-save-hook #'lsp-format-buffer t t)
+  (add-hook 'before-save-hook #'lsp-organize-imports t t))
+(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
+
 ;; Setup flycheck for syntax checking
 (use-package flycheck
   :ensure t

;; LSP mode for all the things
(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-execute-code-action)
  :hook ((go-mode . lsp-deferred)
         (lsp-mode . lsp-enable-which-key-integration)
         (lsp-mode . lsp-modeline-disagnostics-mode))
  :bind ("C-c C-c" . #'lsp-execute-code-action)
  :custom
  (lsp-print-performance t)
  (lsp-log-io t)
  (lsp-diagnostics-modeline-scope :project)
  (lsp-file-watch-threshold 5000)
  (lsp-enable-file-watchers nil))

(use-package lsp-ui
  :ensure t

  :ensure t
  :custom (company-lsp-enable-snippet t)
  :after (company lsp-mode))

;; Optional - provides snippet support.
(use-package yasnippet
  :ensure t
  :commands yas-minor-mode
  :hook (go-mode . yas-minor-mode))

(setq lsp-ui-doc-enable nil
      lsp-ui-peek-enable t
      lsp-ui-sideline-enable t
      lsp-ui-imenu-enable t
      lsp-ui-flycheck-enable t)

;; org mode configuration
(use-package org
