mirror of
https://github.com/mrfluffy-dev/dotfiles.git
synced 2026-01-16 21:30:33 +00:00
Some doom changes
This commit is contained in:
@@ -63,12 +63,12 @@
|
|||||||
(add-hook 'prog-mode-hook 'fci-mode)
|
(add-hook 'prog-mode-hook 'fci-mode)
|
||||||
|
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
'(org-level-1 ((t (:inherit outline-1 :height 1.4))))
|
'(org-level-1 ((t (:inherit outline-1 :height 1.4))))
|
||||||
'(org-level-2 ((t (:inherit outline-2 :height 1.3))))
|
'(org-level-2 ((t (:inherit outline-2 :height 1.3))))
|
||||||
'(org-level-3 ((t (:inherit outline-3 :height 1.2))))
|
'(org-level-3 ((t (:inherit outline-3 :height 1.2))))
|
||||||
'(org-level-4 ((t (:inherit outline-4 :height 1.1))))
|
'(org-level-4 ((t (:inherit outline-4 :height 1.1))))
|
||||||
'(org-level-5 ((t (:inherit outline-5 :height 1.0))))
|
'(org-level-5 ((t (:inherit outline-5 :height 1.0)))))
|
||||||
)
|
|
||||||
|
|
||||||
;; company mode delay 0
|
;; company mode delay 0
|
||||||
(setq company-idle-delay 0)
|
(setq company-idle-delay 0)
|
||||||
@@ -88,6 +88,9 @@
|
|||||||
|
|
||||||
;;
|
;;
|
||||||
;;
|
;;
|
||||||
|
;;
|
||||||
|
(setq org-image-actual-width 300)
|
||||||
|
|
||||||
(setq fancy-splash-image (concat doom-user-dir "xenia.png"))
|
(setq fancy-splash-image (concat doom-user-dir "xenia.png"))
|
||||||
|
|
||||||
(setq ess-r--no-company-meta t)
|
(setq ess-r--no-company-meta t)
|
||||||
@@ -96,7 +99,7 @@
|
|||||||
(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames henceforth
|
(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames henceforth
|
||||||
|
|
||||||
|
|
||||||
;undo fix
|
;undo fix
|
||||||
(setq undo-tree-enable-undo-in-region nil)
|
(setq undo-tree-enable-undo-in-region nil)
|
||||||
(setq undo-limit 8000000000)
|
(setq undo-limit 8000000000)
|
||||||
|
|
||||||
@@ -146,17 +149,10 @@
|
|||||||
:config
|
:config
|
||||||
(setq x86-lookup-pdf "~/.config/doom/asm-ref.pdf"))
|
(setq x86-lookup-pdf "~/.config/doom/asm-ref.pdf"))
|
||||||
|
|
||||||
|
(setq openai-key (getenv "OPENAIKEY"))
|
||||||
|
(setq chatgpt-input-method 'minibuffer)
|
||||||
|
|
||||||
|
|
||||||
;; chatgpt stuff
|
|
||||||
(use-package! chatgpt
|
|
||||||
:defer t
|
|
||||||
:config
|
|
||||||
(unless (boundp 'python-interpreter)
|
|
||||||
(defvaralias 'python-interpreter 'python-shell-interpreter))
|
|
||||||
(setq chatgpt-repo-path (expand-file-name "straight/repos/ChatGPT.el/" doom-local-dir))
|
|
||||||
(set-popup-rule! (regexp-quote "*ChatGPT*")
|
|
||||||
:side 'bottom :size .5 :ttl nil :quit t :modeline nil)
|
|
||||||
:bind ("C-c q" . chatgpt-query))
|
|
||||||
|
|
||||||
;;discord rich presence
|
;;discord rich presence
|
||||||
(require 'elcord)
|
(require 'elcord)
|
||||||
@@ -167,24 +163,24 @@
|
|||||||
(elcord-mode 1))))
|
(elcord-mode 1))))
|
||||||
|
|
||||||
(defun elcord--disable-elcord-if-no-frames (f)
|
(defun elcord--disable-elcord-if-no-frames (f)
|
||||||
(declare (ignore f))
|
(declare (ignore f))
|
||||||
(when (let ((frames (delete f (visible-frame-list))))
|
(when (let ((frames (delete f (visible-frame-list))))
|
||||||
(or (null frames)
|
(or (null frames)
|
||||||
(and (null (cdr frames))
|
(and (null (cdr frames))
|
||||||
(eq (car frames) terminal-frame))))
|
(eq (car frames) terminal-frame))))
|
||||||
(elcord-mode -1)
|
(elcord-mode -1)
|
||||||
(add-hook 'after-make-frame-functions 'elcord--enable-on-frame-created)))
|
(add-hook 'after-make-frame-functions 'elcord--enable-on-frame-created)))
|
||||||
|
|
||||||
(defun elcord--enable-on-frame-created (f)
|
(defun elcord--enable-on-frame-created (f)
|
||||||
(declare (ignore f))
|
(declare (ignore f))
|
||||||
(elcord-mode +1))
|
(elcord-mode +1))
|
||||||
|
|
||||||
(defun my/elcord-mode-hook ()
|
(defun my/elcord-mode-hook ()
|
||||||
(if elcord-mode
|
(if elcord-mode
|
||||||
(add-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames)
|
(add-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames)
|
||||||
(remove-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames)))
|
(remove-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames)))
|
||||||
|
|
||||||
(add-hook 'elcord-mode-hook 'my/elcord-mode-hook)
|
(add-hook 'elcord-mode-hook 'my/elcord-mode-hook)
|
||||||
|
|
||||||
(setq elcord-idle-message "Out doing your mom")
|
(setq elcord-idle-message "Out doing your mom")
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
'(elfeed-feeds
|
'(elfeed-feeds '("https://www.reddit.com/r/pcmasterrace/rss"))
|
||||||
'("https://www.reddit.com/r/hentai.rss" "https://www.reddit.com/r/AnimeFeets.rss" "https://www.reddit.com/r/thighdeology.rss" "https://www.reddit.com/r/UndressingHentai.rss" "https://www.reddit.com/r/hentaibondage.rss" "https://www.reddit.com/r/ElegantR34.rss" "https://www.reddit.com/r/AnimeGirlsAndThongs.rss" "https://www.reddit.com/r/AnimeGirls.rss"))
|
|
||||||
'(warning-suppress-log-types '((initialization)))
|
'(warning-suppress-log-types '((initialization)))
|
||||||
'(warning-suppress-types '((initialization) (initialization))))
|
'(warning-suppress-types '((initialization) (initialization))))
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
|
|||||||
@@ -134,7 +134,7 @@
|
|||||||
;;fsharp ; ML stands for Microsoft's Language
|
;;fsharp ; ML stands for Microsoft's Language
|
||||||
;;fstar ; (dependent) types and (monadic) effects and Z3
|
;;fstar ; (dependent) types and (monadic) effects and Z3
|
||||||
;;gdscript ; the language you waited for
|
;;gdscript ; the language you waited for
|
||||||
;;(go +lsp) ; the hipster dialect
|
(go +lsp) ; the hipster dialect
|
||||||
(haskell +lsp) ; a language that's lazier than I am
|
(haskell +lsp) ; a language that's lazier than I am
|
||||||
;;hy ; readability of scheme w/ speed of python
|
;;hy ; readability of scheme w/ speed of python
|
||||||
;;idris ; a language you can depend on
|
;;idris ; a language you can depend on
|
||||||
|
|||||||
@@ -1,220 +0,0 @@
|
|||||||
;;; chatgpt.el --- Simple ChatGPT frontend for Emacs -*- lexical-binding: t -*-
|
|
||||||
|
|
||||||
;; Copyright (C) Gavin Jaeger-Freeborn
|
|
||||||
|
|
||||||
;; This package 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 package 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
;; Author: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
|
|
||||||
;; Maintainer: Gavin Jaeger-Freeborn <gavinfreeborn@gmail.com>
|
|
||||||
;; Created: 2022
|
|
||||||
;; Version: 0.34
|
|
||||||
;; Package-Requires: ((emacs "28.1"))
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; Basic commands to use the OpenAI API and use some of the power
|
|
||||||
;; ChatGPT provides within Emacs.
|
|
||||||
|
|
||||||
;; Features include code explanation, attempted code completion,
|
|
||||||
;; replacing inline queries with the results and more.
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
|
|
||||||
(require 'seq)
|
|
||||||
(eval-when-compile
|
|
||||||
(require 'cl-lib)
|
|
||||||
(require 'subr-x)
|
|
||||||
(require 'env)
|
|
||||||
(require 'json))
|
|
||||||
|
|
||||||
(defgroup chatgpt nil
|
|
||||||
"ChatGPT frontend."
|
|
||||||
:group 'convenience
|
|
||||||
:prefix "chatgpt-")
|
|
||||||
|
|
||||||
(defcustom chatgpt-max-tokens 300
|
|
||||||
"Upper limit on the number of tokens the API will return."
|
|
||||||
:type 'integer)
|
|
||||||
|
|
||||||
(defvar chatgpt-buffer "*ChatGPT*"
|
|
||||||
"Title of the buffer used to store the results of an OpenAI API query.")
|
|
||||||
|
|
||||||
(define-error 'chatgpt-error "An error related to the ChatGPT emacs package")
|
|
||||||
|
|
||||||
(define-error 'chatgpt-parsing-error
|
|
||||||
"An error caused by a failure to parse an OpenAI API Response")
|
|
||||||
|
|
||||||
(defmacro chatgpt-show-results-buffer-if-active ()
|
|
||||||
"Show the results in other window if necessary."
|
|
||||||
`(if (and (not ;; visible
|
|
||||||
(get-buffer-window chatgpt-buffer))
|
|
||||||
(called-interactively-p 'interactive))
|
|
||||||
(lambda (&optional buf) (ignore buf)
|
|
||||||
(with-current-buffer buf
|
|
||||||
(view-mode t))
|
|
||||||
(switch-to-buffer-other-window chatgpt-buffer))
|
|
||||||
#'identity))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-prompt (prompt callback)
|
|
||||||
"Query OpenAI with PROMPT calling the CALLBACK function on the resulting buffer.
|
|
||||||
Returns buffer containing the text from this query"
|
|
||||||
(interactive (list (read-string "Prompt ChatGPT with: ")
|
|
||||||
(lambda (buf) (with-current-buffer buf
|
|
||||||
(view-mode t))
|
|
||||||
(switch-to-buffer-other-window chatgpt-buffer))))
|
|
||||||
(chatgpt--query-open-api prompt
|
|
||||||
(lambda (results)
|
|
||||||
(with-current-buffer (get-buffer-create chatgpt-buffer)
|
|
||||||
;; Erase contents of buffer after receiving response
|
|
||||||
(read-only-mode -1)
|
|
||||||
(erase-buffer)
|
|
||||||
(insert results)
|
|
||||||
;; Return the chatgpt output buffer for non interactive usage
|
|
||||||
(funcall callback (current-buffer))))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-fix-region (BEG END)
|
|
||||||
"Takes a region BEG to END asks ChatGPT to explain whats wrong with it.
|
|
||||||
It then displays the answer in the `chatgpt-buffer'."
|
|
||||||
(interactive "r")
|
|
||||||
(let ((current-code (buffer-substring BEG END)))
|
|
||||||
(chatgpt-prompt (chatgpt--append-to-prompt
|
|
||||||
current-code
|
|
||||||
"Why doesn't this code work?")
|
|
||||||
(chatgpt-show-results-buffer-if-active))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-explain-region (BEG END)
|
|
||||||
"Takes a region BEG to END asks ChatGPT what it does.
|
|
||||||
The answer in the displays in `chatgpt-buffer'."
|
|
||||||
(interactive "r")
|
|
||||||
(let ((current-code (buffer-substring BEG END)))
|
|
||||||
(chatgpt-prompt (chatgpt--append-to-prompt
|
|
||||||
current-code
|
|
||||||
"What does this code do?")
|
|
||||||
(chatgpt-show-results-buffer-if-active))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-gen-tests-for-region (BEG END)
|
|
||||||
"Takes a region BEG to END asks ChatGPT to write a test for it.
|
|
||||||
It then displays the answer in the `chatgpt-buffer'."
|
|
||||||
(interactive "r")
|
|
||||||
(let ((current-code (buffer-substring BEG END)))
|
|
||||||
(chatgpt-prompt (chatgpt--append-to-prompt
|
|
||||||
current-code
|
|
||||||
"Write me a tests for this code")
|
|
||||||
(chatgpt-show-results-buffer-if-active))))
|
|
||||||
|
|
||||||
;; TODO currently just says what changed but doesn't wanna show the code it's self
|
|
||||||
;; (defun chatgpt-optimize-region (BEG END)
|
|
||||||
;; "Takes a region BEG to END asks ChatGPT to optimize it for speed.
|
|
||||||
;; It then displays the answer in the `chatgpt-buffer'."
|
|
||||||
;; (interactive "r")
|
|
||||||
;; (let ((current-code (buffer-substring BEG END)))
|
|
||||||
;; (chatgpt-prompt (chatgpt--append-to-prompt
|
|
||||||
;; current-code
|
|
||||||
;; "Refactor this code for speed and tell me what you changed and why it's faster")
|
|
||||||
;; (chatgpt-show-results-buffer-if-active))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-refactor-region (BEG END)
|
|
||||||
"Takes a region BEG to END asks ChatGPT refactor it.
|
|
||||||
It then displays the answer in the `chatgpt-buffer'."
|
|
||||||
(interactive "r")
|
|
||||||
(let ((current-code (buffer-substring BEG END)))
|
|
||||||
(chatgpt-prompt (chatgpt--append-to-prompt
|
|
||||||
current-code
|
|
||||||
"Refactor this code and tell me what you changed")
|
|
||||||
(chatgpt-show-results-buffer-if-active))))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-prompt-region (BEG END)
|
|
||||||
"Prompt ChatGPT with the region BEG END.
|
|
||||||
It then displays the results in a separate buffer `chatgpt-buffer'."
|
|
||||||
(interactive "r")
|
|
||||||
(chatgpt-prompt (buffer-substring BEG END)
|
|
||||||
;; Show the results if not already being viewed
|
|
||||||
(chatgpt-show-results-buffer-if-active)))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(defun chatgpt-prompt-region-and-replace (BEG END)
|
|
||||||
"Replace region from BEG to END with the response from the ChatGPT API.
|
|
||||||
|
|
||||||
The region is BEG and until END"
|
|
||||||
(interactive "r")
|
|
||||||
|
|
||||||
(let ((og-buf (current-buffer)))
|
|
||||||
(chatgpt-prompt (buffer-substring BEG END)
|
|
||||||
(lambda (buf)
|
|
||||||
(save-excursion
|
|
||||||
(with-current-buffer og-buf
|
|
||||||
(delete-region BEG END)
|
|
||||||
(goto-char BEG)
|
|
||||||
(insert (with-current-buffer buf (buffer-string)))))))))
|
|
||||||
(defun chatgpt--append-to-prompt (prompt comment-str)
|
|
||||||
"Append the string COMMENT-STR extra information to a PROMPT as a comment."
|
|
||||||
(concat prompt
|
|
||||||
"\n"
|
|
||||||
comment-start
|
|
||||||
" "
|
|
||||||
comment-str))
|
|
||||||
|
|
||||||
(defun chatgpt--extract-text-from-query (query-result)
|
|
||||||
"Extract the resulting text from a given OpenAI response QUERY-RESULT."
|
|
||||||
(condition-case err
|
|
||||||
(thread-last query-result
|
|
||||||
(assoc-default 'choices)
|
|
||||||
seq-first
|
|
||||||
(assoc-default 'text)
|
|
||||||
string-trim)
|
|
||||||
(error
|
|
||||||
(signal 'chatgpt-parsing-error err))))
|
|
||||||
|
|
||||||
(defun chatgpt--parse-response (status callback)
|
|
||||||
"Ignoring STATUS and parse the response executing the CALLBACK function on the resulting string."
|
|
||||||
(ignore status)
|
|
||||||
;; All this is ran inside the buffer containing the response
|
|
||||||
(goto-char 0)
|
|
||||||
(re-search-forward "^$")
|
|
||||||
(funcall callback (chatgpt--extract-text-from-query (json-read))))
|
|
||||||
|
|
||||||
(defun chatgpt--query-open-api (prompt callback)
|
|
||||||
"Send a string PROMPT to OpenAI API and pass the resulting buffer to CALLBACK.
|
|
||||||
The environment variable OPENAI_API_KEY is used as your API key
|
|
||||||
|
|
||||||
You can register an account here
|
|
||||||
https://beta.openai.com/docs/introduction/key-concepts"
|
|
||||||
(let* ((api-key (getenv "OPENAI_API_KEY"))
|
|
||||||
(url-request-method (encode-coding-string "POST" 'us-ascii))
|
|
||||||
(url-request-extra-headers `(("Content-Type" . "application/json")
|
|
||||||
("Authorization" . ,(format "Bearer %s" api-key))))
|
|
||||||
(url-request-data (json-encode
|
|
||||||
`(("model" . "text-davinci-003")
|
|
||||||
("prompt" . ,prompt)
|
|
||||||
("max_tokens" . ,chatgpt-max-tokens)
|
|
||||||
("temperature" . 0)))))
|
|
||||||
(cl-assert (not (string= "" api-key))
|
|
||||||
t
|
|
||||||
"Current contents of the environmental variable OPENAI_API_KEY
|
|
||||||
are '%s' which is not an appropriate OpenAI token please ensure
|
|
||||||
you have the correctly set the OPENAI_API_KEY variable"
|
|
||||||
api-key)
|
|
||||||
(url-retrieve
|
|
||||||
"https://api.openai.com/v1/completions"
|
|
||||||
'chatgpt--parse-response
|
|
||||||
(list callback))))
|
|
||||||
|
|
||||||
(provide 'chatgpt)
|
|
||||||
;;; chatgpt.el ends here
|
|
||||||
0
doom/.config/doom/lisp/test.el
Normal file
0
doom/.config/doom/lisp/test.el
Normal file
@@ -57,8 +57,10 @@
|
|||||||
:recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist")))
|
:recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist")))
|
||||||
(package! highlight-indent-guides)
|
(package! highlight-indent-guides)
|
||||||
(package! yuck-mode)
|
(package! yuck-mode)
|
||||||
|
(package! openai
|
||||||
|
:recipe (:host github :repo "emacs-openai/openai" :files ("*.el")))
|
||||||
(package! chatgpt
|
(package! chatgpt
|
||||||
:recipe (:host github :repo "joshcho/ChatGPT.el" :files ("dist" "*.el")))
|
:recipe (:host github :repo "mrfluffy-dev/chatgpt" :files ("*.el")))
|
||||||
|
|
||||||
(package! nasm-mode :pin "65ca6546fc395711fac5b3b4299e76c2303d43a8")
|
(package! nasm-mode :pin "65ca6546fc395711fac5b3b4299e76c2303d43a8")
|
||||||
(package! haxor-mode :pin "6fa25a8e6b6a59481bc0354c2fe1e0ed53cbdc91")
|
(package! haxor-mode :pin "6fa25a8e6b6a59481bc0354c2fe1e0ed53cbdc91")
|
||||||
|
|||||||
Reference in New Issue
Block a user