-(add-to-list 'term-file-aliases '("alacritty" . "xterm"))
-
-(setq auto-window-vscroll nil)
-(global-auto-revert-mode t)
-(menu-bar-mode -1)
-;; (tool-bar-mode -1)
-;; (scroll-bar-mode -1)
-(global-linum-mode t)
-
-(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
-(when (file-exists-p custom-file)
-  (load custom-file))
-
-(setq straight-recipes-gnu-elpa-use-mirror    t
-      straight-repository-branch              "develop"
-      straight-enable-use-package-integration t
-      warning-minimum-level :error)
-
-(defvar bootstrap-version)
+(setq package-enable-at-startup nil)
 
 (defconst default-snapshot-dir (expand-file-name "snapshots" user-emacs-directory))
 
-(add-hook 'before-save-hook 'delete-trailing-whitespace)
-
-(setq-default indent-tabs-mode nil
-              tab-width 3)
-
-(setq inhibit-startup-screen t
+(progn
+  (setenv "LANG"   "en_US.UTF-8")
+  (setenv "LC_ALL" "en_US.UTF-8")
+  (prefer-coding-system 'utf-8)
+  (set-language-environment "UTF-8")
+  (setenv "GO111MODULE" "on")
+  (global-auto-revert-mode t)
+  (menu-bar-mode -1)
+  (tooltip-mode -1)
+  (global-linum-mode t)
+  (tool-bar-mode -1)
+  (add-hook 'before-save-hook 'delete-trailing-whitespace)
+  (set-face-attribute 'default nil :font "Source Code Pro" :height 120))
+
+(setq auto-window-vscroll nil
+      custom-file (expand-file-name "custom.el" user-emacs-directory)
+      inhibit-startup-screen t
       initial-scratch-message nil
       initial-major-mode 'text-mode
       make-backup-files nil

     treemacs-filewatch-mode t))
  :bind (("C-c C-o" . treemacs-select-window)))

(use-package treemacs-projectile :straight t :after treemacs projectile)
(use-package treemacs-magit :straight t :after treemacs magit)

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

(use-package flycheck-inline :straight t
  :init
  (add-hook 'flycheck-mode-hook #'turn-on-flycheck-inline))

(use-package flycheck :straight t
  :config (global-flycheck-mode))

(use-package epg :straight t :config (setq epg-gpgconf-program "gpg"))

(use-package gradle-mode :straight t)
(use-package flycheck-gradle :straight t)

(use-package kotlin-mode :straight t)

;; (use-package persistent-scratch :straight t
;;   :config (persistent-scratch-setup-default))

(use-package dashboard :straight t
  :init
  (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))
        dashboard-org-agenda-categories '("Tasks" "Appointments")
        ;; dashboard-projects-switch-function 'counsel-projectile-switch-project-by-name
        dashboard-items '((bookmarks . 5)
                          (projects . 5)
                          (agenda . 5)
                          (registers . 5)))
  :config (dashboard-setup-startup-hook))

(use-package dockerfile-mode :straight t)
(use-package docker-compose-mode :straight t)
(use-package dune :straight t)

(use-package pass :straight t)
(use-package password-store :straight t)
(use-package password-store-otp :straight t)
(use-package auth-source-pass :straight t :config (auth-source-pass-enable))

(use-package graphviz-dot-mode :straight t)

(use-package ripgrep :straight t)

(use-package bnf-mode :straight t)

(use-package emacsql-psql :straight t)
(use-package emacsql-mysql :straight t)
(use-package pcap-mode :straight t)

;; (use-package magithub :straight t)
;; (use-package ghub :straight t)
;; (use-package ghub+ :straight t)
(use-package github-browse-file :straight t)

(use-package yaml-mode :straight t)

(use-package typescript-mode :straight t
  :init
  (add-to-list 'auto-mode-alist '("\\.tsx$" . typescript-mode)))

(use-package envrc :straight t)

;; (use-package elfeed :straight t)
;; (use-package elfeed-protocol :straight t)
;; (use-package elfeed-org :straight t
;;  :init
;;  (setq rmh-elfeed-org-files (list "~/.emacs.d/research-papers.org")))
;; (use-package elfeed-dashboard :straight t)

(setq wl-copy-process nil)

