This commit is contained in:
Mateusz Słodkowicz 2024-11-21 20:55:04 +01:00
parent 1d99fb630f
commit 3ee90d9e60
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
9 changed files with 449 additions and 217 deletions

View File

@ -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

21
README.org Normal file
View File

@ -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

View File

@ -2,28 +2,43 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, materusCfg, materusArg, ... }: {
config,
pkgs,
materusCfg,
materusArg,
...
}:
let 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 in
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
./network.nix ./network.nix
]; ];
boot.supportedFilesystems = [ "ntfs" ]; 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.auto-optimise-store = true;
nix.settings.substituters = [ nix.settings.substituters = [
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://cache.nixos.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; nixpkgs.config.allowUnfree = true;
# Use the systemd-boot EFI boot loader. # Use the systemd-boot EFI boot loader.
boot.loader.grub = { boot.loader.grub = {
enable = true; enable = true;
@ -70,20 +85,11 @@ in
# Enable the X11 windowing system. # Enable the X11 windowing system.
services.xserver.enable = true; services.xserver.enable = true;
hardware.opengl.enable = true; hardware.opengl.enable = true;
hardware.opengl.driSupport32Bit = true; hardware.opengl.driSupport32Bit = true;
materus.profile.steam.enable = true; materus.profile.steam.enable = true;
# Configure keymap in X11 # Configure keymap in X11
services.xserver.xkb.layout = "pl"; services.xserver.xkb.layout = "pl";
# services.xserver.xkbOptions = { # services.xserver.xkbOptions = {
@ -114,17 +120,25 @@ in
''; '';
}; };
virtualisation.podman = { virtualisation.podman = {
enable = true; enable = true;
dockerCompat = true; dockerCompat = true;
dockerSocket.enable = true; dockerSocket.enable = true;
}; };
users.users.materus = { users.users.materus = {
isNormalUser = true; 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; shell = pkgs.zsh;
description = "Mateusz Słodkowicz"; description = "Mateusz Słodkowicz";
@ -140,9 +154,7 @@ in
STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d"; STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d";
MOZ_USE_XINPUT2 = "1"; MOZ_USE_XINPUT2 = "1";
PATH = [ PATH = [ "\${XDG_BIN_HOME}" ];
"\${XDG_BIN_HOME}"
];
}; };
environment.shellInit = '' environment.shellInit = ''
if ! [ -z "$DISPLAY" ]; then xhost +si:localuser:root &> /dev/null; fi; 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: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
i18n.inputMethod.enabled = "fcitx5"; 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; [ environment.systemPackages = with pkgs; [
brave brave
@ -172,10 +186,14 @@ in
curl curl
jdk jdk
nss_latest nss_latest
aspell (aspellWithDicts (
aspellDicts.pl ds: with ds; [
aspellDicts.en en
aspellDicts.en-computers en-computers
en-science
pl
]
))
distrobox distrobox
p7zip p7zip
unrar unrar
@ -197,12 +215,9 @@ in
iptraf-ng iptraf-ng
mprocs mprocs
nix-du nix-du
git-crypt git-crypt
wineWowPackages.stagingFull wineWowPackages.stagingFull
winetricks winetricks
protontricks protontricks
@ -215,9 +230,6 @@ in
inkscape inkscape
gimp gimp
virt-manager virt-manager
libguestfs libguestfs
@ -228,7 +240,6 @@ in
binutils binutils
]; ];
fonts.fontDir.enable = true; fonts.fontDir.enable = true;
@ -244,15 +255,38 @@ in
ubuntu_font_family ubuntu_font_family
wqy_zenhei wqy_zenhei
monocraft monocraft
(nerdfonts.override { fonts = [ "FiraCode" "DroidSansMono" "Meslo" "ProFont" ]; }) (nerdfonts.override {
fonts = [
"FiraCode"
"DroidSansMono"
"Meslo"
"ProFont"
];
})
]; ];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
fonts.fontconfig.cache32Bit = true; fonts.fontconfig.cache32Bit = true;
fonts.fontconfig.defaultFonts.sansSerif = [ "Noto Sans" "DejaVu Sans" "WenQuanYi Zen Hei" "Noto Color Emoji" ]; fonts.fontconfig.defaultFonts.sansSerif = [
fonts.fontconfig.defaultFonts.serif = [ "Noto Serif" "DejaVu Serif" "WenQuanYi Zen Hei" "Noto Color Emoji" ]; "Noto Sans"
fonts.fontconfig.defaultFonts.emoji = [ "Noto Color Emoji" "OpenMoji Color" ]; "DejaVu Sans"
fonts.fontconfig.defaultFonts.monospace = [ "Hack Nerd Font" "Noto Sans Mono" "WenQuanYi Zen Hei Mono" ]; "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.enableAllTerminfo = true;
environment.pathsToLink = [ "/share/zsh" ]; environment.pathsToLink = [ "/share/zsh" ];
@ -273,14 +307,15 @@ in
# programs.mtr.enable = true; # programs.mtr.enable = true;
services.pcscd.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 \ ${pkgs.gnupg}/bin/gpg-agent --supervised \
--pinentry-program ${pkgs.kwalletcli}/bin/pinentry-kwallet --pinentry-program ${pkgs.kwalletcli}/bin/pinentry-kwallet
'' ''
];*/ ];
*/
programs.gnupg.agent = { programs.gnupg.agent = {
enable = true; enable = true;
@ -294,9 +329,6 @@ in
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
services.openssh.enable = true; services.openssh.enable = true;
# Copy the NixOS configuration file and link it from the resulting system # Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you # (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix. # accidentally delete configuration.nix.
@ -311,4 +343,3 @@ in
system.stateVersion = "23.11"; # Did you read the comment? system.stateVersion = "23.11"; # Did you read the comment?
} }

View File

@ -1,4 +1,9 @@
{ config, pkgs, materusArg, ... }: {
config,
pkgs,
materusArg,
...
}:
{ {
services.jackett.enable = true; services.jackett.enable = true;
@ -7,11 +12,26 @@
]; ];
environment.systemPackages = with pkgs; [ 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 ]; }) #(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 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 glibc
glib glib
gtk3 gtk3
@ -38,10 +58,14 @@
pciutils pciutils
aspell (aspellWithDicts (
aspellDicts.pl ds: with ds; [
aspellDicts.en en
aspellDicts.en-computers en-computers
en-science
pl
]
))
steamtinkerlaunch steamtinkerlaunch
distrobox distrobox
# WebP support # WebP support
@ -78,7 +102,6 @@
nix-du nix-du
kate kate
krusader krusader
@ -93,22 +116,16 @@
monkeysphere monkeysphere
gparted gparted
virt-viewer virt-viewer
inkscape inkscape
gimp gimp
git-crypt git-crypt
bubblewrap bubblewrap
bindfs bindfs
binutils binutils
materusArg.unstable.qbittorrent materusArg.unstable.qbittorrent

View File

@ -1,20 +1,26 @@
{ config, pkgs, lib, materusArg, ... }: {
config,
pkgs,
lib,
materusArg,
...
}:
with materusArg.pkgs.lib; with materusArg.pkgs.lib;
{ {
imports = [ imports = [ ./fonts.nix ];
./fonts.nix
];
#Single Packages #Single Packages
options.materus.profile.packages.home-manager = mkPrivateVar materusArg.cfg.configInputs.home-manager.packages.${pkgs.system}.home-manager; options.materus.profile.packages.home-manager =
options.materus.profile.packages.firefox = mkPrivateVar (pkgs.firefox.override { mkPrivateVar
nativeMessagingHosts = [ materusArg.cfg.configInputs.home-manager.packages.${pkgs.system}.home-manager;
pkgs.plasma-browser-integration options.materus.profile.packages.firefox = mkPrivateVar (
]; pkgs.firefox.override { nativeMessagingHosts = [ pkgs.plasma-browser-integration ]; }
}); );
#Package Lists #Package Lists
options.materus.profile.packages.list.nixRelated = mkPrivateVar (with pkgs; [ options.materus.profile.packages.list.nixRelated = mkPrivateVar (
with pkgs;
[
nix-prefetch nix-prefetch
nix-prefetch-scripts nix-prefetch-scripts
nix-prefetch-github nix-prefetch-github
@ -26,10 +32,17 @@ with materusArg.pkgs.lib;
nix-ld nix-ld
nixpkgs-fmt nixpkgs-fmt
nixpkgs-review nixpkgs-review
]); ]
);
options.materus.profile.packages.list.desktopApps = mkPrivateVar (with pkgs; [ options.materus.profile.packages.list.desktopApps = mkPrivateVar (
(discord.override { nss = nss_latest; withOpenASAR = true; withTTS = true; }) with pkgs;
[
(discord.override {
nss = nss_latest;
withOpenASAR = true;
withTTS = true;
})
tdesktop tdesktop
syncplay syncplay
ani-cli ani-cli
@ -37,17 +50,27 @@ with materusArg.pkgs.lib;
spotify spotify
thunderbird thunderbird
keepassxc keepassxc
(aspellWithDicts (ds: with ds; [ en en-computers en-science pl ])) (aspellWithDicts (
ds: with ds; [
en
en-computers
en-science
pl
]
))
onlyoffice-bin onlyoffice-bin
qalculate-qt qalculate-qt
]); ]
);
options.materus.profile.packages.list.terminalApps = mkPrivateVar (with pkgs; [ options.materus.profile.packages.list.terminalApps = mkPrivateVar (
with pkgs;
[
neofetch neofetch
ripgrep ripgrep
fd fd
micro micro
]); ]
);
} }

View File

@ -127,11 +127,13 @@ let
visual-replace visual-replace
scroll-restore scroll-restore
highlight-indent-guides highlight-indent-guides
diff-hl
# Completions & Minibuffer # Completions & Minibuffer
corfu corfu
company corfu-terminal
company-quickhelp kind-icon
cape cape
embark embark
embark-consult embark-consult
orderless orderless

View File

@ -27,8 +27,10 @@ My emacs config, tangled file is [[file:etc/materus/emacs-config.el][there]]
- [[#misc][Misc]] - [[#misc][Misc]]
- [[#dashboard][Dashboard]] - [[#dashboard][Dashboard]]
- [[#modeline][Modeline]] - [[#modeline][Modeline]]
- [[#diff-hl][Diff-hl]]
- [[#org-mode][Org-mode]] - [[#org-mode][Org-mode]]
- [[#completions][Completions]] - [[#completions][Completions]]
- [[#style][Style]]
- [[#minibuffer][Minibuffer]] - [[#minibuffer][Minibuffer]]
- [[#code-completion][Code completion]] - [[#code-completion][Code completion]]
- [[#terms][Terms]] - [[#terms][Terms]]
@ -459,6 +461,17 @@ Graphical related settings.
(use-package minions (use-package minions
:hook (after-init . minions-mode)) :hook (after-init . minions-mode))
#+end_src #+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
Org mode settings Org mode settings
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -496,11 +509,20 @@ Org mode settings
#+end_src #+end_src
** Completions ** 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 *** Minibuffer
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package consult) (use-package consult)
(use-package marginalia) (use-package marginalia)
(use-package orderless)
(use-package which-key (use-package which-key
:config :config
@ -523,10 +545,52 @@ Org mode settings
#+end_src #+end_src
*** Code completion *** Code completion
#+begin_src emacs-lisp #+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 :config
(setq global-corfu-minibuffer nil) (when (or (daemonp) (not (display-graphic-p)))
(global-company-mode 1)) (corfu-terminal-mode)))
(use-package corfu-mouse
:after (corfu)
:config
(corfu-mouse-mode)
(keymap-set corfu--mouse-ignore-map "<mouse-movement>" 'ignore)
(keymap-set corfu-map "<mouse-movement>" 'ignore))
(use-package kind-icon
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
#+end_src #+end_src
** Terms ** Terms
*** Eat *** Eat
@ -538,6 +602,7 @@ Other configs
*** Defaults *** Defaults
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq-default buffer-file-coding-system 'utf-8-unix) (setq-default buffer-file-coding-system 'utf-8-unix)
(setq text-mode-ispell-word-completion nil) ; Disable ispell
#+end_src #+end_src
*** Elcord *** Elcord
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -610,7 +675,24 @@ Other configs
* Programming * Programming
** LSP ** LSP
#+begin_src emacs-lisp #+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 lsp-ui)
@ -754,7 +836,8 @@ Other configs
;; perspective ;; perspective
(global-set-key (kbd "C-x C-b") 'persp-list-buffers) (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 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 ;; CUA
(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo)
@ -817,8 +900,6 @@ Just for testing some code
#+begin_src emacs-lisp #+begin_src emacs-lisp
;;; (global-set-key (kbd "C-∇") (kbd "C-H")) ;;; (global-set-key (kbd "C-∇") (kbd "C-H"))
;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) ;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207)))
;;; (keymap-set corfu--mouse-ignore-map "<mouse-movement>" 'ignore)
;;; (keymap-set corfu-map "<mouse-movement>" 'ignore)
;;; (buffer-text-pixel-size) ;;; (buffer-text-pixel-size)
;;; (set-window-vscroll nil 960 t t) ;;; (set-window-vscroll nil 960 t t)

View File

@ -259,6 +259,16 @@
:hook (after-init . minions-mode)) :hook (after-init . minions-mode))
;; Modeline:1 ends here ;; 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]] ;; [[file:../../emacs-materus-config.org::*Org-mode][Org-mode:1]]
(use-package org (use-package org
:mode (("\\.org$" . org-mode)) :mode (("\\.org$" . org-mode))
@ -293,10 +303,19 @@
(markdown-mode . toc-org-mode))) (markdown-mode . toc-org-mode)))
;; Org-mode:1 ends here ;; 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]] ;; [[file:../../emacs-materus-config.org::*Minibuffer][Minibuffer:1]]
(use-package consult) (use-package consult)
(use-package marginalia) (use-package marginalia)
(use-package orderless)
(use-package which-key (use-package which-key
:config :config
@ -319,10 +338,50 @@
;; Minibuffer:1 ends here ;; Minibuffer:1 ends here
;; [[file:../../emacs-materus-config.org::*Code completion][Code completion:1]] ;; [[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 :config
(setq global-corfu-minibuffer nil) (when (or (daemonp) (not (display-graphic-p)))
(global-company-mode 1)) (corfu-terminal-mode)))
(use-package corfu-mouse
:after (corfu)
:config
(corfu-mouse-mode)
(keymap-set corfu--mouse-ignore-map "<mouse-movement>" 'ignore)
(keymap-set corfu-map "<mouse-movement>" 'ignore))
(use-package kind-icon
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
;; Code completion:1 ends here ;; Code completion:1 ends here
;; [[file:../../emacs-materus-config.org::*Eat][Eat:1]] ;; [[file:../../emacs-materus-config.org::*Eat][Eat:1]]
@ -331,6 +390,7 @@
;; [[file:../../emacs-materus-config.org::*Defaults][Defaults:1]] ;; [[file:../../emacs-materus-config.org::*Defaults][Defaults:1]]
(setq-default buffer-file-coding-system 'utf-8-unix) (setq-default buffer-file-coding-system 'utf-8-unix)
(setq text-mode-ispell-word-completion nil) ; Disable ispell
;; Defaults:1 ends here ;; Defaults:1 ends here
;; [[file:../../emacs-materus-config.org::*Elcord][Elcord:1]] ;; [[file:../../emacs-materus-config.org::*Elcord][Elcord:1]]
@ -401,18 +461,35 @@
;; Perspective:1 ends here ;; Perspective:1 ends here
;; [[file:../../emacs-materus-config.org::*LSP][LSP:1]] ;; [[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 lsp-ui)
(use-package dap-mode) (use-package dap-mode)
(use-package dap-lldb) (use-package dap-lldb)
(use-package dap-gdb-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) (defun lsp-booster--advice-json-parse (old-fn &rest args)
"Try to parse bytecode instead of json." "Try to parse bytecode instead of json."
(or (or
(when (equal (following-char) ?#) (when (equal (following-char) ?#)
@ -420,14 +497,14 @@
(when (byte-code-function-p bytecode) (when (byte-code-function-p bytecode)
(funcall bytecode)))) (funcall bytecode))))
(apply old-fn args))) (apply old-fn args)))
(advice-add (if (progn (require 'json) (advice-add (if (progn (require 'json)
(fboundp 'json-parse-buffer)) (fboundp 'json-parse-buffer))
'json-parse-buffer 'json-parse-buffer
'json-read) 'json-read)
:around :around
#'lsp-booster--advice-json-parse) #'lsp-booster--advice-json-parse)
(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) (defun lsp-booster--advice-final-command (old-fn cmd &optional test?)
"Prepend emacs-lsp-booster command to lsp CMD." "Prepend emacs-lsp-booster command to lsp CMD."
(let ((orig-result (funcall old-fn cmd test?))) (let ((orig-result (funcall old-fn cmd test?)))
(if (and (not test?) ; for check lsp-server-present? (if (and (not test?) ; for check lsp-server-present?
@ -441,7 +518,7 @@
(message "Using emacs-lsp-booster for %s!" orig-result) (message "Using emacs-lsp-booster for %s!" orig-result)
(cons "emacs-lsp-booster" orig-result)) (cons "emacs-lsp-booster" orig-result))
orig-result))) orig-result)))
(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)
;; LSP:1 ends here ;; LSP:1 ends here
;; [[file:../../emacs-materus-config.org::*Nix][Nix:1]] ;; [[file:../../emacs-materus-config.org::*Nix][Nix:1]]
@ -543,7 +620,8 @@
;; perspective ;; perspective
(global-set-key (kbd "C-x C-b") 'persp-list-buffers) (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 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 ;; CUA
(keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo) (keymap-set cua--cua-keys-keymap "C-z" 'undo-tree-undo)
@ -601,8 +679,6 @@
;; [[file:../../emacs-materus-config.org::*Test][Test:1]] ;; [[file:../../emacs-materus-config.org::*Test][Test:1]]
;;; (global-set-key (kbd "C-∇") (kbd "C-H")) ;;; (global-set-key (kbd "C-∇") (kbd "C-H"))
;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207))) ;;; (global-set-key (kbd "H-∇") (lambda () (interactive) (insert-char #x2207)))
;;; (keymap-set corfu--mouse-ignore-map "<mouse-movement>" 'ignore)
;;; (keymap-set corfu-map "<mouse-movement>" 'ignore)
;;; (buffer-text-pixel-size) ;;; (buffer-text-pixel-size)
;;; (set-window-vscroll nil 960 t t) ;;; (set-window-vscroll nil 960 t t)

View File

@ -40,7 +40,6 @@
;;; Code: ;;; Code:
(require 'corfu) (require 'corfu)
(make-gdb-table)
(defgroup corfu-mouse nil (defgroup corfu-mouse nil
"Mouse support for Corfu." "Mouse support for Corfu."
:group 'corfu :group 'corfu
@ -78,7 +77,7 @@
(defun corfu-mouse--format-candidates (fcands) (defun corfu-mouse--format-candidates (fcands)
"Format candidates. "Format candidates.
FCANDS is the return value of `corfu--format-candidates'." FCANDS is the return value of `corfu--format-candidates'."
(let ((index corfu--scroll) (let ((index corfu--scroll)
(cands (caddr fcands))) (cands (caddr fcands)))
(while cands (while cands