From c390ed0977d69107d652207ec547b4ab536aa2c2 Mon Sep 17 00:00:00 2001 From: materus Date: Sun, 10 Nov 2024 11:50:21 +0100 Subject: [PATCH] configurations: emacs, move config to org file --- .../host/materusPC/home/materus/default.nix | 2 +- .../profile/home/editor/emacs/default.nix | 160 ++++---- configurations/profile/home/editor/neovim.nix | 2 +- configurations/profile/home/shell/default.nix | 9 + extraFiles/config/emacs/early-init.el | 27 +- .../config/emacs/emacs-materus-config.org | 1 + .../config/emacs/etc/materus/emacs-config.el | 374 ++++++++++++++++++ .../config/emacs/etc/materus/internals.el | 59 --- .../config/emacs/etc/materus/lsp/cpp.el | 5 - .../config/emacs/etc/materus/lsp/default.el | 52 --- .../config/emacs/etc/materus/lsp/java.el | 1 - .../config/emacs/etc/materus/lsp/lisp.el | 2 - .../config/emacs/etc/materus/lsp/nix.el | 2 - .../config/emacs/etc/materus/packages.el | 78 ---- extraFiles/config/emacs/etc/materus/start.el | 118 ------ extraFiles/config/emacs/init.el | 10 +- 16 files changed, 481 insertions(+), 421 deletions(-) create mode 100644 extraFiles/config/emacs/emacs-materus-config.org create mode 100644 extraFiles/config/emacs/etc/materus/emacs-config.el delete mode 100644 extraFiles/config/emacs/etc/materus/internals.el delete mode 100644 extraFiles/config/emacs/etc/materus/lsp/cpp.el delete mode 100644 extraFiles/config/emacs/etc/materus/lsp/default.el delete mode 100644 extraFiles/config/emacs/etc/materus/lsp/java.el delete mode 100644 extraFiles/config/emacs/etc/materus/lsp/lisp.el delete mode 100644 extraFiles/config/emacs/etc/materus/lsp/nix.el delete mode 100644 extraFiles/config/emacs/etc/materus/packages.el delete mode 100644 extraFiles/config/emacs/etc/materus/start.el diff --git a/configurations/host/materusPC/home/materus/default.nix b/configurations/host/materusPC/home/materus/default.nix index 17318da..1331d49 100644 --- a/configurations/host/materusPC/home/materus/default.nix +++ b/configurations/host/materusPC/home/materus/default.nix @@ -17,7 +17,7 @@ enableTerminal = lib.mkDefault true; enableTerminalExtra = lib.mkDefault true; enableNixDevel = lib.mkDefault true; - editor.emacs.enable = false; + editor.emacs.enable = true; editor.code.fhs.enable = true; editor.code.fhs.packages = (ps: with ps; let llvmpkgs = llvmPackages_18; in [ llvmpkgs.clang diff --git a/configurations/profile/home/editor/emacs/default.nix b/configurations/profile/home/editor/emacs/default.nix index 9109ce2..e4058c6 100644 --- a/configurations/profile/home/editor/emacs/default.nix +++ b/configurations/profile/home/editor/emacs/default.nix @@ -1,5 +1,21 @@ -{ config, lib, pkgs, materusArg, ... }: +{ config, lib, pkgs, materusArg, materusCfg, ... }: let + emacs-git = + materusCfg.configInputs.emacs-overlay.packages.x86_64-linux.emacs-git; + + materus-config = e: + e.trivialBuild { + pname = "materus-config"; + src = pkgs.writeText "materus-config.el" '' + (when (file-exists-p "${config.programs.emacs.package}/opt/emacs/buildtime") + (setq emacs-build-time (decode-time (seconds-to-time (string-to-number (with-temp-buffer + (insert-file-contents "${config.programs.emacs.package}/opt/emacs/buildtime") + (buffer-string))))))) + (provide 'materus-config) + ''; + version = "1.0.0"; + }; + configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/"; inits = import ./init.nix { path = configPath; @@ -7,66 +23,8 @@ let }; packages = epkgs: with epkgs; [ - elcord - persp-mode - dashboard - magit - avy - corfu - vterm - projectile - company - clipetty - which-key - iedit - hideshowvis - evil - treemacs-evil - treemacs - treemacs-nerd-icons - treemacs-perspective - treemacs-icons-dired - treemacs-magit - treemacs-projectile - tree-edit - vertico - marginalia - nerd-icons - nerd-icons-completion - perspective - minions - telephone-line - rainbow-delimiters - use-package - cmake-mode - lsp-mode - lsp-java - lsp-jedi - lsp-haskell - lsp-ui - lsp-treemacs - dap-mode - d-mode - lua-mode - multiple-cursors - org - org-rainbow-tags - org-roam - org-roam-ui - org-review - csharp-mode - markdown-mode - json-mode - nix-mode - no-littering - right-click-context - dracula-theme - doom-themes - orderless - popper - undo-tree - bash-completion - consult + (materus-config epkgs) + treesit-grammars.with-all-grammars ]; default-config = '' @@ -77,6 +35,7 @@ let emacsEnv = pkgs.buildEnv { name = "emacs-env"; paths = with pkgs; [ + nixfmt-classic python3 lua multimarkdown @@ -101,46 +60,85 @@ let (call-process-shell-command "${pkgs.xorg.xmodmap}/bin/xmodmap -e \"keycode 148 = Hyper_L\" -e \"remove Mod4 = Hyper_L\" -e \"add Mod3 = Hyper_L\" &" nil 0) (call-process-shell-command "${pkgs.xorg.xmodmap}/bin/xmodmap -e \"keycode 66 = Hyper_L\" -e \"remove Mod4 = Hyper_L\" -e \"add Mod3 = Hyper_L\" &" nil 0) ''; -in -{ +in { options.materus.profile.editor.emacs.enable = materusArg.pkgs.lib.mkBoolOpt false "Enable emacs with materus cfg"; config = lib.mkIf cfg.enable { home.activation.emacsCompile = lib.hm.dag.entryAfter [ "linkGeneration" ] '' - mkdir -p ${config.xdg.configHome}/emacs/var/backups mkdir -p ${config.xdg.configHome}/emacs/var/recovery mkdir -p ${config.xdg.configHome}/emacs/etc + + mkdir -p ${config.xdg.configHome}/emacs/var/backups run ${config.programs.emacs.finalPackage}/bin/emacs --batch \ --eval '(setq warning-minimum-log-level :error)' \ - --eval '(byte-recompile-directory "${config.xdg.configHome}/emacs/etc/materus" 0 t)' \ --eval '(byte-compile-file "${config.xdg.configHome}/emacs/early-init.el")' \ + --eval '(byte-compile-file "${config.xdg.configHome}/emacs/etc/materus/emacs-config.el")' \ --eval '(byte-compile-file "${config.xdg.configHome}/emacs/init.el")' ''; xdg.configFile = { "emacs/early-init.el".text = inits.earlyInitText; "emacs/init.el".text = default-config; - "emacs/etc/materus" = - { - source = configPath + "etc/materus"; - recursive = true; - }; + "emacs/etc/materus" = { + source = configPath + "etc/materus"; + recursive = true; + }; + }; + xdg.desktopEntries.emacs = { + name = "Emacs"; + genericName = "Edytor tekstu"; + comment = "Edytuj tekst"; + exec = ''env COLORTERM=truecolor emacsclient -a "" -c %F''; + icon = "emacs"; + terminal = false; + type = "Application"; + categories = [ "Development" "TextEditor" ]; + mimeType = [ + "text/english" + "text/plain" + "text/x-makefile" + "text/x-c++hdr" + "text/x-c++src" + "text/x-chdr" + "text/x-csrc" + "text/x-java" + "text/x-moc" + "text/x-pascal" + "text/x-tcl" + "text/x-tex" + "application/x-shellscript" + "text/x-c" + "text/x-c++" + "x-scheme-handler/org-protocol" + ]; + actions.new-window = { + exec = ''env COLORTERM=truecolor emacsclient -a "" -c %F''; + name = "Nowe okno"; + }; + actions.no-daemon = { + exec = "env COLORTERM=truecolor emacs %F"; + name = "Instancja samodzielna"; + }; }; programs.emacs = { enable = true; - package = - lib.mkDefault (pkgs.emacs29.override { - withSQLite3 = true; - withWebP = true; - withX = true; - withGTK3 = true; - withAlsaLib = true; - withGconf = true; - withImageMagick = true; - withXwidgets = true; - }); + package = lib.mkDefault ((emacs-git.override { + withSQLite3 = true; + withWebP = true; + withX = true; + withGTK3 = true; + withAlsaLib = true; + withGconf = true; + withImageMagick = true; + }).overrideAttrs (f: p: { + postInstall = p.postInstall + '' + rm -fr $out/share/applications/* + mkdir -p $out/opt/emacs + date +%s | tr -d '\n' > $out/opt/emacs/buildtime + ''; + })); extraPackages = epkgs: (packages epkgs); }; diff --git a/configurations/profile/home/editor/neovim.nix b/configurations/profile/home/editor/neovim.nix index 22031af..46585ed 100644 --- a/configurations/profile/home/editor/neovim.nix +++ b/configurations/profile/home/editor/neovim.nix @@ -13,7 +13,7 @@ in viAlias = true; vimAlias = true; vimdiffAlias = true; - defaultEditor = true; + defaultEditor = lib.mkDefault false; extraConfig = '' diff --git a/configurations/profile/home/shell/default.nix b/configurations/profile/home/shell/default.nix index dd77eb7..ea28819 100644 --- a/configurations/profile/home/shell/default.nix +++ b/configurations/profile/home/shell/default.nix @@ -1,3 +1,4 @@ +{config, pkgs, lib, ...}: { imports = [ @@ -6,4 +7,12 @@ ./fish.nix ./starship.nix ]; + home.sessionVariables = { + EDITOR = lib.mkDefault (if (config.materus.profile.editor.emacs.enable) then + lib.getBin (pkgs.writeShellScript "editor" ''${config.programs.emacs.finalPackage}/bin/emacsclient --alternate-editor= -c -nw $@'') + else "${pkgs.micro}/bin/micro"); + VISUAL = lib.mkDefault (if (config.materus.profile.editor.emacs.enable) then + lib.getBin (pkgs.writeShellScript "editor-visual" ''exec env COLORTERM=truecolor ${config.programs.emacs.finalPackage}/bin/emacsclient --alternate-editor= -c $@'') + else "${pkgs.micro}/bin/micro"); + }; } diff --git a/extraFiles/config/emacs/early-init.el b/extraFiles/config/emacs/early-init.el index 51a7a26..26925a0 100644 --- a/extraFiles/config/emacs/early-init.el +++ b/extraFiles/config/emacs/early-init.el @@ -1,21 +1,15 @@ +(defvar materus/init-early t) ; Var to ensure early-init loaded +(setq materus/init-early t) ; Probably useless - - -(defvar materus/init-early t) -(setq materus/init-early t) - -(when (boundp 'native-comp-eln-load-path) - (startup-redirect-eln-cache (expand-file-name "/var/eln-cache/" user-emacs-directory))) - -(tool-bar-mode -1) (setq initial-major-mode 'fundamental-mode) -(setq-default package-quickstart t) +(setq native-comp-async-report-warnings-errors nil) +(setq package-enable-at-startup nil) + (setq native-comp-speed 3) (add-hook 'emacs-startup-hook (lambda () (package-initialize) (setq gc-cons-threshold 100000000 ; ~100mb gc-cons-percentage 0.1) )) -(setq package-enable-at-startup nil) (unless (daemonp) (setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes gc-cons-percentage 0.6) @@ -30,6 +24,9 @@ ) ) +(when (boundp 'native-comp-eln-load-path) ; Change dir for eln-cache + (startup-redirect-eln-cache (expand-file-name "/var/eln-cache/" user-emacs-directory))) + (when (and (fboundp 'startup-redirect-eln-cache) (fboundp 'native-comp-available-p) (native-comp-available-p)) @@ -39,6 +36,8 @@ (setq auto-save-default nil) (setq backup-directory-alist - `((".*" . ,(concat user-emacs-directory "var/backups/")))) -(setq auto-save-file-name-transforms - `((".*" ,(concat user-emacs-directory "var/recovery/") t))) \ No newline at end of file + `((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir +(setq auto-save-file-name-transforms + `((".*" ,(concat user-emacs-directory "var/recovery/") t))) +(setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/")) +(setq custom-file (concat user-emacs-directory "etc/custom.el")) diff --git a/extraFiles/config/emacs/emacs-materus-config.org b/extraFiles/config/emacs/emacs-materus-config.org new file mode 100644 index 0000000..47b8770 --- /dev/null +++ b/extraFiles/config/emacs/emacs-materus-config.org @@ -0,0 +1 @@ +:PROPERTIES: :header-args: :tangle etc/materus/emacs-config.el :END: #+STARTUP: overview #+AUTHOR: materus #+LANGUAGE: en #+auto_tangle: t * Table of Contents :noexport:TOC_3_gh: - [[#init-files][Init Files]] - [[#early-init][Early Init]] - [[#init][Init]] - [[#byte-compile][Byte compile]] - [[#packages][Packages]] - [[#init-1][Init]] - [[#packages-1][Packages]] - [[#configuration][Configuration]] - [[#no-littering][No Littering]] - [[#graphical][Graphical]] - [[#mouse][Mouse]] - [[#misc][Misc]] - [[#dashboard][Dashboard]] - [[#modeline][Modeline]] - [[#org-mode][Org-mode]] - [[#completions][Completions]] - [[#minibuffer][Minibuffer]] - [[#company][Company]] - [[#miscellaneous][Miscellaneous]] - [[#defaults][Defaults]] - [[#elcord][Elcord]] - [[#undo-tree][Undo-Tree]] - [[#projectile][Projectile]] - [[#treemacs][Treemacs]] - [[#programming][Programming]] - [[#lsp][LSP]] - [[#nix][Nix]] - [[#emacs-lisp][Emacs Lisp]] - [[#cc][C/C++]] - [[#java][Java]] - [[#keybindings][Keybindings]] - [[#test][Test]] * Init Files ** Early Init :PROPERTIES: :header-args: :tangle early-init.el :END: Early init file, setting for GC and some paths. #+begin_src emacs-lisp (defvar materus/init-early t) ; Var to ensure early-init loaded (setq materus/init-early t) ; Probably useless (setq initial-major-mode 'fundamental-mode) (setq native-comp-async-report-warnings-errors nil) (setq package-enable-at-startup nil) (setq native-comp-speed 3) (add-hook 'emacs-startup-hook (lambda () (package-initialize) (setq gc-cons-threshold 100000000 ; ~100mb gc-cons-percentage 0.1) )) (unless (daemonp) (setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes gc-cons-percentage 0.6) (advice-add #'tty-run-terminal-initialization :override #'ignore) (add-hook 'window-setup-hook (lambda () (advice-remove #'tty-run-terminal-initialization #'ignore) (tty-run-terminal-initialization (selected-frame) nil t) ) ) ) (when (boundp 'native-comp-eln-load-path) ; Change dir for eln-cache (startup-redirect-eln-cache (expand-file-name "/var/eln-cache/" user-emacs-directory))) (when (and (fboundp 'startup-redirect-eln-cache) (fboundp 'native-comp-available-p) (native-comp-available-p)) (startup-redirect-eln-cache (convert-standard-filename (expand-file-name "var/eln-cache/" user-emacs-directory)))) (setq auto-save-default nil) (setq backup-directory-alist `((".*" . ,(concat user-emacs-directory "var/backups/")))) ; Change backup and auto save dir to var dir (setq auto-save-file-name-transforms `((".*" ,(concat user-emacs-directory "var/recovery/") t))) (setq auto-save-list-file-prefix (concat user-emacs-directory "var/auto-save/sessions/")) (setq custom-file (concat user-emacs-directory "etc/custom.el")) #+end_src ** Init :PROPERTIES: :header-args: :tangle init.el :END: Init File Checking if using emacs from nix package, loads config and custom.el #+begin_src emacs-lisp (setq-default materus/use-nix-packages (require 'materus-config nil 'noerror)) (cua-mode 0) ; To load cua variables/functions but not set it up yet (load (concat user-emacs-directory "etc/materus/emacs-config")) (when (file-exists-p custom-file) (load custom-file)) #+end_src ** Byte compile #+begin_src emacs-lisp (unless (file-exists-p (concat user-emacs-directory "etc/materus/emacs-config.elc")) (byte-compile-file (concat user-emacs-directory "etc/materus/emacs-config.el"))) (unless (file-exists-p (concat user-emacs-directory "init.elc")) (byte-compile-file (concat user-emacs-directory "init.el"))) (unless (file-exists-p (concat user-emacs-directory "early-init.elc")) (byte-compile-file (concat user-emacs-directory "early-init.el"))) #+end_src * Packages Package manager config. Nix not used for portability and easier control. ** Init #+begin_src emacs-lisp (require 'cl-lib) (require 'package) (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) (add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/")) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) #+end_src ** Packages Packages to install #+begin_src emacs-lisp (defvar materus/packages '( use-package elcord persp-mode dashboard magit git-timemachine avy corfu vterm projectile company clipetty which-key iedit hideshowvis evil treemacs-evil treemacs treemacs-nerd-icons treemacs-perspective treemacs-icons-dired treemacs-magit treemacs-projectile tree-edit vertico marginalia nerd-icons nerd-icons-completion perspective minions doom-modeline rainbow-delimiters rainbow-mode use-package cmake-mode lsp-mode lsp-java lsp-jedi lsp-haskell lsp-ui lsp-treemacs gradle-mode groovy-mode kotlin-mode dap-mode d-mode lua-mode multiple-cursors org org-contrib org-ql org-rainbow-tags org-roam org-roam-ui org-review org-superstar org-auto-tangle visual-fill-column csharp-mode markdown-mode json-mode nix-mode no-littering right-click-context dracula-theme doom-themes doom-modeline orderless popper undo-tree bash-completion consult eldoc-box yasnippet async request nix-ts-mode markdown-ts-mode llvm-ts-mode treesit-fold treesit-auto tree-sitter-langs eat vlf edit-indirect zones sudo-edit toc-org eshell-vterm empv volatile-highlights ) "A list of packages to ensure are installed at launch.") (defun materus/packages-installed-p () (cl-loop for p in materus/packages when (not (package-installed-p p)) do (cl-return nil) finally (cl-return t))) (defun materus/install-packages () (unless (materus/packages-installed-p) (package-refresh-contents) (dolist (p materus/packages) (when (not (package-installed-p p)) (package-install p))))) (materus/install-packages) #+end_src * Configuration ** No Littering Set up no littering #+begin_src emacs-lisp (require 'recentf) (use-package no-littering :config (add-to-list 'recentf-exclude (recentf-expand-file-name no-littering-var-directory)) (add-to-list 'recentf-exclude (recentf-expand-file-name no-littering-etc-directory))) #+end_src ** Graphical Graphical related settings. *** Mouse #+begin_src emacs-lisp (context-menu-mode 1) (setq mouse-wheel-follow-mouse 't) (setq scroll-step 1) (setq mouse-drag-and-drop-region t) (xterm-mouse-mode 1) (pixel-scroll-precision-mode 1) (setq-default pixel-scroll-precision-large-scroll-height 10.0) #+end_src *** Misc #+begin_src emacs-lisp (setq frame-inhibit-implied-resize t) (setq frame-resize-pixelwise t) (setq window-resize-pixelwise t) (when (display-graphic-p) (set-frame-font "Hack Nerd Font" nil t) ) (setq-default display-line-numbers-width 4) (global-tab-line-mode 1) (setq-default tab-width 4) (tool-bar-mode -1) (setq read-process-output-max (* 1024 1024 3)) (setq ring-bell-function 'ignore) (setq-default cursor-type '(bar . 1)) ;; Delimiters (use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode) :config (custom-set-faces '(rainbow-delimiters-depth-1-face ((t (:foreground "#FFFFFF")))) '(rainbow-delimiters-depth-2-face ((t (:foreground "#FFFF00")))) '(rainbow-delimiters-depth-5-face ((t (:foreground "#6A5ACD")))) '(rainbow-delimiters-unmatched-face ((t (:foreground "#FF0000"))))) ) ;; Nerd Icons (use-package nerd-icons) ;; Theme (use-package dracula-theme :config (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame (load-theme 'dracula t)))) (load-theme 'dracula t))) (defun startup-screen-advice (orig-fun &rest args) (when (= (seq-count #'buffer-file-name (buffer-list)) 0) (apply orig-fun args))) (advice-add 'display-startup-screen :around #'startup-screen-advice) ; Hide startup screen if started with file #+end_src *** Dashboard #+begin_src emacs-lisp (use-package dashboard :after (nerd-icons) :config (setq dashboard-center-content t) (setq dashboard-display-icons-p t) (setq dashboard-icon-type 'nerd-icons) (dashboard-setup-startup-hook) (when (daemonp) (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon ) ) #+end_src *** Modeline #+begin_src emacs-lisp (use-package doom-modeline :init (setq doom-modeline-support-imenu t) :hook (after-init . doom-modeline-mode) :config (setq doom-modeline-icon t) (setq display-time-24hr-format t) (display-time-mode 1)) (use-package minions :hook (after-init . minions-mode)) #+end_src ** Org-mode Org mode settings #+begin_src emacs-lisp (use-package org :mode (("\\.org$" . org-mode)) :hook ((org-mode . org-indent-mode) (org-mode . (lambda () (setq-local electric-pair-inhibit-predicate `(lambda (c) (if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))) :config (require 'org-mouse) (require 'org-tempo)) (use-package org-superstar :after (org) :hook (org-mode . org-superstar-mode)) :config (setq org-superstar-leading-bullet " ") (use-package org-auto-tangle :after (org) :hook (org-mode . org-auto-tangle-mode)) (use-package toc-org :after (org) :hook ((org-mode . toc-org-mode ) (markdown-mode . toc-org-mode))) #+end_src ** Completions *** Minibuffer #+begin_src emacs-lisp (use-package consult) (use-package marginalia) (use-package orderless) (use-package which-key :config (which-key-mode 1)) (use-package vertico :after (consult marginalia) :config (setq completion-in-region-function (lambda (&rest args) (apply (if vertico-mode #'consult-completion-in-region #'completion--in-region) args))) (vertico-mode 1) (marginalia-mode 1)) #+end_src *** Company #+begin_src emacs-lisp (use-package company :hook (after-init-hook . global-company-mode)) #+end_src ** Miscellaneous *** Defaults #+begin_src emacs-lisp (electric-pair-mode 1) (electric-indent-mode 0) #+end_src *** Elcord #+begin_src emacs-lisp (defun materus/elcord-toggle (&optional _frame) "Toggle elcord based on visible frames" (if (> (length (frame-list)) 1) (elcord-mode 1) (elcord-mode -1)) ) (use-package elcord :init (unless (daemonp) (elcord-mode 1)) :config (add-hook 'after-delete-frame-functions 'materus/elcord-toggle) (add-hook 'server-after-make-frame-hook 'materus/elcord-toggle)) #+end_src *** Undo-Tree #+begin_src emacs-lisp (use-package undo-tree :init (global-undo-tree-mode 1) :config (defvar materus/undo-tree-dir (concat user-emacs-directory "var/undo-tree/")) (unless (file-exists-p materus/undo-tree-dir) (make-directory materus/undo-tree-dir t)) (setq undo-tree-visualizer-diff t) (setq undo-tree-history-directory-alist `(("." . ,materus/undo-tree-dir ))) (setq undo-tree-visualizer-timestamps t) ) #+end_src *** Projectile #+begin_src emacs-lisp (use-package projectile) #+end_src *** Treemacs #+begin_src emacs-lisp (use-package treemacs) (use-package treemacs-projectile :after (projectile treemacs)) (use-package treemacs-nerd-icons :after (nerd-icons treemacs)) #+end_src * Programming ** LSP #+begin_src emacs-lisp (use-package lsp-mode) (use-package lsp-ui) (use-package dap-mode) (use-package dap-lldb) (use-package dap-gdb-lldb) (defun lsp-booster--advice-json-parse (old-fn &rest args) "Try to parse bytecode instead of json." (or (when (equal (following-char) ?#) (let ((bytecode (read (current-buffer)))) (when (byte-code-function-p bytecode) (funcall bytecode)))) (apply old-fn args))) (advice-add (if (progn (require 'json) (fboundp 'json-parse-buffer)) 'json-parse-buffer 'json-read) :around #'lsp-booster--advice-json-parse) (defun lsp-booster--advice-final-command (old-fn cmd &optional test?) "Prepend emacs-lsp-booster command to lsp CMD." (let ((orig-result (funcall old-fn cmd test?))) (if (and (not test?) ;; for check lsp-server-present? (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper lsp-use-plists (not (functionp 'json-rpc-connection)) ;; native json-rpc (executable-find "emacs-lsp-booster")) (progn (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) (setcar orig-result command-from-exec-path)) (message "Using emacs-lsp-booster for %s!" orig-result) (cons "emacs-lsp-booster" orig-result)) orig-result))) (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) #+end_src ** Nix #+begin_src emacs-lisp (with-eval-after-load 'lsp-mode (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection "nixd") :major-modes '(nix-mode) :priority 0 :server-id 'nixd))) (setq lsp-nix-nixd-formatting-command "nixfmt") (add-hook 'nix-mode-hook 'lsp-deferred) (add-hook 'nix-mode-hook 'display-line-numbers-mode) #+end_src ** Emacs Lisp #+begin_src emacs-lisp (add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) (add-hook 'emacs-lisp-mode-hook 'company-mode) #+end_src ** C/C++ #+begin_src emacs-lisp (add-hook 'c-mode-hook 'lsp-deferred) (add-hook 'c-mode-hook 'display-line-numbers-mode) (add-hook 'c++-mode-hook 'lsp-deferred) (add-hook 'c++-mode-hook 'display-line-numbers-mode) #+end_src ** Java #+begin_src emacs-lisp (add-hook 'java-mode-hook 'lsp-deferred) #+end_src * TODO Keybindings #+begin_src emacs-lisp ;; Keybinds (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) (keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo) (keymap-set global-map "C-" #'indent-rigidly-left-to-tab-stop) (keymap-set global-map "C-" #'indent-rigidly-right-to-tab-stop) (define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) (define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) (define-key key-translation-map (kbd "∇") 'event-apply-hyper-modifier ) (global-set-key (kbd "C-H-t") 'treemacs) (cua-mode 1) #+end_src * Test Just for testing some code #+begin_src emacs-lisp ;;; (global-set-key (kbd "C-∇") (kbd "C-H")) ;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) ;;; (setq completion-styles '(orderless basic) ;;; completion-category-defaults nil ;;; completion-category-overrides '((file (styles partial-completion)))) #+end_src \ No newline at end of file diff --git a/extraFiles/config/emacs/etc/materus/emacs-config.el b/extraFiles/config/emacs/etc/materus/emacs-config.el new file mode 100644 index 0000000..228504f --- /dev/null +++ b/extraFiles/config/emacs/etc/materus/emacs-config.el @@ -0,0 +1,374 @@ +(unless (file-exists-p (concat user-emacs-directory "etc/materus/emacs-config.elc")) + (byte-compile-file (concat user-emacs-directory "etc/materus/emacs-config.el"))) + +(unless (file-exists-p (concat user-emacs-directory "init.elc")) + (byte-compile-file (concat user-emacs-directory "init.el"))) + +(unless (file-exists-p (concat user-emacs-directory "early-init.elc")) + (byte-compile-file (concat user-emacs-directory "early-init.el"))) + +(require 'cl-lib) +(require 'package) +(setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) +(add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/")) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(package-initialize) + +(defvar materus/packages + '( + use-package + elcord + persp-mode + dashboard + magit + git-timemachine + avy + corfu + vterm + projectile + company + clipetty + which-key + iedit + hideshowvis + evil + treemacs-evil + treemacs + treemacs-nerd-icons + treemacs-perspective + treemacs-icons-dired + treemacs-magit + treemacs-projectile + tree-edit + vertico + marginalia + nerd-icons + nerd-icons-completion + perspective + minions + doom-modeline + rainbow-delimiters + rainbow-mode + use-package + cmake-mode + lsp-mode + lsp-java + lsp-jedi + lsp-haskell + lsp-ui + lsp-treemacs + gradle-mode + groovy-mode + kotlin-mode + dap-mode + d-mode + lua-mode + multiple-cursors + org + org-contrib + org-ql + org-rainbow-tags + org-roam + org-roam-ui + org-review + org-superstar + org-auto-tangle + visual-fill-column + csharp-mode + markdown-mode + json-mode + nix-mode + no-littering + right-click-context + dracula-theme + doom-themes + doom-modeline + orderless + popper + undo-tree + bash-completion + consult + eldoc-box + yasnippet + async + request + nix-ts-mode + markdown-ts-mode + llvm-ts-mode + treesit-fold + treesit-auto + tree-sitter-langs + eat + vlf + edit-indirect + zones + sudo-edit + toc-org + eshell-vterm + empv + volatile-highlights + ) + "A list of packages to ensure are installed at launch.") + +(defun materus/packages-installed-p () + (cl-loop for p in materus/packages + when (not (package-installed-p p)) do (cl-return nil) + finally (cl-return t))) + +(defun materus/install-packages () + (unless (materus/packages-installed-p) + (package-refresh-contents) + (dolist (p materus/packages) + (when (not (package-installed-p p)) + (package-install p))))) +(materus/install-packages) + +(require 'recentf) +(use-package no-littering +:config +(add-to-list 'recentf-exclude + (recentf-expand-file-name no-littering-var-directory)) +(add-to-list 'recentf-exclude + (recentf-expand-file-name no-littering-etc-directory))) + +(context-menu-mode 1) +(setq mouse-wheel-follow-mouse 't) +(setq scroll-step 1) +(setq mouse-drag-and-drop-region t) +(xterm-mouse-mode 1) +(pixel-scroll-precision-mode 1) +(setq-default pixel-scroll-precision-large-scroll-height 10.0) + +(setq frame-inhibit-implied-resize t) +(setq frame-resize-pixelwise t) +(setq window-resize-pixelwise t) +(when (display-graphic-p) + (set-frame-font "Hack Nerd Font" nil t) + ) + +(setq-default display-line-numbers-width 4) + + +(global-tab-line-mode 1) +(setq-default tab-width 4) +(tool-bar-mode -1) + +(setq read-process-output-max (* 1024 1024 3)) +(setq ring-bell-function 'ignore) +(setq-default cursor-type '(bar . 1)) + + +;; Delimiters +(use-package rainbow-delimiters :hook + (prog-mode . rainbow-delimiters-mode) + :config + (custom-set-faces + '(rainbow-delimiters-depth-1-face ((t (:foreground "#FFFFFF")))) + '(rainbow-delimiters-depth-2-face ((t (:foreground "#FFFF00")))) + '(rainbow-delimiters-depth-5-face ((t (:foreground "#6A5ACD")))) + '(rainbow-delimiters-unmatched-face ((t (:foreground "#FF0000"))))) + ) +;; Nerd Icons +(use-package nerd-icons) + +;; Theme +(use-package dracula-theme :config + (if (daemonp) + (add-hook 'after-make-frame-functions + (lambda (frame) + (with-selected-frame frame (load-theme 'dracula t)))) + (load-theme 'dracula t))) + +(defun startup-screen-advice (orig-fun &rest args) + (when (= (seq-count #'buffer-file-name (buffer-list)) 0) + (apply orig-fun args))) +(advice-add 'display-startup-screen :around #'startup-screen-advice) ; Hide startup screen if started with file + +(use-package dashboard +:after (nerd-icons) +:config + (setq dashboard-center-content t) + (setq dashboard-display-icons-p t) + (setq dashboard-icon-type 'nerd-icons) + (dashboard-setup-startup-hook) + (when (daemonp) + (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon + ) + ) + +(use-package doom-modeline + :init (setq doom-modeline-support-imenu t) + :hook (after-init . doom-modeline-mode) + :config + (setq doom-modeline-icon t) + (setq display-time-24hr-format t) + (display-time-mode 1)) + +(use-package minions + :hook (after-init . minions-mode)) + +(use-package org + :mode (("\\.org$" . org-mode)) + :hook + ((org-mode . org-indent-mode) + (org-mode . (lambda () + (setq-local electric-pair-inhibit-predicate + `(lambda (c) + (if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))) + :config + (require 'org-mouse) + (require 'org-tempo)) +(use-package org-superstar + :after (org) + :hook + (org-mode . org-superstar-mode)) + :config + (setq org-superstar-leading-bullet " ") +(use-package org-auto-tangle + :after (org) + :hook (org-mode . org-auto-tangle-mode)) +(use-package toc-org + :after (org) + :hook + ((org-mode . toc-org-mode ) + (markdown-mode . toc-org-mode))) + +(use-package consult) +(use-package marginalia) +(use-package orderless) + +(use-package which-key + :config + (which-key-mode 1)) + +(use-package vertico + :after (consult marginalia) + :config + (setq completion-in-region-function + (lambda (&rest args) + (apply (if vertico-mode + #'consult-completion-in-region + #'completion--in-region) + args))) + (vertico-mode 1) + (marginalia-mode 1)) + +(use-package company +:hook (after-init-hook . global-company-mode)) + +(electric-pair-mode 1) +(electric-indent-mode 0) + +(defun materus/elcord-toggle (&optional _frame) + "Toggle elcord based on visible frames" + (if (> (length (frame-list)) 1) + (elcord-mode 1) + (elcord-mode -1)) + ) +(use-package elcord + :init (unless (daemonp) (elcord-mode 1)) + :config + (add-hook 'after-delete-frame-functions 'materus/elcord-toggle) + (add-hook 'server-after-make-frame-hook 'materus/elcord-toggle)) + +(use-package undo-tree +:init (global-undo-tree-mode 1) +:config +(defvar materus/undo-tree-dir (concat user-emacs-directory "var/undo-tree/")) +(unless (file-exists-p materus/undo-tree-dir) + (make-directory materus/undo-tree-dir t)) +(setq undo-tree-visualizer-diff t) +(setq undo-tree-history-directory-alist `(("." . ,materus/undo-tree-dir ))) +(setq undo-tree-visualizer-timestamps t) +) + +(use-package projectile) + +(use-package treemacs) +(use-package treemacs-projectile +:after (projectile treemacs)) +(use-package treemacs-nerd-icons +:after (nerd-icons treemacs)) + +(use-package lsp-mode) +(use-package lsp-ui) +(use-package dap-mode) +(use-package dap-lldb) +(use-package dap-gdb-lldb) + + +(defun lsp-booster--advice-json-parse (old-fn &rest args) + "Try to parse bytecode instead of json." + (or + (when (equal (following-char) ?#) + (let ((bytecode (read (current-buffer)))) + (when (byte-code-function-p bytecode) + (funcall bytecode)))) + (apply old-fn args))) +(advice-add (if (progn (require 'json) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) + +(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) + "Prepend emacs-lsp-booster command to lsp CMD." + (let ((orig-result (funcall old-fn cmd test?))) + (if (and (not test?) ;; for check lsp-server-present? + (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper + lsp-use-plists + (not (functionp 'json-rpc-connection)) ;; native json-rpc + (executable-find "emacs-lsp-booster")) + (progn + (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) + (setcar orig-result command-from-exec-path)) + (message "Using emacs-lsp-booster for %s!" orig-result) + (cons "emacs-lsp-booster" orig-result)) + orig-result))) +(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) + +(with-eval-after-load 'lsp-mode + (lsp-register-client + (make-lsp-client :new-connection (lsp-stdio-connection "nixd") + :major-modes '(nix-mode) + :priority 0 + :server-id 'nixd))) +(setq lsp-nix-nixd-formatting-command "nixfmt") +(add-hook 'nix-mode-hook 'lsp-deferred) +(add-hook 'nix-mode-hook 'display-line-numbers-mode) + +(add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) +(add-hook 'emacs-lisp-mode-hook 'company-mode) + +(add-hook 'c-mode-hook 'lsp-deferred) +(add-hook 'c-mode-hook 'display-line-numbers-mode) + +(add-hook 'c++-mode-hook 'lsp-deferred) +(add-hook 'c++-mode-hook 'display-line-numbers-mode) + +(add-hook 'java-mode-hook 'lsp-deferred) + +;; Keybinds +(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) +(keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo) + + +(keymap-set global-map "C-" #'indent-rigidly-left-to-tab-stop) +(keymap-set global-map "C-" #'indent-rigidly-right-to-tab-stop) + +(define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) +(define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) +(define-key key-translation-map (kbd "∇") 'event-apply-hyper-modifier ) + +(global-set-key (kbd "C-H-t") 'treemacs) +(cua-mode 1) + +;;; (global-set-key (kbd "C-∇") (kbd "C-H")) +;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) + + + +;;; (setq completion-styles '(orderless basic) +;;; completion-category-defaults nil +;;; completion-category-overrides '((file (styles partial-completion)))) diff --git a/extraFiles/config/emacs/etc/materus/internals.el b/extraFiles/config/emacs/etc/materus/internals.el deleted file mode 100644 index 29a2228..0000000 --- a/extraFiles/config/emacs/etc/materus/internals.el +++ /dev/null @@ -1,59 +0,0 @@ -(require 'recentf) -(require 'no-littering) -(add-to-list 'recentf-exclude - (recentf-expand-file-name no-littering-var-directory)) -(add-to-list 'recentf-exclude - (recentf-expand-file-name no-littering-etc-directory)) - -(setq native-comp-async-report-warnings-errors nil) -(setq package-enable-at-startup nil) -(setq frame-inhibit-implied-resize t) -(defvar materus/init-early nil) -(unless materus/init-early - (tool-bar-mode -1) - (setq initial-major-mode 'fundamental-mode) - (setq-default package-quickstart t) - (setq native-comp-speed 3) - (add-hook 'emacs-startup-hook (lambda () (package-initialize) - (setq gc-cons-threshold 100000000 ; ~100mb - gc-cons-percentage 0.1) - )) - (unless (daemonp) - (setq gc-cons-threshold most-positive-fixnum ; 2^61 bytes - gc-cons-percentage 0.6) - (setq package-enable-at-startup nil) - - (advice-add #'tty-run-terminal-initialization :override #'ignore) - (add-hook 'window-setup-hook - (lambda () - (advice-remove #'tty-run-terminal-initialization #'ignore) - (tty-run-terminal-initialization (selected-frame) nil t) - ) - ) - ) - ) - - - -(setq custom-file (concat user-emacs-directory "etc/custom.el")) - - - - - - -;;. Graphical -(setq frame-resize-pixelwise t) -(setq window-resize-pixelwise t) - -(when (display-graphic-p) - (set-frame-font "Hack Nerd Font" nil t) - ) - - -(xterm-mouse-mode 1) - -(setq read-process-output-max (* 1024 1024 3)) - - -(setq ring-bell-function 'ignore) diff --git a/extraFiles/config/emacs/etc/materus/lsp/cpp.el b/extraFiles/config/emacs/etc/materus/lsp/cpp.el deleted file mode 100644 index d9d1c1e..0000000 --- a/extraFiles/config/emacs/etc/materus/lsp/cpp.el +++ /dev/null @@ -1,5 +0,0 @@ -(add-hook 'c-mode-hook 'lsp-deferred) -(add-hook 'c-mode-hook 'display-line-numbers-mode) - -(add-hook 'c++-mode-hook 'lsp-deferred) -(add-hook 'c++-mode-hook 'display-line-numbers-mode) diff --git a/extraFiles/config/emacs/etc/materus/lsp/default.el b/extraFiles/config/emacs/etc/materus/lsp/default.el deleted file mode 100644 index 0057816..0000000 --- a/extraFiles/config/emacs/etc/materus/lsp/default.el +++ /dev/null @@ -1,52 +0,0 @@ -(defun lsp-booster--advice-json-parse (old-fn &rest args) - "Try to parse bytecode instead of json." - (or - (when (equal (following-char) ?#) - (let ((bytecode (read (current-buffer)))) - (when (byte-code-function-p bytecode) - (funcall bytecode)))) - (apply old-fn args))) -(advice-add (if (progn (require 'json) - (fboundp 'json-parse-buffer)) - 'json-parse-buffer - 'json-read) - :around - #'lsp-booster--advice-json-parse) - -(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) - "Prepend emacs-lsp-booster command to lsp CMD." - (let ((orig-result (funcall old-fn cmd test?))) - (if (and (not test?) ;; for check lsp-server-present? - (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper - lsp-use-plists - (not (functionp 'json-rpc-connection)) ;; native json-rpc - (executable-find "emacs-lsp-booster")) - (progn - (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) - (setcar orig-result command-from-exec-path)) - (message "Using emacs-lsp-booster for %s!" orig-result) - (cons "emacs-lsp-booster" orig-result)) - orig-result))) -(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) - - -(require 'lsp-mode) -(require 'lsp-ui) -(require 'dap-lldb) -(require 'dap-gdb-lldb) - -(with-eval-after-load 'lsp-mode - (lsp-register-client - (make-lsp-client :new-connection (lsp-stdio-connection "nixd") - :major-modes '(nix-mode) - :priority 0 - :server-id 'nixd))) - -(load (concat materus/cfg "/lsp/cpp")) -(load (concat materus/cfg "/lsp/java")) -(load (concat materus/cfg "/lsp/nix")) -(load (concat materus/cfg "/lsp/lisp")) - - - - diff --git a/extraFiles/config/emacs/etc/materus/lsp/java.el b/extraFiles/config/emacs/etc/materus/lsp/java.el deleted file mode 100644 index 3a7bf03..0000000 --- a/extraFiles/config/emacs/etc/materus/lsp/java.el +++ /dev/null @@ -1 +0,0 @@ -(add-hook 'java-mode-hook 'lsp-deferred) diff --git a/extraFiles/config/emacs/etc/materus/lsp/lisp.el b/extraFiles/config/emacs/etc/materus/lsp/lisp.el deleted file mode 100644 index d6effe6..0000000 --- a/extraFiles/config/emacs/etc/materus/lsp/lisp.el +++ /dev/null @@ -1,2 +0,0 @@ -(add-hook 'emacs-lisp-mode-hook 'display-line-numbers-mode) -(add-hook 'emacs-lisp-mode-hook 'company-mode) diff --git a/extraFiles/config/emacs/etc/materus/lsp/nix.el b/extraFiles/config/emacs/etc/materus/lsp/nix.el deleted file mode 100644 index 560dbc0..0000000 --- a/extraFiles/config/emacs/etc/materus/lsp/nix.el +++ /dev/null @@ -1,2 +0,0 @@ -(add-hook 'nix-mode-hook 'lsp-deferred) -(add-hook 'nix-mode-hook 'display-line-numbers-mode) diff --git a/extraFiles/config/emacs/etc/materus/packages.el b/extraFiles/config/emacs/etc/materus/packages.el deleted file mode 100644 index ffc9740..0000000 --- a/extraFiles/config/emacs/etc/materus/packages.el +++ /dev/null @@ -1,78 +0,0 @@ -(defvar bootstrap-version) -(defvar straight-base-dir) -(setq straight-base-dir (concat user-emacs-directory "var/" )) -(let ((bootstrap-file - (expand-file-name - "straight/repos/straight.el/bootstrap.el" - (or (bound-and-true-p straight-base-dir) - user-emacs-directory))) - (bootstrap-version 7)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) - -(straight-use-package 'elcord) -(straight-use-package 'persp-mode) -(straight-use-package 'dashboard) -(straight-use-package 'magit) -(straight-use-package 'avy) -(straight-use-package 'corfu) -(straight-use-package 'vterm) -(straight-use-package 'centaur-tabs) -(straight-use-package 'projectile) -(straight-use-package 'company) -(straight-use-package 'clipetty) -(straight-use-package 'which-key) -(straight-use-package 'iedit) -(straight-use-package 'hideshowvis) -(straight-use-package 'evil) -(straight-use-package 'treemacs-evil) -(straight-use-package 'treemacs) -(straight-use-package 'treemacs-nerd-icons) -(straight-use-package 'treemacs-perspective) -(straight-use-package 'treemacs-icons-dired) -(straight-use-package 'treemacs-magit) -(straight-use-package 'treemacs-projectile) -(straight-use-package 'tree-edit) -(straight-use-package 'vertico) -(straight-use-package 'marginalia) -(straight-use-package 'nerd-icons) -(straight-use-package 'nerd-icons-completion) -(straight-use-package 'perspective) -(straight-use-package 'minions) -(straight-use-package 'telephone-line) -(straight-use-package 'rainbow-delimiters) -(straight-use-package 'use-package) -(straight-use-package 'cmake-mode) -(straight-use-package 'lsp-mode) -(straight-use-package 'lsp-java) -(straight-use-package 'lsp-jedi) -(straight-use-package 'lsp-haskell) -(straight-use-package 'lsp-ui) -(straight-use-package 'lsp-treemacs) -(straight-use-package 'dap-mode) -(straight-use-package 'd-mode) -(straight-use-package 'lua-mode) -(straight-use-package 'multiple-cursors) -(straight-use-package 'org) -(straight-use-package 'org-rainbow-tags) -(straight-use-package 'org-roam) -(straight-use-package 'org-roam-ui) -(straight-use-package 'org-review) -(straight-use-package 'csharp-mode) -(straight-use-package 'markdown-mode) -(straight-use-package 'json-mode) -(straight-use-package 'nix-mode) -(straight-use-package 'no-littering) -(straight-use-package 'right-click-context) -(straight-use-package 'dracula-theme) -(straight-use-package 'doom-themes) -(straight-use-package 'orderless) -(straight-use-package 'undo-tree) -(straight-use-package 'bash-completion) -(straight-use-package 'consult) \ No newline at end of file diff --git a/extraFiles/config/emacs/etc/materus/start.el b/extraFiles/config/emacs/etc/materus/start.el deleted file mode 100644 index 7cd0156..0000000 --- a/extraFiles/config/emacs/etc/materus/start.el +++ /dev/null @@ -1,118 +0,0 @@ -(defvar materus/cfg nil) -(setq materus/cfg (concat user-emacs-directory "etc/materus")) - -; Load packages -(require 'telephone-line) -(require 'elcord) -(require 'dashboard) -(require 'minions) -(require 'dracula-theme) -(require 'nerd-icons) -(require 'projectile) -(require 'treemacs) -(require 'treemacs-projectile) -(require 'treemacs-nerd-icons) -(require 'vertico) -(require 'orderless) -(require 'marginalia) -(require 'undo-tree) -(require 'consult) - -(cua-mode 0) - -;Keybinds -(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) -(keymap-set cua--cua-keys-keymap "C-y" 'undo-tree-redo) - - - - -(keymap-set global-map "TAB" #'indent-rigidly-right-to-tab-stop) -(keymap-set global-map "" #'indent-rigidly-left-to-tab-stop) -(keymap-set global-map "C-" #'indent-for-tab-commandn) -(keymap-set vertico-map "TAB" #'vertico-insert) - -(define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) -(define-key key-translation-map (kbd "") 'event-apply-hyper-modifier ) -(define-key key-translation-map (kbd "∇") 'event-apply-hyper-modifier ) - -(global-set-key (kbd "C-H-t") 'treemacs) - -(setq completion-in-region-function - (lambda (&rest args) - (apply (if vertico-mode - #'consult-completion-in-region - #'completion--in-region) - args))) - - -(tool-bar-mode -1) -(if (daemonp) - (add-hook 'after-make-frame-functions - (lambda (frame) - (with-selected-frame frame (load-theme 'dracula t)))) - (load-theme 'dracula t)) - - -(setq-default cursor-type '(bar . 1)) -(pixel-scroll-precision-mode 1) - -(context-menu-mode 1) -(setq mouse-wheel-follow-mouse 't) -(setq scroll-step 1) -(setq mouse-drag-and-drop-region t) -(telephone-line-mode 1) -(setq-default pixel-scroll-precision-large-scroll-height 10.0) -(minions-mode 1) -(unless (daemonp) - (elcord-mode 1)) - -;Hide startup screen if started with file -(defun startup-screen-advice (orig-fun &rest args) - (when (= (seq-count #'buffer-file-name (buffer-list)) 0) - (apply orig-fun args))) -(advice-add 'display-startup-screen :around #'startup-screen-advice) - - - - - -;Enable dashboard -(setq dashboard-center-content t) -(setq dashboard-display-icons-p t) -(setq dashboard-icon-type 'nerd-icons) -(dashboard-setup-startup-hook) -(when (daemonp) - (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon -) - - -(setq-default display-line-numbers-width 4) - - - - - -(cua-mode 1) - - -;(global-set-key (kbd "C-∇") (kbd "C-H")) -;(global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) - -;; Enable vertico -(vertico-mode 1) -(marginalia-mode 1) - -;(setq completion-styles '(orderless basic) -; completion-category-defaults nil -; completion-category-overrides '((file (styles partial-completion)))) - -(electric-pair-mode 1) - -(global-undo-tree-mode 1) -(global-tab-line-mode 1) -(setq-default tab-width 4) - - - -(load (concat materus/cfg "/lsp/default")) diff --git a/extraFiles/config/emacs/init.el b/extraFiles/config/emacs/init.el index 1e2306f..b88a1b1 100644 --- a/extraFiles/config/emacs/init.el +++ b/extraFiles/config/emacs/init.el @@ -1,9 +1,5 @@ -(setq-default materus/nix-packages (require 'evil nil 'noerror)) - - - -(unless materus/nix-packages (load (concat user-emacs-directory "etc/materus/packages"))) -(load (concat user-emacs-directory "etc/materus/internals")) -(load (concat user-emacs-directory "etc/materus/start")) +(setq-default materus/use-nix-packages (require 'materus-config nil 'noerror)) +(cua-mode 0) ; To load cua variables/functions but not set it up yet +(load (concat user-emacs-directory "etc/materus/emacs-config")) (when (file-exists-p custom-file) (load custom-file))