mirror of
https://github.com/materusPL/nixos-config
synced 2026-07-02 12:46:42 +00:00
Lot of changes, ignoring previous commits format
This commit is contained in:
@@ -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)))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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)))
|
||||
|
||||
|
||||
@@ -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 <akib@disroot.org>
|
||||
;; Maintainer: Akib Azmain Turja <akib@disroot.org>
|
||||
;; 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
;; 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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user