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

204 lines
8.4 KiB
EmacsLisp
Raw Permalink Normal View History

;; -*- lexical-binding: t; -*-
2024-07-27 22:50:46 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; windows performance tweaks
(when (eq system-type 'windows-nt)
; https://lists.gnu.org/archive/html/bug-gnu-emacs/2012-10/msg00274.html
; https://gioorgi.com/2013/solving-emacs-freeze-andor-slowdown-on-windows7/
(setq w32-get-true-file-attributes nil)
; https://www.reddit.com/r/emacs/comments/c9ef5i/comment/esx5ndr/
(setq inhibit-compacting-font-caches t)
; https://www.reddit.com/r/emacs/comments/c9ef5i/comment/esx5snw/
(when (boundp 'w32-pipe-read-delay)
(setq w32-pipe-read-delay 0))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; misc performance tweaks
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))
;; disable warnings from popping up, they are still logged
(setq warning-suppress-types '((comp)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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 (and (eq system-type 'windows-nt)
(not kmn/is-termux))
; 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")
(add-to-list 'exec-path "C:/Users/mcros/OneDrive/Programs/PortableApps/MultiMarkdown-Windows-6.6.0/bin")
)
(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/")
(setq default-directory "/data/data/com.termux/files/home/")
; 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 browse-url-browser-function 'browse-url-xdg-open)
(setq org-file-apps
'(;; default
(auto-mode . emacs)
("\\.org" . emacs)
("\\.txt" . emacs)
(".*" . "xdg-open %s")))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; global config
(load "~/.emacs.d.profiles/common/_global.el")
(load "~/.emacs.d.profiles/common/generic_functions.el")
(load "~/.emacs.d.profiles/common/workspaces.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; compile bytecode for this profile
(unless (was-compiled-p "~/.emacs.d.profiles/code")
(byte-recompile-directory "~/.emacs.d.profiles/code" 0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; additional packages
(add-to-list 'package-selected-packages
2023-08-30 13:59:55 +00:00
'(helm-xref helm-lsp lsp-ui lsp-mode json-mode python-mode powershell rust-mode origami go-mode yaml-mode lua-mode)
)
(add-to-list 'package-selected-packages
'(auctex-latexmk auctex dockerfile-mode)
)
2023-07-27 21:26:26 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; activate helm after its fully configured (may be configured beyond global defaults in other profiles so we have to activate locally)
(helm-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tab line via centaur tabs
(centaur-tabs-mode t)
2023-07-27 21:26:26 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; code folding
(require 'origami)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; lsp-mode
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-SPC")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(python-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)
;; if you are helm user
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
2023-07-27 21:26:26 +00:00
;; which key
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; programming
; 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
2022-08-25 17:42:37 +00:00
(use-package tex
:ensure auctex)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
; 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))
(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.
'(custom-safe-themes
2024-03-20 13:57:39 +00:00
'("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" default))
'(package-selected-packages
'((auctex-latexmk auctex dockerfile-mode)
(helm-xref helm-lsp lsp-ui lsp-mode json-mode python-mode powershell rust-mode origami go-mode yaml-mode lua-mode)
(devdocs devdocs-browser magit helm-ls-git xclip)
(which-key all-the-icons revert-buffer-all centaur-tabs scratch persistent-scratch persp-mode rainbow-mode rainbow-delimiters markdown-mode focus zoom popwin dired-single diredfl doominhibitinhibit-modeline helpful helm helm-org dired-rainbow dired-rainbow-listing dired-single dash s origami modus-themes use-package)))
'(temp-buffer-resize-mode t)
'(zoom-ignored-major-modes '(dired-mode)))
(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.
'(fixed-pitch ((t (:family "MonoLisa Variable" :height 120))))
'(variable-pitch ((t (:family "Atkinson Hyperlegible" :height 120)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set ui to standard empty code workspace at launch
(add-hook 'after-init-hook (lambda ()
(kmn/workspace-code-empty)
))