The great config remake.
I decided to go back to the basics with this one. Only the packages I think I *REALLY* need (or want) are left, the rest are replaced by the built-in alternatives or even better, removed.
This commit is contained in:
@@ -1,103 +1,17 @@
|
||||
;;; 05-basic.el --- Setup some basics. -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
;; Setup the font
|
||||
(set-face-attribute 'default nil :height 110 :font "Iosevka Nerd Font" :weight 'normal)
|
||||
|
||||
;; I use narrowing, I am a mature emacs user! I do not need the hand-holding
|
||||
;; (usually).
|
||||
(put 'narrow-to-region 'disabled nil)
|
||||
|
||||
;; This package provides which-key, which is a minor mode for Emacs
|
||||
;; that displays the key bindings following your currently entered
|
||||
;; incomplete command (a prefix) in a popup.
|
||||
(use-package which-key
|
||||
:ensure t
|
||||
:diminish which-key-mode
|
||||
:config
|
||||
(which-key-mode))
|
||||
|
||||
;; Pixel perfect scrolling
|
||||
(unless (version< emacs-version "29.0")
|
||||
(pixel-scroll-precision-mode))
|
||||
|
||||
;; Display time
|
||||
(display-time-mode)
|
||||
(setq display-time-24hr-format t)
|
||||
|
||||
(show-paren-mode +1) ; Paren match highlighting
|
||||
|
||||
;; Winner mode is a global minor mode that records the changes in the
|
||||
;; window configuration (i.e. how the frames are partitioned into
|
||||
;; windows) so that the changes can be "undone" using the command
|
||||
;; ‘winner-undo’.
|
||||
(winner-mode 1)
|
||||
|
||||
;; Configure Emacs to ask for confirmation before exiting
|
||||
(setq confirm-kill-emacs 'y-or-n-p)
|
||||
|
||||
;; This package provides a complete git integration
|
||||
(use-package magit
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (magit))
|
||||
|
||||
(electric-indent-mode)
|
||||
(electric-pair-mode)
|
||||
|
||||
(use-package modus-themes
|
||||
:ensure t
|
||||
:defer nil
|
||||
:config
|
||||
(load-theme 'modus-operandi t))
|
||||
|
||||
(use-package hbdh
|
||||
:straight (hbdh :type git :host github :repo "zzhjerry/hbdh-mode")
|
||||
:config (hbdh-mode))
|
||||
|
||||
(defun my-hbdh-highlight-line ()
|
||||
"Activate hbdh, dim text outside of current line"
|
||||
(interactive)
|
||||
(let ((point-beginning (line-beginning-position))
|
||||
(point-end (line-end-position)))
|
||||
;; note that those are internal functions
|
||||
;; probably should use hbdh activation commands instead of this
|
||||
(hbdh--activate-overlay point-beginning point-end)
|
||||
(hbdh--rewrite-region-face)))
|
||||
|
||||
(setq hbdh-mode-map (make-sparse-keymap))
|
||||
(define-key hbdh-mode-map "a" 'hbdh-activate-on-region)
|
||||
(define-key hbdh-mode-map "d" 'hbdh-deactivate)
|
||||
(define-key hbdh-mode-map "l" 'my-hbdh-highlight-line)
|
||||
|
||||
(global-set-key "\C-ch" hbdh-mode-map)
|
||||
|
||||
;; A must have for any NixOS user
|
||||
(use-package direnv
|
||||
:ensure t
|
||||
:defer nil
|
||||
:config (direnv-mode))
|
||||
|
||||
;; RSS reader
|
||||
(use-package
|
||||
elfeed
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (elfeed)
|
||||
:init (setq elfeed-feeds
|
||||
'((http://feeds.nightvalepresents.com/welcometonightvalepodcast
|
||||
nightvale)
|
||||
("https://sachachua.com/blog/category/emacs-news/feed"
|
||||
emacs)
|
||||
("https://planet.emacslife.com/atom.xml"
|
||||
emacs)
|
||||
("https://kagi.com/smallweb/appreciated"
|
||||
small-web)
|
||||
("https://kagi.com/api/v1/smallweb/feed/?gh"
|
||||
small-web)
|
||||
("https://scour.ing/@DiToast/rss.xml"
|
||||
scour)))
|
||||
:bind (("C-c f" . elfeed)))
|
||||
|
||||
;; Setting this to true makes it so that Emacs saves existing clipboard text
|
||||
;; into kill ring before replacing it.
|
||||
(setq save-interprogram-paste-before-kill t)
|
||||
@@ -147,4 +61,13 @@
|
||||
|
||||
(reverse-im-mode t)
|
||||
|
||||
;; Windmove family of commands allow easy navigation when there is more than two
|
||||
;; buffers on screen. The bindings are the Vim movement commands with the
|
||||
;; Control+Shift modifiers, adjusted for the workman layout and shifted a bit
|
||||
;; down and to the left.
|
||||
(keymap-global-set "C-S-k" #'windmove-left)
|
||||
(keymap-global-set "C-S-l" #'windmove-down)
|
||||
(keymap-global-set "C-<" #'windmove-up)
|
||||
(keymap-global-set "C->" #'windmove-right)
|
||||
|
||||
;;; 05-basic.el ends here
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
;;; 05-tatoeba.el --- Tatoeba utilities. -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
;;; Description:
|
||||
;; This file contains my utilities for the tatoeba website.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun tatoeba--request-word-data (word)
|
||||
"Gets raw senteces from the tatoeba api"
|
||||
(request-response-data
|
||||
(request
|
||||
(format
|
||||
"https://tatoeba.org/eng/api_v0/search?from=deu&has_audio=&list=&native=&original=&orphans=no&query=%s&sort=relevance&sort_reverse=&tags=&to=eng&trans_filter=limit&trans_has_audio=&trans_link=&trans_orphan=no&trans_to=&trans_unapproved=no&trans_user=&unapproved=no&user=&word_count_max=&word_count_min=2"
|
||||
word)
|
||||
:parser 'json-read
|
||||
:sync t)))
|
||||
|
||||
(defun tatoeba--get-eng-translations (translations)
|
||||
"Converts the translations list into the (id . translation) form"
|
||||
(let* ((translation-list (append
|
||||
(aref translations 0)
|
||||
(aref translations 1)
|
||||
'())))
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(if (equal (cdr (assoc 'lang x))
|
||||
"eng")
|
||||
(cons
|
||||
(cdr (assoc 'id x))
|
||||
(cdr (assoc 'text x)))))
|
||||
translation-list)))
|
||||
|
||||
(defun tatoeba--get-sentence-list (word)
|
||||
"Requests sentences and transforms them into an easy to use form."
|
||||
(let* ((raw-data (tatoeba--request-word-data
|
||||
word))
|
||||
(results (cdadr raw-data)))
|
||||
(mapcar
|
||||
(lambda (x)
|
||||
(list
|
||||
(assoc 'id x)
|
||||
(cons 'user (cdadr (assoc 'user x)))
|
||||
(assoc 'text x)
|
||||
(cons 'translations
|
||||
(tatoeba--get-eng-translations
|
||||
(cdr (assoc 'translations x))))))
|
||||
results)))
|
||||
|
||||
(defun tatoeba-get-capture-template ()
|
||||
"Returns a template for the org-capture"
|
||||
(let* ((word (read-string "Word: "))
|
||||
(sentence-list (tatoeba--get-sentence-list
|
||||
word)))
|
||||
(with-output-to-string
|
||||
(princ
|
||||
(format "\n** %s\n" word))
|
||||
(dolist (sentence sentence-list)
|
||||
(if (not (eq (cdadr
|
||||
(assoc 'translations sentence))
|
||||
nil))
|
||||
(princ
|
||||
(format
|
||||
"*** %s\n%s\n\n"
|
||||
(cdr (assoc 'text sentence))
|
||||
(cdadr
|
||||
(assoc 'translations sentence)))))))))
|
||||
|
||||
;;; 05-tatoeba.el ends here
|
||||
@@ -6,86 +6,6 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; COmpletion in Region FUnction. Corfu enhances in-buffer completion
|
||||
;; with a small completion popup. Corfu is the minimalistic in-buffer
|
||||
;; completion counterpart of the Vertico minibuffer UI.
|
||||
(use-package corfu
|
||||
:ensure t
|
||||
:defer nil
|
||||
:commands (corfu-mode global-corfu-mode)
|
||||
|
||||
:hook ((prog-mode . corfu-mode)
|
||||
(shell-mode . corfu-mode)
|
||||
(eshell-mode . corfu-mode))
|
||||
|
||||
:bind (:map corfu-map
|
||||
("s-SPC" . corfu-insert-separator)
|
||||
("M-d" . corfu-info-documentation)
|
||||
)
|
||||
:custom
|
||||
;; Hide commands in M-x which do not apply to the current mode.
|
||||
(read-extended-command-predicate #'command-completion-default-include-p)
|
||||
;; Disable Ispell completion function. As an alternative try `cape-dict'.
|
||||
(text-mode-ispell-word-completion nil)
|
||||
(tab-always-indent 'complete)
|
||||
|
||||
:init
|
||||
(setq corfu-auto t)
|
||||
(setq tab-always-indent 'complete)
|
||||
(setq corfu-preview-current 'insert)
|
||||
(setq corfu-echo-documentation nil)
|
||||
(setq corfu-popupinfo-delay '(1.0 . 0.5))
|
||||
|
||||
;; Enable Corfu
|
||||
:config
|
||||
(global-corfu-mode t)
|
||||
(corfu-popupinfo-mode t))
|
||||
|
||||
;; This package provides icons to corfu completions. Requires nerd fonts to be
|
||||
;; installed to work.
|
||||
(use-package nerd-icons-corfu
|
||||
:config
|
||||
(add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter))
|
||||
|
||||
;; Cape provides Completion At Point Extensions which can be used in
|
||||
;; combination with Corfu, Company or the default completion UI. The
|
||||
;; completion backends used by completion-at-point are so called
|
||||
;; completion-at-point-functions (Capfs).
|
||||
(use-package cape
|
||||
:ensure t
|
||||
:defer nil
|
||||
:commands (cape-dabbrev cape-file cape-elisp-block)
|
||||
:bind ("C-c p" . cape-prefix-map)
|
||||
:init
|
||||
;; Add to the global default value of `completion-at-point-functions' which is
|
||||
;; used by `completion-at-point'.
|
||||
(add-hook 'completion-at-point-functions #'cape-dabbrev)
|
||||
(add-hook 'completion-at-point-functions #'cape-file)
|
||||
(add-hook 'completion-at-point-functions #'cape-elisp-block))
|
||||
|
||||
;; VERTical Interactive COmpletion. Vertico provides a performant and
|
||||
;; minimalistic vertical completion UI based on the default completion
|
||||
;; system.
|
||||
(use-package vertico
|
||||
;; (Note: It is recommended to also enable the savehist package.)
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands vertico-mode
|
||||
:hook (after-init . vertico-mode))
|
||||
|
||||
;; This package provides an orderless completion style that divides
|
||||
;; the pattern into space-separated components, and matches candidates
|
||||
;; that match all of the components in any order.
|
||||
(use-package orderless
|
||||
;; Vertico leverages Orderless' flexible matching capabilities, allowing users
|
||||
;; to input multiple patterns separated by spaces, which Orderless then
|
||||
;; matches in any order against the candidates.
|
||||
:ensure t
|
||||
:custom
|
||||
(completion-styles '(orderless basic))
|
||||
(completion-category-defaults nil)
|
||||
(completion-category-overrides '((file (styles partial-completion)))))
|
||||
|
||||
;; This package provides marginalia-mode which adds marginalia to the
|
||||
;; minibuffer completions. Marginalia are marks or annotations placed
|
||||
;; at the margin of the page of a book or in this case helpful
|
||||
@@ -231,4 +151,30 @@
|
||||
:preview-key '(:debounce 0.4 any))
|
||||
(setq consult-narrow-key "<"))
|
||||
|
||||
(setq tab-always-indent 'complete) ;; Starts completion with TAB
|
||||
|
||||
(fido-mode -1)
|
||||
(icomplete-mode)
|
||||
(icomplete-vertical-mode)
|
||||
|
||||
(setq icomplete-delay-completions-threshold 0)
|
||||
(setq icomplete-compute-delay 0)
|
||||
(setq icomplete-show-matches-on-no-input t)
|
||||
(setq icomplete-hide-common-prefix nil)
|
||||
(setq icomplete-prospects-height 10)
|
||||
(setq icomplete-separator " . ")
|
||||
(setq icomplete-with-completion-tables t)
|
||||
(setq icomplete-max-delay-chars 0)
|
||||
(setq icomplete-scroll t)
|
||||
|
||||
(keymap-set icomplete-minibuffer-map "RET" 'icomplete-force-complete-and-exit)
|
||||
|
||||
(setq completion-styles '(initials flex basic partial-completion emacs22))
|
||||
(setq completion-auto-select t) ;; Show completion on first call
|
||||
(setq completion-auto-help 'visible) ;; Display *Completions* upon first request
|
||||
(setq completions-format 'one-column) ;; Use only one column
|
||||
(setq completions-sort 'historical) ;; Order based on minibuffer history
|
||||
(setq completions-max-height 15) ;; Limit completions to 10 (completions start at line 5)
|
||||
(setq completion-ignore-case t)
|
||||
|
||||
;;; 10-completion.el ends here
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
;;; 15-lsp.el --- Setup LSP -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
;; Despite the name, this file not only sets up LSP integration, but
|
||||
;; also native Emacs modes for various programming lanuguages, such as
|
||||
;; Prolog, that do not use LSP.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; This package provides syntax highlighting and some utilities for
|
||||
;; working with rust code.
|
||||
(use-package rust-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (rust-mode))
|
||||
|
||||
(add-hook 'rust-mode-hook #'eglot-ensure)
|
||||
|
||||
;; Clippy backend for flymake so we get propa error reporting in Rust
|
||||
(use-package flymake-clippy
|
||||
:hook (rust-mode . flymake-clippy-setup-backend))
|
||||
|
||||
(defun manually-activate-flymake ()
|
||||
(add-hook 'flymake-diagnostic-functions #'eglot-flymake-backend nil t)
|
||||
(flymake-mode 1))
|
||||
|
||||
;; Eglot is the built-in LSP client.
|
||||
(use-package eglot
|
||||
:ensure nil
|
||||
:defer t
|
||||
:commands (eglot
|
||||
eglot-rename
|
||||
eglot-ensure
|
||||
eglot-rename
|
||||
eglot-format-buffer)
|
||||
|
||||
:hook ((eglot-managed-mode . manually-activate-flymake))
|
||||
|
||||
:custom
|
||||
(eglot-report-progress nil) ; Prevent minibuffer spam
|
||||
|
||||
:config
|
||||
(add-to-list 'eglot-server-programs '((rust-mode) . ("rust-analyzer" :initializationOptions
|
||||
( :procMacro (:enable t)
|
||||
:cargo ( :buildScripts (:enable t) )))))
|
||||
(add-to-list 'eglot-server-programs '(nix-mode . ("nil")))
|
||||
(add-to-list 'eglot-stay-out-of 'flymake)
|
||||
;; Optimizations
|
||||
(fset #'jsonrpc--log-event #'ignore)
|
||||
(setq jsonrpc-event-hook nil)
|
||||
)
|
||||
|
||||
;; This function raises the window to the front using KDE KWin.
|
||||
(defun my-raise-window ()
|
||||
"Raises the window to the front using KDE KWin.
|
||||
|
||||
Won't work if the script is not there."
|
||||
(call-process-shell-command "~/wayland-window -f emacs &" nil 0))
|
||||
|
||||
;; Usually, when I open a file with emacsclient and the frame already exists, I
|
||||
;; want it to be raised to the top. Unfortunately, that does not happen by
|
||||
;; default. Here is my solution.
|
||||
(add-hook 'server-visit-hook #'my-raise-window)
|
||||
|
||||
;; This package provides syntax highlighting for gdscript.
|
||||
(use-package gdscript-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (gdscript-mode))
|
||||
|
||||
(add-hook 'gdscript-mode-hook #'eglot-ensure)
|
||||
|
||||
;; This package provides integration with Prolog (SWI).
|
||||
(use-package sweeprolog
|
||||
:straight (sweeprolog :type git
|
||||
:host nil
|
||||
:repo "https://git.sr.ht/~eshel/sweep"
|
||||
:branch "main"
|
||||
:files ("*.el" "sweep.pl" "sweep.texi")) ; Custom recipe because
|
||||
; the normal one did not
|
||||
; build properly.
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (sweeprolog-mode
|
||||
sweeprolog-top-level)
|
||||
:init
|
||||
(setq sweeprolog-swipl-path "swipl"))
|
||||
|
||||
|
||||
;; This package provides integration with Prolog (scryer) Note that editing
|
||||
;; prolog is supported through built-in prolog-mode, this only allows actually
|
||||
;; consulting prolog from within emacs.
|
||||
(use-package ediprolog
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (prolog-mode)
|
||||
:config
|
||||
(my-ediprolog-select-system "swi-prolog"))
|
||||
|
||||
(defun ediprolog-set-term-type (orig &rest args)
|
||||
"Advice to set the TERM env var to dumb for the function call.
|
||||
|
||||
Originally created for scryer prolog, as either it itself or systemd-run
|
||||
used to constrain its resources assumed that the terminal supports
|
||||
escape codes (it does not in this case), so this was used as an
|
||||
\":around\" advice on 'ediprolog-run-prolog', to clearly indicate that
|
||||
control codes are not supported."
|
||||
(let ((process-environment process-environment))
|
||||
(setenv "TERM" "dumb")
|
||||
(apply orig args)))
|
||||
|
||||
(with-eval-after-load "prolog"
|
||||
(bind-key "C-c C-e" #'ediprolog-dwim prolog-mode-map)
|
||||
(advice-add 'ediprolog-run-prolog :around #'ediprolog-set-term-type))
|
||||
|
||||
(add-to-list 'auto-mode-alist '("\\.plt?\\'" . prolog-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.axaml?\\'" . nxml-mode))
|
||||
|
||||
;; Nix language
|
||||
(use-package nix-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (nix-mode)
|
||||
:hook
|
||||
(nix-mode . eglot-ensure))
|
||||
|
||||
;; Common Lisp
|
||||
(use-package sly
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (sly)
|
||||
:init
|
||||
(setq inferior-lisp-program "sbcl"))
|
||||
|
||||
;; Racket lisp
|
||||
(use-package racket-mode
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (racket-mode racket-xp-mode)
|
||||
:hook ((racket-mode . racket-xp-mode))
|
||||
:bind (("C-c C-n" . racket-run-and-switch-to-repl))
|
||||
:config
|
||||
(setq racket-xp-eldoc-level 'summary))
|
||||
|
||||
(defun racket-restart ()
|
||||
"Restarts the backend and reinitializes the mode to cope with the
|
||||
consequences of direnv activating after racket-mode(-s)."
|
||||
(interactive)
|
||||
(when (eq major-mode 'racket-mode)
|
||||
(racket-stop-back-end)
|
||||
(racket-start-back-end)
|
||||
(racket-mode)))
|
||||
|
||||
;; Markdown
|
||||
(use-package markdown-mode
|
||||
:ensure t
|
||||
:defer t)
|
||||
|
||||
(if (memq 'lispy-autoloads features)
|
||||
(add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1))))
|
||||
|
||||
;; This package adds indent bars. Currently only configured for rust and python.
|
||||
(use-package indent-bars
|
||||
:ensure t
|
||||
:defer t
|
||||
:custom
|
||||
(indent-bars-no-descend-lists t) ; no extra bars in continued func arg lists
|
||||
(indent-bars-treesit-support t)
|
||||
(indent-bars-treesit-ignore-blank-lines-types '("module"))
|
||||
;; Add other languages as needed
|
||||
(indent-bars-treesit-scope '((python function_definition class_definition for_statement
|
||||
if_statement with_statement while_statement)
|
||||
(rust trait_item impl_item
|
||||
macro_definition macro_invocation
|
||||
struct_item enum_item mod_item
|
||||
const_item let_declaration
|
||||
function_item for_expression
|
||||
if_expression loop_expression
|
||||
while_expression match_expression
|
||||
match_arm call_expression
|
||||
token_tree token_tree_pattern
|
||||
token_repetition)))
|
||||
(indent-bars-treesit-wrap '((rust arguments parameters)))
|
||||
:hook ((python-base-mode yaml-mode rust-mode) . indent-bars-mode))
|
||||
|
||||
;; Configure Tempel
|
||||
(use-package tempel
|
||||
:bind (("C-S-e" . tempel-complete) ;; Alternative tempel-expand
|
||||
("M-*" . tempel-insert))
|
||||
|
||||
:init
|
||||
|
||||
;; Setup completion at point
|
||||
(defun tempel-setup-capf ()
|
||||
;; Add the Tempel Capf to `completion-at-point-functions'. `tempel-expand'
|
||||
;; only triggers on exact matches. We add `tempel-expand' *before* the main
|
||||
;; programming mode Capf, such that it will be tried first.
|
||||
(setq-local completion-at-point-functions
|
||||
(cons #'tempel-expand completion-at-point-functions))
|
||||
|
||||
;; Alternatively use `tempel-complete' if you want to see all matches. Use
|
||||
;; a trigger prefix character in order to prevent Tempel from triggering
|
||||
;; unexpectly.
|
||||
;; (setq-local corfu-auto-trigger "/"
|
||||
;; completion-at-point-functions
|
||||
;; (cons (cape-capf-trigger #'tempel-complete ?/)
|
||||
;; completion-at-point-functions))
|
||||
)
|
||||
|
||||
(add-hook 'conf-mode-hook 'tempel-setup-capf)
|
||||
(add-hook 'prog-mode-hook 'tempel-setup-capf)
|
||||
(add-hook 'text-mode-hook 'tempel-setup-capf)
|
||||
|
||||
(setq tempel-path (concat minimal-emacs-user-directory "templates"))
|
||||
|
||||
;; Optionally make the Tempel templates available to Abbrev,
|
||||
;; either locally or globally. `expand-abbrev' is bound to C-x '.
|
||||
;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode)
|
||||
;; (global-tempel-abbrev-mode)
|
||||
)
|
||||
|
||||
;; Optional: Add tempel-collection if you want ready-made templates. Yes sir, I
|
||||
;; do.
|
||||
(use-package tempel-collection)
|
||||
|
||||
|
||||
;;; 15-lsp.el end here
|
||||
@@ -1,25 +0,0 @@
|
||||
;;; 20-window-management.el --- Setup concerning windowing. -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
;; Treemacs is a package that provides a tree view of the current project.
|
||||
(use-package treemacs
|
||||
:ensure t
|
||||
:defer t
|
||||
:commands (treemacs))
|
||||
|
||||
;; Windmove family of commands allow easy navigation when there is more than two
|
||||
;; buffers on screen. The bindings are the Vim movement commands with the
|
||||
;; Control+Shift modifiers, adjusted for the workman layout and shifted a bit
|
||||
;; down and to the left.
|
||||
(keymap-global-set "C-S-k" #'windmove-left)
|
||||
(keymap-global-set "C-S-l" #'windmove-down)
|
||||
(keymap-global-set "C-<" #'windmove-up)
|
||||
(keymap-global-set "C->" #'windmove-right)
|
||||
|
||||
;; Still thinking on this one
|
||||
;; (setq
|
||||
;; display-buffer-alist
|
||||
;; `(("\\*vterm\\*" display-buffer-in-side-window
|
||||
;; (side . bottom) (slot . 0) (window-height . fit-window-to-buffer)
|
||||
;; (preserve-size . (nil . t)) '(window-parameters . ((no-delete-other-windows . t))))))
|
||||
|
||||
;;; 20-window-management.el ends here
|
||||
@@ -22,8 +22,14 @@
|
||||
;; main configuration eventually.
|
||||
|
||||
;;; Code:
|
||||
(use-package whisper
|
||||
|
||||
; Whisper should be available in path, so we overwrite the search function so
|
||||
; that it takes the executable from there instead of the install directory.
|
||||
(defun my-whisper--find-whispercpp-server ()
|
||||
(executable-find "whisper-server"))
|
||||
|
||||
(use-package whisper
|
||||
:defer t
|
||||
:straight (whisper :type git
|
||||
:host github
|
||||
:repo "natrys/whisper.el"
|
||||
@@ -39,12 +45,8 @@
|
||||
whisper-translate nil
|
||||
whisper-use-threads (/ (num-processors) 2))
|
||||
|
||||
;; Lets get hacking
|
||||
|
||||
; The whisper is available in path, so we overwrite the search function so
|
||||
; that it takes the executable from there instead of the install directory.
|
||||
(defun whisper--find-whispercpp-server ()
|
||||
(executable-find "whisper-server")))
|
||||
(advice-add 'whisper--find-whispercpp-server :override #'my-whisper--find-whispercpp-server))
|
||||
|
||||
(keymap-global-set "<f9>" #'whisper-run)
|
||||
|
||||
;;; 90-experimental.el ends here
|
||||
|
||||
@@ -7,45 +7,6 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun my-resize-margins-to-fill ()
|
||||
"Set the current buffer margins so that its width is equal to the fill
|
||||
column."
|
||||
(interactive)
|
||||
(let ((margin-size (/ (- (frame-width) fill-column) 2)))
|
||||
(set-window-margins nil margin-size margin-size)))
|
||||
|
||||
(defun my-reset-margins ()
|
||||
"Removes margins from the current buffer."
|
||||
(interactive)
|
||||
(set-window-margins nil nil nil))
|
||||
|
||||
(defun my-insert-buffer-name ()
|
||||
"Inserts the name of the current buffer at point."
|
||||
(interactive)
|
||||
(let ((name (buffer-name)))
|
||||
(insert name)))
|
||||
|
||||
(defun my-create-org-fc-word-card ()
|
||||
"Inserts and initialzes an org-fc double card with a word and its
|
||||
translation at point."
|
||||
(interactive)
|
||||
(let* ((engw (read-from-minibuffer "Enter English word: "))
|
||||
(rusw (read-from-minibuffer "Enter Russian word: ")))
|
||||
(insert "* " engw)
|
||||
(newline)
|
||||
(insert rusw)
|
||||
(previous-line)
|
||||
(org-fc-type-double-init)))
|
||||
|
||||
(keymap-set org-mode-map "C-c C-n" 'my-create-org-fc-word-card)
|
||||
|
||||
(setq margins-map (make-sparse-keymap))
|
||||
(keymap-set margins-map "f" 'my-resize-margins-to-fill)
|
||||
(keymap-set margins-map "r" 'my-reset-margins)
|
||||
|
||||
(keymap-set mode-specific-map "C-m" margins-map)
|
||||
(keymap-set mode-specific-map "b" 'my-insert-buffer-name)
|
||||
|
||||
(defun my-preview-macro-expansion (arg)
|
||||
"Previews the expansion of a macro in a temporary window.
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
;;; 99-my-ediprolog.el --- ediprolog extras -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
;; ediprolog is a very minimalist package, and I find myself needing to code
|
||||
;; some functionality myself. Ergo, this file.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun my-ediprolog-run-in-own-buffer ()
|
||||
"Copy this query to another buffer and run it there."
|
||||
(interactive)
|
||||
;; This is the same logic ediprolog uses to check if the point is on query.
|
||||
(when (and (not (and transient-mark-mode mark-active))
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "\\([\t ]*%*[\t ]*[:?]- *\\)")))
|
||||
(let* ((from (goto-char (match-end 0)))
|
||||
(to (if (re-search-forward "\\.[\t ]*\\(?:%.*\\)?$" nil t)
|
||||
;; omit trailing whitespace
|
||||
(+ (point) (skip-chars-backward "\t "))
|
||||
(error "Missing `.' at the end of this query")))
|
||||
(query (buffer-substring-no-properties from to))
|
||||
(buffer (get-buffer-create "*Prolog Query*")))
|
||||
|
||||
(pop-to-buffer buffer)
|
||||
|
||||
(unless (eq major-mode "prolog-mode")
|
||||
(prolog-mode))
|
||||
(goto-char (point-max))
|
||||
(unless (eq (line-number-at-pos) 1)
|
||||
(insert "\n\n"))
|
||||
(insert "/*\n ?- ")
|
||||
(save-excursion
|
||||
(insert query "\n*/"))
|
||||
|
||||
(ediprolog-dwim))))
|
||||
|
||||
(defun my-ediprolog-delete-next-comments ()
|
||||
"Delete all commented lines after point (excluding the line under point).
|
||||
Will continue until a line without a comment is encountered. See also
|
||||
'ediprolog-dwim'."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(next-line)
|
||||
(while (looking-at "[ ]*%")
|
||||
(delete-line))))
|
||||
|
||||
(defun my-ediprolog-return-to-closest-query ()
|
||||
"Tries to set point to closest query (starts with ?-) preceding it."
|
||||
(interactive)
|
||||
(re-search-backward "\\([\t ]*%*[\t ]*[:?]- *\\)" nil t))
|
||||
|
||||
(defcustom my-ediprolog-system-types
|
||||
'(("scryer-prolog" . (scryer . ("systemd-run" "--user" "--scope" "-p" "MemoryMax=2G" "-p" "MemoryHigh=1.9G" "scryer-prolog")))
|
||||
("swi-prolog" . (swi . ("swipl"))))
|
||||
"An alist of prolog systems and their respective run commands.
|
||||
|
||||
This has the form of form (NAME . TYPE . COMMAND). NAME is the display
|
||||
name that user will be presented with, TYPE is one of swi or scryer, for
|
||||
the two supported prolog systems respectively. COMMAND is a list, where
|
||||
the first element is the command and the rest are arguments. See
|
||||
'my-ediprolog-select-system'"
|
||||
:type '(alist
|
||||
:key-type string
|
||||
:value-type (cons (choice (const :tag "Scryer Prolog" :value scryer)
|
||||
(const :tag "SWI Prolog" :value swi))
|
||||
(repeat string))))
|
||||
|
||||
(defun my-ediprolog-select-system (&optional system)
|
||||
"Prompts the user to select a prolog SYSTEM and configures ediprolog to use it.
|
||||
|
||||
The prolog systems are defined in 'my-ediprolog-system-types'."
|
||||
(interactive (list (completing-read "Select system:" my-ediprolog-system-types)))
|
||||
|
||||
(let ((pair (alist-get system my-ediprolog-system-types nil nil #'equal)))
|
||||
(setq ediprolog-system (car pair))
|
||||
(setq ediprolog-program (cadr pair))
|
||||
(setq ediprolog-program-switches (cddr pair))))
|
||||
|
||||
(with-eval-after-load 'prolog
|
||||
(keymap-set prolog-mode-map "C-c C-d" #'my-ediprolog-delete-next-comments)
|
||||
(keymap-set prolog-mode-map "C-c C-b" #'my-ediprolog-return-to-closest-query))
|
||||
|
||||
;;; 99-my-ediprolog.el ends here
|
||||
68
post-init.el
68
post-init.el
@@ -1,5 +1,11 @@
|
||||
;;; post-init.el --- This file is loaded after init.el. -*- no-byte-compile: t; lexical-binding: t; -*-
|
||||
|
||||
(load-theme 'modus-operandi)
|
||||
|
||||
(set-face-attribute 'default nil :height 110 :font "Iosevka Nerd Font" :weight 'normal)
|
||||
(setq initial-frame-alist
|
||||
'((width . 100) (height . 25)))
|
||||
|
||||
;; Use straight.el for package management, integrate with use-package.
|
||||
(setq straight-use-package-by-default t)
|
||||
|
||||
@@ -22,18 +28,14 @@
|
||||
(unless (memq 'use-package-autoloads features)
|
||||
(straight-use-package 'use-package))
|
||||
|
||||
;; The compile-angel package automatically byte-compiles and
|
||||
;; native-compiles Emacs Lisp libraries. It should be loaded before
|
||||
;; any other package.
|
||||
(use-package compile-angel
|
||||
:demand t
|
||||
:custom
|
||||
(compile-angel-verbose nil)
|
||||
:config
|
||||
(compile-angel-on-load-mode)
|
||||
(add-hook 'emacs-lisp-mode-hook #'compile-angel-on-save-local-mode))
|
||||
;; Minibuffers and stuff
|
||||
(setq enable-recursive-minibuffers t)
|
||||
(which-key-mode t)
|
||||
|
||||
;; Modeline
|
||||
(display-time-mode)
|
||||
(setq display-time-24hr-format t)
|
||||
|
||||
;; Diminish allows us to clear up our modeline
|
||||
(use-package diminish
|
||||
:ensure t)
|
||||
|
||||
@@ -41,11 +43,49 @@
|
||||
;; integration to diminish it. So, we do it manually here.
|
||||
(diminish 'compile-angel-on-save-local-mode)
|
||||
(diminish 'compile-angel-on-load-mode)
|
||||
|
||||
;; Since I did not explicitly install it, I cannot use the use-package
|
||||
;; integration to deminish eldoc either. So I do it explicitly here.
|
||||
(diminish 'eldoc-mode)
|
||||
|
||||
;; Avoid backups or lockfiles to prevent creating world-readable copies of files
|
||||
(setq create-lockfiles nil)
|
||||
(setq make-backup-files nil)
|
||||
|
||||
(setq backup-directory-alist
|
||||
`((".*" . ,(expand-file-name "backup" user-emacs-directory))))
|
||||
(setq tramp-backup-directory-alist backup-directory-alist)
|
||||
(setq backup-by-copying-when-linked t)
|
||||
(setq backup-by-copying t) ; Backup by copying rather renaming
|
||||
(setq delete-old-versions t) ; Delete excess backup versions silently
|
||||
(setq version-control t) ; Use version numbers for backup files
|
||||
(setq kept-new-versions 5)
|
||||
(setq kept-old-versions 5)
|
||||
|
||||
;; Syntax highlights
|
||||
(setq treesit-font-lock-level 4)
|
||||
|
||||
;; NixOS Specific
|
||||
(unless (functionp 'nix--profile-paths)
|
||||
(message "Not on NixOS. Will try to install packages usually managed by it through use-package.")
|
||||
|
||||
(use-package compile-angel
|
||||
:demand t
|
||||
:custom
|
||||
(compile-angel-verbose nil)
|
||||
:config
|
||||
(compile-angel-on-load-mode)
|
||||
(add-hook 'emacs-lisp-mode-hook #'compile-angel-on-save-local-mode))
|
||||
|
||||
(use-package vterm
|
||||
:defer t
|
||||
:ensure t)
|
||||
|
||||
(use-package nix-ts-mode
|
||||
:defer t
|
||||
:ensure t))
|
||||
|
||||
;; LSP and stuff
|
||||
(add-hook 'nix-ts-mode-hook 'eglot-ensure)
|
||||
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-ts-mode))
|
||||
|
||||
;; Load the configs from plug-in files.
|
||||
(let ((config-dir (concat minimal-emacs-user-directory ".config.d")))
|
||||
(if (not (file-exists-p config-dir))
|
||||
|
||||
Reference in New Issue
Block a user