Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
/ .emacs.d Public archive

b's .emacs.d, with configurations for OCaml, .NET, Coq/Proof General, and Rust

Notifications You must be signed in to change notification settings

bklebe/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Superseded by my Doom config. Please see https://github.com/bklebe/dotfiles/tree/main/.config/doom.

;; -*- lexical-binding: t; -*-

(defvar file-name-handler-alist-handle file-name-handler-alist)
(setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes
      gc-cons-percentage 0.6
      file-name-handler-alist nil)
(add-hook 'emacs-startup-hook
          (lambda ()
            (setq gc-cons-threshold 16777216 ; 16mb
                  gc-cons-percentage 0.1
                  file-name-handler-alist file-name-handler-alist-handle)))

Preamble

(defvar root-dir (file-name-directory load-file-name)
  "The root of the current Emacs configuration.")

(defvar autogen-dir (expand-file-name "autogen" root-dir)
  "Location for all automatically generated Lisp files.")

(defvar custom-storage-file (expand-file-name "custom.el" autogen-dir)
  "Where autogenerated custom.el settings go.")

(setq custom-file custom-storage-file)
(load custom-file)

Emacs settings

;;; backup settings
(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

;; always prefer fresh bytecode
(setq load-prefer-newer t)

(setq default-directory "~/")

Editor settings

;;; editor settings
(setq require-final-newline t)
(delete-selection-mode t)
(setq-default indent-tabs-mode nil)   ;; don't use tabs to indent
(setq-default tab-width 8)            ;; but maintain correct appearance
(setq tab-always-indent 'complete)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(setq next-line-add-newlines nil)

(setq-default truncate-lines t)

Packaging

;;; Commentary:
;;; This config borrows liberally from bbatsov's Emacs Prelude (https://github.com/bbatsov/prelude).

;;; Code:
(use-package bind-key :demand t)

Global functional packages

(use-package esup)

(use-package counsel :demand t
  :bind
  (("C-s" . swiper-isearch)
   ("C-x b" . ivy-switch-buffer)
   ("C-c v" . ivy-push-view)
   ("C-c V" . ivy-pop-view)
   ("C-c C-r" . ivy-resume)
   ("C-c c" . counsel-compile)
   ("C-c g" . counsel-git)
   ("C-c j" . counsel-git-grep)
   ("C-c L" . counsel-git-log)
   ("C-c k" . counsel-rg)
   ("C-x l" . counsel-locate)
   ("C-c J" . counsel-file-jump)
   ("C-c w" . counsel-wmctrl))
  :config
  (setq ivy-use-virtual-buffers t)
  (setq ivy-count-format "(%d/%d) ")
  (counsel-mode 1))

(use-package server
  :commands server-running-p
  :config (or (server-running-p) (server-mode)))

Appearance

;;; As in many other places in this config, a good portion from this is
;;; from bbatsov/prelude.

;;; Nice syntax theme
(use-package doom-themes :demand t
  :config
  (setq doom-themes-enable-bold t
        doom-themes-enable-italic t)
  (load-theme 'doom-flatwhite t))

;;; Show line and column numbers
(line-number-mode t)
(column-number-mode t)
(size-indication-mode t)
(when (version<= "26.0.50" emacs-version)
  (global-display-line-numbers-mode))

;;; Turn off toolbar
(when (fboundp 'tool-bar-mode)
  (tool-bar-mode -1))

;;; Turn off menubar (note: gets reverted if on macOS)
(menu-bar-mode -1)

;;; bar cursor
(setq-default cursor-type 'bar)

;;; Turns off annoying alarm
(setq ring-bell-function 'ignore)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)

;;; Warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)

;; Nice scrolling
(setq scroll-margin 0
      scroll-conservatively 100000
      scroll-preserve-screen-position t)

;;; More useful frame title, that shows either a file or a
;;; buffer name (if the buffer isn't visiting a file).
(setq frame-title-format
      '(:eval (if (buffer-file-name)
                  (abbreviate-file-name (buffer-file-name))
                "%b")))

;;; Highlight current line
(global-hl-line-mode 1)

macOS configuration

;;; macOS-specific configuration
(when (eq system-type 'darwin)
  (use-package exec-path-from-shell :demand t
    :if (eq system-type 'darwin)
    :config
    (exec-path-from-shell-copy-env "SSH_AGENT_PID")
    (exec-path-from-shell-copy-env "SSH_AUTH_SOCK")
    (exec-path-from-shell-initialize))

  (setq insert-directory-program "gls"
        auth-sources '(macos-keychain-internet)
        mac-option-modifier 'meta
        mac-command-modifier 'hyper)

  ;; There's no point in hiding the menu bar on macOS, so let's not do it
  (menu-bar-mode 1)

  ;; Enable emoji, and stop the UI from freezing when trying to display them.
  (when (fboundp 'set-fontset-font)
    (set-fontset-font t 'unicode "Apple Color Emoji" nil 'prepend))

  (add-to-list 'default-frame-alist '(font . "Triplicate T3c-18"))

  (setq auth-sources '(macos-keychain-internet)))

Windows configuration

;;; Windows-specific configuration
(when (eq system-type 'windows-nt)
  (add-to-list 'default-frame-alist '(font . "Consolas-12"))
  (setq default-directory "~/")

  (use-package powershell)

  (defvar tramp-default-method)
  (defvar tramp-histfile-override)
  (setq tramp-default-method "plink"
        tramp-histfile-override "/dev/null")

  (setq auth-sources '("~/.authinfo")))

Linux configuration

;;; Linux-specific configuration
(when (eq system-type 'gnu/linux)
  (add-to-list 'default-frame-alist '(font . "Operator Mono SSm Book-14")))

Global programming packages

(use-package company
  :defines company-dabbrev-downcase
  :hook prog-mode
  :config
  (setq company-idle-delay 0
        company-dabbrev-downcase nil))

(use-package magit
  :bind ("C-x g" . magit-status)
  :config
  (setq-default magit-repository-directories '(("~/Projects". 2))))

(use-package git-commit)

(use-package company-quickhelp
  :config (company-quickhelp-mode))

(use-package dash-at-point)

(use-package forge :after magit)

(use-package projectile
  :bind (("s-p" . projectile-command-map)
         ("C-c p" . projectile-command-map))
  :config
  (projectile-mode t))

(use-package csv-mode)

(use-package yasnippet
  :commands yas-reload-all
  :hook (prog-mode . yas-minor-mode)
  :config
  (yas-reload-all))

(use-package rainbow-delimiters
  :hook (prog-mode . rainbow-delimiters-mode))

(use-package yasnippet-snippets)

(use-package eglot
  :hook ((rust-mode . eglot-ensure)
         (elixir-mode . eglot-ensure))
  :config
  (add-to-list 'eglot-server-programs '(elixir-mode "~/.emacs.d/elixir_ls/language_server.sh")))

OCaml configuration

;;; OCaml configuration
(use-package tuareg
  :bind ("C-c C-s" . utop)
  :config
  (setq compile-command "opam config exec corebuild "))

(use-package merlin
  :after company-mode
  :hook (tuareg-mode . merlin-mode)
  :config
  (setq merlin-error-after-save nil)
  (add-to-list 'company-backends 'merlin-company-backend)
  (flycheck-ocaml-setup))

(use-package flycheck-ocaml)

(use-package utop
  :hook (tuareg-mode . utop-minor-mode)
  :config
  (setq utop-command "opam config exec utop -- -emacs"))

(use-package dune)

Language major modes

(use-package lispy
  :hook (emacs-lisp-mode . lispy-mode))

;;; .NET configuration
(use-package csharp-mode)

;; (use-package fsharp-mode)

;;; Proof General configuration
(use-package proof-general
  :no-require t)

;;; Rust configuration
(use-package rust-mode)

;;; Python configuration
(use-package elpy
  :init
  (elpy-enable))

(use-package elixir-mode
  :init
  (add-hook 'elixir-mode-hook
            (lambda () (add-hook 'before-save-hook 'elixir-format nil t))))

(use-package web-mode
  :mode
  "\\.html?\\'"
  "\\.eex\\'"
  "\\.[jt]sx?\\'"
  "\\.s?css\\'"
  :config
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2))

(use-package dockerfile-mode)

(use-package erlang
  :init
  (setq erlang-root-dir "/usr/local/lib/erlang")
  (setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
  (setq erlang-compile-extra-opts '(debug_info))
  :config
  (require 'erlang-start))

(use-package dtrace-script-mode
  :mode "\\.d\\'")

(use-package haskell-mode)

(use-package kotlin-mode)

About

b's .emacs.d, with configurations for OCaml, .NET, Coq/Proof General, and Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published