new and impruved

This commit is contained in:
zastian@mrthoddata.com
2025-05-07 15:45:08 +01:00
commit bdf553079b
197 changed files with 5824 additions and 0 deletions

112
dots/doom/lisp/ollama.el Executable file
View File

@@ -0,0 +1,112 @@
;;; ollama.el --- ollama client for Emacs
;; Copyright (C) 2023 ZHOU Feng
;; Author: ZHOU Feng <zf.pascal@gmail.com>
;; URL: http://github.com/zweifisch/ollama
;; Keywords: ollama llama2
;; Version: 0.0.1
;; Created: 6th Aug 2023
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; ollama client for Emacs
;;
;;; Code:
(require 'json)
(require 'cl-lib)
(require 'url)
(defgroup ollama nil
"Ollama client for Emacs."
:group 'ollama)
(defcustom ollama:endpoint "http://localhost:11434/api/generate"
"Ollama http service endpoint."
:group 'ollama
:type 'string)
(defcustom ollama:model "codellama:13b"
"Ollama model."
:group 'ollama
:type 'string)
(defcustom ollama:language "English"
"Language to translate to."
:group 'ollama
:type 'string)
(defun ollama-fetch (url prompt model)
(let* ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/json")))
(url-request-data
(encode-coding-string
(json-encode `((model . ,model) (prompt . ,prompt)))
'utf-8)))
(with-current-buffer (url-retrieve-synchronously url)
(goto-char url-http-end-of-headers)
(decode-coding-string
(buffer-substring-no-properties
(point)
(point-max))
'utf-8))))
(defun ollama-get-response-from-line (line)
(cdr
(assoc 'response
(json-read-from-string line))))
(defun ollama-prompt (url prompt model)
(mapconcat 'ollama-get-response-from-line
(cl-remove-if #'(lambda (str) (string= str ""))
(split-string (ollama-fetch url prompt model) "\n")) ""))
;;;###autoload
(defun ollama-prompt-line ()
"Prompt with current word."
(interactive)
(with-output-to-temp-buffer "*ollama*"
(princ
(ollama-prompt ollama:endpoint (thing-at-point 'line) ollama:model))))
;;;###autoload
(defun ollama-define-word ()
"Find definition of current word."
(interactive)
(with-output-to-temp-buffer "*ollama*"
(princ
(ollama-prompt ollama:endpoint (format "define %s" (thing-at-point 'word)) ollama:model))))
;;;###autoload
(defun ollama-translate-word ()
"Translate current word."
(interactive)
(with-output-to-temp-buffer "*ollama*"
(princ
(ollama-prompt ollama:endpoint (format "translate \"%s\" to %s" (thing-at-point 'word) ollama:language) ollama:model))))
;;;###autoload
(defun ollama-summarize-region ()
"Summarize marked text."
(interactive)
(with-output-to-temp-buffer "*ollama*"
(princ
(ollama-prompt ollama:endpoint (format "summarize \"\"\"%s\"\"\"" (buffer-substring (region-beginning) (region-end))) ollama:model))))
(provide 'ollama)
;;; ollama.el ends here

111
dots/doom/lisp/oxycarbon.el Executable file
View File

@@ -0,0 +1,111 @@
(autothemer-deftheme oxocarbon "A port of oxocarbon"
;; Specify the color classes used by the theme
((((class color) (min-colors #xFFFFFF))
((class color) (min-colors #xFF)))
;; Specify the color palette, color columns correspond to each of the classes above.
(oxocarbon-bg "#161616")
(oxocarbon-fg "#f2f4f8")
(oxocarbon-base00 "#161616")
(oxocarbon-base01 "#262626")
(oxocarbon-base02 "#393939")
(oxocarbon-base03 "#525252")
(oxocarbon-base04 "#dde1e6")
(oxocarbon-base05 "#f2f4f8")
(oxocarbon-base06 "#ffffff")
(oxocarbon-base07 "#08bdba")
(oxocarbon-base08 "#3ddbd9")
(oxocarbon-base09 "#78a9ff")
(oxocarbon-base10 "#ee5396")
(oxocarbon-base11 "#33b1ff")
(oxocarbon-base12 "#ff7eb6")
(oxocarbon-base13 "#42be65")
(oxocarbon-base14 "#be95ff")
(oxocarbon-base15 "#82cfff"))
;; Specifications for Emacs faces.
;; Simpler than deftheme, just specify a face name and
;; a plist of face definitions (nested for :underline, :box etc.)
(
(default (:foreground oxocarbon-fg :background oxocarbon-bg)) ;; background and foreground
(button (:foreground oxocarbon-fg :background oxocarbon-base01))
;; (counsel--mark-ring-highlight)
;; Programming ;;
(font-lock-string-face (:foreground oxocarbon-base14)) ;; strings
(font-lock-keyword-face (:foreground oxocarbon-base09)) ;; keywords
(font-lock-type-face (:foreground oxocarbon-base09)) ;; variable types
(font-lock-variable-name-face (:foreground oxocarbon-base04)) ;; variable names
(font-lock-comment-face (:foreground oxocarbon-base03)) ;; comments
(font-lock-builtin-face (:foreground oxocarbon-base12)) ;; builtin functions
(font-lock-constant-face (:foreground oxocarbon-base14)) ;; constants
(font-lock-function-name-face (:foreground oxocarbon-base08)) ;; function names
(font-lock-preprocessor-face (:foreground oxocarbon-base09))
(font-lock-doc-face (:foreground oxocarbon-base14))
(corfu-current (:background oxocarbon-base02 :foreground oxocarbon-base08))
;; END ;;
;; General ;;
(error (:foreground oxocarbon-base10))
(warning (:foreground oxocarbon-base13))
;; END ;;
;; UI ;;
(region (:background oxocarbon-base02)) ;; selction background
(highlight (:background oxocarbon-base02)) ;; highlight when hovering over a link etc.
(mode-line (:foreground oxocarbon-fg :background oxocarbon-bg)) ;; modeline
(mode-line-inactive (:foreground oxocarbon-fg :background oxocarbon-bg))
(line-number-current-line (:foreground oxocarbon-base04 :background oxocarbon-base00)) ;; the current line num
(line-number (:foreground oxocarbon-base02)) ;; line numbers
;; parens
(show-paren-match (:background oxocarbon-base02)) ;; matching parens
(show-paren-mismatch (:background oxocarbon-base11)) ;; mismatching parens
;; isearch
(isearch-fail (:background oxocarbon-base10))
;; ivy
(ivy-current-match (:background oxocarbon-base02 :foreground oxocarbon-base08))
(ivy-minibuffer-match-face-1 (:foreground oxocarbon-base08))
(ivy-minibuffer-match-face-2 (:foreground oxocarbon-base08))
(ivy-minibuffer-match-face-3 (:foreground oxocarbon-base08))
(ivy-minibuffer-match-face-4 (:foreground oxocarbon-base08))
;; END ;;
)
;; (custom-theme-set-variables 'oxocarbon
;; `(ansi-color-names-vector [
;; ,oxocarbon-base00
;; ,oxocarbon-base01
;; ,oxocarbon-base02
;; ,oxocarbon-base03
;; ,oxocarbon-base04
;; ,oxocarbon-base05
;; ,oxocarbon-base06
;; ,oxocarbon-base07
;; ,oxocarbon-base08
;; ,oxocarbon-base09
;; ,oxocarbon-base10
;; ,oxocarbon-base11
;; ,oxocarbon-base12
;; ,oxocarbon-base13
;; ,oxocarbon-base14
;; ,oxocarbon-base15
;; ]))
)
(provide-theme 'oxocarbon) ;; theme ends here

9
dots/doom/lisp/programs.el Executable file
View File

@@ -0,0 +1,9 @@
;;; ../../dotfiles/doom/.config/doom/lisp/programs.el -*- lexical-binding: t; -*-
;; make a function to run a program with a given name and arguments
(defun run-program (name &rest args)
(interactive)
(let ((program (executable-find name)))
(if program
(apply #'start-process name nil program args)
(error "Could not find program %s" name))))

0
dots/doom/lisp/test.el Executable file
View File