updating config and corfu module

This commit is contained in:
Matt Nish-Lapidus 2023-10-19 11:23:45 -04:00
parent 8bd123ef11
commit b59a7f8cf8
8 changed files with 224 additions and 298 deletions

View file

@ -33,7 +33,7 @@
:desc "Universal argument" "u" #'universal-argument :desc "Universal argument" "u" #'universal-argument
(:prefix-map ("w" . "window") (:prefix-map ("w" . "window")
:desc "ace-window" "w" #'ace-window :desc "ace-window" "w" #'ace-window
:desc "split vertical" "v" #'split-window-horizontally :desc "split vertical" "v" #'split-window-horizontally
:desc "split horizontal" "h" #'split-window-vertically :desc "split horizontal" "h" #'split-window-vertically
:desc "make taller" "+" #'enlarge-window :desc "make taller" "+" #'enlarge-window
@ -167,6 +167,19 @@
(modulep! :completion helm))) (modulep! :completion helm)))
:desc "List project tasks" "z" #'+taskrunner/project-tasks)) :desc "List project tasks" "z" #'+taskrunner/project-tasks))
;;; <leader> i --- insert
(:prefix-map ("i" . "insert")
(:when (> emacs-major-version 28)
:desc "Emoji" "e" #'emoji-search)
(:when (modulep! :ui emoji)
:desc "Emoji" "e" #'emojify-insert-emoji)
:desc "Current file name" "f" #'+default/insert-file-path
:desc "Current file path" "F" (cmd!! #'+default/insert-file-path t)
:desc "Snippet" "s" #'yas-insert-snippet
:desc "Unicode" "u" #'insert-char
:desc "From clipboard" "y" #'+default/yank-pop)
;;; <leader> s --- search ;;; <leader> s --- search
(:prefix-map ("s" . "search") (:prefix-map ("s" . "search")
:desc "Search buffer" "b" #'+default/search-buffer :desc "Search buffer" "b" #'+default/search-buffer
@ -338,6 +351,7 @@
:desc "LSP Find declaration" "j" #'eglot-find-declaration :desc "LSP Find declaration" "j" #'eglot-find-declaration
(:when (modulep! :completion vertico) (:when (modulep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols)) :desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols))
:desc "PlatformIO Mode Toggle" "p" #'platformio-mode
:desc "Compile" "c" #'compile :desc "Compile" "c" #'compile
:desc "Recompile" "C" #'recompile :desc "Recompile" "C" #'recompile
:desc "Jump to definition" "d" #'+lookup/definition :desc "Jump to definition" "d" #'+lookup/definition
@ -373,13 +387,13 @@
;; some helpful general keys ;; some helpful general keys
(map! "s-c" #'kill-ring-save (map! "s-c" #'kill-ring-save
"s-v" #'yank "s-v" #'yank
"s-V" #'consult-yank-from-kill-ring ; paste from previous copdied text
"s-x" #'kill-region "s-x" #'kill-region
"s-a" #'mark-whole-buffer "s-a" #'mark-whole-buffer
"s-z" #'undo "s-z" #'undo
"s-w" #'kill-buffer "s-w" #'kill-buffer
"s-f" #'+default/search-buffer "s-f" #'+default/search-buffer
"s-g" #'vertico-repeat ; repeat last search (or other vertico action) "s-g" #'vertico-repeat
"s-V" #'consult-yank-from-kill-ring ; paste from previous copdied text
"M-s-<up>" #'next-window-any-frame "M-s-<up>" #'next-window-any-frame
"M-s-<down>" #'previous-window-any-frame "M-s-<down>" #'previous-window-any-frame
;; "s-<up>" #'beginning-of-buffer ;; "s-<up>" #'beginning-of-buffer
@ -416,10 +430,10 @@
"s-M-]" #'sp-forward-sexp "s-M-]" #'sp-forward-sexp
"s-M-{" #'sp-backward-up-sexp "s-M-{" #'sp-backward-up-sexp
"s-M-}" #'sp-down-sexp "s-M-}" #'sp-down-sexp
"s-M-S-<left>" #'sp-backward-sexp "C-M-[" #'sp-backward-sexp
"s-M-S-<right>" #'sp-forward-sexp "C-M-]" #'sp-forward-sexp
"s-M-S-<up>" #'sp-backward-up-sexp "C-M-{" #'sp-backward-up-sexp
"s-M-S-<down>" #'sp-down-sexp "C-M-}" #'sp-down-sexp
"s-(" #'sp-wrap-round "s-(" #'sp-wrap-round
"s-)" #'sp-unwrap-sexp "s-)" #'sp-unwrap-sexp
"s-[" #'sp-wrap-square "s-[" #'sp-wrap-square
@ -427,6 +441,33 @@
"s-{" #'sp-wrap-curly "s-{" #'sp-wrap-curly
"s-}" #'sp-unwrap-sexp) "s-}" #'sp-unwrap-sexp)
;; platform io local leader bindings
(map!
:map platformio-mode-map
:localleader
"b" #'platformio-build
"u" #'platformio-upload
"B" #'platformio-boards
"c" #'platformio-clean
"m" #'platformio-device-monitor)
(map!
:map sclang-mode-map
:localleader
"b" 'sclang-server-boot
"." 'sclang-server-free-all
"k" 'sclang-kill
"r" 'sclang-server-reboot
"e" 'sclang-eval-region-or-line
"h" 'sclang-find-help
"H" 'sclang-open-help-gui
"s" 'sclang-start)
(map!
:map sclang-mode-map
"M-C-x" 'sclang-eval-region-or-line
"M-C-z" 'sclang-server-free-all)
(map! (map!
:map web-mode-map :map web-mode-map
"s-<" #'web-mode-element-wrap) "s-<" #'web-mode-element-wrap)

View file

@ -20,6 +20,11 @@
(setq scroll-preserve-screen-position t) (setq scroll-preserve-screen-position t)
(setq global-hl-line-modes nil) (setq global-hl-line-modes nil)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq org-directory "~/Library/Mobile Documents/iCloud~md~obsidian/Documents/Primary/org/") (setq org-directory "~/Library/Mobile Documents/iCloud~md~obsidian/Documents/Primary/org/")
;; Modeline ;; Modeline
@ -90,19 +95,19 @@
(smart-tabs-insinuate 'c 'javascript 'python)) (smart-tabs-insinuate 'c 'javascript 'python))
;; lsp mode config to work with corfu/cape ;; lsp mode config to work with corfu/cape
(after! lsp-mode ;; (after! lsp-mode
(setq lsp-completion-provider :none) ;; (setq lsp-completion-provider :none)
(setq lsp-signature-render-documentation nil) ;; (setq lsp-signature-render-documentation nil)
(setq lsp-completion-show-kind t) ;; (setq lsp-completion-show-kind t)
(setq lsp-ui-doc-show-with-mouse nil) ;; (setq lsp-ui-doc-show-with-mouse nil)
(setq +lsp-company-backends ;; (setq +lsp-company-backends
'(:separate company-capf company-yasnippet company-dabbrev)) ;; '(:separate company-capf company-yasnippet company-dabbrev))
(defun my/lsp-mode-setup-completion () ;; (defun my/lsp-mode-setup-completion ()
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) ;; (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
'(orderless))) ;; '(orderless)))
(add-hook! lsp-completion-mode 'my/lsp-mode-setup-completion)) ;; (add-hook! lsp-completion-mode 'my/lsp-mode-setup-completion))
;; bibliography file location ;; bibliography file location
(after! citar (after! citar
@ -115,6 +120,7 @@
(setq web-mode-engines-alist (setq web-mode-engines-alist
'(("svelte" . "\\.svelte\\'"))) '(("svelte" . "\\.svelte\\'")))
(add-hook! web-mode (web-mode-use-tabs) (setq indent-tabs-mode t)) (add-hook! web-mode (web-mode-use-tabs) (setq indent-tabs-mode t))
(add-hook! web-mode (web-mode-toggle-current-element-highlight))
;; fix centaur tabs to show at the right times and add my muscle memory keybind ;; fix centaur tabs to show at the right times and add my muscle memory keybind
(after! centaur-tabs (after! centaur-tabs
@ -171,9 +177,16 @@
;; (define-key sly-doc-map (kbd "s") 'cl-patterns-supercollider-documentation)) ;; (define-key sly-doc-map (kbd "s") 'cl-patterns-supercollider-documentation))
(add-hook 'sly-connected-hook 'cl-patterns-helpers-load))) (add-hook 'sly-connected-hook 'cl-patterns-helpers-load)))
;; adding supercollider path
(setq exec-path (append exec-path '("/Applications/SuperCollider.app/Contents/MacOS/")))
;; tidal cycles! ;; tidal cycles!
(setq tidal-boot-script-path "~/.cabal/share/aarch64-osx-ghc-9.4.2/tidal-1.9.3/BootTidal.hs") (setq tidal-boot-script-path "~/.cabal/share/aarch64-osx-ghc-9.4.2/tidal-1.9.3/BootTidal.hs")
;; add platformio to ino files
(add-to-list 'auto-mode-alist '("\\.ino\\'" . arduino-mode))
(add-to-list 'auto-mode-alist '("\\.ino\\'" . platformio-mode))
;; (defvar company-backends '()) ;; (defvar company-backends '())
(load! "obsidian-config.el") (load! "obsidian-config.el")

14
init.el
View file

@ -26,19 +26,19 @@
;;ido ; the other *other* search engine... ;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life ;;ivy ; a search engine for love and life
(vertico +orderless) ; the search engine of the future (vertico +orderless) ; the search engine of the future
(corfu +orderless) (corfu +orderless +icons)
:ui :ui
;;deft ; notational velocity for Emacs ;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs doom-dashboard ; a nifty splash screen for Emacs
;;doom-quit ; DOOM quit-message prompts when you quit Emacs ;;doom-quit ; DOOM quit-message prompts when you quit Emacs
;; (emoji +unicode) ; 🙂 (emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;hydra ;;hydra
;; indent-guides ; highlighted indent columns ;; indent-guides ; highlighted indent columns
ligatures ; ligatures and symbols to make your code pretty again ligatures ; ligatures and symbols to make your code pretty again
;; minimap ; show a map of the code on the side minimap ; show a map of the code on the side
modeline ; snazzy, Atom-inspired modeline, plus API modeline ; snazzy, Atom-inspired modeline, plus API
nav-flash ; blink cursor line after big motions nav-flash ; blink cursor line after big motions
;; neotree ; a project drawer, like NERDTree for vim ;; neotree ; a project drawer, like NERDTree for vim
@ -46,7 +46,7 @@
(popup +all +defaults) ; tame sudden yet inevitable temporary windows (popup +all +defaults) ; tame sudden yet inevitable temporary windows
tabs ; a tab bar for Emacs tabs ; a tab bar for Emacs
(treemacs +lsp +icons) ; a project drawer, like neotree but cooler (treemacs +lsp +icons) ; a project drawer, like neotree but cooler
;;unicode ; extended unicode support for various languages unicode ; extended unicode support for various languages
(vc-gutter +pretty) ; vcs diff in the fringe (vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB vi-tilde-fringe ; fringe tildes to mark beyond EOB
;;window-select ; visually switch windows ;;window-select ; visually switch windows
@ -90,7 +90,7 @@
;;ansible ;;ansible
biblio ; Writes a PhD for you (citation needed) biblio ; Writes a PhD for you (citation needed)
;;debugger ; FIXME stepping through code, to help you add bugs ;;debugger ; FIXME stepping through code, to help you add bugs
;;direnv direnv
;;docker ;;docker
;;editorconfig ; let someone else argue about tabs vs spaces ;;editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs ;;ein ; tame Jupyter notebooks with emacs
@ -165,8 +165,8 @@
;;raku ; the artist formerly known as perl6 ;;raku ; the artist formerly known as perl6
;;rest ; Emacs as a REST client ;;rest ; Emacs as a REST client
;;rst ; ReST in peace ;;rst ; ReST in peace
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} (ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
;; (rust +lsp +tree-sitter) ; Fe2O3.unwrap().unwrap().unwrap().unwrap() (rust +lsp +tree-sitter) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good ;;scala ; java, but good
(scheme +guile +chez) ; a fully conniving family of lisps (scheme +guile +chez) ; a fully conniving family of lisps
sh ; she sells {ba,z,fi}sh shells on the C xor sh ; she sells {ba,z,fi}sh shells on the C xor

View file

@ -25,12 +25,12 @@ highly non-native, but has some extra features and more maturity.
supported. supported.
- +orderless :: - +orderless ::
Pull in [[doom-package:orderless]] if necessary and apply multi-component Pull in [[doom-package:orderless]] if necessary and apply multi-component
completion (still needed if [[:completion vertico]] is active). completion (still needed if [[doom-module::completion vertico]] is active).
** Packages ** Packages
- [[doom-package:corfu]] - [[doom-package:corfu]]
- [[doom-package:cape]] - [[doom-package:cape]]
- [[doom-package:kind-icon]] if [[doom-module::completion corfu +icons]] - [[doom-package:nerd-icons-completion]] if [[doom-module::completion corfu +icons]]
- [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]] - [[doom-package:orderless]] if [[doom-module::completion corfu +orderless]]
- [[doom-package:corfu-terminal]] if [[doom-module::os tty]] - [[doom-package:corfu-terminal]] if [[doom-module::os tty]]
- [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]] - [[doom-package:yasnippet-capf]] if [[doom-module::editor snippets]]
@ -78,13 +78,13 @@ is visible, the following relevant keys are available:
| [[kbd:][C-S-j]] | (evil) Go to next doc line | | [[kbd:][C-S-j]] | (evil) Go to next doc line |
| [[kbd:][C-S-k]] | (evil) Go to previous doc line | | [[kbd:][C-S-k]] | (evil) Go to previous doc line |
| [[kbd:][C-h]] | Toggle documentation (if available) | | [[kbd:][C-h]] | Toggle documentation (if available) |
| [[kbd:][s-<down>]] | Export to minibuffer (if [[doom-module:][:completion vertico]]) | | [[kbd:][s-<down>]] | Export to minibuffer (if [[doom-module::completion vertico]]) |
| [[kbd:][s-j]] | (evil) Export to minibuffer (if [[doom-module:][:completion vertico]]) | | [[kbd:][s-j]] | (evil) Export to minibuffer (if [[doom-module::completion vertico]]) |
| [[kbd:][RET]] | Insert candidate | | [[kbd:][RET]] | Insert candidate |
| [[kbd:][C-SPC]] | (when completing) Insert separator (see below) | | [[kbd:][C-SPC]] | (when completing) Insert separator (see below) |
| [[kbd:][C-SPC]] | Complete (unless [[doom-module:][:completion corfu +tng]]) | | [[kbd:][C-SPC]] | Complete (unless [[doom-module::completion corfu +tng]]) |
If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module:][:completion corfu +tng]] If you prefer a [[kbd:][TAB]]-centric completion style, enable the [[doom-module::completion corfu +tng]]
flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the following flag so that, instead, you trigger completion with [[kbd:][TAB]], getting the following
additional binds: additional binds:
@ -95,15 +95,16 @@ additional binds:
| [[kbd:][S-TAB]] | (when completing) Go to previous candidate | | [[kbd:][S-TAB]] | (when completing) Go to previous candidate |
** Searching with multiple keywords ** Searching with multiple keywords
If the ~+orderless~ flag is enabled, users can perform code completion If the [[doom-module::completion corfu +orderless]] flag is enabled, users can
with multiple search keywords by use of space as separator. More information can perform code completion with multiple search keywords by use of space as
be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while completing inserts a space as separator. More information can be found [[https://github.com/oantolin/orderless#company][here]]. Pressing [[kdb:][C-SPC]] again while
separator. This allows searching with space-separated terms; each piece will completing inserts a space as separator. This allows searching with
match individually and in any order, with smart casing. Pressing just [[kbd:][SPC]] acts space-separated terms; each piece will match individually and in any order, with
as normal and restarts completion, so that when typing sentences it doesn't try smart casing. Pressing just [[kbd:][SPC]] acts as normal and restarts completion, so that
to complete the whole sentence instead of just the word. when typing sentences it doesn't try to complete the whole sentence instead of
just the word.
** Exporting to the minibuffer (requires [[doom-module:][:completion vertico]]) ** Exporting to the minibuffer (requires [[doom-module::completion vertico]])
When using the [[doom-module::completion vertico]] module, which pulls in the When using the [[doom-module::completion vertico]] module, which pulls in the
[[doom-package:consult]] package, the entries shown in the completion popup can be [[doom-package:consult]] package, the entries shown in the completion popup can be
exported to a consult minibuffer, giving access to all the manipulations the exported to a consult minibuffer, giving access to all the manipulations the
@ -117,13 +118,28 @@ A few variables may be set to change behavior of this module:
Number of seconds till completion occurs automatically. Defaults to 0.1. Number of seconds till completion occurs automatically. Defaults to 0.1.
- [[var:corfu-auto-prefix]] :: - [[var:corfu-auto-prefix]] ::
Number of characters till auto-completion starts to happen. Defaults to 2. Number of characters till auto-completion starts to happen. Defaults to 2.
- [[var:+corfu-want-multi-component]] ::
Sets whether orderless-style matching should be supported with space as a
separator.
- [[var:corfu-on-exact-match]] :: - [[var:corfu-on-exact-match]] ::
Configures behavior for exact matches. Its default is nil, and it's Configures behavior for exact matches. Its default is nil, and it's
recommended to leave it at that. Otherwise, single matches on snippet keys recommended to leave it at that. Otherwise, single matches on snippet keys
expand immediately. expand immediately.
- [[var:+corfu-completion-styles]] ::
Used to override [[var:completion-styles]] for corfu invocations, such that it
can have a value separate from, say, [[doom-package:consult]].
- [[var:+corfu-icon-mapping]] ::
Configures icons used for each completion. See its documentation for details.
** Adding CAPFs to a mode
To add other CAPFs on a mode-per-mode basis, put either of the following in your
~config.el~:
#+begin_src emacs-lisp
(add-hook! some-mode (add-to-list 'completion-at-point-functions #'some-capf))
;; OR, but note the different call signature
(add-hook 'some-mode-hook (lambda () (add-to-list 'completion-at-point-functions #'some-capf)))
#+end_src
Also see ~add-hook!~'s documentation for additional ways to call it.
~add-hook~ only accepts the quoted arguments form above.
* Troubleshooting * Troubleshooting
[[doom-report:][Report an issue?]] [[doom-report:][Report an issue?]]

View file

@ -1,9 +1,64 @@
;;; completion/corfu/config.el -*- lexical-binding: t; -*- ;;; completion/corfu/config.el -*- lexical-binding: t; -*-
(defvar +corfu-completion-styles '(basic partial-completion flex)
"Completion styles for corfu to use.
If the user enables +orderless, `orderless' is automatically appended to this
list before fowarding to `completion-styles'.")
(defvar +corfu-icon-mapping
`((array ,(nerd-icons-codicon "nf-cod-symbol_array") :face font-lock-type-face)
(boolean ,(nerd-icons-codicon "nf-cod-symbol_boolean") :face font-lock-builtin-face)
(class ,(nerd-icons-codicon "nf-cod-symbol_class") :face font-lock-type-face)
(color ,(nerd-icons-codicon "nf-cod-symbol_color") :face success)
(command ,(nerd-icons-codicon "nf-cod-terminal") :face default)
(constant ,(nerd-icons-codicon "nf-cod-symbol_constant") :face font-lock-constant-face)
(constructor ,(nerd-icons-codicon "nf-cod-triangle_right") :face font-lock-function-name-face)
(enummember ,(nerd-icons-codicon "nf-cod-symbol_enum_member") :face font-lock-builtin-face)
(enum-member ,(nerd-icons-codicon "nf-cod-symbol_enum_member") :face font-lock-builtin-face)
(enum ,(nerd-icons-codicon "nf-cod-symbol_enum") :face font-lock-builtin-face)
(event ,(nerd-icons-codicon "nf-cod-symbol_event") :face font-lock-warning-face)
(field ,(nerd-icons-codicon "nf-cod-symbol_field") :face font-lock-variable-name-face)
(file ,(nerd-icons-codicon "nf-cod-symbol_file") :face font-lock-string-face)
(folder ,(nerd-icons-codicon "nf-cod-folder") :face font-lock-doc-face)
(interface ,(nerd-icons-codicon "nf-cod-symbol_interface") :face font-lock-type-face)
(keyword ,(nerd-icons-codicon "nf-cod-symbol_keyword") :face font-lock-keyword-face)
(macro ,(nerd-icons-codicon "nf-cod-symbol_misc") :face font-lock-keyword-face)
(magic ,(nerd-icons-codicon "nf-cod-wand") :face font-lock-builtin-face)
(method ,(nerd-icons-codicon "nf-cod-symbol_method") :face font-lock-function-name-face)
(function ,(nerd-icons-codicon "nf-cod-symbol_method") :face font-lock-function-name-face)
(module ,(nerd-icons-codicon "nf-cod-file_submodule") :face font-lock-preprocessor-face)
(numeric ,(nerd-icons-codicon "nf-cod-symbol_numeric") :face font-lock-builtin-face)
(operator ,(nerd-icons-codicon "nf-cod-symbol_operator") :face font-lock-comment-delimiter-face)
(param ,(nerd-icons-codicon "nf-cod-symbol_parameter") :face default)
(property ,(nerd-icons-codicon "nf-cod-symbol_property") :face font-lock-variable-name-face)
(reference ,(nerd-icons-codicon "nf-cod-references") :face font-lock-variable-name-face)
(snippet ,(nerd-icons-codicon "nf-cod-symbol_snippet") :face font-lock-string-face)
(string ,(nerd-icons-codicon "nf-cod-symbol_string") :face font-lock-string-face)
(struct ,(nerd-icons-codicon "nf-cod-symbol_structure") :face font-lock-variable-name-face)
(text ,(nerd-icons-codicon "nf-cod-text_size") :face font-lock-doc-face)
(typeparameter ,(nerd-icons-codicon "nf-cod-list_unordered") :face font-lock-type-face)
(type-parameter ,(nerd-icons-codicon "nf-cod-list_unordered") :face font-lock-type-face)
(unit ,(nerd-icons-codicon "nf-cod-symbol_ruler") :face font-lock-constant-face)
(value ,(nerd-icons-codicon "nf-cod-symbol_field") :face font-lock-builtin-face)
(variable ,(nerd-icons-codicon "nf-cod-symbol_variable") :face font-lock-variable-name-face)
(t ,(nerd-icons-codicon "nf-cod-code") :face font-lock-warning-face))
"Mapping of completion kinds to icons.
It should be a list of elements with the form (KIND ICON-TXT [:face FACE]).
KIND is a symbol determining what the completion is, and comes from calling the
`:company-kind' property of the completion. ICON-TXT is a string with the icon
to use, usually as a character from the `nerd-icons' symbol font. See that
package for how to get these. Note that it can be simple text if that is
preferred. FACE, if present, is applied to the icon, mainly for its color. The
special `t' symbol should be used for KIND to represent the default icon, and
must be present.")
;; ;;
;;; Packages ;;; Packages
(use-package! corfu (use-package! corfu
:hook (doom-first-buffer . global-corfu-mode) :hook (doom-first-buffer . global-corfu-mode)
:hook (org-mode . corfu-mode)
:init :init
;; Auto-completion settings, must be set before calling `global-corfu-mode'. ;; Auto-completion settings, must be set before calling `global-corfu-mode'.
;; Due to lazy-loading, setting them in config.el works too. ;; Due to lazy-loading, setting them in config.el works too.
@ -16,8 +71,6 @@
gud-mode gud-mode
vterm-mode)) vterm-mode))
:config :config
(add-to-list 'completion-styles 'partial-completion t)
(add-to-list 'completion-styles 'initials t)
(setq corfu-cycle t (setq corfu-cycle t
corfu-separator (when (modulep! +orderless) ?\s) corfu-separator (when (modulep! +orderless) ?\s)
corfu-preselect t corfu-preselect t
@ -30,12 +83,50 @@
;; In the case of +tng, TAB should be smart regarding completion; ;; In the case of +tng, TAB should be smart regarding completion;
;; However, it should otherwise behave like normal, whatever normal was. ;; However, it should otherwise behave like normal, whatever normal was.
tab-always-indent (if (modulep! +tng) 'complete tab-always-indent)) tab-always-indent (if (modulep! +tng) 'complete tab-always-indent))
(when (modulep! +orderless) (when (modulep! +orderless)
(cond ((modulep! :tools lsp +eglot) (add-to-list 'completion-category-overrides '(eglot (styles orderless)))) (after! 'lsp-mode
((modulep! :tools lsp) (add-hook 'lsp-completion-mode-hook (add-to-list 'completion-category-overrides
(defun doom--use-orderless-lsp-capf () `(lsp-capf (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless)))))
(setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) (after! 'eglot
'(orderless))))))) (add-to-list 'completion-category-overrides
`(eglot (styles ,@+corfu-completion-styles ,(when (modulep! +orderless) 'orderless))))))
;; For the icons, we use a custom margin formatter, which simply reads the
;; mapping in `+corfu-icon-mapping'.
(when (modulep! +icons)
(defun icon-margin-formatter (metadata)
(when-let ((kindfunc (or (plist-get completion-extra-properties :company-kind)
(assq 'company-kind metadata))))
(lambda (cand)
(let* ((kind (funcall kindfunc cand))
(icon-entry (assq (or kind t) +corfu-icon-mapping))
(str (cadr icon-entry))
(props (cddr icon-entry))
(extra-face (plist-get props :face))
(space (propertize " " 'display '(space :width 1)))
(str (concat " " str space)))
(when extra-face
(put-text-property 0 3 'face extra-face str))
str))))
(setq corfu-margin-formatters '(icon-margin-formatter)))
;; This is to decouple the use of `completion-styles' in corfu from other
;; completion packages, such as vertico. That way, the user can leave the
;; global value of the variable alone, say, to be used by the default
;; front-end or consult. The vertico module also does something similar with
;; `+vertico-company-completion-styles'.
(defadvice! +corfu--completion-styles (orig &rest args)
"Try default completion styles before orderless.
Meant as :around advice for `corfu--recompute'."
:around #'corfu--recompute
(let ((completion-styles
(append +corfu-completion-styles (when (modulep! +orderless)
'(orderless))))
completion-category-overrides completion-category-defaults)
(apply orig args)))
(map! (:unless (modulep! +tng) (map! (:unless (modulep! +tng)
"C-SPC" #'completion-at-point) "C-SPC" #'completion-at-point)
(:map 'corfu-map (:map 'corfu-map
@ -46,8 +137,7 @@
[backtab] #'corfu-previous [backtab] #'corfu-previous
"TAB" #'corfu-next "TAB" #'corfu-next
"S-TAB" #'corfu-previous))) "S-TAB" #'corfu-previous)))
(after! evil-collection-corfu
(when (modulep! :editor evil)
(evil-collection-define-key 'insert 'corfu-map (evil-collection-define-key 'insert 'corfu-map
(kbd "RET") #'corfu-insert (kbd "RET") #'corfu-insert
[return] #'corfu-insert)) [return] #'corfu-insert))
@ -66,10 +156,9 @@
(use-package! cape (use-package! cape
:after corfu :after corfu
:config :config
(add-hook 'prog-mode-hook (add-hook! prog-mode (add-to-list 'completion-at-point-functions #'cape-file))
(lambda () (add-to-list 'completion-at-point-functions #'cape-file))) (add-hook! (org-mode markdown-mode) (add-to-list 'completion-at-point-functions #'cape-elisp-block))
(add-hook! (markdown-mode org-mode) (advice-add #'lsp-completion-at-point :around #'cape-wrap-noninterruptible))
(lambda () (add-to-list 'completion-at-point-functions #'cape-elisp-block))))
(use-package! yasnippet-capf (use-package! yasnippet-capf
:after corfu :after corfu
@ -77,47 +166,6 @@
(add-hook 'yas-minor-mode-hook (add-hook 'yas-minor-mode-hook
(lambda () (add-to-list 'completion-at-point-functions #'yasnippet-capf)))) (lambda () (add-to-list 'completion-at-point-functions #'yasnippet-capf))))
(use-package! svg-lib
:after kind-icon)
(use-package! kind-icon
:commands (kind-icon-margin-formatter
kind-icon-reset-cache
kind-icon-formatted)
:init
(add-hook 'corfu-margin-formatters #'kind-icon-margin-formatter)
:config
(defface corfu-kind-icon '((t :inherit corfu-default))
"Face for the icons in the corfu popup.
For changing color, you should probably use `kind-icon-mapping', which see. The
purpose here is overriding size and helping with scaling issues."
:group 'corfu)
(setq kind-icon-default-face 'corfu-kind-icon
kind-icon-blend-background t
kind-icon-blend-frac 0.2)
(let ((def-style (svg-lib-style-compute-default 'corfu-kind-icon))
res)
(cl-loop for (key value) on def-style by 'cddr
do (unless (member key '(:foreground
:background
:font-size
:font-width
:font-weight
:font-family
:width))
(setq res (plist-put res key value))))
(setq kind-icon-default-style (plist-put res :stroke 0.25)))
(defadvice! doom--kind-icon-remove-padding (orig kind)
"Rescale icon images to 1, and set surrounding spaces to width 0.
This fixes the cropping due to scaling issues."
:around #'kind-icon-formatted
(let* ((text (funcall orig kind))
(image (get-text-property 1 'display text)))
(when (eq (car-safe image) 'image)
(setf (image-property image :scale) 1)
(put-text-property 0 1 'display '(space :width (0)) text)
(put-text-property 2 3 'display '(space :width (0)) text))
text)))
(use-package! corfu-terminal (use-package! corfu-terminal
:when (not (display-graphic-p)) :when (not (display-graphic-p))
:hook (corfu-mode . corfu-terminal-mode)) :hook (corfu-mode . corfu-terminal-mode))

View file

@ -1,14 +1,13 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; completion/corfu/packages.el ;;; completion/corfu/packages.el
(package! corfu) (package! corfu :recipe (:files ("*.el" "extensions/*.el")) :pin "cc244c54b392ce4d27ed166730efde4f4d01a07f")
(package! cape) (package! cape :pin "4506ee82129a8e9ff9e4650a9b16eb8c4ae355f3")
(when (modulep! +icons) (when (modulep! +icons)
(package! svg-lib) (package! nerd-icons-completion :pin "c2db8557a3c1a9588d111f8c8e91cae96ee85010"))
(package! kind-icon))
(when (modulep! +orderless) (when (modulep! +orderless)
(package! orderless)) (package! orderless :pin "e6784026717a8a6a7dcd0bf31fd3414f148c542e"))
(when (modulep! :os tty) (when (modulep! :os tty)
(package! corfu-terminal)) (package! corfu-terminal :pin "501548c3d51f926c687e8cd838c5865ec45d03cc"))
(when (modulep! :editor snippets) (when (modulep! :editor snippets)
(package! yasnippet-capf)) (package! yasnippet-capf :pin "40654214db7a44db3a99321447632b43a10fae57"))

View file

@ -56,116 +56,6 @@
"'" #'repeat "'" #'repeat
"<escape>" #'corfu-quit)) "<escape>" #'corfu-quit))
;; Colemak
(defun meow/setup-colemak ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-colemak)
(meow/setup)
(when (modulep! +override)
(meow-motion-overwrite-define-key
;; Use e to move up, n to move down.
;; Since special modes usually use n to move down, we only overwrite e here.
'("e" . meow-prev))
(when (modulep! :editor meow +leader)
(meow-motion-overwrite-define-key '("\\ e" . "H-e")))
(meow-leader-define-key '("e" . "H-e")))
(map! :map meow-normal-state-keymap
"[" #'meow-beginning-of-thing
"]" #'meow-end-of-thing
"/" #'meow-visit
"a" #'meow-append
"A" #'meow-open-below
"b" #'meow-back-word
"B" #'meow-back-symbol
"c" #'meow-change
"d" #'meow-delete
"e" #'meow-prev
"E" #'meow-prev-expand
"f" #'meow-find
"g" #'meow-cancel-selection
"G" #'meow-grab
"h" #'meow-left
"H" #'meow-left-expand
"i" #'meow-right
"I" #'meow-right-expand
"j" #'meow-join
"k" #'meow-kill
"l" #'meow-line
"L" #'meow-goto-line
"m" #'meow-mark-word
"M" #'meow-mark-symbol
"n" #'meow-next
"N" #'meow-next-expand
"o" #'meow-block
"O" #'meow-to-block
"p" #'meow-yank
"q" #'meow-quit
"r" #'meow-replace
"s" #'meow-insert
"S" #'meow-open-above
"t" #'meow-till
"u" #'meow-undo
"U" #'meow-undo-in-selection
"v" #'meow-search
"w" #'meow-next-word
"W" #'meow-next-symbol
"x" #'meow-delete
"X" #'meow-backward-delete
"y" #'meow-save
"z" #'meow-pop-selection))
;; Dvorak
(defun meow/setup-dvorak ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-dvorak)
(when (modulep! +override)
(meow-motion-overwrite-define-key)) ; custom keybinding for motion state
(meow/setup)
(map! :map meow-normal-state-keymap
"<" #'meow-beginning-of-thing
">" #'meow-end-of-thing
"a" #'meow-append
"A" #'meow-open-below
"b" #'meow-back-word
"B" #'meow-back-symbol
"c" #'meow-change
"d" #'meow-delete
"D" #'meow-backward-delete
"e" #'meow-line
"E" #'meow-goto-line
"f" #'meow-find
"g" #'meow-cancel-selection
"G" #'meow-grab
"h" #'meow-left
"H" #'meow-left-expand
"I" #'meow-open-above
"i" #'meow-insert
"j" #'meow-join
"k" #'meow-kill
"l" #'meow-till
"m" #'meow-mark-word
"M" #'meow-mark-symbol
"n" #'meow-next
"N" #'meow-next-expand
"o" #'meow-block
"O" #'meow-to-block
"p" #'meow-prev
"P" #'meow-prev-expand
"q" #'meow-quit
"Q" #'meow-goto-line
"r" #'meow-replace
"R" #'meow-swap-grab
"s" #'meow-search
"t" #'meow-right
"T" #'meow-right-expand
"u" #'meow-undo
"U" #'meow-undo-in-selection
"v" #'meow-visit
"w" #'meow-next-word
"W" #'meow-next-symbol
"x" #'meow-save
"X" #'meow-sync-grab
"y" #'meow-yank
"z" #'meow-pop-selection))
;; Qwerty ;; Qwerty
(defun meow/setup-qwerty () (defun meow/setup-qwerty ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
@ -229,93 +119,11 @@
"Y" #'meow-sync-grab "Y" #'meow-sync-grab
"z" #'meow-pop-selection)) "z" #'meow-pop-selection))
;; Programmer Dvorak
(defun meow/setup-dvp ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-dvp)
(when (modulep! +override)
(meow-motion-overwrite-define-key)) ; custom keybinding for motion state
(map! :map meow-normal-state-keymap
"?" #'meow-cheatsheet
"*" #'meow-expand-0
"=" #'meow-expand-9
"!" #'meow-expand-8
"[" #'meow-expand-7
"]" #'meow-expand-6
"{" #'meow-expand-5
"+" #'meow-expand-4
"}" #'meow-expand-3
")" #'meow-expand-2
"(" #'meow-expand-1
"1" #'digit-argument
"2" #'digit-argument
"3" #'digit-argument
"4" #'digit-argument
"5" #'digit-argument
"6" #'digit-argument
"7" #'digit-argument
"8" #'digit-argument
"9" #'digit-argument
"0" #'digit-argument
"-" #'negative-argument
";" #'meow-reverse
"," #'meow-inner-of-thing
"." #'meow-bounds-of-thing
"<" #'meow-beginning-of-thing
">" #'meow-end-of-thing
"a" #'meow-append
"A" #'meow-open-below
"b" #'meow-back-word
"B" #'meow-back-symbol
"c" #'meow-change
"d" #'meow-delete
"D" #'meow-backward-delete
"e" #'meow-line
"E" #'meow-goto-line
"f" #'meow-find
"g" #'meow-cancel-selection
"G" #'meow-grab
"h" #'meow-left
"H" #'meow-left-expand
"i" #'meow-insert
"I" #'meow-open-above
"j" #'meow-join
"k" #'meow-kill
"l" #'meow-till
"m" #'meow-mark-word
"M" #'meow-mark-symbol
"n" #'meow-next
"N" #'meow-next-expand
"o" #'meow-block
"O" #'meow-to-block
"p" #'meow-prev
"P" #'meow-prev-expand
"q" #'meow-quit
"r" #'meow-replace
"R" #'meow-swap-grab
"s" #'meow-search
"t" #'meow-right
"T" #'meow-right-expand
"u" #'meow-undo
"U" #'meow-undo-in-selection
"v" #'meow-visit
"w" #'meow-next-word
"W" #'meow-next-symbol
"x" #'meow-save
"X" #'meow-sync-grab
"y" #'meow-yank
"z" #'meow-pop-selection
"'" #'repeat
"<escape>" #'ignore))
(use-package! meow (use-package! meow
:hook (doom-after-modules-config . meow-global-mode) :hook (doom-after-modules-config . meow-global-mode)
:demand t :demand t
:config :config
(cond (meow/setup-qwerty)
((modulep! +colemak) (meow/setup-colemak))
((modulep! +dvorak) (meow/setup-dvorak))
((modulep! +qwerty) (meow/setup-qwerty))
((modulep! +dvp) (meow/setup-dvp)))
(cond (cond
((modulep! +leader) ((modulep! +leader)
(map! :map meow-normal-state-keymap (map! :map meow-normal-state-keymap
@ -328,4 +136,5 @@
(t (meow/setup-keypad))) (t (meow/setup-keypad)))
(pushnew! meow-mode-state-list '(sly-db-mode . motion)) (pushnew! meow-mode-state-list '(sly-db-mode . motion))
(pushnew! meow-mode-state-list '(sly-inspector-mode . motion)) (pushnew! meow-mode-state-list '(sly-inspector-mode . motion))
(map! :map meow-keymap [remap describe-key] #'helpful-key)) (pushnew! meow-mode-state-list '(Custom-mode . normal))
(map! :map meow-keymap [remap describe-key] #'helpfl-key))

View file

@ -42,7 +42,7 @@
:host github :host github
:repo "serialdev/ijanet-mode")) :repo "serialdev/ijanet-mode"))
(package! platformio-mode)
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: