Archived
1
0
Fork 0
This repository has been archived on 2024-10-19. You can view files and clone it, but cannot push or open issues or pull requests.
emacs/code/init.el
2022-04-21 23:14:55 -04:00

129 lines
4.8 KiB
EmacsLisp

;; -*- lexical-binding: t; -*-
;; TURN ON IN INIT FILE!!!!!
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; helper functions
;; Figure out if inside Termux
(require 'subr-x)
(setq kmn/is-termux
(string-suffix-p "Android" (string-trim (shell-command-to-string "uname -a"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; os specific config
(when (eq system-type 'windows-nt)
; Fix resolution of ~ to match other client paths
(setenv "HOME" "C:/Users/mcros/Nextcloud")
(setq default-directory "C:/Users/mcros/Nextcloud")
; add executables to path ahead of them being used by extensions / emacs stuff
(add-to-list 'exec-path "C:/Users/mcros/OneDrive/Programs/PortableApps/sqlite3")
)
(when kmn/is-termux
; setup storage locations -- cheat so mobile/desktop look alike for file urls
;(setq user-init-file "/data/data/com.termux/files/home/storage/shared/.emacs")
;(setq user-emacs-directory "/data/data/com.termux/files/home/storage/shared/.emacs.d/")
;(setenv "HOME" "/data/data/com.termux/files/home/storage/shared/")
;(load user-init-file)
; Fix resolution of ~ to match other client paths
(setenv "HOME" "/data/data/com.termux/files/home/storage/shared/")
(setq default-directory "/data/data/com.termux/files/home/storage/shared/")
; Better fonts
(setq org-src-fontify-natively t)
; Setup xdg-open as the default for opening files (except for the few we want emacs to open native)
; xdg-open is linked to termux-open by default ; if you need 'more' look into tmux-open and adjust accordingly
; (add-to-list 'org-file-apps '("\\.doc.*" . "open %s"))
(setq org-file-apps
'(;; default
(auto-mode . emacs)
("\\.org" . emacs)
("\\.txt" . emacs)
(".*" . "xdg-open %s")))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; global config
(load "~/.emacs.d.profiles/common/_global.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; additional packages
(add-to-list 'package-selected-packages
'(json-mode python-mode powershell rust-mode origami go-mode yaml-mode dockerfile-mode lua-mode rainbow-mode rainbow-delimiters markdown-mode)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; programming
; general
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
; code folding
(require 'origami)
; markdown config
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
; lua
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
(setq lua-indent-level 4)
; dockerfile
(autoload 'dockerfile-mode "dockerfile-mode" "Dockerfile editing mode." t)
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
; yaml
(autoload 'yaml-mode "yaml-mode" "YAML editing mode." t)
(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-mode))
; go
(autoload 'go-mode "go-mode" "go editing mode." t)
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
; rust
(autoload 'rust-mode "rust-mode" "rust editing mode" t)
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
; c/cpp
(autoload 'cc-mode "cc-mode" "c/cpp editing mode" t)
(add-to-list 'auto-mode-alist '("\\.h\\'" . cc-mode))
(add-to-list 'auto-mode-alist '("\\.c\\'" . cc-mode))
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . cc-mode))
; shell
(autoload 'sh-script "sh-script" "shell script editing mode" t)
(add-to-list 'auto-mode-alist '("\\.sh\\'" . sh-script))
; makefile
(autoload 'make-mode "make-mode" "makefile editing mode" t)
(add-to-list 'auto-mode-alist '("Makefile\\'" . make-mode))
; powershell
(autoload 'powershell "powershell" "powershell editing mode" t)
(add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell))
; [la]tex
(autoload 'tex-mode "tex-mode" "[la]tex editing mode" t)
(add-to-list 'auto-mode-alist '("\\.tex\\'" . tex-mode))
; python
(autoload 'python-mode "python-mode" "python editing mode" t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
; json
(autoload 'json-mode "json-mode" "json editing mode" t)
(add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))