(defun wl-copy (text)
  (setq wl-copy-process (make-process :name "wl-copy"
                                      :buffer nil
                                      :command '("wl-copy" "-f" "-n")
                                      :connection-type 'pipe))
  (process-send-string wl-copy-process text)
  (process-send-eof wl-copy-process))


(defun wl-paste ()
  (if (and wl-copy-process (process-live-p wl-copy-process))
      nil
    (shell-command-to-string "wl-paste -n | tr -d \r")))

(setq interprogram-cut-function 'wl-copy)
(setq interprogram-paste-function 'wl-paste)

;; (use-package gist :straight t
;;   :config
;;   (setq gist-list-format '((created "Created" 15 nil "%D" "%R")
;;                            (id      "Id"      10 nil identity)
;;                            (files   "Files"   35 nil (lambda (files) (mapconcat 'identity files ", ")))
;;                            (visibility "Private" 8 nil (lambda (public) (or (and public "") "   Y")))
;;                            (description "Description" 0 nil identity))))

(use-package browse-at-remote :straight t)

(use-package git-link :straight t)

(use-package xclip :straight t :init (xclip-mode))

(use-package spthy-mode
  :init
  (add-to-list 'auto-mode-alist '("\\.spthy" . spthy-mode))
  :straight (spthy-mode :type git
                        :host github :repo "tamarin-prover/tamarin-prover"
                        :branch "develop"
                        :files (("etc/spthy-mode.el" . "spthy-mode.el"))))

;; (straight-use-package
;;  '(lean-mode :type git
;;              :host github :repo "leanprover/lean4"
;;              :branch "master"
;;              :files (:defaults "lean4-mode/*.el")))

(use-package tla+-mode
  :init
  (add-to-list 'auto-mode-alist '("\\.tla\\'" . tla+-mode))
  :config
  (setq tla+-tlatools-path "~/.local/share/tlaplus/tla2tools.jar")
  :straight (tla+-mode :type git
                       :repo "https://git.sdf.org/bch/tlamode"
                       :branch "master"
                       :files (("lisp/tla+-mode.el" . "tla+-mode.el"))))

(use-package fsharp-mode
  :straight (fsharp-mode :type git
                         :host github :repo "zerosign/emacs-fsharp-mode"
                         :branch "master"))


(global-set-key (kbd "C-c C-_") 'comment-or-uncomment-region)

(use-package json-mode :straight t)

(use-package jdecomp :straight t
  :config
  (setq
   jdecomp-decompiler-paths '((fernflower . "/home/zerosign/.m2/repository/org/jetbrains/fernflower/fernflower/1.0/fernflower-1.0.jar"))
   jdecomp-decompiler-type 'fernflower))


(use-package editorconfig :straight t  :config (editorconfig-mode 1))
(add-hook 'prog-mode-hook #'editorconfig-mode-apply)

(use-package deft :straight t
  :custom
  (deft-extensions '("org"))
  (deft-directory  "~/Repositories/notes/zerodevs")
  (deft-use-filename-as-title t))

(use-package zetteldeft
  :straight t
  :after deft
  :config (zetteldeft-set-classic-keybindings))

(use-package julia-mode :straight t)

(use-package hcl-mode :straight t)

(use-package meson-mode :straight t)

(use-package lean-mode :straight t)

(use-package org-roam :straight t)

;; (straight-use-package
;;  '(tsc :host github
;;        :repo "mallt/mysql-to-org-mode"
;;        :files ("*.el")))

(use-package kubernetes :straight t)

(use-package org-journal :straight t
  :init
  (setq org-journal-dir "~/org/journal"
        org-journal-date-format "%A, %d %B %Y"))

(use-package org-jira :straight t
  :init
  (setq jiralib-url "https://ruanggguru.atlassian.net"))

(defun org-journal-find-location ()
  ;; Open today's journal, but specify a non-nil prefix argument in order to
  ;; inhibit inserting the heading; org-capture will insert the heading.
  (org-journal-new-entry t)
  (unless (eq org-journal-file-type 'daily)
    (org-narrow-to-subtree))
  (goto-char (point-max)))

(setq org-capture-templates '(("j" "Journal entry" plain (function org-journal-find-location)
                               "** %(format-time-string org-journal-time-format)%^{Title}\n%i%?"
                               :jump-to-captured t :immediate-finish t)))

;; (setq smooth-scroll-margin 0
;;       scroll-margin 1
;;       scroll-conservatively 10
;;       mouse-wheel-scroll-amount '(1 ((shift) . 1))
;;       mouse-wheel-progressive-speed nil
;;       mouse-wheel-follow-mouse 't
;;       scroll-step 2)

;; (unless (display-graphic-p)
;;   (defun scroll-mouse-up ()
;;     (interactive)
;;     (scroll-up 2))
;;   (defun scroll-mouse-down ()
;;     (interactive)
;;     (scroll-down 2))
;;   ;; activate mouse-based scrolling
;;   (xterm-mouse-mode 1)

;;   (global-set-key (kbd "<mouse-4>") 'scroll-mouse-down)
;;   (global-set-key (kbd "<mouse-5>") 'scroll-mouse-up))

;; (use-package vterm :straight t)


(setq ad-redefinition-action 'accept)
(put 'magit-clean 'disabled nil)

        ;; Immediately activate completion.
        company-idle-delay 0.5))

(use-package magit
  :straight t
  :commands magit-status
  :hook ((magit-popup-mode-hook . no-trailing-whitespace)
	 (git-commit-mode . goto-address-mode)))

(use-package projectile :straight t :diminish projectile-mode
  :init
  (setq projectile-enable-caching t
        projectile-require-project-root t
	projectile-cache-file (expand-file-name "projectile.cache" default-snapshot-dir)
	projectile-known-projects-file (expand-file-name "projectile-bookmarks.eld" default-snapshot-dir)
	projectile-completion-system 'ivy
        projectile-indexing-method 'alien
        projectile-project-root-files-functions '(projectile-root-local
                                                  projectile-root-top-down
                                                  projectile-root-top-down-recurring
                                                  projectile-root-bottom-up)
	projectile-switch-project-action #'projectile-find-dir)
  :config
  (projectile-mode)
  :bind (("C-c f" . projectile-find-file)
	 ("C-c p" . projectile-switch-project)))

(use-package treemacs :straight t
  :config
