diff --git a/README.md b/README.md deleted file mode 100644 index fbe4899..0000000 --- a/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# nixos-config -My NixOS and home-manager configs. -Dotfiles and helper scripts. - -Not all config is here, some I keep in private flake. - -## Hosts -materusPC - my main PC - -Old-materusPC - my old PC, barely used - -flamaster - my laptop, used mostly as server for games. - -valkyrie - VPS, my website and pleroma instance - -waffentrager - raspberry pi4, home server - - diff --git a/README.org b/README.org new file mode 100644 index 0000000..fe28e90 --- /dev/null +++ b/README.org @@ -0,0 +1,21 @@ +#+TITLE: nixos-config +#+AUTHOR: materus +#+DESCRIPTION: NixOS config and dotfiles +#+OPTIONS: \n:t +My NixOS and home-manager configs. +Dotfiles and helper scripts. + +Part of it is encrypted by git-crypt, mostly just ips and names. Secrets are managed by sops. + +* Hosts +[[./configurations/host/materusPC/][materusPC]] - my main PC + +[[./configurations/host/Old-materusPC/][Old-materusPC]] - my old PC, barely used + +[[./configurations/host/flamaster/][flamaster]] - my laptop, used mostly as server for games. + +[[./configurations/host/valkyrie/][valkyrie]] - VPS, my website and pleroma instance + +[[./configurations/host/waffentrager/][waffentrager]] - raspberry pi4, home server + + diff --git a/configurations/host/Old-materusPC/configuration.nix b/configurations/host/Old-materusPC/configuration.nix index ebfd75f..68d9ab9 100755 --- a/configurations/host/Old-materusPC/configuration.nix +++ b/configurations/host/Old-materusPC/configuration.nix @@ -2,28 +2,43 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, materusCfg, materusArg, ... }: +{ + config, + pkgs, + materusCfg, + materusArg, + ... +}: let - unstable = import materusCfg.materusFlake.inputs.nixpkgs { system = "x86_64-linux"; config = { allowUnfree = true; nvidia.acceptLicense = true; }; }; + unstable = import materusCfg.materusFlake.inputs.nixpkgs { + system = "x86_64-linux"; + config = { + allowUnfree = true; + nvidia.acceptLicense = true; + }; + }; in { - imports = - [ - # Include the results of the hardware scan. - ./hardware-configuration.nix - ./network.nix - ]; + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ./network.nix + ]; boot.supportedFilesystems = [ "ntfs" ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; nix.settings.auto-optimise-store = true; nix.settings.substituters = [ "https://nix-community.cachix.org" "https://cache.nixos.org/" ]; - nix.settings.trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; + nix.settings.trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; nixpkgs.config.allowUnfree = true; - # Use the systemd-boot EFI boot loader. boot.loader.grub = { enable = true; @@ -70,20 +85,11 @@ in # Enable the X11 windowing system. services.xserver.enable = true; - hardware.opengl.enable = true; hardware.opengl.driSupport32Bit = true; materus.profile.steam.enable = true; - - - - - - - - # Configure keymap in X11 services.xserver.xkb.layout = "pl"; # services.xserver.xkbOptions = { @@ -114,17 +120,25 @@ in ''; }; - virtualisation.podman = { enable = true; dockerCompat = true; dockerSocket.enable = true; }; - users.users.materus = { isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" "kvm" "input" "libvirt" "libvirtd" "podman" "audio" "pipewire" ]; + extraGroups = [ + "wheel" + "networkmanager" + "kvm" + "input" + "libvirt" + "libvirtd" + "podman" + "audio" + "pipewire" + ]; shell = pkgs.zsh; description = "Mateusz Słodkowicz"; @@ -140,9 +154,7 @@ in STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d"; MOZ_USE_XINPUT2 = "1"; - PATH = [ - "\${XDG_BIN_HOME}" - ]; + PATH = [ "\${XDG_BIN_HOME}" ]; }; environment.shellInit = '' if ! [ -z "$DISPLAY" ]; then xhost +si:localuser:root &> /dev/null; fi; @@ -151,11 +163,13 @@ in # List packages installed in system profile. To search, run: # $ nix search wget - - - i18n.inputMethod.enabled = "fcitx5"; - i18n.inputMethod.fcitx5.addons = [ pkgs.fcitx5-configtool pkgs.fcitx5-lua pkgs.fcitx5-mozc pkgs.libsForQt5.fcitx5-qt ]; + i18n.inputMethod.fcitx5.addons = [ + pkgs.fcitx5-configtool + pkgs.fcitx5-lua + pkgs.fcitx5-mozc + pkgs.libsForQt5.fcitx5-qt + ]; environment.systemPackages = with pkgs; [ brave @@ -172,10 +186,14 @@ in curl jdk nss_latest - aspell - aspellDicts.pl - aspellDicts.en - aspellDicts.en-computers + (aspellWithDicts ( + ds: with ds; [ + en + en-computers + en-science + pl + ] + )) distrobox p7zip unrar @@ -197,12 +215,9 @@ in iptraf-ng mprocs - - nix-du git-crypt - wineWowPackages.stagingFull winetricks protontricks @@ -215,9 +230,6 @@ in inkscape gimp - - - virt-manager libguestfs @@ -228,7 +240,6 @@ in binutils - ]; fonts.fontDir.enable = true; @@ -244,15 +255,38 @@ in ubuntu_font_family wqy_zenhei monocraft - (nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" "Meslo" "ProFont" ]; }) + (nerdfonts.override { + fonts = [ + "FiraCode" + "DroidSansMono" + "Meslo" + "ProFont" + ]; + }) ]; fonts.fontconfig.enable = true; fonts.fontconfig.cache32Bit = true; - fonts.fontconfig.defaultFonts.sansSerif = [ "Noto Sans" "DejaVu Sans" "WenQuanYi Zen Hei" "Noto Color Emoji" ]; - fonts.fontconfig.defaultFonts.serif = [ "Noto Serif" "DejaVu Serif" "WenQuanYi Zen Hei" "Noto Color Emoji" ]; - fonts.fontconfig.defaultFonts.emoji = [ "Noto Color Emoji" "OpenMoji Color" ]; - fonts.fontconfig.defaultFonts.monospace = [ "Hack Nerd Font" "Noto Sans Mono" "WenQuanYi Zen Hei Mono" ]; - + fonts.fontconfig.defaultFonts.sansSerif = [ + "Noto Sans" + "DejaVu Sans" + "WenQuanYi Zen Hei" + "Noto Color Emoji" + ]; + fonts.fontconfig.defaultFonts.serif = [ + "Noto Serif" + "DejaVu Serif" + "WenQuanYi Zen Hei" + "Noto Color Emoji" + ]; + fonts.fontconfig.defaultFonts.emoji = [ + "Noto Color Emoji" + "OpenMoji Color" + ]; + fonts.fontconfig.defaultFonts.monospace = [ + "Hack Nerd Font" + "Noto Sans Mono" + "WenQuanYi Zen Hei Mono" + ]; environment.enableAllTerminfo = true; environment.pathsToLink = [ "/share/zsh" ]; @@ -273,14 +307,15 @@ in # programs.mtr.enable = true; services.pcscd.enable = true; - /*systemd.user.services.gpg-agent.serviceConfig.ExecStart = [ + /* + systemd.user.services.gpg-agent.serviceConfig.ExecStart = [ "" '' ${pkgs.gnupg}/bin/gpg-agent --supervised \ --pinentry-program ${pkgs.kwalletcli}/bin/pinentry-kwallet '' - ];*/ - + ]; + */ programs.gnupg.agent = { enable = true; @@ -294,9 +329,6 @@ in # Enable the OpenSSH daemon. services.openssh.enable = true; - - - # Copy the NixOS configuration file and link it from the resulting system # (/run/current-system/configuration.nix). This is useful in case you # accidentally delete configuration.nix. @@ -311,4 +343,3 @@ in system.stateVersion = "23.11"; # Did you read the comment? } - diff --git a/configurations/host/materusPC/other/apps.nix b/configurations/host/materusPC/other/apps.nix index 6f3319e..cc801b7 100644 --- a/configurations/host/materusPC/other/apps.nix +++ b/configurations/host/materusPC/other/apps.nix @@ -1,4 +1,9 @@ -{ config, pkgs, materusArg, ... }: +{ + config, + pkgs, + materusArg, + ... +}: { services.jackett.enable = true; @@ -7,11 +12,26 @@ ]; - environment.systemPackages = with pkgs; [ #(pkgs.lutris.override { extraLibraries = pkgs: with pkgs; [ pkgs.samba pkgs.jansson pkgs.tdb pkgs.libunwind pkgs.libusb1 pkgs.gnutls pkgs.gtk3 pkgs.pango ]; }) materusArg.pkgs.amdgpu-pro-libs.prefixes - (pkgs.bottles.override { extraPkgs = pkgs: [ pkgs.libsForQt5.breeze-qt5 pkgs.kdePackages.breeze-gtk pkgs.nss_latest ]; extraLibraries = pkgs: [ pkgs.samba pkgs.jansson pkgs.tdb pkgs.libunwind pkgs.libusb1 pkgs.gnutls pkgs.gtk3 pkgs.pango ]; }) + (pkgs.bottles.override { + extraPkgs = pkgs: [ + pkgs.libsForQt5.breeze-qt5 + pkgs.kdePackages.breeze-gtk + pkgs.nss_latest + ]; + extraLibraries = pkgs: [ + pkgs.samba + pkgs.jansson + pkgs.tdb + pkgs.libunwind + pkgs.libusb1 + pkgs.gnutls + pkgs.gtk3 + pkgs.pango + ]; + }) glibc glib gtk3 @@ -38,10 +58,14 @@ pciutils - aspell - aspellDicts.pl - aspellDicts.en - aspellDicts.en-computers + (aspellWithDicts ( + ds: with ds; [ + en + en-computers + en-science + pl + ] + )) steamtinkerlaunch distrobox # WebP support @@ -78,7 +102,6 @@ nix-du - kate krusader @@ -93,22 +116,16 @@ monkeysphere gparted - - virt-viewer inkscape gimp - - git-crypt bubblewrap bindfs - - binutils materusArg.unstable.qbittorrent diff --git a/configurations/profile/common/packages/default.nix b/configurations/profile/common/packages/default.nix index 5c0b704..dbd91fe 100644 --- a/configurations/profile/common/packages/default.nix +++ b/configurations/profile/common/packages/default.nix @@ -1,53 +1,76 @@ -{ config, pkgs, lib, materusArg, ... }: +{ + config, + pkgs, + lib, + materusArg, + ... +}: with materusArg.pkgs.lib; { - imports = [ - ./fonts.nix - ]; + imports = [ ./fonts.nix ]; #Single Packages - options.materus.profile.packages.home-manager = mkPrivateVar materusArg.cfg.configInputs.home-manager.packages.${pkgs.system}.home-manager; - options.materus.profile.packages.firefox = mkPrivateVar (pkgs.firefox.override { - nativeMessagingHosts = [ - pkgs.plasma-browser-integration - ]; - }); + options.materus.profile.packages.home-manager = + mkPrivateVar + materusArg.cfg.configInputs.home-manager.packages.${pkgs.system}.home-manager; + options.materus.profile.packages.firefox = mkPrivateVar ( + pkgs.firefox.override { nativeMessagingHosts = [ pkgs.plasma-browser-integration ]; } + ); #Package Lists - options.materus.profile.packages.list.nixRelated = mkPrivateVar (with pkgs; [ - nix-prefetch - nix-prefetch-scripts - nix-prefetch-github - nix-prefetch-docker - nixfmt-rfc-style - nix-top - nix-tree - nix-diff - nix-ld - nixpkgs-fmt - nixpkgs-review - ]); + options.materus.profile.packages.list.nixRelated = mkPrivateVar ( + with pkgs; + [ + nix-prefetch + nix-prefetch-scripts + nix-prefetch-github + nix-prefetch-docker + nixfmt-rfc-style + nix-top + nix-tree + nix-diff + nix-ld + nixpkgs-fmt + nixpkgs-review + ] + ); - options.materus.profile.packages.list.desktopApps = mkPrivateVar (with pkgs; [ - (discord.override { nss = nss_latest; withOpenASAR = true; withTTS = true; }) - tdesktop - syncplay - ani-cli - nextcloud-client - spotify - thunderbird - keepassxc - (aspellWithDicts (ds: with ds; [ en en-computers en-science pl ])) - onlyoffice-bin - qalculate-qt - ]); + options.materus.profile.packages.list.desktopApps = mkPrivateVar ( + with pkgs; + [ + (discord.override { + nss = nss_latest; + withOpenASAR = true; + withTTS = true; + }) + tdesktop + syncplay + ani-cli + nextcloud-client + spotify + thunderbird + keepassxc + (aspellWithDicts ( + ds: with ds; [ + en + en-computers + en-science + pl + ] + )) + onlyoffice-bin + qalculate-qt + ] + ); - options.materus.profile.packages.list.terminalApps = mkPrivateVar (with pkgs; [ - neofetch - ripgrep - fd - micro - ]); + options.materus.profile.packages.list.terminalApps = mkPrivateVar ( + with pkgs; + [ + neofetch + ripgrep + fd + micro + ] + ); } - diff --git a/configurations/profile/home/editor/emacs/default.nix b/configurations/profile/home/editor/emacs/default.nix index 6505ef7..ebd67e4 100644 --- a/configurations/profile/home/editor/emacs/default.nix +++ b/configurations/profile/home/editor/emacs/default.nix @@ -127,11 +127,13 @@ let visual-replace scroll-restore highlight-indent-guides + diff-hl # Completions & Minibuffer corfu - company - company-quickhelp + corfu-terminal + kind-icon cape + embark embark-consult orderless diff --git a/extraFiles/config/emacs/emacs-materus-config.org b/extraFiles/config/emacs/emacs-materus-config.org index c4b3427..bee7946 100644 --- a/extraFiles/config/emacs/emacs-materus-config.org +++ b/extraFiles/config/emacs/emacs-materus-config.org @@ -27,8 +27,10 @@ My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]] - [[#misc][Misc]] - [[#dashboard][Dashboard]] - [[#modeline][Modeline]] + - [[#diff-hl][Diff-hl]] - [[#org-mode][Org-mode]] - [[#completions][Completions]] + - [[#style][Style]] - [[#minibuffer][Minibuffer]] - [[#code-completion][Code completion]] - [[#terms][Terms]] @@ -459,6 +461,17 @@ Graphical related settings. (use-package minions :hook (after-init . minions-mode)) #+end_src +*** Diff-hl +#+begin_src emacs-lisp + (use-package diff-hl + :config + (setq diff-hl-side 'right) + (global-diff-hl-mode 1) + (diff-hl-margin-mode 1) + (diff-hl-flydiff-mode 1) + (global-diff-hl-show-hunk-mouse-mode 1)) + +#+end_src ** Org-mode Org mode settings #+begin_src emacs-lisp @@ -496,11 +509,20 @@ Org mode settings #+end_src ** Completions +*** Style +#+begin_src emacs-lisp + (use-package orderless + :init + ;; Tune the global completion style settings to your liking! + ;; This affects the minibuffer and non-lsp completion at point. + (setq completion-styles '(basic partial-completion orderless) + completion-category-defaults nil + completion-category-overrides nil)) +#+end_src *** Minibuffer #+begin_src emacs-lisp (use-package consult) (use-package marginalia) - (use-package orderless) (use-package which-key :config @@ -523,10 +545,52 @@ Org mode settings #+end_src *** Code completion #+begin_src emacs-lisp - (use-package company + + (use-package cape) + + (use-package corfu + ;; Optional customizations + :custom + (corfu-cycle nil) ;; Enable cycling for `corfu-next/previous' + (corfu-auto t) ;; Enable auto completion + (global-corfu-minibuffer nil) + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + + ;; Enable Corfu only for certain modes. See also `global-corfu-modes'. + ;; :hook ((prog-mode . corfu-mode) + ;; (shell-mode . corfu-mode) + ;; (eshell-mode . corfu-mode)) + + ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can + ;; be used globally (M-/). See also the customization variable + ;; `global-corfu-modes' to exclude certain modes. + :init + (global-corfu-mode 1) + (corfu-popupinfo-mode 1) + (corfu-history-mode 1)) + + + (use-package corfu-terminal + :after (corfu) + :config + (when (or (daemonp) (not (display-graphic-p))) + (corfu-terminal-mode))) + + (use-package corfu-mouse + :after (corfu) :config - (setq global-corfu-minibuffer nil) - (global-company-mode 1)) + (corfu-mouse-mode) + (keymap-set corfu--mouse-ignore-map "" 'ignore) + (keymap-set corfu-map "" 'ignore)) + + (use-package kind-icon + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) + #+end_src ** Terms *** Eat @@ -538,6 +602,7 @@ Other configs *** Defaults #+begin_src emacs-lisp (setq-default buffer-file-coding-system 'utf-8-unix) + (setq text-mode-ispell-word-completion nil) ; Disable ispell #+end_src *** Elcord #+begin_src emacs-lisp @@ -610,47 +675,64 @@ Other configs * Programming ** LSP #+begin_src emacs-lisp - (use-package lsp-mode) + (use-package lsp-mode + :custom + (lsp-completion-provider :none) ;; we use Corfu! + + :init + (defun materus/orderless-dispatch-flex-first (_pattern index _total) + (and (eq index 0) 'orderless-flex)) + + (defun materus/lsp-mode-setup-completion () + (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) + '(orderless)) + ;; Optionally configure the first word as flex filtered. + (add-hook 'orderless-style-dispatchers #'materus/orderless-dispatch-flex-first nil 'local) + ;; Optionally configure the cape-capf-buster. + (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point)))) + + :hook + (lsp-completion-mode . materus/lsp-mode-setup-completion)) - (use-package lsp-ui) - (use-package dap-mode) - (use-package dap-lldb) - (use-package dap-gdb-lldb) + (use-package lsp-ui) + (use-package dap-mode) + (use-package dap-lldb) + (use-package dap-gdb-lldb) - (setq read-process-output-max (* 1024 1024 3)) + (setq read-process-output-max (* 1024 1024 3)) - (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-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) + (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 @@ -754,7 +836,8 @@ Other configs ;; perspective (global-set-key (kbd "C-x C-b") 'persp-list-buffers) (global-set-key (kbd "C-x C-B") 'list-buffers) - (global-set-key (kbd "C-x B") 'persp-switch-to-buffer) + (global-set-key (kbd "C-x b") 'persp-switch-to-buffer) + (global-set-key (kbd "C-x B") 'consult-buffer) ;; CUA (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) @@ -817,8 +900,6 @@ 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))) - ;;; (keymap-set corfu--mouse-ignore-map "" 'ignore) - ;;; (keymap-set corfu-map "" 'ignore) ;;; (buffer-text-pixel-size) ;;; (set-window-vscroll nil 960 t t) diff --git a/extraFiles/config/emacs/etc/materus/emacs-config.el b/extraFiles/config/emacs/etc/materus/emacs-config.el index 5e41837..da7c4d0 100644 --- a/extraFiles/config/emacs/etc/materus/emacs-config.el +++ b/extraFiles/config/emacs/etc/materus/emacs-config.el @@ -259,6 +259,16 @@ :hook (after-init . minions-mode)) ;; Modeline:1 ends here +;; [[file:../../emacs-materus-config.org::*Diff-hl][Diff-hl:1]] +(use-package diff-hl + :config + (setq diff-hl-side 'right) + (global-diff-hl-mode 1) + (diff-hl-margin-mode 1) + (diff-hl-flydiff-mode 1) + (global-diff-hl-show-hunk-mouse-mode 1)) +;; Diff-hl:1 ends here + ;; [[file:../../emacs-materus-config.org::*Org-mode][Org-mode:1]] (use-package org :mode (("\\.org$" . org-mode)) @@ -293,10 +303,19 @@ (markdown-mode . toc-org-mode))) ;; Org-mode:1 ends here +;; [[file:../../emacs-materus-config.org::*Style][Style:1]] +(use-package orderless + :init + ;; Tune the global completion style settings to your liking! + ;; This affects the minibuffer and non-lsp completion at point. + (setq completion-styles '(basic partial-completion orderless) + completion-category-defaults nil + completion-category-overrides nil)) +;; Style:1 ends here + ;; [[file:../../emacs-materus-config.org::*Minibuffer][Minibuffer:1]] (use-package consult) (use-package marginalia) -(use-package orderless) (use-package which-key :config @@ -319,10 +338,50 @@ ;; Minibuffer:1 ends here ;; [[file:../../emacs-materus-config.org::*Code completion][Code completion:1]] -(use-package company +(use-package cape) + +(use-package corfu + ;; Optional customizations + :custom + (corfu-cycle nil) ;; Enable cycling for `corfu-next/previous' + (corfu-auto t) ;; Enable auto completion + (global-corfu-minibuffer nil) + ;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary + ;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match + (corfu-preview-current nil) ;; Disable current candidate preview + ;; (corfu-preselect 'prompt) ;; Preselect the prompt + ;; (corfu-on-exact-match nil) ;; Configure handling of exact matches + + ;; Enable Corfu only for certain modes. See also `global-corfu-modes'. + ;; :hook ((prog-mode . corfu-mode) + ;; (shell-mode . corfu-mode) + ;; (eshell-mode . corfu-mode)) + + ;; Recommended: Enable Corfu globally. This is recommended since Dabbrev can + ;; be used globally (M-/). See also the customization variable + ;; `global-corfu-modes' to exclude certain modes. + :init + (global-corfu-mode 1) + (corfu-popupinfo-mode 1) + (corfu-history-mode 1)) + + +(use-package corfu-terminal + :after (corfu) + :config + (when (or (daemonp) (not (display-graphic-p))) + (corfu-terminal-mode))) + +(use-package corfu-mouse + :after (corfu) :config - (setq global-corfu-minibuffer nil) - (global-company-mode 1)) + (corfu-mouse-mode) + (keymap-set corfu--mouse-ignore-map "" 'ignore) + (keymap-set corfu-map "" 'ignore)) + +(use-package kind-icon + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) ;; Code completion:1 ends here ;; [[file:../../emacs-materus-config.org::*Eat][Eat:1]] @@ -331,6 +390,7 @@ ;; [[file:../../emacs-materus-config.org::*Defaults][Defaults:1]] (setq-default buffer-file-coding-system 'utf-8-unix) +(setq text-mode-ispell-word-completion nil) ; Disable ispell ;; Defaults:1 ends here ;; [[file:../../emacs-materus-config.org::*Elcord][Elcord:1]] @@ -401,47 +461,64 @@ ;; Perspective:1 ends here ;; [[file:../../emacs-materus-config.org::*LSP][LSP:1]] -(use-package lsp-mode) +(use-package lsp-mode + :custom + (lsp-completion-provider :none) ;; we use Corfu! + + :init + (defun materus/orderless-dispatch-flex-first (_pattern index _total) + (and (eq index 0) 'orderless-flex)) + + (defun materus/lsp-mode-setup-completion () + (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) + '(orderless)) + ;; Optionally configure the first word as flex filtered. + (add-hook 'orderless-style-dispatchers #'materus/orderless-dispatch-flex-first nil 'local) + ;; Optionally configure the cape-capf-buster. + (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point)))) + + :hook + (lsp-completion-mode . materus/lsp-mode-setup-completion)) -(use-package lsp-ui) -(use-package dap-mode) -(use-package dap-lldb) -(use-package dap-gdb-lldb) + (use-package lsp-ui) + (use-package dap-mode) + (use-package dap-lldb) + (use-package dap-gdb-lldb) -(setq read-process-output-max (* 1024 1024 3)) + (setq read-process-output-max (* 1024 1024 3)) -(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-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) + (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) ;; LSP:1 ends here ;; [[file:../../emacs-materus-config.org::*Nix][Nix:1]] @@ -543,7 +620,8 @@ ;; perspective (global-set-key (kbd "C-x C-b") 'persp-list-buffers) (global-set-key (kbd "C-x C-B") 'list-buffers) -(global-set-key (kbd "C-x B") 'persp-switch-to-buffer) +(global-set-key (kbd "C-x b") 'persp-switch-to-buffer) +(global-set-key (kbd "C-x B") 'consult-buffer) ;; CUA (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) @@ -601,8 +679,6 @@ ;; [[file:../../emacs-materus-config.org::*Test][Test:1]] ;;; (global-set-key (kbd "C-∇") (kbd "C-H")) ;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) -;;; (keymap-set corfu--mouse-ignore-map "" 'ignore) -;;; (keymap-set corfu-map "" 'ignore) ;;; (buffer-text-pixel-size) ;;; (set-window-vscroll nil 960 t t) diff --git a/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el b/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el index 3b424cf..1b1a2b9 100644 --- a/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el +++ b/extraFiles/config/emacs/etc/materus/extra/corfu-mouse.el @@ -40,7 +40,6 @@ ;;; Code: (require 'corfu) -(make-gdb-table) (defgroup corfu-mouse nil "Mouse support for Corfu." :group 'corfu @@ -78,7 +77,7 @@ (defun corfu-mouse--format-candidates (fcands) "Format candidates. -FCANDS is the return value of `corfu--format-candidates'." + FCANDS is the return value of `corfu--format-candidates'." (let ((index corfu--scroll) (cands (caddr fcands))) (while cands