Compare commits
	
		
			No commits in common. "04c1d8c317560f86f61327725e17498f95017240" and "d9f7ec85f5da96a2b14b284bcc64b9111760e075" have entirely different histories.
		
	
	
		
			04c1d8c317
			...
			d9f7ec85f5
		
	
		
							
								
								
									
										531
									
								
								init.org
									
									
									
									
									
								
							
							
						
						
									
										531
									
								
								init.org
									
									
									
									
									
								
							|  | @ -319,18 +319,6 @@ Font size [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attri | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (defun apply-if-gui (&rest action) |  | ||||||
|   "apply ACTION if emacs is run in GUI context, regardless of daemonp or display-graphic-p" |  | ||||||
|   (if (daemonp) |  | ||||||
|       (add-hook 'after-make-frame-functions |  | ||||||
|                 (lambda (frame) |  | ||||||
|                   (select-frame frame) |  | ||||||
|                   (if (display-graphic-p frame) |  | ||||||
|                       (apply action)))) |  | ||||||
|     (if (display-graphic-p) |  | ||||||
|         (apply action)))) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| (set-face-attribute 'default nil :font "monospace" :height nemo/font-height-mono) | (set-face-attribute 'default nil :font "monospace" :height nemo/font-height-mono) | ||||||
| (set-face-attribute 'fixed-pitch nil :font "monospace" :height nemo/font-height-mono) | (set-face-attribute 'fixed-pitch nil :font "monospace" :height nemo/font-height-mono) | ||||||
| (set-face-attribute 'variable-pitch nil :font "sans-serif" :height nemo/font-height-sans) | (set-face-attribute 'variable-pitch nil :font "sans-serif" :height nemo/font-height-sans) | ||||||
|  | @ -338,18 +326,13 @@ Font size [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Face-Attri | ||||||
| ;; (when (member "SF Mono" (font-family-list)) | ;; (when (member "SF Mono" (font-family-list)) | ||||||
| ;;   (set-face-attribute 'default nil :font "SF Mono" :height nemo/font-height-mono) | ;;   (set-face-attribute 'default nil :font "SF Mono" :height nemo/font-height-mono) | ||||||
| ;;   (set-face-attribute 'fixed-pitch nil :family "SF Mono" :height nemo/font-height-mono)) | ;;   (set-face-attribute 'fixed-pitch nil :family "SF Mono" :height nemo/font-height-mono)) | ||||||
| (when (member "SF Pro Text" (font-family-list)) |  | ||||||
|   (set-face-attribute 'variable-pitch nil :family "SF Pro Text" :height nemo/font-height-sans)) |  | ||||||
| 
 |  | ||||||
| (defvar nemo/nerd-fonts-font "Symbols Nerd Font") | (defvar nemo/nerd-fonts-font "Symbols Nerd Font") | ||||||
| 
 | 
 | ||||||
| (defun nemo/set-fallback-fonts () | (when (member nemo/nerd-fonts-font (font-family-list)) | ||||||
|   "Set fallback fonts for icons/symbols." |  | ||||||
|   (when (member nemo/nerd-fonts-font (font-family-list)) |  | ||||||
|   (set-fontset-font t nil (font-spec :height nemo/font-height-mono :font "Symbols Nerd Font"))) |   (set-fontset-font t nil (font-spec :height nemo/font-height-mono :font "Symbols Nerd Font"))) | ||||||
|   ) |  | ||||||
| 
 | 
 | ||||||
| (apply-if-gui #'nemo/set-fallback-fonts) | (when (member "SF Pro Text" (font-family-list)) | ||||||
|  |   (set-face-attribute 'variable-pitch nil :family "SF Pro Text" :height nemo/font-height-sans)) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| Use nerd-icons and apple emojis | Use nerd-icons and apple emojis | ||||||
|  | @ -582,8 +565,6 @@ try out =diff-hl= for highlighting diffs in magit: | ||||||
|     "gSb" 'magit-blame) |     "gSb" 'magit-blame) | ||||||
|   :config |   :config | ||||||
|   (setq magit-mode-quit-window 'magit-restore-window-configuration |   (setq magit-mode-quit-window 'magit-restore-window-configuration | ||||||
|         ediff-window-setup-function #'ediff-setup-windows-plain |  | ||||||
|         ediff-merge-split-window-function #'split-window-horizontally |  | ||||||
|         ;;magit-auto-revert-mode t |         ;;magit-auto-revert-mode t | ||||||
|         )) |         )) | ||||||
| #+end_src | #+end_src | ||||||
|  | @ -769,15 +750,6 @@ Also use =undo-fu=, which evil can use. | ||||||
|   (setq jinx-languages "en_GB dk_DK de_DE")) |   (setq jinx-languages "en_GB dk_DK de_DE")) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| Use =ispell= with company mode for completion in text-modes |  | ||||||
| #+begin_src emacs-lisp  |  | ||||||
| (use-package ispell |  | ||||||
|   :straight t |  | ||||||
|   :defer t |  | ||||||
|   :config |  | ||||||
|   (setq ispell-dictionary "en_GB")) |  | ||||||
| #+end_src |  | ||||||
| 
 |  | ||||||
| ** LaTeX | ** LaTeX | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (use-package auctex | (use-package auctex | ||||||
|  | @ -840,7 +812,8 @@ Taken from [[https://sophiebos.io/posts/prettifying-emacs-org-mode/][ here]]. | ||||||
|     "m" '(:keymap nemo/org-map :wk "Org") |     "m" '(:keymap nemo/org-map :wk "Org") | ||||||
|     ) |     ) | ||||||
|   (general-def 'normal 'org-src-mode-map ",," 'org-edit-src-exit) |   (general-def 'normal 'org-src-mode-map ",," 'org-edit-src-exit) | ||||||
|   (general-def 'normal 'org-mode-map |   (general-def 'normal | ||||||
|  |     :keymaps 'org-mode-map | ||||||
|     "TAB" 'org-cycle |     "TAB" 'org-cycle | ||||||
|     "RET" 'org-open-at-point) |     "RET" 'org-open-at-point) | ||||||
|   :config |   :config | ||||||
|  | @ -1171,7 +1144,7 @@ Use =consult-xref= for =lsp-xref= and =xref-find-references=. | ||||||
|   ) |   ) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| ** COMMENT Company - Auto-Completion | ** Company - Auto-Completion | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (use-package company | (use-package company | ||||||
|   :straight t |   :straight t | ||||||
|  | @ -1184,12 +1157,20 @@ Use =consult-xref= for =lsp-xref= and =xref-find-references=. | ||||||
|    company-idle-delay 0.0)) |    company-idle-delay 0.0)) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| ** Corfu - Auto-Completion | Use =ispell= with company mode for completion in text-modes | ||||||
|  | #+begin_src emacs-lisp  | ||||||
|  | (use-package ispell | ||||||
|  |   :straight t | ||||||
|  |   :defer t | ||||||
|  |   :config | ||||||
|  |   (setq ispell-dictionary "en_GB")) | ||||||
|  | #+end_src | ||||||
|  | 
 | ||||||
