diff --git a/.gitignore b/.gitignore index 216102d..ab386ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -\#*\# \ No newline at end of file +\#*\# +.vscode \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 1c56df3..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "nixEnvSelector.suggestion": false, - "files.associations": { - "iostream": "cpp" - } -} \ No newline at end of file diff --git a/configurations/host/materusPC/containers/arch.nix b/configurations/host/materusPC/containers/arch.nix index c18c770..11bdee2 100644 --- a/configurations/host/materusPC/containers/arch.nix +++ b/configurations/host/materusPC/containers/arch.nix @@ -2,8 +2,8 @@ let mainMirror = "https://ftp.icm.edu.pl/pub/Linux/dist/archlinux"; extraMirrors = [ ]; - getty = [ 5 6 ]; - ttys = [ 5 6 7 8 ] ++ getty; + getty = [ 6 7 ]; + ttys = [ 6 7 8 ] ++ getty; startPkgs = lib.strings.concatStringsSep " " [ "base" "base-devel" "dbus" "less" "nano" "bash-completion" ]; scripts = { @@ -28,6 +28,7 @@ let systemd-machine-id-setup --root="/var/lib/machines/archlinux" systemd-nspawn -q --settings=false --system-call-filter=@sandbox -D "/var/lib/machines/archlinux" /bin/sh -c " export PATH=/bin + touch /etc/systemd/do-not-udevadm-trigger-on-update pacman-key --init && pacman-key --populate pacman -Rs --noconfirm arch-install-scripts pacman -Sy --noconfirm --needed ${startPkgs} diff --git a/configurations/host/materusPC/home/materus/default.nix b/configurations/host/materusPC/home/materus/default.nix index 1331d49..160edeb 100644 --- a/configurations/host/materusPC/home/materus/default.nix +++ b/configurations/host/materusPC/home/materus/default.nix @@ -53,6 +53,8 @@ lua gtk4.dev gtk4 + glib + glib.dev miniaudio SDL2.dev SDL2 diff --git a/configurations/host/materusPC/other/apps.nix b/configurations/host/materusPC/other/apps.nix index 8c6eada..6f3319e 100644 --- a/configurations/host/materusPC/other/apps.nix +++ b/configurations/host/materusPC/other/apps.nix @@ -111,7 +111,7 @@ binutils - qbittorrent + materusArg.unstable.qbittorrent mkvtoolnix nicotine-plus picard diff --git a/configurations/host/materusPC/other/java.nix b/configurations/host/materusPC/other/java.nix index 55446e1..46d4f2e 100644 --- a/configurations/host/materusPC/other/java.nix +++ b/configurations/host/materusPC/other/java.nix @@ -7,8 +7,8 @@ }; environment.variables = { - JAVA_8_HOME = pkgs.jdk8; - JAVA_17_HOME = pkgs.jdk17; - JAVA_21_HOME = pkgs.jdk21; + JAVA_8_HOME = "${pkgs.jdk8}/lib/openjdk/"; + JAVA_17_HOME = "${pkgs.jdk17}/lib/openjdk/"; + JAVA_21_HOME = "${pkgs.jdk21}/lib/openjdk/"; }; } diff --git a/configurations/host/materusPC/other/users.nix b/configurations/host/materusPC/other/users.nix index 7101093..f097820 100644 --- a/configurations/host/materusPC/other/users.nix +++ b/configurations/host/materusPC/other/users.nix @@ -22,6 +22,6 @@ users.users.materus = { shell = pkgs.zsh; description = "Mateusz Słodkowicz"; openssh.authorizedKeys.keyFiles = [ ("${materusArg.cfg.path}" + "/extraFiles/keys/ssh/materus.pub") ]; - hashedPasswordFile = config.sops.secrets."users/materus".path; + #hashedPasswordFile = config.sops.secrets."users/materus".path; }; } \ No newline at end of file diff --git a/configurations/host/materusPC/secrets/default.nix b/configurations/host/materusPC/secrets/default.nix index 8cfcae1..5116f5f 100644 --- a/configurations/host/materusPC/secrets/default.nix +++ b/configurations/host/materusPC/secrets/default.nix @@ -10,7 +10,7 @@ sops.gnupg.sshKeyPaths = [ ]; sops.age.sshKeyPaths = [ "/materus/root/ssh_host_ed25519_key" ]; sops.defaultSopsFile = materusCfg.hostPath + "/secrets/secrets.yaml"; - sops.secrets."users/materus" = { neededForUsers = true; }; + #sops.secrets."users/materus" = { neededForUsers = true; }; sops.secrets.wireguard = { }; services.openssh.hostKeys = [ diff --git a/configurations/profile/home/editor/code.nix b/configurations/profile/home/editor/code.nix index af5bf99..8e8f281 100644 --- a/configurations/profile/home/editor/code.nix +++ b/configurations/profile/home/editor/code.nix @@ -111,6 +111,11 @@ let "[cpp]" = { "editor.defaultFormatter" = lib.mkDefault "xaver.clang-format"; }; + "cmake.showOptionsMovedNotification" = false; + "cmake.pinnedCommands" = [ + "workbench.action.tasks.configureTaskRunner" + "workbench.action.tasks.runTask" + ]; }; in { diff --git a/configurations/profile/home/editor/emacs/default.nix b/configurations/profile/home/editor/emacs/default.nix index aa50681..9b01f3d 100644 --- a/configurations/profile/home/editor/emacs/default.nix +++ b/configurations/profile/home/editor/emacs/default.nix @@ -17,24 +17,120 @@ let }; configPath = "${materusArg.cfg.path}" + "/extraFiles/config/emacs/"; - inits = import ./init.nix { - path = configPath; - inherit pkgs; - }; packages = epkgs: with epkgs; [ (materus-config epkgs) treesit-grammars.with-all-grammars - ]; - default-config = '' - ${setNixInit} - ${inits.initText} - ''; + use-package + elcord + persp-mode + dashboard + magit + git-timemachine + avy + vterm + direnv + projectile + clipetty + which-key + iedit + hideshowvis + evil + treemacs-evil + treemacs + treemacs-nerd-icons + treemacs-perspective + treemacs-icons-dired + treemacs-magit + treemacs-projectile + tree-edit + nerd-icons + nerd-icons-completion + perspective + minions + rainbow-delimiters + rainbow-mode + cmake-mode + lsp-mode + lsp-java + lsp-jedi + lsp-haskell + lsp-ui + lsp-treemacs + dap-mode + flycheck + gradle-mode + groovy-mode + kotlin-mode + d-mode + lua-mode + multiple-cursors + org + org-contrib + org-ql + org-rainbow-tags + org-roam + org-roam-ui + org-review + org-present + 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 + popper + undo-tree + bash-completion + 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 + empv + volatile-highlights + highlight + elfeed + elfeed-goodies + drag-stuff + dirvish + rg + # Completions & Minibuffer + corfu + company + company-quickhelp + cape + embark + embark-consult + orderless + vertico + marginalia + ]; emacsEnv = pkgs.buildEnv { name = "emacs-env"; paths = with pkgs; [ + ripgrep + cmake + gnumake nixfmt-classic python3 lua @@ -48,6 +144,8 @@ let gdb nixd jdt-language-server + jdk + gradle omnisharp-roslyn ]; }; @@ -56,6 +154,7 @@ let setNixInit = '' (setenv "PATH" (concat (getenv "PATH") ":${emacsEnv}/bin")) + (setenv "LD_LIBRARY_PATH" (concat (getenv "LD_LIBRARY_PATH") ":${emacsEnv}/lib")) (setq exec-path (append exec-path '("${emacsEnv}/bin"))) (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) @@ -65,26 +164,28 @@ in { materusArg.pkgs.lib.mkBoolOpt false "Enable emacs with materus cfg"; config = lib.mkIf cfg.enable { - home.activation.emacsCompile = lib.hm.dag.entryAfter [ "linkGeneration" ] '' + home.activation.emacsSetup = lib.hm.dag.entryAfter [ "linkGeneration" ] '' mkdir -p ${config.xdg.configHome}/emacs/var/recovery - mkdir -p ${config.xdg.configHome}/emacs/etc - + mkdir -p ${config.xdg.configHome}/emacs/etc/materus 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-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")' + ${pkgs.rsync}/bin/rsync -zr --no-times --chmod=744 "${configPath}" "${config.xdg.configHome}/emacs" + + + run ${config.programs.emacs.finalPackage}/bin/emacs -Q --batch \ + --eval '(setq warning-minimum-log-level :error)' \ + --eval '(setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" ))' \ + --eval '(setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" ))' \ + --eval '(package-initialize)' \ + --eval '(byte-recompile-directory (concat user-emacs-directory "etc/materus/extra") 0 t)' \ + --eval '(byte-compile-file "${config.xdg.configHome}/emacs/early-init.el")' \ + --eval '(byte-compile-file "${config.xdg.configHome}/emacs/init.el")' \ + --eval '(byte-compile-file "${config.xdg.configHome}/emacs/nix-init.el")' \ + --eval '(byte-compile-file "${config.xdg.configHome}/emacs/etc/materus/emacs-config.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; - }; - }; + xdg.configFile = { "emacs/nix-init.el".text = setNixInit; }; + + #Emacsclient with COLORTERM env variable, without it display in "-nw" client is broken xdg.desktopEntries.emacs = { name = "Emacs"; genericName = "Edytor tekstu"; @@ -128,18 +229,31 @@ in { withSQLite3 = true; withWebP = true; withX = true; + #withXwidgets = true; withGTK3 = true; withAlsaLib = true; withGconf = true; withImageMagick = true; }).overrideAttrs (f: p: { + #Remove .desktop files, will use my own. Add file with buildtime in case of using elpaca 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); + extraPackages = epkgs: + (packages (epkgs.overrideScope (ff: pp: { + #Build lsp-mode with plist support, need to set this in emacs too + + lsp-mode = (pp.lsp-mode.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + lsp-java = (pp.lsp-java.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + lsp-jedi= (pp.lsp-jedi.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + lsp-haskell = (pp.lsp-haskell.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + lsp-ui = (pp.lsp-ui.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + lsp-treemacs = (pp.lsp-treemacs.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + dap-mode = (pp.dap-mode.overrideAttrs (f: p: { buildPhase = "export LSP_USE_PLISTS=true\n" + p.buildPhase;})); + }))); }; }; diff --git a/configurations/profile/home/editor/emacs/init.nix b/configurations/profile/home/editor/emacs/init.nix deleted file mode 100644 index 76289d1..0000000 --- a/configurations/profile/home/editor/emacs/init.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ path, pkgs }: -{ - - earlyInitText = '' - ${builtins.readFile (path + "early-init.el")} - ''; - initText = '' - ${builtins.readFile (path + "init.el")} - - - ''; - -} diff --git a/configurations/profile/home/shell/bash.nix b/configurations/profile/home/shell/bash.nix index 3efd68a..b674545 100644 --- a/configurations/profile/home/shell/bash.nix +++ b/configurations/profile/home/shell/bash.nix @@ -9,11 +9,17 @@ in config = lib.mkIf cfg.enable { programs.bash = { + enable = true; enableCompletion = lib.mkDefault true; enableVteIntegration = lib.mkDefault true; historyControl = lib.mkDefault [ "erasedups" "ignorespace" ]; shellOptions = lib.mkDefault [ "autocd" "checkwinsize" "cmdhist" "expand_aliases" "extglob" "globstar" "checkjobs" "nocaseglob" ]; + initExtra = '' + if [ -n "$EAT_SHELL_INTEGRATION_DIR" ]; then + source "$EAT_SHELL_INTEGRATION_DIR/bash"; + fi + ''; }; }; diff --git a/configurations/profile/home/shell/zsh.nix b/configurations/profile/home/shell/zsh.nix index 35a3598..3ef5e64 100644 --- a/configurations/profile/home/shell/zsh.nix +++ b/configurations/profile/home/shell/zsh.nix @@ -85,6 +85,11 @@ in ${makeEnv "__MATERUS_HM_ZSH_PRIVATE" "0"} ''; initExtraFirst = '' + + if [ -n "$EAT_SHELL_INTEGRATION_DIR" ]; then + source "$EAT_SHELL_INTEGRATION_DIR/zsh"; + fi + ${makeIfVar "__MATERUS_HM_ZSH_PROMPT" "p10k" '' if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" @@ -166,6 +171,8 @@ in ${lib.optionalString config.materus.profile.editor.emacs.enable ''alias "e"="emacsclient -nw -c --alternate-editor= "''} ${lib.optionalString config.materus.profile.editor.emacs.enable ''alias "ee"="emacsclient -n -r --alternate-editor= "''} + + '' + makeIfVar "__MATERUS_HM_ZSH_PROMPT" "p10k" '' diff --git a/configurations/profile/os/default.nix b/configurations/profile/os/default.nix index 4209792..40afbc8 100644 --- a/configurations/profile/os/default.nix +++ b/configurations/profile/os/default.nix @@ -1,5 +1,4 @@ -{ config, pkgs, lib, ... }: -{ +{ config, pkgs, lib, ... }: { imports = [ ./nix.nix ./fonts.nix @@ -18,12 +17,17 @@ font = lib.mkDefault "LatArCyrHeb-16"; keyMap = lib.mkDefault "pl"; }; + environment.sessionVariables = { + MATERUS_CONFIG_DIR = lib.mkDefault "/etc/nixos/"; + }; programs.tmux = { enable = lib.mkDefault true; clock24 = lib.mkDefault true; }; - environment.systemPackages = lib.mkIf config.programs.tmux.enable [ pkgs.tmux.terminfo ]; + environment.systemPackages = + lib.mkIf config.programs.tmux.enable [ pkgs.tmux.terminfo ]; } - \ No newline at end of file + + diff --git a/extraFiles/config/emacs/early-init.el b/extraFiles/config/emacs/early-init.el index 3340ba2..ad10fec 100644 --- a/extraFiles/config/emacs/early-init.el +++ b/extraFiles/config/emacs/early-init.el @@ -1,26 +1,33 @@ +;;; -*- lexical-binding: t; -*- (defvar materus/init-early t) ; Var to ensure early-init loaded (setq materus/init-early t) ; Probably useless +(setenv "LSP_USE_PLISTS" "true") (setq initial-major-mode 'fundamental-mode) (setq native-comp-async-report-warnings-errors nil) (setq package-enable-at-startup nil) +(unless (daemonp) + (add-to-list 'initial-frame-alist '(fullscreen . maximized))) +(setq default-frame-alist + '((width . 130) + (height . 40))) (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 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) + 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) - ) + (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))) diff --git a/extraFiles/config/emacs/emacs-materus-config.org b/extraFiles/config/emacs/emacs-materus-config.org index a17df02..e6364fd 100644 --- a/extraFiles/config/emacs/emacs-materus-config.org +++ b/extraFiles/config/emacs/emacs-materus-config.org @@ -1,576 +1,710 @@ -#+TITLE: Materus Emacs Cfg -#+AUTHOR: materus -#+DESCRIPTION: materus emacs configuration -#+STARTUP: overview -#+PROPERTY: header-args :tangle etc/materus/emacs-config.el -#+auto_tangle: t -My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]] -* Table of Contents :noexport:TOC_3: -- [[#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 my nix config (not used anymore, might use in future), 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 -Byte compile files if not already. -#+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. -After some testing default package manager works best for me. -** Init -#+begin_src emacs-lisp - (require 'cl-lib) - (require 'package) - (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) - (setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" )) - (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 - 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 - highlight - elfeed - elfeed-goodies - drag-stuff - ) - "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 -General configurations of packages modes etc. -** 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)) - ;; Rainbow mode - (use-package rainbow-mode - :hook - ((org-mode . rainbow-mode) - (prog-mode . rainbow-mode))) - - ;; 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 - :init (global-company-mode 1)) - -#+end_src -** Miscellaneous -Other configs -*** Defaults -#+begin_src emacs-lisp - (electric-pair-mode 1) - (electric-indent-mode -1) - (setq-default indent-tabs-mode nil) - (setq-default buffer-file-coding-system 'utf-8-dos) -#+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 - -* 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 +#+TITLE: Materus Emacs Cfg +#+AUTHOR: materus +#+DESCRIPTION: materus emacs configuration +#+STARTUP: overview +#+PROPERTY: header-args :tangle etc/materus/emacs-config.el +#+auto_tangle: t +My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]] +* Table of Contents :noexport:TOC_3: +- [[#init-files][Init Files]] + - [[#early-init][Early Init]] + - [[#init][Init]] + - [[#compile-time][Compile Time]] +- [[#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]] + - [[#code-completion][Code completion]] + - [[#miscellaneous][Miscellaneous]] + - [[#defaults][Defaults]] + - [[#elcord][Elcord]] + - [[#undo-tree][Undo-Tree]] + - [[#projectile][Projectile]] + - [[#treemacs][Treemacs]] + - [[#magit][Magit]] + - [[#dirvish][Dirvish]] +- [[#programming][Programming]] + - [[#lsp][LSP]] + - [[#nix][Nix]] + - [[#emacs-lisp][Emacs Lisp]] + - [[#cc][C/C++]] + - [[#java][Java]] +- [[#keybindings][Keybindings]] +- [[#snippets][Snippets]] + - [[#yasnippet-init][Yasnippet init]] +- [[#other][Other]] + - [[#update-config-script][Update config script]] + - [[#byte-compile][Byte compile]] +- [[#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 + ;;; -*- lexical-binding: t; -*- + (defvar materus/init-early t) ; Var to ensure early-init loaded + (setq materus/init-early t) ; Probably useless + (setenv "LSP_USE_PLISTS" "true") + + (setq initial-major-mode 'fundamental-mode) + (setq native-comp-async-report-warnings-errors nil) + (setq package-enable-at-startup nil) + (unless (daemonp) + (add-to-list 'initial-frame-alist '(fullscreen . maximized))) + (setq default-frame-alist + '((width . 130) + (height . 40))) + + (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 my nix config (not used anymore, might use in future), loads config and custom.el +#+begin_src emacs-lisp + ;;; -*- lexical-binding: t; -*- + (setq-default materus/use-nix-packages (require 'materus-config nil 'noerror)) + (unless (file-directory-p (concat user-emacs-directory "var/quickstart")) + (make-directory (concat user-emacs-directory "var/quickstart") t)) + (load (concat user-emacs-directory "nix-init") t) + (load (concat user-emacs-directory "etc/materus/emacs-config")) + (load custom-file t) +#+end_src +** Compile Time +#+begin_src emacs-lisp + ;;; -*- lexical-binding: t; -*- + (eval-when-compile + (defvar doom-modeline-support-imenu nil) + (defvar display-time-24hr-format nil) + (defvar lsp-nix-nixd-formatting-command nil) + (defvar cua--cua-keys-keymap nil) + (declare-function lsp-stdio-connection "lsp-mode" (COMMAND &optional TEST-COMMAND)) + (declare-function make-lsp-client "lsp-mode") + (declare-function lsp-register-client "lsp-mode" ( CLIENT )) + ) +#+end_src +* Packages +Package manager config if not using nix. +After some testing default package manager works best for me. +** Init +#+begin_src emacs-lisp + (require 'cl-lib) + (require 'package) + (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) + (setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" )) + (setq package-quickstart t) + (setq package-quickstart-file + (concat user-emacs-directory "var/quickstart/package-quickstart-" emacs-version ".el" )) + (add-to-list 'load-path (concat user-emacs-directory "etc/materus/extra")) + + (add-to-list 'package-archives '("nongnu-devel" . "https://elpa.nongnu.org/nongnu-devel/")) + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) + + + #+end_src +** Packages +Packages to install +#+begin_src emacs-lisp + (defvar materus/packages + '( + use-package + elcord + persp-mode + dashboard + magit + git-timemachine + avy + vterm + direnv + projectile + clipetty + which-key + iedit + hideshowvis + evil + treemacs-evil + treemacs + treemacs-nerd-icons + treemacs-perspective + treemacs-icons-dired + treemacs-magit + treemacs-projectile + tree-edit + nerd-icons + nerd-icons-completion + perspective + minions + rainbow-delimiters + rainbow-mode + cmake-mode + lsp-mode + lsp-java + lsp-jedi + lsp-haskell + lsp-ui + lsp-treemacs + flycheck + 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-present + 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 + popper + undo-tree + bash-completion + 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 + empv + volatile-highlights + highlight + elfeed + elfeed-goodies + drag-stuff + dirvish + rg + ;; Completions & Minibuffer + corfu + company + company-quickhelp + cape + embark + embark-consult + orderless + vertico + marginalia + ) + "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))) + (package-quickstart-refresh))) + (unless materus/use-nix-packages + (package-initialize) + (materus/install-packages) + (unless (file-exists-p package-quickstart-file) (package-quickstart-refresh) )) + +#+end_src +* Configuration +General configurations of packages modes etc. +** No Littering +Set up no littering +#+begin_src emacs-lisp + (require 'recentf) + (use-package no-littering + :config + (setq package-quickstart-file + (concat user-emacs-directory "var/quickstart/package-quickstart-" emacs-version ".el" )) + (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 + + (when (daemonp) + (add-hook 'after-make-frame-functions + (lambda (frame) (when (= (length (frame-list)) 2) + (set-frame-parameter frame 'fullscreen 'maximized))))) + + (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 3) + + + (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)) + ;; Rainbow mode + (use-package rainbow-mode + :hook + ((org-mode . rainbow-mode) + (prog-mode . rainbow-mode))) + + ;; 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) + (use-package nerd-icons-completion + :after (marginalia) + :config + (nerd-icons-completion-mode 1) + (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) + + ;; 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 projectile) + :config + (setq dashboard-center-content t) + (setq dashboard-display-icons-p t) + (setq dashboard-icon-type 'nerd-icons) + (setq dashboard-projects-backend 'projectile) + (setq dashboard-items '((recents . 5) + (bookmarks . 5) + (projects . 5) + (agenda . 5) + (registers . 5))) + (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 doom-modeline-project-detection 'auto) + (setq doom-modeline-height 20) + (setq doom-modeline-enable-word-count t) + (setq doom-modeline-minor-modes t) + (setq display-time-24hr-format t) + (display-time-mode 1) + (column-number-mode 1) + (line-number-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 . display-line-numbers-mode) + ) + :config + (require 'org-mouse) + (require 'org-tempo) + (add-hook 'org-mode-hook (lambda () + (setq-local + electric-pair-inhibit-predicate + `(lambda (c) + (if + (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))) + + (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)) + (use-package vertico-mouse + :config + (vertico-mouse-mode 1)) + + +#+end_src +*** Code completion +#+begin_src emacs-lisp + (use-package company + :config + (setq global-corfu-minibuffer nil) + (global-company-mode 1)) + + #+end_src + +** Miscellaneous +Other configs +*** Defaults +#+begin_src emacs-lisp + (electric-pair-mode 1) + (electric-indent-mode -1) + (setq-default indent-tabs-mode nil) + (setq-default buffer-file-coding-system 'utf-8-unix) +#+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 + :config + (unless (daemonp) (elcord-mode 1)) + (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 +:config +(global-undo-tree-mode 1) +(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 + :config (projectile-mode 1)) +#+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 +*** Magit +#+begin_src emacs-lisp +(use-package magit) +#+end_src +*** Dirvish +#+begin_src emacs-lisp + (use-package dirvish + :config (dirvish-override-dired-mode 1) + (setq dirvish-attributes + '(vc-state + subtree-state + nerd-icons + collapse + git-msg + file-time + file-size))) + +#+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) + + + (add-hook 'prog-mode-hook 'display-line-numbers-mode) + +#+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) +#+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 + (use-package lsp-java + :config + (add-hook 'java-mode-hook (lambda () (when (getenv "JDTLS_PATH") (setq lsp-java-server-install-dir (getenv "JDTLS_PATH"))))) + (add-hook 'java-mode-hook 'lsp-deferred) + (add-hook 'java-mode-hook 'display-line-numbers-mode)) + +#+end_src + +* Keybindings +#+begin_src emacs-lisp + (use-package cua-base) + + ;; 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 +* Snippets +** Yasnippet init +#+begin_src emacs-lisp +(use-package yasnippet +:config (yas-global-mode 1)) +#+end_src +* Other +** Update config script +#+begin_src emacs-lisp + (defun materus/sync-config () + "Function to sync config from MATERUS_CONFIG_DIR to emacs folder" + (if (getenv "MATERUS_CONFIG_DIR") + (progn (copy-directory (concat (getenv "MATERUS_CONFIG_DIR") "extraFiles/config/emacs/") + user-emacs-directory t t t) t) + (progn (message "Can't use if MATERUS_CONFIG_DIR is not set!") nil))) + (defun materus/compare-file-time (file1 file2) + "Returns t when file1 is newer than file2" + (time-less-p + (nth 5 (file-attributes file2)) + (nth 5 (file-attributes file1)) + )) + (defun materus/compile-if-needed (file) + (unless (and (file-exists-p (concat user-emacs-directory file "c")) + (materus/compare-file-time (concat user-emacs-directory file "c") + (concat user-emacs-directory file))) + (byte-compile-file (concat user-emacs-directory file))) + ) + (defun materus/compile-config-if-needed () + (materus/compile-if-needed "early-init.el") + (materus/compile-if-needed "init.el") + (materus/compile-if-needed "etc/materus/emacs-config.el")) + (defun materus/update-config () + "Will sync and compile config" + (interactive) + (when (materus/sync-config) (materus/compile-config-if-needed) (byte-recompile-directory (concat user-emacs-directory "etc/materus/extra") 0 t))) +#+end_src + +** Byte compile +Byte compile files. +#+begin_src emacs-lisp + (materus/compile-config-if-needed) +#+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 diff --git a/extraFiles/config/emacs/etc/materus/emacs-config.el b/extraFiles/config/emacs/etc/materus/emacs-config.el index 53893cc..60a8823 100644 --- a/extraFiles/config/emacs/etc/materus/emacs-config.el +++ b/extraFiles/config/emacs/etc/materus/emacs-config.el @@ -1,19 +1,25 @@ -(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"))) +;;; -*- lexical-binding: t; -*- +(eval-when-compile + (defvar doom-modeline-support-imenu nil) + (defvar display-time-24hr-format nil) + (defvar lsp-nix-nixd-formatting-command nil) + (defvar cua--cua-keys-keymap nil) + (declare-function lsp-stdio-connection "lsp-mode" (COMMAND &optional TEST-COMMAND)) + (declare-function make-lsp-client "lsp-mode") + (declare-function lsp-register-client "lsp-mode" ( CLIENT )) + ) (require 'cl-lib) (require 'package) (setq package-user-dir (concat user-emacs-directory "var/elpa/" emacs-version "/" )) (setq package-gnupghome-dir (concat user-emacs-directory "var/elpa/gnupg/" )) +(setq package-quickstart t) +(setq package-quickstart-file + (concat user-emacs-directory "var/quickstart/package-quickstart-" emacs-version ".el" )) +(add-to-list 'load-path (concat user-emacs-directory "etc/materus/extra")) + (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 '( @@ -24,10 +30,9 @@ magit git-timemachine avy - corfu vterm + direnv projectile - company clipetty which-key iedit @@ -41,13 +46,10 @@ treemacs-magit treemacs-projectile tree-edit - vertico - marginalia nerd-icons nerd-icons-completion perspective minions - doom-modeline rainbow-delimiters rainbow-mode cmake-mode @@ -57,6 +59,7 @@ lsp-haskell lsp-ui lsp-treemacs + flycheck gradle-mode groovy-mode kotlin-mode @@ -71,6 +74,7 @@ org-roam org-roam-ui org-review + org-present org-superstar org-auto-tangle visual-fill-column @@ -83,11 +87,9 @@ dracula-theme doom-themes doom-modeline - orderless popper undo-tree bash-completion - consult eldoc-box yasnippet async @@ -104,13 +106,24 @@ zones sudo-edit toc-org - eshell-vterm empv volatile-highlights highlight elfeed elfeed-goodies drag-stuff + dirvish + rg + ;; Completions & Minibuffer + corfu + company + company-quickhelp + cape + embark + embark-consult + orderless + vertico + marginalia ) "A list of packages to ensure are installed at launch.") @@ -124,12 +137,18 @@ (package-refresh-contents) (dolist (p materus/packages) (when (not (package-installed-p p)) - (package-install p))))) -(materus/install-packages) + (package-install p))) + (package-quickstart-refresh))) +(unless materus/use-nix-packages + (package-initialize) + (materus/install-packages) + (unless (file-exists-p package-quickstart-file) (package-quickstart-refresh) )) (require 'recentf) (use-package no-littering :config +(setq package-quickstart-file + (concat user-emacs-directory "var/quickstart/package-quickstart-" emacs-version ".el" )) (add-to-list 'recentf-exclude (recentf-expand-file-name no-littering-var-directory)) (add-to-list 'recentf-exclude @@ -143,6 +162,11 @@ (pixel-scroll-precision-mode 1) (setq-default pixel-scroll-precision-large-scroll-height 10.0) +(when (daemonp) + (add-hook 'after-make-frame-functions + (lambda (frame) (when (= (length (frame-list)) 2) + (set-frame-parameter frame 'fullscreen 'maximized))))) + (setq frame-inhibit-implied-resize t) (setq frame-resize-pixelwise t) (setq window-resize-pixelwise t) @@ -150,7 +174,7 @@ (set-frame-font "Hack Nerd Font" nil t) ) -(setq-default display-line-numbers-width 4) +(setq-default display-line-numbers-width 3) (global-tab-line-mode 1) @@ -178,6 +202,11 @@ ) ;; Nerd Icons (use-package nerd-icons) +(use-package nerd-icons-completion + :after (marginalia) + :config + (nerd-icons-completion-mode 1) + (add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Theme (use-package dracula-theme :config @@ -193,11 +222,17 @@ (advice-add 'display-startup-screen :around #'startup-screen-advice) ; Hide startup screen if started with file (use-package dashboard -:after (nerd-icons) -:config + :after (nerd-icons projectile) + :config (setq dashboard-center-content t) (setq dashboard-display-icons-p t) (setq dashboard-icon-type 'nerd-icons) + (setq dashboard-projects-backend 'projectile) + (setq dashboard-items '((recents . 5) + (bookmarks . 5) + (projects . 5) + (agenda . 5) + (registers . 5))) (dashboard-setup-startup-hook) (when (daemonp) (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) ; Show dashboard when emacs is running as daemon @@ -209,8 +244,14 @@ :hook (after-init . doom-modeline-mode) :config (setq doom-modeline-icon t) - (setq display-time-24hr-format t)' - (display-time-mode 1)) + (setq doom-modeline-project-detection 'auto) + (setq doom-modeline-height 20) + (setq doom-modeline-enable-word-count t) + (setq doom-modeline-minor-modes t) + (setq display-time-24hr-format t) + (display-time-mode 1) + (column-number-mode 1) + (line-number-mode 1)) (use-package minions :hook (after-init . minions-mode)) @@ -219,19 +260,24 @@ :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))))))) + (org-mode . display-line-numbers-mode) + ) :config (require 'org-mouse) - (require 'org-tempo)) + (require 'org-tempo) + (add-hook 'org-mode-hook (lambda () + (setq-local + electric-pair-inhibit-predicate + `(lambda (c) + (if + (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))) + (use-package org-superstar :after (org) :hook (org-mode . org-superstar-mode)) - :config - (setq org-superstar-leading-bullet " ") +:config +(setq org-superstar-leading-bullet " ") (use-package org-auto-tangle :after (org) :hook (org-mode . org-auto-tangle-mode)) @@ -260,14 +306,19 @@ args))) (vertico-mode 1) (marginalia-mode 1)) +(use-package vertico-mouse + :config + (vertico-mouse-mode 1)) (use-package company -:init (global-company-mode 1)) + :config + (setq global-corfu-minibuffer nil) + (global-company-mode 1)) (electric-pair-mode 1) (electric-indent-mode -1) (setq-default indent-tabs-mode nil) -(setq-default buffer-file-coding-system 'utf-8-dos) +(setq-default buffer-file-coding-system 'utf-8-unix) (defun materus/elcord-toggle (&optional _frame) "Toggle elcord based on visible frames" @@ -276,14 +327,14 @@ (elcord-mode -1)) ) (use-package elcord - :init (unless (daemonp) (elcord-mode 1)) :config + (unless (daemonp) (elcord-mode 1)) (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 +(global-undo-tree-mode 1) (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)) @@ -292,7 +343,8 @@ (setq undo-tree-visualizer-timestamps t) ) -(use-package projectile) +(use-package projectile + :config (projectile-mode 1)) (use-package treemacs) (use-package treemacs-projectile @@ -300,7 +352,22 @@ (use-package treemacs-nerd-icons :after (nerd-icons treemacs)) +(use-package magit) + +(use-package dirvish + :config (dirvish-override-dired-mode 1) + (setq dirvish-attributes + '(vc-state + subtree-state + nerd-icons + collapse + git-msg + file-time + file-size))) + (use-package lsp-mode) + + (use-package lsp-ui) (use-package dap-mode) (use-package dap-lldb) @@ -331,13 +398,16 @@ (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) + (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) + +(add-hook 'prog-mode-hook 'display-line-numbers-mode) + (with-eval-after-load 'lsp-mode (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection "nixd") @@ -349,7 +419,6 @@ (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) @@ -357,7 +426,13 @@ (add-hook 'c++-mode-hook 'lsp-deferred) (add-hook 'c++-mode-hook 'display-line-numbers-mode) -(add-hook 'java-mode-hook 'lsp-deferred) +(use-package lsp-java + :config + (add-hook 'java-mode-hook (lambda () (when (getenv "JDTLS_PATH") (setq lsp-java-server-install-dir (getenv "JDTLS_PATH"))))) + (add-hook 'java-mode-hook 'lsp-deferred) + (add-hook 'java-mode-hook 'display-line-numbers-mode)) + +(use-package cua-base) ;; Keybinds (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) @@ -373,6 +448,38 @@ (global-set-key (kbd "C-H-t") 'treemacs) (cua-mode 1) +(use-package yasnippet +:config (yas-global-mode 1)) + +(defun materus/sync-config () + "Function to sync config from MATERUS_CONFIG_DIR to emacs folder" + (if (getenv "MATERUS_CONFIG_DIR") + (progn (copy-directory (concat (getenv "MATERUS_CONFIG_DIR") "extraFiles/config/emacs/") + user-emacs-directory t t t) t) + (progn (message "Can't use if MATERUS_CONFIG_DIR is not set!") nil))) +(defun materus/compare-file-time (file1 file2) + "Returns t when file1 is newer than file2" + (time-less-p + (nth 5 (file-attributes file2)) + (nth 5 (file-attributes file1)) + )) +(defun materus/compile-if-needed (file) + (unless (and (file-exists-p (concat user-emacs-directory file "c")) + (materus/compare-file-time (concat user-emacs-directory file "c") + (concat user-emacs-directory file))) + (byte-compile-file (concat user-emacs-directory file))) + ) +(defun materus/compile-config-if-needed () + (materus/compile-if-needed "early-init.el") + (materus/compile-if-needed "init.el") + (materus/compile-if-needed "etc/materus/emacs-config.el")) +(defun materus/update-config () + "Will sync and compile config" + (interactive) + (when (materus/sync-config) (materus/compile-config-if-needed) (byte-recompile-directory (concat user-emacs-directory "etc/materus/extra") 0 t))) + +(materus/compile-config-if-needed) + ;;; (global-set-key (kbd "C-∇") (kbd "C-H")) ;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) diff --git a/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el b/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el new file mode 100644 index 0000000..5ea2c94 --- /dev/null +++ b/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el @@ -0,0 +1,171 @@ +;;; corfu-mouse.el --- Mouse support for Corfu -*- lexical-binding: t; -*- + +;; Copyright (C) 2021, 2022 Free Software Foundation, Inc. +;; Copyright (C) 2022 Akib Azmain Turja. + +;; Author: Akib Azmain Turja +;; Maintainer: Akib Azmain Turja +;; Created: 2022 +;; Version: 0.1 +;; Package-Requires: ((emacs "24.4") (corfu "0.25")) +;; Homepage: https://codeberg.org/akib/emacs-corfu-mouse + +;; This file is not part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; Disclaimer: This file is based on vertico-mouse.el of Vertico +;; package, which is a part of GNU Emacs. + +;;; Commentary: + +;; This package is a Corfu extension, which adds mouse support. + +;; To enable, M-x corfu-mouse-mode. + + +;; Modified to support pixel-scroll-precision-mode + +;;; Code: + +(require 'corfu) + +(defgroup corfu-mouse nil + "Mouse support for Corfu." + :group 'corfu + :link '(url-link "https://codeberg.org/akib/emacs-corfu-mouse") + :prefix "corfu-mouse-") + +(defface corfu-mouse + '((t :inherit highlight)) + "Face used for mouse highlighting." + :group 'corfu-mouse) + +(defvar corfu-mouse--completion-buffer nil + "The buffer for which the popup is being shown.") + +(defun corfu-mouse--candidate-map (index) + "Return keymap for candidate with INDEX." + (let ((map (make-sparse-keymap)) + (mouse-1 (make-symbol "corfu-mouse--on-mouse-1")) + (mouse-3 (make-symbol "corfu-mouse--on-mouse-3"))) + (fset mouse-1 (lambda () + (interactive) + (corfu--goto index) + (corfu-insert))) + (fset mouse-3 (lambda () + (interactive) + (corfu--goto index) + (corfu-complete))) + (define-key map [mouse-1] mouse-1) + (define-key map [mouse-3] mouse-3) + + ;; Ignore these events to keep completion session alive. + (define-key map [down-mouse-1] #'ignore) + (define-key map [down-mouse-3] #'ignore) + map)) + +(defun corfu-mouse--format-candidates (fcands) + "Format candidates. + +FCANDS is the return value of `corfu--format-candidates'." + (let ((index corfu--scroll) + (cands (caddr fcands))) + (while cands + (let ((line (car cands))) + + ;; Append necessary amount of spaces to make it as wide as the + ;; popup. + (setq line (concat line (make-string (- (cadr fcands) + (string-width line)) + ? ))) + (add-text-properties 0 (length line) + `(mouse-face + corfu-mouse + keymap + ,(corfu-mouse--candidate-map index)) + line) + (setcar cands line) + (setq cands (cdr cands)) + (setq index (1+ index)))) + fcands)) + +(defun corfu-mouse--scroll-up (n) + "Scroll up by N lines." + (with-current-buffer corfu-mouse--completion-buffer + (corfu-next n))) + +(defun corfu-mouse--scroll-down (n) + "Scroll down by N lines." + (corfu-mouse--scroll-up (- n))) + +(defun corfu-mouse-mwheel-scroll () + "Call `mwheel-scroll'." + (interactive) + (call-interactively #'mwheel-scroll)) + +(defun corfu-mouse--setup-scrolling (buffer) + "Setup mouse scrolling on BUFFER." + (let ((current-buffer (current-buffer))) + (with-current-buffer buffer + (when (boundp 'pixel-scroll-precision-mode) + (setq-local pixel-scroll-precision-mode nil)) + (setq-local mwheel-scroll-up-function #'corfu-mouse--scroll-up) + (setq-local mwheel-scroll-down-function + #'corfu-mouse--scroll-down) + (setq-local corfu-mouse--completion-buffer current-buffer))) + buffer) + +(defun corfu-mouse--post-command-set-buffer () + "Set `corfu-mouse--completion-buffer' the current buffer." + (when corfu-mouse--completion-buffer + (switch-to-buffer corfu-mouse--completion-buffer))) + +;;;###autoload +(define-minor-mode corfu-mouse-mode + "Mouse support for Corfu." + :global t :group 'corfu + (let ((scroll-events '(wheel-up wheel-down mouse-4 mouse-5)) + (continue-commands '("corfu-mouse--on-mouse-1" + "corfu-mouse--on-mouse-3" + corfu-mouse-mwheel-scroll))) + (cond + (corfu-mouse-mode + (advice-add #'corfu--format-candidates :filter-return + #'corfu-mouse--format-candidates) + (advice-add #'corfu--make-buffer :filter-return + #'corfu-mouse--setup-scrolling) + (advice-add #'corfu--post-command :before + #'corfu-mouse--post-command-set-buffer) + (setq corfu-continue-commands + (append corfu-continue-commands continue-commands)) + (dolist (event scroll-events) + (define-key corfu--mouse-ignore-map (vector event) + #'corfu-mouse-mwheel-scroll))) + (t + (advice-remove #'corfu--format-candidates + #'corfu-mouse--format-candidates) + (advice-remove #'corfu--make-buffer + #'corfu-mouse--setup-scrolling) + (advice-remove #'corfu--post-command + #'corfu-mouse--post-command-set-buffer) + (dolist (command continue-commands) + (setq corfu-continue-commands + (delete command corfu-continue-commands))) + (dolist (event scroll-events) + (define-key corfu--mouse-ignore-map (vector event) + #'ignore)))))) + +(provide 'corfu-mouse) +;;; corfu-mouse.el ends here diff --git a/extraFiles/config/emacs/init.el b/extraFiles/config/emacs/init.el index b88a1b1..92d07f3 100644 --- a/extraFiles/config/emacs/init.el +++ b/extraFiles/config/emacs/init.el @@ -1,5 +1,7 @@ +;;; -*- lexical-binding: t; -*- (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 +(unless (file-directory-p (concat user-emacs-directory "var/quickstart")) + (make-directory (concat user-emacs-directory "var/quickstart") t)) +(load (concat user-emacs-directory "nix-init") t) (load (concat user-emacs-directory "etc/materus/emacs-config")) -(when (file-exists-p custom-file) - (load custom-file)) +(load custom-file t) diff --git a/flake.lock b/flake.lock index 3f8b91d..4d938e9 100644 --- a/flake.lock +++ b/flake.lock @@ -159,11 +159,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1730739613, - "narHash": "sha256-UNwS+2868c7B1CcInYTZfCKj+DlChm6BbEL5m/VtbDY=", + "lastModified": 1731517933, + "narHash": "sha256-j59F8M6LBre2Cc3QzxiYRlNe4wX/Jw1ziqPnbbmE3+Y=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "8d1826ba7648bd2704c6beed35a9e9e3327178d1", + "rev": "e074a4f54d88af0db5284d77e0b80bb1a8d2c80f", "type": "github" }, "original": { @@ -182,11 +182,11 @@ "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { - "lastModified": 1730711584, - "narHash": "sha256-7XpfL6x0or0qH3NjtiujcyUzFrZu72b/pyLCbwk0+2s=", + "lastModified": 1731517933, + "narHash": "sha256-j59F8M6LBre2Cc3QzxiYRlNe4wX/Jw1ziqPnbbmE3+Y=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "ca2129b1d5afb32e46299dc48e03467522352bd5", + "rev": "e074a4f54d88af0db5284d77e0b80bb1a8d2c80f", "type": "github" }, "original": { @@ -233,11 +233,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -252,11 +252,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -379,11 +379,11 @@ ] }, "locked": { - "lastModified": 1730633670, - "narHash": "sha256-ZFJqIXpvVKvzOVFKWNRDyIyAo+GYdmEPaYi1bZB6uf0=", + "lastModified": 1731535640, + "narHash": "sha256-2EckCJn4wxran/TsRiCOFcmVpep2m9EBKl99NBh2GnM=", "owner": "nix-community", "repo": "home-manager", - "rev": "8f6ca7855d409aeebe2a582c6fd6b6a8d0bf5661", + "rev": "35b055009afd0107b69c286fca34d2ad98940d57", "type": "github" }, "original": { @@ -422,11 +422,11 @@ ] }, "locked": { - "lastModified": 1730685024, - "narHash": "sha256-w0cQSTjLBaUSziPGwyI0nbWVD64+N3ByoSxC0CEZmeI=", + "lastModified": 1731462465, + "narHash": "sha256-SL/d2lvJO+CDzQno7sOyUuktE7+o6kW1qpWsG8tBte4=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "16ca007ec37c29a8b97e4899f33c013defbdb2f9", + "rev": "ac80fc4a7e7604c5699cbe61839af03bd55bf7bf", "type": "github" }, "original": { @@ -449,11 +449,11 @@ ] }, "locked": { - "lastModified": 1730685024, - "narHash": "sha256-w0cQSTjLBaUSziPGwyI0nbWVD64+N3ByoSxC0CEZmeI=", + "lastModified": 1731462465, + "narHash": "sha256-SL/d2lvJO+CDzQno7sOyUuktE7+o6kW1qpWsG8tBte4=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "16ca007ec37c29a8b97e4899f33c013defbdb2f9", + "rev": "ac80fc4a7e7604c5699cbe61839af03bd55bf7bf", "type": "github" }, "original": { @@ -519,11 +519,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1730537918, - "narHash": "sha256-GJB1/aaTnAtt9sso/EQ77TAGJ/rt6uvlP0RqZFnWue8=", + "lastModified": 1731403644, + "narHash": "sha256-T9V7CTucjRZ4Qc6pUEV/kpgNGzQbHWfGcfK6JJLfUeI=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "f6e0cd5c47d150c4718199084e5764f968f1b560", + "rev": "f6581f1c3b137086e42a08a906bdada63045f991", "type": "github" }, "original": { @@ -535,11 +535,11 @@ }, "nixos-hardware_2": { "locked": { - "lastModified": 1730537918, - "narHash": "sha256-GJB1/aaTnAtt9sso/EQ77TAGJ/rt6uvlP0RqZFnWue8=", + "lastModified": 1731403644, + "narHash": "sha256-T9V7CTucjRZ4Qc6pUEV/kpgNGzQbHWfGcfK6JJLfUeI=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "f6e0cd5c47d150c4718199084e5764f968f1b560", + "rev": "f6581f1c3b137086e42a08a906bdada63045f991", "type": "github" }, "original": { @@ -567,11 +567,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1730327045, - "narHash": "sha256-xKel5kd1AbExymxoIfQ7pgcX6hjw9jCgbiBjiUfSVJ8=", + "lastModified": 1731239293, + "narHash": "sha256-q2yjIWFFcTzp5REWQUOU9L6kHdCDmFDpqeix86SOvDc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "080166c15633801df010977d9d7474b4a6c549d7", + "rev": "9256f7c71a195ebe7a218043d9f93390d49e6884", "type": "github" }, "original": { @@ -599,11 +599,11 @@ }, "nixpkgs-stable_3": { "locked": { - "lastModified": 1730327045, - "narHash": "sha256-xKel5kd1AbExymxoIfQ7pgcX6hjw9jCgbiBjiUfSVJ8=", + "lastModified": 1731239293, + "narHash": "sha256-q2yjIWFFcTzp5REWQUOU9L6kHdCDmFDpqeix86SOvDc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "080166c15633801df010977d9d7474b4a6c549d7", + "rev": "9256f7c71a195ebe7a218043d9f93390d49e6884", "type": "github" }, "original": { @@ -631,11 +631,11 @@ }, "nixpkgs-stable_5": { "locked": { - "lastModified": 1730327045, - "narHash": "sha256-xKel5kd1AbExymxoIfQ7pgcX6hjw9jCgbiBjiUfSVJ8=", + "lastModified": 1731239293, + "narHash": "sha256-q2yjIWFFcTzp5REWQUOU9L6kHdCDmFDpqeix86SOvDc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "080166c15633801df010977d9d7474b4a6c549d7", + "rev": "9256f7c71a195ebe7a218043d9f93390d49e6884", "type": "github" }, "original": { @@ -647,11 +647,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1730531603, - "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=", + "lastModified": 1731139594, + "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d", + "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", "type": "github" }, "original": { @@ -676,11 +676,11 @@ }, "nur_2": { "locked": { - "lastModified": 1730742119, - "narHash": "sha256-npA4wtBgm9s5C0ElDYkyiBXeBGsxDqT6e7sPGwtDLFc=", + "lastModified": 1731530667, + "narHash": "sha256-/EBYF3f2kAPX3IOwxcjP/KTvXeX9b2cZyxgxGvp+XWI=", "owner": "nix-community", "repo": "NUR", - "rev": "3c7a45327b6a9f8b02df8d3acf213fd0616d59ef", + "rev": "481bba9ab4c2054b7cac86ee3be24f67e5256820", "type": "github" }, "original": { @@ -705,11 +705,11 @@ }, "nur_4": { "locked": { - "lastModified": 1730720916, - "narHash": "sha256-sLuyisXE2KkcQ3gai2Y10e7vrddDCnR4n+op9n67AD0=", + "lastModified": 1731530667, + "narHash": "sha256-/EBYF3f2kAPX3IOwxcjP/KTvXeX9b2cZyxgxGvp+XWI=", "owner": "nix-community", "repo": "NUR", - "rev": "4a9ef04ed3048a17b50a11499e7f08d2ff00080c", + "rev": "481bba9ab4c2054b7cac86ee3be24f67e5256820", "type": "github" }, "original": { @@ -721,10 +721,10 @@ }, "nur_5": { "locked": { - "lastModified": 1729545054, - "narHash": "sha256-Duxerj7QvZuOBD+MQSsGS5HX08P1YoaXgMsXaS9OP8A=", - "path": "/nix/store/c645p1n6k9nyh9b1y5f98lx9ywgwgq8l-source", - "rev": "52e70a5189a360d779f71624e2adaf3b0cd85716", + "lastModified": 1730720916, + "narHash": "sha256-sLuyisXE2KkcQ3gai2Y10e7vrddDCnR4n+op9n67AD0=", + "path": "/nix/store/n52f84spncfhpbgbx1gydvdqmwfkic3p-source", + "rev": "4a9ef04ed3048a17b50a11499e7f08d2ff00080c", "type": "path" }, "original": { @@ -744,11 +744,11 @@ ] }, "locked": { - "lastModified": 1730635861, - "narHash": "sha256-Npp3pl9aeAiq+wZPDbw2ZxybNuZWyuN7AY6fik56DCo=", + "lastModified": 1731193165, + "narHash": "sha256-pGF8L5g9QpkQtJP9JmNIRNZfcyhJHf7uT+d8tqI1h6Y=", "owner": "nix-community", "repo": "plasma-manager", - "rev": "293668587937daae1df085ee36d2b2d0792b7a0f", + "rev": "f33173b9d22e554a6f869626bc01808d35995257", "type": "github" }, "original": { @@ -770,11 +770,11 @@ ] }, "locked": { - "lastModified": 1730635861, - "narHash": "sha256-Npp3pl9aeAiq+wZPDbw2ZxybNuZWyuN7AY6fik56DCo=", + "lastModified": 1731193165, + "narHash": "sha256-pGF8L5g9QpkQtJP9JmNIRNZfcyhJHf7uT+d8tqI1h6Y=", "owner": "nix-community", "repo": "plasma-manager", - "rev": "293668587937daae1df085ee36d2b2d0792b7a0f", + "rev": "f33173b9d22e554a6f869626bc01808d35995257", "type": "github" }, "original": { @@ -821,11 +821,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1730605784, - "narHash": "sha256-1NveNAMLHbxOg0BpBMSVuZ2yW2PpDnZLbZ25wV50PMc=", + "lastModified": 1731364708, + "narHash": "sha256-HC0anOL+KmUQ2hdRl0AtunbAckasxrkn4VLmxbW/WaA=", "owner": "Mic92", "repo": "sops-nix", - "rev": "e9b5eef9b51cdf966c76143e13a9476725b2f760", + "rev": "4c91d52db103e757fc25b58998b0576ae702d659", "type": "github" }, "original": { @@ -844,11 +844,11 @@ "nixpkgs-stable": "nixpkgs-stable_4" }, "locked": { - "lastModified": 1730605784, - "narHash": "sha256-1NveNAMLHbxOg0BpBMSVuZ2yW2PpDnZLbZ25wV50PMc=", + "lastModified": 1731364708, + "narHash": "sha256-HC0anOL+KmUQ2hdRl0AtunbAckasxrkn4VLmxbW/WaA=", "owner": "Mic92", "repo": "sops-nix", - "rev": "e9b5eef9b51cdf966c76143e13a9476725b2f760", + "rev": "4c91d52db103e757fc25b58998b0576ae702d659", "type": "github" }, "original": {