;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;; from http://melpa.org/#/getting-started
(require 'package) ;; You might already have this line
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
                    (not (gnutls-available-p))))
       (url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
  (add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(with-eval-after-load 'package
  (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize) ;; You might already have this line

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default bold shadow italic underline bold bold-italic bold])
 '(column-number-mode t)
 '(fill-column 100)
 '(flycheck-checker-error-threshold 4000)
 '(inhibit-startup-buffer-menu t)
 '(inhibit-startup-echo-area-message "alyjak")
 '(inhibit-startup-screen t)
 '(js-indent-level 2)
 '(js-switch-indent-offset 2)
 '(js2-bounce-indent-p t)
 '(js2-mode-assume-strict t)
 '(lsp-rust-server (quote rust-analyzer))
 '(org-agenda-files
   (quote
    ("~/code/h3id/todo.org" "/home/alyjak/code/alyjak/journal/2020-09.org")))
 '(org-modules
   (quote
    (org-bbdb org-bibtex org-docview org-gnus org-habit org-info org-irc org-mhe org-rmail org-w3m)))
 '(package-selected-packages
   (quote
    (js2-mode python-mode sphinx-doc python-docstring magit ansible yaml-mode dockerfile-mode bitbake chronos sass-mode dap-mode company toml-mode org vue-html-mode vue-mode flycheck-pest pest-mode dash fullframe which-key yasnippet lsp-ui lsp-mode use-package flycheck-inline cargo rust-mode flycheck ess markdown-mode material-theme ##)))
 '(rst-preferred-adornments
   (quote
    ((35 over-and-under 0)
     (42 over-and-under 0)
     (61 simple 0)
     (95 simple 0)
     (94 simple 0)
     (34 simple 0)
     (126 simple 0)
     (96 simple 0))))
 '(rst-toc-indent 3)
 '(safe-local-variable-values
   (quote
    ((flycheck-python-pylint-executable . "/home/alyjak/code/h3id/ansible_env/bin/python3")
     (flycheck-python-flake8-executable . "/home/alyjak/code/h3id/ansible_env/bin/python3"))))
 '(scroll-bar-mode nil)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Iosevka Term" :slant normal :weight normal :height 90 :width normal :foundry "BE5N")))))

;; rust notes
;; https://emacs-lsp.github.io/lsp-mode/page/lsp-rust/
;; set up rust-analyzer
;; https://github.com/rust-analyzer/rust-analyzer
;; rust install:
;; https://www.rust-lang.org/tools/install
;; (update path to include ~/.cargo/bin)
(use-package lsp)
(use-package yasnippet
  :ensure t
  )

(setenv "LC_ALL" "en_US.UTF-8")
(setenv "LC_CTYPE" "en_US.UTF-8")

;; Use js2-mode for js editing
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

; Map txt files to rst mode
(setq auto-mode-alist
  (append
   ;; File name (within directory) starts with a dot.
   '(("\\.txt\\'" . rst-mode)
     ("\\.rst\\'" . rst-mode)
     ("\\.rest\\'" . rst-mode)) auto-mode-alist))

; Map bitbake files to bitbake-mode
(setq auto-mode-alist
  (append
   ;; File name (within directory) starts with a dot.
   '(("\\.bb\\'" . bitbake-mode)
     ("\\.bbappend\\'" . bitbake-mode)
     ("\\.inc\\'" . bitbake-mode)) auto-mode-alist))

(load-theme 'material t)

;; Always highlight parenthesis!
(show-paren-mode 1)

;; make trailing whitespace display in an annoying manner
(setq-default show-trailing-whitespace t)

;; Mode for editing Temporal Logic of Actions files
(add-to-list 'load-path "~/.emacs.d/lisp/")

(require 'fullframe)
(use-package fullframe
  :ensure t
  :defer t
  :init
  (progn
    (toggle-debug-on-error)
    (fullframe magit-status magit-mode-quit-window)
    (fullframe list-packages quit-window)
    )
  )

(use-package flycheck
  :ensure t
  :init (global-flycheck-mode))

(setq lsp-keymap-prefix "s-l")
(setq lsp-enable-file-watchers nil)
(use-package lsp-mode
    :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
            (rust-mode . lsp-deferred)
            ;; if you want which-key integration
            (lsp-mode . lsp-enable-which-key-integration))
    :commands (lsp lsp-deferred))
;; optionally
(use-package lsp-ui :commands lsp-ui-mode)

;; optional if you want which-key integration
(use-package which-key
    :config
    (which-key-mode))

;; rustfmt on save
(setq rust-format-on-save t)

;; Debug adapter protocol
;; Enabling only some features
(setq dap-auto-configure-features '(sessions locals controls tooltip))
(add-hook 'dap-stopped-hook
          (lambda (arg) (call-interactively #'dap-hydra)))

;; Remove the stupid stupid beeps
(setq visible-bell 1)

;; Org mode
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key (kbd "C-c c") 'org-capture)
(add-hook 'org-mode-hook #'toggle-word-wrap)

;; fly spell
(dolist (hook '(text-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(rst-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(org-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(markdown-mode-hook))
  (add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(change-log-mode-hook log-edit-mode-hook))
  (add-hook hook (lambda () (flyspell-mode -1))))
(add-hook 'c++-mode-hook
        (lambda ()
          (flyspell-prog-mode)
        ))
(add-hook 'rust-mode-hook
        (lambda ()
          (flyspell-prog-mode)
        ))
(add-hook 'python-mode-hook
        (lambda ()
          (flyspell-prog-mode)
        ))

(use-package python-docstring
  :ensure t
  :config (setq python-docstring-sentence-end-double-space nil)
  :hook (python-mode . python-docstring-mode))

(defun flycheck-python-setup ()
  (flycheck-mode))
(add-hook 'python-mode-hook #'flycheck-python-setup)

;; so that we can use .dir-locals.el values to set python flycheck options and not get warnings
;; every time.
;; allow remembering risky variables
(advice-add 'risky-local-variable-p :override #'ignore)

;; Main reason for this is to get ~/.cargo/bin/rust-analyzer into PATH
(setenv "PATH" (concat (getenv "PATH") ":/home/alyjak/.cargo/bin"))
(setq exec-path (append exec-path '("/home/alyjak/.cargo/bin")))

;; better window selection than stupid other-window command
(when (fboundp 'windmove-default-keybindings)
  (windmove-default-keybindings))

;; don't show trailing whitespace in term mode
(defun turn-off-trailing-whitespace ()
  (setq show-trailing-whitespace nil))
(add-hook 'term-mode-hook 'turn-off-trailing-whitespace)

;; Save last session
(desktop-save-mode 1)

;; no tabs!
(setq-default indent-tabs-mode nil)

;; follow logs
(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-tail-mode))

;; https://emacs.stackexchange.com/questions/37417/flyspell-in-terminal
(eval-after-load "flyspell"
  '(progn
     (fset 'flyspell-emacs-popup 'flyspell-emacs-popup-textual)))

<<<<<<< HEAD
=======
(put 'upcase-region 'disabled nil)

>>>>>>> more emacs conf edits
(provide '.emacs)
;;; .emacs.el ends here