|  | ** COMMENT Corfu - Auto-Completion | ||||||
| Auto-completion using =corfu=: | Auto-completion using =corfu=: | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (use-package corfu | (use-package corfu | ||||||
|   :straight t |   :straight t | ||||||
|   :hook ((prog-mode text-mode) . completion-preview-mode) |  | ||||||
|   :custom |   :custom | ||||||
|   ;; Enable auto completion |   ;; Enable auto completion | ||||||
|   (corfu-auto t) |   (corfu-auto t) | ||||||
|  | @ -1204,16 +1185,6 @@ Auto-completion using =corfu=: | ||||||
|   ;; Preselect the first suggestion |   ;; Preselect the first suggestion | ||||||
|   (corfu-preselect 'first) |   (corfu-preselect 'first) | ||||||
|   (corfu-on-exact-match nil) |   (corfu-on-exact-match nil) | ||||||
|   :custom |  | ||||||
|   (lsp-completion-provider :none) |  | ||||||
|   :init |  | ||||||
|   (defun nemo/orderless-dispatch-flex-first (_pattern index _total) |  | ||||||
|     (and (eq index 0) 'orderless-flex)) |  | ||||||
| 
 |  | ||||||
|   (defun nemo/lsp-mode-setup-completion () |  | ||||||
|     (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) '(orderless)) |  | ||||||
|     (add-hook 'orderless-style-dispatchers #'nemo/orderless-dispatch-flex-first nil 'local)) |  | ||||||
|   :hook (lsp-completion-mode . nemo/lsp-mode-setup-completion) |  | ||||||
|   :config |   :config | ||||||
|   (global-corfu-mode)) |   (global-corfu-mode)) | ||||||
| 
 | 
 | ||||||
|  | @ -1226,28 +1197,26 @@ Auto-completion using =corfu=: | ||||||
|                               (if (display-graphic-p) -1 +1)))) |                               (if (display-graphic-p) -1 +1)))) | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
| ;; (use-package emacs | (use-package emacs | ||||||
| ;;   ;; :custom |   ;; :custom | ||||||
| ;;   ;; TODO |   ;; TODO | ||||||
| ;;   :init |   :init | ||||||
| ;;   ;; TAB cycle if there are only few candidates |   ;; TAB cycle if there are only few candidates | ||||||
| ;;   ;; (setq completion-cycle-threshold 3) |   ;; (setq completion-cycle-threshold 3) | ||||||
| 
 | 
 | ||||||
| ;;   (setq enable-recursive-minibuffers t) |   (setq enable-recursive-minibuffers t) | ||||||
| ;;   ;; Hide commands in M-x which do not apply to the current mode.  Corfu |   ;; Hide commands in M-x which do not apply to the current mode.  Corfu | ||||||
| ;;   ;; commands are hidden, since they are not supposed to be used via M-x. |   ;; commands are hidden, since they are not supposed to be used via M-x. | ||||||
| ;;   (setq read-extended-command-predicate |   (setq read-extended-command-predicate | ||||||
| ;;         #'command-completion-default-include-p) |         #'command-completion-default-include-p) | ||||||
| 
 | 
 | ||||||
| ;;   (setq text-mode-ispell-word-completion nil) |   (setq text-mode-ispell-word-completion nil) | ||||||
| 
 | 
 | ||||||
| ;;   ;; Enable indentation+completion using the TAB key. |   ;; Enable indentation+completion using the TAB key. | ||||||
| ;;   ;; `completion-at-point' is often bound to M-TAB. |   ;; `completion-at-point' is often bound to M-TAB. | ||||||
| ;;   (setq tab-always-indent 'complete) |   (setq tab-always-indent 'complete)) | ||||||
| ;;   ) |  | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| *** kind-icon |  | ||||||
| Use =kind-icon= to decorate corfu completion candidates: | Use =kind-icon= to decorate corfu completion candidates: | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (use-package kind-icon | (use-package kind-icon | ||||||
|  | @ -1257,47 +1226,45 @@ Use =kind-icon= to decorate corfu completion candidates: | ||||||
|   (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) |   (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| *** Cape | This package seems to slow down search quite a bit in common buffers like find-file and exectue-extended-comand: | ||||||
| This package seems to slow down search quite a bit in common buffers like =find-file= and =exectue-extended-comand=: | #+begin_src emacs-lisp :tangle no | ||||||
| #+begin_src emacs-lisp  |  | ||||||
| (use-package cape | (use-package cape | ||||||
|   :straight t |   :straight t | ||||||
|   ;; Bind dedicated completion commands |   ;; Bind dedicated completion commands | ||||||
|   ;; Alternative prefix keys: C-c p, M-p, M-+, ... |   ;; Alternative prefix keys: C-c p, M-p, M-+, ... | ||||||
|   ;; :bind (("C-c p p"  . completion-at-point) ;; capf |   :bind (("C-c p p"  . completion-at-point) ;; capf | ||||||
|   ;;        ("C-c p t"  . complete-tag)        ;; etags |          ("C-c p t"  . complete-tag)        ;; etags | ||||||
|   ;;        ("C-c p d"  . cape-dabbrev)        ;; or dabbrev-completion |          ("C-c p d"  . cape-dabbrev)        ;; or dabbrev-completion | ||||||
|   ;;        ("C-c p h"  . cape-history) |          ("C-c p h"  . cape-history) | ||||||
|   ;;        ("C-c p f"  . cape-file) |          ("C-c p f"  . cape-file) | ||||||
|   ;;        ("C-c p k"  . cape-keyword) |          ("C-c p k"  . cape-keyword) | ||||||
|   ;;        ("C-c p s"  . cape-symbol) |          ("C-c p s"  . cape-symbol) | ||||||
|   ;;        ("C-c p a"  . cape-abbrev) |          ("C-c p a"  . cape-abbrev) | ||||||
|   ;;        ("C-c p l"  . cape-line) |          ("C-c p l"  . cape-line) | ||||||
|   ;;        ("C-c p w"  . cape-dict) |          ("C-c p w"  . cape-dict) | ||||||
|   ;;        ("C-c p \\" . cape-tex) |          ("C-c p \\" . cape-tex) | ||||||
|   ;;        ("C-c p _"  . cape-tex) |          ("C-c p _"  . cape-tex) | ||||||
|   ;;        ("C-c p ^"  . cape-tex) |          ("C-c p ^"  . cape-tex) | ||||||
|   ;;        ("C-c p &"  . cape-sgml) |          ("C-c p &"  . cape-sgml) | ||||||
|   ;;        ("C-c p r"  . cape-rfc1345)) |          ("C-c p r"  . cape-rfc1345)) | ||||||
|   :init |   :init | ||||||
|   ;; Add `completion-at-point-functions', used by `completion-at-point'. |   ;; Add `completion-at-point-functions', used by `completion-at-point'. | ||||||
|   ;; NOTE: The order matters! |   ;; NOTE: The order matters! | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-dabbrev) |   (add-to-list 'completion-at-point-functions #'cape-dabbrev) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-file) |   (add-to-list 'completion-at-point-functions #'cape-file) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-elisp-block) |   (add-to-list 'completion-at-point-functions #'cape-elisp-block) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-history) |   (add-to-list 'completion-at-point-functions #'cape-history) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-keyword) |   (add-to-list 'completion-at-point-functions #'cape-keyword) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-tex) |   (add-to-list 'completion-at-point-functions #'cape-tex) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-dict) |   (add-to-list 'completion-at-point-functions #'cape-dict) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-sgml) |   ;;(add-to-list 'completion-at-point-functions #'cape-sgml) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-rfc1345) |   ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-abbrev) |   ;;(add-to-list 'completion-at-point-functions #'cape-abbrev) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-symbol) |   ;;(add-to-list 'completion-at-point-functions #'cape-symbol) | ||||||
|   ;; (add-to-list 'completion-at-point-functions #'cape-line) |   ;;(add-to-list 'completion-at-point-functions #'cape-line) | ||||||
|   ) |   ) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| *** Embark |  | ||||||
| Use =embark= for in-mini-buffer actions: | Use =embark= for in-mini-buffer actions: | ||||||
| #+begin_src emacs-lisp :tangle no | #+begin_src emacs-lisp :tangle no | ||||||
| (use-package embark | (use-package embark | ||||||
|  | @ -1313,7 +1280,6 @@ Use =embark= for in-mini-buffer actions: | ||||||
|   :hook (embark-collect-mode . consult-preview-at-point-mode)) |   :hook (embark-collect-mode . consult-preview-at-point-mode)) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| *** COMMENT corfu + prescient |  | ||||||
| Use =corfu-prescient= to sort completion candidates: | Use =corfu-prescient= to sort completion candidates: | ||||||
| #+begin_src emacs-lisp  | #+begin_src emacs-lisp  | ||||||
| (use-package corfu-prescient | (use-package corfu-prescient | ||||||
|  | @ -1323,7 +1289,7 @@ Use =corfu-prescient= to sort completion candidates: | ||||||
|   ;; :hook (corfu-mode . corfu-prescient-mode) |   ;; :hook (corfu-mode . corfu-prescient-mode) | ||||||
|   ;; :hook (text-mode . corfu-prescient-mode) |   ;; :hook (text-mode . corfu-prescient-mode) | ||||||
|   :config |   :config | ||||||
|   (setq corfu-prescient-completion-styles '(orderless prescient basic partial-completion)) |   (setq corfu-prescient-completion-styles '(prescient orderless basic partial-completion)) | ||||||
|   (corfu-prescient-mode 1) |   (corfu-prescient-mode 1) | ||||||
|   ) |   ) | ||||||
| 
 | 
 | ||||||
|  | @ -1352,8 +1318,7 @@ Fuzzy and out-of-order completion matching using =orderless=: | ||||||
|   (add-to-list 'completion-styles 'orderless) |   (add-to-list 'completion-styles 'orderless) | ||||||
|   (setq orderless-matching-styles '(orderless-flex) |   (setq orderless-matching-styles '(orderless-flex) | ||||||
|         completion-category-overrides '((file (styles basic partial-completion))) |         completion-category-overrides '((file (styles basic partial-completion))) | ||||||
|         orderless-component-separator "[ |]") |         orderless-component-separator "[ |]")) | ||||||
|   ) |  | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| * Programming | * Programming | ||||||
|  | @ -1373,103 +1338,6 @@ Enable =hs-minor-mode= in =prog-mode= to allow for folding away comments and mod | ||||||
|   ) |   ) | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| ** Copilot 😭 |  | ||||||
| I feel so bad for this.. but its not awful.. |  | ||||||
| 
 |  | ||||||
| #+begin_src emacs-lisp |  | ||||||
| (use-package plz |  | ||||||
|   :straight t) |  | ||||||
| 
 |  | ||||||
| (require 'ollama-complete) |  | ||||||
| #+end_src |  | ||||||
| 
 |  | ||||||
| #+begin_src emacs-lisp :tangle "local-lisp/ollama-complete.el" |  | ||||||
| (defgroup ollama-complete nil "Ollama Code Completion." :group 'completion) |  | ||||||
| 
 |  | ||||||
| (require 'plz) |  | ||||||
| 
 |  | ||||||
| (defcustom ollama-complete-host "http://localhost:11434" |  | ||||||
|   "URL of local ollama service." |  | ||||||
|   :type 'url) |  | ||||||
| 
 |  | ||||||
| (defcustom ollama-complete-model "qwen2.5-coder:3b-instruct-q4_K_M" |  | ||||||
|   "Model to use for Fill-in-Middle completion.") |  | ||||||
| 
 |  | ||||||
| (defvar ollama-complete--options |  | ||||||
|   '(("temperature" . 0) ("top_p" . 0.5) ("num_predict" . 30))) |  | ||||||
| 
 |  | ||||||
| (defvar ollama-complete--overlay nil) |  | ||||||
| 
 |  | ||||||
| (defvar ollama-complete--overlay-buffer nil |  | ||||||
|     "Buffer in which the overlay is placed.") |  | ||||||
| 
 |  | ||||||
| (defun ollama-complete--fill-in-middle () |  | ||||||
|   "Ask ollama to generate response for fill-in-middle prompt." |  | ||||||
|   (interactive) |  | ||||||
|   (let ((prompt |  | ||||||
|          (concat |  | ||||||
|           "<|fim_prefix|>" |  | ||||||
|           (concat |  | ||||||
|            (buffer-substring-no-properties (point-min) (point)) |  | ||||||
|            (concat |  | ||||||
|             "<|fim_suffix|>" |  | ||||||
|             (concat |  | ||||||
|              (buffer-substring-no-properties (point) (point-max)) |  | ||||||
|              "<|fim_middle|>")))))) |  | ||||||
|     (setq ollama-complete--overlay-buffer (current-buffer)) |  | ||||||
|     (message "overlay-buffer: %s" ollama-complete--overlay-buffer) |  | ||||||
|     (plz 'post |  | ||||||
|       (concat ollama-complete-host "/api/generate") |  | ||||||
|       :body (json-encode `(("model" . "qwen2.5-coder:3b-instruct-q4_K_M") |  | ||||||
|                            ("raw" . t) |  | ||||||
|                            ("stream" . :json-false) |  | ||||||
|                            ("options" . ,ollama-complete--options) |  | ||||||
|                            ("prompt" . ,prompt) |  | ||||||
|                            )) |  | ||||||
|       :as #'json-read |  | ||||||
|       :then (lambda (alist) |  | ||||||
|               (message "Ollama: FIM Completion: %s" (alist-get 'response alist)) |  | ||||||
|               (ollama-complete--make-overlay (alist-get 'response alist)))) |  | ||||||
|     ) |  | ||||||
|   ) |  | ||||||
| 
 |  | ||||||
| (defun ollama-complete--make-overlay (string) |  | ||||||
|   "make overlay showign STRING at POS, or move existing overlay there." |  | ||||||
|   (interactive) |  | ||||||
|   (if ollama-complete--overlay-buffer |  | ||||||
|       (with-current-buffer ollama-complete--overlay-buffer |  | ||||||
|         (message "make-overlay %d \"%s\" %s" (point) string ollama-complete--overlay-buffer) |  | ||||||
|         (if ollama-complete--overlay |  | ||||||
|             (move-overlay ollama-complete--overlay (point) (point) ollama-complete--overlay-buffer) |  | ||||||
|           (setq ollama-complete--overlay (make-overlay (point) (point) ollama-complete--overlay-buffer)) |  | ||||||
|           (overlay-put ollama-complete--overlay 'window (selected-window)) |  | ||||||
|           (overlay-put ollama-complete--overlay |  | ||||||
|                        'after-string (propertize string 'face 'font-lock-comment-face)) |  | ||||||
|           (add-text-properties 0 1 '(cursor 1) string) |  | ||||||
|           ollama-complete--overlay))) |  | ||||||
|   ) |  | ||||||
| 
 |  | ||||||
| (defun ollama-complete--hide-overlay () |  | ||||||
|   "Hide temporary completion candidate overlay." |  | ||||||
|   (interactive) |  | ||||||
|   (when ollama-complete--overlay |  | ||||||
|     (delete-overlay ollama-complete--overlay) |  | ||||||
|     (setq ollama-complete--overlay nil) |  | ||||||
|     (setq ollama-complete--overlay-buffer nil)) |  | ||||||
|   ) |  | ||||||
| 
 |  | ||||||
| (defun ollama-complete--insert-completion () |  | ||||||
|   "Hide temporary completion candidate overlay." |  | ||||||
|   (interactive) |  | ||||||
|   (when ollama-complete--overlay |  | ||||||
|     (let ((completion (overlay-get ollama-complete--overlay 'after-string))) |  | ||||||
|       (set-text-properties 0 (length completion) nil completion) |  | ||||||
|         (goto-char (overlay-start ollama-complete--overlay)) |  | ||||||
|         (insert (substring-no-properties completion))) |  | ||||||
|     (ollama-complete--hide-overlay))) |  | ||||||
| 
 |  | ||||||
| (provide 'ollama-complete) |  | ||||||
| #+end_src |  | ||||||
| ** smart-parens | ** smart-parens | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
| (use-package smartparens | (use-package smartparens | ||||||
|  | @ -1571,21 +1439,6 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u | ||||||
|                                         ; lsp-ui-doc-use-webkit t |                                         ; lsp-ui-doc-use-webkit t | ||||||
|    ) |    ) | ||||||
|   :commands lsp-ui-mode) |   :commands lsp-ui-mode) | ||||||
| 
 |  | ||||||
| (defvar-local nemo/lsp-format-on-save t) |  | ||||||
| 
 |  | ||||||
| (define-minor-mode nemo/lsp-format-on-save-mode |  | ||||||
|   "Run lsp-format-buffer on save." |  | ||||||
|   :lighter " fmt" |  | ||||||
|   (if nemo/lsp-format-on-save-mode |  | ||||||
|       (add-hook 'before-save-hook #'lsp-format-buffer nil t) |  | ||||||
|       (remove-hook 'before-save-hook #'lsp-format-buffer nil t) |  | ||||||
|     )) |  | ||||||
| 
 |  | ||||||
| (defun nemo/do-lsp-format-on-save () |  | ||||||
|   "Format on save using LSP server." |  | ||||||
|   (if nemo/lsp-format-on-save |  | ||||||
|       (lsp-format-buffer))) |  | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| ** Graphics | ** Graphics | ||||||
|  | @ -1608,254 +1461,6 @@ hlsl-mode: | ||||||
|   (add-to-list 'auto-mode-alist '("\\.frag\\'" . hlsl-mode)) |   (add-to-list 'auto-mode-alist '("\\.frag\\'" . hlsl-mode)) | ||||||
|   ) |   ) | ||||||
| #+end_src | #+end_src | ||||||
| 
 |  | ||||||
| #+begin_src emacs-lisp |  | ||||||
| (require 'treesit) |  | ||||||
| 
 |  | ||||||
| (add-to-list |  | ||||||
|  'treesit-language-source-alist |  | ||||||
|  '(slang "https://github.com/tree-sitter-grammars/tree-sitter-slang")) |  | ||||||
| 
 |  | ||||||
| (with-eval-after-load 'lsp-mode |  | ||||||
|   (progn |  | ||||||
|     ;; tree-sitter |  | ||||||
| 
 |  | ||||||
|     ;; LSP |  | ||||||
|     (add-to-list 'lsp-language-id-configuration '(".*\\.slang$" . "slang")) |  | ||||||
|     (lsp-register-client (make-lsp-client |  | ||||||
|                           :new-connection (lsp-stdio-connection "/opt/shader-slang-bin/bin/slangd") |  | ||||||
|                           :activation-fn (lsp-activate-on "slang") |  | ||||||
|                           :server-id 'slang)) |  | ||||||
|     )) |  | ||||||
| 
 |  | ||||||
| (require 'c-ts-common) |  | ||||||
| (require 'c-ts-mode) |  | ||||||
| 
 |  | ||||||
| (defgroup slang nil "Khronos Slang Major Mode." |  | ||||||
|   :group 'languages) |  | ||||||
| 
 |  | ||||||
| (defcustom slang-ts-mode-indent-offset 4 |  | ||||||
|   "Number of spaces for each indentation step in `slang-ts-mode'." |  | ||||||
|   :version "29.1" |  | ||||||
|   :type 'integer |  | ||||||
|   :safe 'integerp |  | ||||||
|   :group 'slang) |  | ||||||
| 
 |  | ||||||
| (declare-function treesit-parser-create "treesit.c") |  | ||||||
| (declare-function treesit-node-parent "treesit.c") |  | ||||||
| (declare-function treesit-node-start "treesit.c") |  | ||||||
| (declare-function treesit-node-end "treesit.c") |  | ||||||
| (declare-function treesit-node-child "treesit.c") |  | ||||||
| (declare-function treesit-node-child-by-field-name "treesit.c") |  | ||||||
| (declare-function treesit-node-type "treesit.c") |  | ||||||
| (declare-function treesit-node-prev-sibling "treesit.c") |  | ||||||
| (declare-function treesit-node-first-child-for-pos "treesit.c") |  | ||||||
| (declare-function treesit-node-next-sibling "treesit.c") |  | ||||||
| (declare-function treesit-parser-set-included-ranges "treesit.c") |  | ||||||
| (declare-function treesit-query-compile "treesit.c") |  | ||||||
| 
 |  | ||||||
| ;; taken from rust-ts-mode |  | ||||||
| (defvar slang-ts-mode--syntax-table |  | ||||||
|   (let ((table (make-syntax-table))) |  | ||||||
|     (modify-syntax-entry ?+   "."      table) |  | ||||||
|     (modify-syntax-entry ?-   "."      table) |  | ||||||
|     (modify-syntax-entry ?=   "."      table) |  | ||||||
|     (modify-syntax-entry ?%   "."      table) |  | ||||||
|     (modify-syntax-entry ?&   "."      table) |  | ||||||
|     (modify-syntax-entry ?|   "."      table) |  | ||||||
|     (modify-syntax-entry ?^   "."      table) |  | ||||||
|     (modify-syntax-entry ?!   "."      table) |  | ||||||
|     (modify-syntax-entry ?@   "."      table) |  | ||||||
|     (modify-syntax-entry ?~   "."      table) |  | ||||||
|     (modify-syntax-entry ?<   "."      table) |  | ||||||
|     (modify-syntax-entry ?>   "."      table) |  | ||||||
|     (modify-syntax-entry ?/   ". 124b" table) |  | ||||||
|     (modify-syntax-entry ?*   ". 23"   table) |  | ||||||
|     (modify-syntax-entry ?\n  "> b"    table) |  | ||||||
|     (modify-syntax-entry ?\^m "> b"    table) |  | ||||||
|     table) |  | ||||||
|   "Syntax table for `slang-ts-mode'.") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--indent-rules |  | ||||||
|   `((slang |  | ||||||
|      ((parent-is "translation_unit") column-0 0) |  | ||||||
|      ((node-is ")") parent-bol 0) |  | ||||||
|      ((node-is "]") parent-bol 0) |  | ||||||
|      ((node-is "}") (and parent parent-bol) 0) |  | ||||||
|      ((and (parent-is "comment") c-ts-common-looking-at-star) |  | ||||||
|       c-ts-common-comment-start-after-first-star -1) |  | ||||||
|      ((parent-is "comment") prev-adaptive-prefix 0) |  | ||||||
|      ((parent-is "parameter_list") parent-bol slang-ts-mode-indent-offset) |  | ||||||
|      ((parent-is "binary_expression") parent-bol slang-ts-mode-indent-offset) |  | ||||||
|      ((parent-is "compount_statement") parent-bol slang-ts-mode-indent-offset) |  | ||||||
|      ((parent-is "field_declaration_list") parent-bol slang-ts-mode-indent-offset) |  | ||||||
|      )) |  | ||||||
|   "Tree-sitter indent rules for `slang-ts-mode'.") |  | ||||||
| 
 |  | ||||||
| ;; taken from rust-ts-mode |  | ||||||
| (defun slang-ts-mode--syntax-propertize (beg end) |  | ||||||
|   "Apply syntax properties to special characters between BEG and END. |  | ||||||
| 
 |  | ||||||
| Apply syntax properties to various special characters with |  | ||||||
| contextual meaning between BEG and END. |  | ||||||
| 
 |  | ||||||
| The apostrophe \\=' should be treated as string when used for char literals. |  | ||||||
| 
 |  | ||||||
| < and > are usually punctuation, e.g., as greater/less-than.  But |  | ||||||
| when used for types, they should be considered pairs. |  | ||||||
| 
 |  | ||||||
| This function checks for < and > in the changed RANGES and apply |  | ||||||
| appropriate text property to alter the syntax of template |  | ||||||
| delimiters < and >'s." |  | ||||||
|   (goto-char beg) |  | ||||||
|   (while (search-forward "'" end t) |  | ||||||
|     (when (string-equal "char_literal" |  | ||||||
|                         (treesit-node-type |  | ||||||
|                          (treesit-node-at (match-beginning 0)))) |  | ||||||
|       (put-text-property (match-beginning 0) (match-end 0) |  | ||||||
|                          'syntax-table (string-to-syntax "\"")))) |  | ||||||
|   (goto-char beg) |  | ||||||
|   (while (re-search-forward (rx (or "<" ">")) end t) |  | ||||||
|     (pcase (treesit-node-type |  | ||||||
|             (treesit-node-parent |  | ||||||
|              (treesit-node-at (match-beginning 0)))) |  | ||||||
|       ("template_argument_list" |  | ||||||
|        (put-text-property (match-beginning 0) |  | ||||||
|                           (match-end 0) |  | ||||||
|                           'syntax-table |  | ||||||
|                           (pcase (char-before) |  | ||||||
|                             (?< '(4 . ?>)) |  | ||||||
|                             (?> '(5 . ?<)))))))) |  | ||||||
| 
 |  | ||||||
| ;; (treesit-query-validate 'slang "(bitfield_clause (identifier) @font-lock-builtin-face) (:match ,(rx bos (or ,@slang-ts-mode--locations) eos))") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--locations |  | ||||||
|   '("SV_Position" "COLOR" "POSITION" "SV_Target") |  | ||||||
|   "Slang built-in location hints for font-locking.") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--keywords |  | ||||||
|   '("struct" "interface" "where" "return") |  | ||||||
|   "Slang built-in location hints for font-locking.") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--types |  | ||||||
|   `(,@(mapcar (lambda (type) |  | ||||||
|                   (concat type "\\([1234]?\\|\\([1234]x[1234]\\)?\\)")) |  | ||||||
|                 '("bool" "int" "uint" "float" |  | ||||||
|                   "min16float" "min10float" "min16int" "min12int" "min16uint"))) |  | ||||||
|   "Slang types for font-locking.") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--operators |  | ||||||
|   '("!"  "!=" "%" "%=" "&" "&=" "&&" "*" "*=" "+" "+=" "," "-" "-=" |  | ||||||
|     "->" "." "/" "/=" ":" ";" "<<" "<<=" "<" "<=" |  | ||||||
|     "=" "==" "=>" ">" ">=" ">>" ">>=" "^" "^=" "|" "|=" "||") |  | ||||||
|   "Slang operators for tree-sitter font-locking.") |  | ||||||
| 
 |  | ||||||
| (defvar slang-ts-mode--font-lock-settings |  | ||||||
|   (treesit-font-lock-rules |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'bracket |  | ||||||
|    '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'comment |  | ||||||
|    '(((comment) @font-lock-comment-face)) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'builtin |  | ||||||
|    '((bitfield_clause (identifier) @font-lock-builtin-face) |  | ||||||
|      (semantics (identifier) @font-lock-builtin-face)) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'keyword |  | ||||||
|    `([,@slang-ts-mode--keywords] @font-lock-keyword-face) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'type |  | ||||||
|    `( |  | ||||||
|      ((call_expression function: (identifier) @font-lock-type-face) |  | ||||||
|      (:match ,(rx bos |  | ||||||
|                   (and (or "bool" "int" "uint" "float") |  | ||||||
|                        (or |  | ||||||
|                         (? (any "1" "2" "3" "4")) |  | ||||||
|                         (? (and (any "1" "2" "3" "4") "x" (any "1" "2" "3" "4"))))) |  | ||||||
|                   eos) @font-lock-type-face)) |  | ||||||
|      ((call_expression function: (identifier) @font-lock-function-call-face)) |  | ||||||
|      (type_identifier) @font-lock-type-face) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'definition |  | ||||||
|    '( |  | ||||||
|      (declaration declarator: (identifier) @font-lock-property-name-face) |  | ||||||
|      (field_declaration declarator: (field_identifier) @font-lock-property-name-face) |  | ||||||
|      (parameter_declaration declarator: (identifier) @font-lock-property-name-face) |  | ||||||
|      (function_declarator declarator: (identifier) @font-lock-function-name-face) |  | ||||||
|      (function_declarator declarator: (template_function name: (identifier) @font-lock-type-face)) |  | ||||||
|      (hlsl_attribute (call_expression function: (identifier) @font-lock-builtin-face)) |  | ||||||
|      ) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'function |  | ||||||
|    '((call_expression function: (identifier) @font-lock-function-call-face) |  | ||||||
|      (call_expression function: (_ field: (field_identifier) @font-lock-function-call-face)) |  | ||||||
|      ) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'string |  | ||||||
|    '(((string_content) @font-lock-string-face)) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'type |  | ||||||
|    '(((type_identifier) @font-lock-type-face) |  | ||||||
|      (function_definition type: (type_identifier) @font-lock-type-face) |  | ||||||
|      (declaration type: (type_identifier) @font-lock-type-face) |  | ||||||
|      (field_declaration type: (type_identifier) @font-lock-type-face) |  | ||||||
|      (parameter_declaration type: (type_identifier) @font-lock-type-face) |  | ||||||
|      (template_argument_list (type_descriptor type: (type_identifier) @font-lock-type-face)) |  | ||||||
|      ) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'operator |  | ||||||
|    `([,@slang-ts-mode--operators] @font-lock-operator-face) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'variable |  | ||||||
|    '(((identifier) @font-lock-property-use-face)) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'number |  | ||||||
|    '(((number_literal) @font-lock-number-face)) |  | ||||||
| 
 |  | ||||||
|    :language 'slang |  | ||||||
|    :feature 'property |  | ||||||
|    '(((field_identifier) @font-lock-property-use-face)) |  | ||||||
|    )) |  | ||||||
| 
 |  | ||||||
| (define-derived-mode slang-ts-mode prog-mode "Slang" |  | ||||||
|   "Major mode for editing Slang, powered by tree-sitter." |  | ||||||
|   :group 'slang |  | ||||||
|   :syntax-table slang-ts-mode--syntax-table |  | ||||||
| 
 |  | ||||||
|   (when (treesit-ready-p 'slang) |  | ||||||
|     (treesit-parser-create 'slang) |  | ||||||
|     (setq-local treesit-font-lock-feature-list |  | ||||||
|                 '((comment definition) |  | ||||||
|                   (keyword string) |  | ||||||
|                   (assignment attribute builtin variable constant escape-sequence number definition property type) |  | ||||||
|                   (bracket delimiter error function operator property variable) |  | ||||||
|                   )) |  | ||||||
|     (setq-local syntax-propertize-function #'slang-ts-mode--syntax-propertize |  | ||||||
|                 indent-tabs-mode nil |  | ||||||
|                 treesit-font-lock-settings slang-ts-mode--font-lock-settings |  | ||||||
|                 treesit-simple-indent-rules slang-ts-mode--indent-rules) |  | ||||||
|     (treesit-major-mode-setup)) |  | ||||||
|   ) |  | ||||||
| 
 |  | ||||||
| (if (treesit-ready-p 'slang) |  | ||||||
|     (add-to-list 'auto-mode-alist '("\\.slang\\'" . slang-ts-mode))) |  | ||||||
| 
 |  | ||||||
| (provide 'slang-ts-mode) |  | ||||||
| #+end_src |  | ||||||
| 
 |  | ||||||
| ** Rust | ** Rust | ||||||
| [[https://github.com/rust-lang/rust-mode][=rust-mode=]] | [[https://github.com/rust-lang/rust-mode][=rust-mode=]] | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
|  | @ -1872,8 +1477,7 @@ delimiters < and >'s." | ||||||
| (use-package rustic | (use-package rustic | ||||||
|   :straight t |   :straight t | ||||||
|   :defer t |   :defer t | ||||||
|   ;; :after (rust-mode) |   :after (rust-mode) | ||||||
|   :hook(rustic-mode . nemo/lsp-format-on-save-mode) |  | ||||||
|   :general-config |   :general-config | ||||||
|   (general-define-key |   (general-define-key | ||||||
|    :prefix-map 'nemo/rust-map |    :prefix-map 'nemo/rust-map | ||||||
|  | @ -1899,15 +1503,14 @@ delimiters < and >'s." | ||||||
|     "m" '(:keymap nemo/rust-map :wk "Cargo") |     "m" '(:keymap nemo/rust-map :wk "Cargo") | ||||||
|     ) |     ) | ||||||
|   :config |   :config | ||||||
|   (setq rust-mode-treesitter-derive t |   (setq rustic-format-on-save t | ||||||
|         rustic-format-on-save nil |         rust-format-on-save t | ||||||
|         ;; rustic-format-trigger 'on-save |         rust-mode-treesitter-derive t | ||||||
|  |         rustic-format-trigger 'on-save | ||||||
|         ;; rustic-format-on-save-method #'rustic-format-buffer |         ;; rustic-format-on-save-method #'rustic-format-buffer | ||||||
|         rustic-analyzer-command '("/usr/bin/rust-analyzer") |         rustic-analyzer-command '("/usr/bin/rust-analyzer") | ||||||
|         ) |         ) | ||||||
|   ;; (setq nemo/lsp-format-on-save t) |  | ||||||
|   ) |   ) | ||||||
| 
 |  | ||||||
| #+end_src | #+end_src | ||||||
| 
 | 
 | ||||||
| #+begin_src emacs-lisp | #+begin_src emacs-lisp | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue