 (require 'golint)
 
 ;;; Markdown mode support
-(autoload 'markdown-mode "markdown-mode"
-   "Major mode for editing Markdown files" t)
-(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
-(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
-(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
-
+(use-package markdown-mode
+  :commands (gfm-mode
+             markdown-mode)
+  :mode (("README\\.md\\'" . gfm-mode)
+         ("\\.md\\'" . markdown-mode)
+         ("\\.markdown\\'" . markdown-mode))
+  :init (setq markdown-command "multimarkdown"))
+
+
+
+(use-package yaml-mode
+  :mode ("\\.yml$" . yaml-mode))
+
+;;;; enable ibuffer and occur
+(use-package ibuffer
+  :bind
+  ("C-x C-b" . ibuffer)
+  ("C-c o" . occur)
+  )
+
+
+;; Turn on column line at 100 columns
+(use-package fill-column-indicator
+  :init
+  (setq-default fill-column 100)
+  :hook
+  ((c-mode
+    c++-mode
+    python-mode
+    yaml-mode
+    json-mode
+    markdown-mode) . fci-mode)
+  :commands fci-mode
+  )
+
+;; Get the path we would have in a terminal
+(use-package exec-path-from-shell
+  :config (exec-path-from-shell-initialize))
+
+;; pretty modeline
+(use-package all-the-icons)
+(use-package doom-modeline
+  :ensure t
+  :hook (after-init . doom-modeline-mode))
+
+;; suggest completions. Show help on potential completions for key sequence
+
+(use-package which-key
+  :diminish ""
+  :config
+  (which-key-mode))
+
+;;; Filladapt is a syntax-highlighting package.  When it is enabled it
+;;; makes filling (e.g. using M-q) much much smarter about paragraphs
+;;; that are indented and/or are set off with semicolons, dashes, etc.
+
+(use-package filladapt
+  :init
+  (setq-default filladapt-mode t)
+  :hook
+  (c-mode . turn-off-filladapt-mode)
+  (c++-mode . turn-off-filladapt-mode)
+  (outline-mode-hook . turn-off-filladapt-mode))
+
+(use-package ivy
+  :diminish ""
+  :init
+  (setq
+   enable-recursive-minibuffers t
+   ivy-use-virtual-buffers t)
+  (ivy-mode 1)
+  :bind
+  ("C-s" . swiper)
+  ("M-x" . counsel-M-x)
+  ("C-x C-f" . counsel-find-file)
+  ("<f1> f" . counsel-describe-function)
+  ("<f1> v" . counsel-describe-variable)
+  ("<f1> l" . counsel-find-library)
+  ("<f2> i" . counsel-info-lookup-symbol)
+  ("<f2> u" . counsel-unicode-char)
+  )
+
+(use-package smex :after 'counsel)
+(use-package counsel
+  :commands (
+             ;; Auto loaded by projectile on use.
+             counsel-ag
+             counsel-rg)
+)
+
+; Highlight trailing white space using whitespace package
+(use-package whitespace
+  :init
+  (setq show-trailing-whitespace t)
+  (setq whitespace-line-column 100)
+  :commands
+  whitespace-mode
+)
+
+(use-package sphinx-doc)
+
+;;;; General Emacs configuration
 ;;; Make sure autosuggest of keybindings is enabled. Maybe I'll learn something
 (setq suggest-key-bindings t)
-
-;;; Key rebindings
-; Remap \C-h to backspace and Help to \C-x?"
-(define-key global-map "\C-h" 'backward-delete-char)
-(define-key global-map "\C-x?" 'help-command)
-
-;;;; enable ibuffer and occur
-(autoload 'ibuffer "ibuffer" "List buffers." t)
-(global-set-key (kbd "C-x C-b") 'ibuffer)
-(global-set-key (kbd "C-c o") 'occur)
-
-;;;; enable revbufs
-(autoload 'revbufs "revbufs" "Revert changed buffers." t)
-
 ;;; Turn on line and column number mode by default
 (line-number-mode 1)
 (column-number-mode 1)
 
-;;; Set wrapping at 100 columns
-(setq-default fill-column 100)
-;;; Turn on column line at 100 columns
-(require 'fill-column-indicator)
-(add-hook 'c-mode-hook 'fci-mode)
-(add-hook 'c++-mode-hook 'fci-mode)
-(add-hook 'python-mode-hook 'fci-mode)
-(add-hook 'yaml-mode-hook 'fci-mode)
-(add-hook 'json-mode-hook 'fci-mode)
-(add-hook 'markdown-mode-hook 'fci-mode)
-
-;;;; Stuff copied from Mathew Robinson's .emacs, and not otherwise integrated into this file
-;;; Copy shell paths over.
-(require 'exec-path-from-shell)
-(exec-path-from-shell-initialize)
-
-(require 'all-the-icons)
-(require 'doom-modeline)
-(doom-modeline-mode 1)
-
-;;; Which key mode: Show help on potential completions for key sequence
-(require 'which-key)
-(which-key-mode)
-
 ;;; Matched delimiters
 (electric-pair-mode 1)
 (electric-indent-mode 1)
 
-;;; Ivy
-(ivy-mode 1)
-(setq ivy-use-virtual-buffers t)
-(setq enable-recursive-minibuffers t)
+;;; Key rebindings
+; Remap Help to \C-x?"
+(define-key global-map "\C-x?" 'help-command)
+
+;;; formatting options
+;; Dealing with tab and space issues
+(setq c-default-style "gnu"
+          c-basic-offset 4)
+; Don't use tabs
+(setq-default indent-tabs-mode nil)
+; Put .h files in c++ mode also
+(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
+(add-to-list 'auto-mode-alist '("\\.hh\\'" . c++-mode))
+; apply clang-format on save
+(add-hook 'c++-mode-hook
+  (lambda () (add-hook 'before-save-hook #'clang-format-buffer nil t)))
+
+;;; Use aspell
+(setq-default ispell-program-name "aspell")
+
+;;;; Use case insensitive file completion
+(setq-default completion-ignore-case t)
+
+(put 'narrow-to-region 'disabled nil)
+;;;; UTF-8
+(define-coding-system-alias 'UTF-8 'utf-8)
+
+;;;; My functions, etc
 
 ;;; From Aaron Sawdey to prevent accidental closing
 (defun ask-before-closing ()

    (setq la (1+ la))))


;;; Filladapt is a syntax-highlighting package.  When it is enabled it
;;; makes filling (e.g. using M-q) much much smarter about paragraphs
;;; that are indented and/or are set off with semicolons, dashes, etc.

(Init-safe-require 'filladapt)
(setq-default filladapt-mode t)
(when (fboundp 'turn-off-filladapt-mode)
  (add-hook 'c-mode-hook 'turn-off-filladapt-mode)
  (add-hook 'outline-mode-hook 'turn-off-filladapt-mode))

;;;; Timestamp functions
; Create a current time stamp
; insert that time stamp into a file

  (setq-default lsp-ui-imenu-enable nil
                lsp-ui-flycheck-enable t))

(use-package yasnippet)

(use-package company-lsp
  :commands company-lsp
  :after (lsp-mode company)
