emacs.d/bundle/bundle--package.el
2024-05-22 20:31:45 +02:00

399 lines
17 KiB
EmacsLisp

;; PACKAGE
(require 'package)
(use-package htmlize)
(use-package tramp
:ensure nil
:config
(when (eq system-type 'windows-nt)
(setq tramp-default-method "sshx")))
(use-package shr
:custom
(shr-use-colors nil)
(shr-use-fonts nil)
(shr-inhibit-images t)
(shr-cookie-policy nil)
(shr-width nil))
(use-package shrface
:hook ((eww-after-render . shrface-mode)
(nov-mode . shrface-mode))
:custom
(shrface-href-versatile t)
(shrface-toggle-bullets t)
:config
(shrface-basic)
(shrface-trial)
(shrface-default-keybindings))
(use-package flyspell
:hook ((LaTeX-mode . flyspell-mode)
(org-mode . flyspell-mode)
(text-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode)))
(defun mk/nov-font-settings ()
(setq-local line-spacing 2))
(use-package browse-url
:custom
(browse-url-browser-function 'eww-browse-url))
(use-package eww
:config
(require 'shrface))
(use-package nov
:hook ((nov-mode . visual-line-mode)
(nov-mode . mk/nov-font-settings))
:mode ("\\.epub\\'" . nov-mode)
:custom
(nov-header-line-format nil)
(nov-text-width 82)
(nov-variable-pitch nil)
:config
(require 'shrface)
(setq nov-shr-rendering-functions '((img . nov-render-img) (title . nov-render-title)))
(setq nov-shr-rendering-functions (append nov-shr-rendering-functions shr-external-rendering-functions)))
;; (when (eq system-type 'windows-nt)
;; (setq nov-unzip-program "c:/msys64/usr/bin/unzip.exe")))
(use-package eglot
:hook ((typescript-mode . eglot-ensure)
(js2-mode . eglot-ensure))
:config
(if (eq system-name 'windows-nt)
;; %USERPROFILE%\AppData\Local\Programs\clangd-windows-17.0.3\clangd_17.0.3\bin
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "clangd"))
(add-to-list 'eglot-server-programs '((c++-mode c-mode) "ccls"))))
(use-package sql
:config
(setq sql-connection-alist
'((finance-db
(sql-product 'sqlite)
(sql-database "~/Documents/org/data/FINANCE.db"))))
(when (eq system-type 'windows-nt)
(setq sql-postgres-program "C:/Program Files/PostgreSQL/16/bin/psql.exe")
(setq sql-sqlite-options '("-interactive"))
(setq sql-mariadb-options '("-C" "-t" "-f" "-n"))
(setq sql-mysql-options '("-C" "-t" "-f" "-n"))))
(defun me/c-mode-style-hook ()
;; https://www.gnu.org/prep/standards/html_node/Writing-C.html
;; if linux kernel source use linux style, else use gnu style
(c-set-style
(if (and (buffer-file-name)
(string-match "/usr/src/linux" (buffer-file-name)))
"linux"
"gnu")))
(use-package cc-mode
:defer t
:ensure nil
:hook ((c-mode-common . c-toggle-auto-newline)
(c-mode-common . me/c-mode-style-hook))
:custom
(fill-column 79)
(c-basic-offset 2)
(indent-tabs-mode nil)
:config
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent))
;; (defun me/c-mode-compile-command-hook ()
;; ;; if no makefile use gcc for compile command
;; (unless (or (file-exists-p "makefile")
;; (file-exists-p "Makefile"))
;; (set (make-local-variable 'compile-command)
;; (concat "gcc " "-Wall " "-g " buffer-file-name " -o "
;; (file-name-sans-extension buffer-file-name)))))
;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-command-hook)
;; (defun me/c-mode-compile-on-save ()
;; ;; compile on save hook
;; (make-local-variable 'after-save-hook)
;; (add-hook 'after-save-hook (lambda () (compile compile-command))))
;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-on-save)
;; (use-package js-mode
;; :ensure nil
;; :hook (js-mode . eglot-ensure)
;; :mode (("\\.webmanifest\\'" . js-mode)
;; ("\\.js\\'" . js-mode)
;; ("\\.mjs\\'" . js-mode)
;; ("\\.cjs\\'" . js-mode)))
(use-package js2-mode
:mode
(("\\.webmanifest\\'" . js2-mode)
("\\.js\\'" . js2-mode)
("\\.mjs\\'" . js2-mode)
("\\.cjs\\'" . js2-mode))
:config
(add-to-list 'interpreter-mode-alist '("node" . js2-mode)))
;; (use-package go-mode
;; :defer t
;; :mode ("\\.go\\'" . go-mode)
;; :hook ((before-save . gofmt-before-save)
;; (go-mode . eglot-ensure))
;; :config
;; (defun me/go-mode-compile-command-hook ()
;; ;; if no makefile use go vet for compile command
;; (unless (or (file-exists-p "makefile")
;; (file-exists-p "Makefile"))
;; (set (make-local-variable 'compile-command)
;; (concat "go " "vet " buffer-file-name))))
;; (add-hook 'go-mode-hook 'me/go-mode-compile-command-hook)
;; (defun me/go-mode-compile-on-save ()
;; ;; compile on save hook
;; (make-local-variable 'after-save-hook)
;; (add-hook 'after-save-hook (lambda () (compile compile-command)))))
;; ;; (add-hook 'go-mode-hook 'me/go-mode-compile-on-save)))
(use-package web-mode
;; :hook html-mode
:mode (("\\.html?\\'" . web-mode)
("\\.xhtml?\\'" . web-mode)
("\\.tmpl\\'" . web-mode)
("\\.hbs\\'" . web-mode)
("\\.handlebars\\'" . web-mode))
:custom
(web-mode-markup-indent-offset 2)
(web-mode-css-indent-offset 2)
(web-mode-code-indent-offset 2)
(web-mode-enable-auto-pairing nil)
(web-mode-enable-auto-closing t)
(web-mode-enable-current-element-highlight t)
(web-mode-enable-current-column-highlight t))
(use-package python
:mode (("\\.py\\'" . python-mode)
("\\.wsgi$" . python-mode)
("\\.j2" . python-mode))
:hook (python-mode . abbrev-mode)
:init
(setq python-indent-guess-indent-offset nil)
(setq python-indent-offset 4)
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "-i --simple-prompt --InteractiveShell.display_page=True")
:custom
(fill-column 79))
;; (use-package simple-httpd
;; :defer t)
(use-package go-translate
:defer t
:config
(setq gts-translate-list '(("en" "de") ("de" "en")))
(setq gts-default-translator
(gts-translator :picker (gts-prompt-picker)
:engines (list (gts-bing-engine) (gts-google-engine))
:render (gts-buffer-render))))
(use-package magit
:bind ("C-x g" . magit-status)
:init
(when (eq system-type 'windows-nt)
(setq magit-git-executable "C:/Program Files/Git/mingw64/libexec/git-core/git.exe"))
:custom
(magit-diff-refine-hunk 'all)
(magit-display-buffer-function 'magit-display-buffer-fullcolumn-most-v1)
(magit-ediff-dwim-show-on-hunks t)
(magit-log-arguments '("--graph" "--color" "--decorate" "--show-signature" "--follow" "-n256"))
(magit-log-margin-show-committer-date t)
(magit-log-remove-graph-args '("--follow" "--grep" "-G" "-S" "-L"))
(magit-todos-insert-after '(bottom))
:config
(global-set-key (kbd "C-x M-g") 'magit-dispatch))
(use-package yaml-mode
:mode "\\.yml\\'"
:hook
(yaml-mode . (lambda () (auto-fill-mode -1))))
(use-package csv-mode
:mode "\\.csv\\'")
(use-package markdown-mode
:mode "\\.md\\'")
;; (use-package typescript-mode
;; :defer t
;; :mode "\\.ts\\'"
;; :hook (typescript-mode . eglot-ensure)
;; :config (setq typescript-indent-level 2))
(when (eq system-type 'gnu/linux)
(use-package spotify :bind ("S-<pause>" . spotify-playpause))
;; (use-package clojure-mode)
;; (use-package cider)
(use-package journalctl-mode
:commands journalctl
:bind (("C-c t j" . journalctl))))
(use-package mastodon
:defer t
:custom
(mastodon-instance-url "https://emacs.ch")
(mastodon-active-user "qhBidG3d"))
(use-package jabber
:defer t
:custom
(jabber-activity-mode nil)
(jabber-account-list
'(("marcus.kammer@mailbox.org")))
(jabber-muc-autojoin
'("lisp@conference.a3.pm"
"emacs@salas.suchat.org"))
(jabber-muc-default-nicknames
'(("lisp@conference.a3.pm" . "marcus")
("emacs@salas.suchat.org" . "marcus"))))
;; (use-package hyperbole
;; :config
;; (setq hyrolo-date-format "%Y-%m-%d %H:%M:%S")
;; (add-hook 'hyperbole-init-hook
;; (lambda ()
;; (setq hyrolo-file-list
;; (append (hyrolo-initialize-file-list)
;; (cons "~/.rolo.otl"
;; (directory-files-recursively org-directory (rx "." (or "org" "otl") eos))))))))
(use-package ispell
:ensure nil
:config
;; On windows: Copy *.aff and *.dic files to C:\msys64\ucrt64\share\hunspell
;; `hunspell -D`, the program will display the dictionaries and affix files it
;; finds and loads.
;; (when (eq system-type 'windows-nt)
;; (setq ispell-program-name "c:/msys64/ucrt64/bin/hunspell.exe"))
(setq ispell-dictionary "german,english")
(setq ispell-local-dictionary-alist
'(("german" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "de_DE_frami,de_AT_frami,de_CH_frami") nil utf-8)
("english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US,en_GB") nil utf-8)
("german,english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "de_DE_frami,en_US") nil utf-8)))
(setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist))
(use-package plantuml-mode
:mode ("\\.puml\\'" "\\.plantuml\\'")
:custom
(plantuml-default-exec-mode 'jar)
(plantuml-jar-path "~/plantuml.jar")
(org-plantuml-jar-path "~/plantuml.jar")
(plantuml-java-args '("-DPLANTUML_DPI=300" "-Djava.awt.headless=true" "-jar" "--illegal-access=deny")))
(use-package tex-mode
:defer t
:ensure auctex
:config
;; TeX mode settings for editing .tex files
(setq TeX-auto-save t) ; Enable auto-save
(setq TeX-electric-math (cons "$" "$")) ; Shortcut for math mode
(if (eq system-type 'windows-nt)
(progn
(setq TeX-view-program-list '(("SumatraPDF" "~/AppData/Local/SumatraPDF/SumatraPDF.exe %o")))
(setq TeX-view-program-selection '((output-pdf "SumatraPDF"))))
(setq TeX-view-program-selection '((output-pdf "Evince"))))
(setq TeX-source-correlate-start-server t) ; Enable source-correlate
(setq TeX-master nil) ; Default master file
(setq TeX-engine 'luatex) ; Set engine to XeTeX
(setq TeX-command-extra-options "-shell-escape")) ; Allow shell escape
(use-package auctex
:hook ((LaTeX-mode . turn-on-reftex)
(LaTeX-mode . LaTeX-math-mode))
:custom
(LaTeX-indent-level 4)
(LaTeX-item-indent 0))
(use-package epg
:ensure nil
:config
(when (eq system-type 'windows-nt)
(setq epg-gpg-home-directory "~/AppData/Roaming/gnupg"
epg-gpg-program "c:/Program Files (x86)/GnuPG/bin/gpg.exe"
epg-gpgconf-program "c:/Program Files (x86)/GnuPG/bin/gpgconf.exe")))
(use-package which-key
:init (which-key-mode))
(use-package ssh-config-mode
:mode ("/sshd_config\\'" . ssh-config-mode)
:config
(add-hook 'ssh-config-mode-hook 'turn-on-font-lock))
(use-package nginx-mode
:mode ("/nginx/.*\\'" . nginx-mode))
(use-package dashboard
:config
(dashboard-setup-startup-hook))
;; (use-package flymake-json)
;; (use-package json-mode
;; :ensure nil
;; :mode "\\.json\\'"
;; :hook (json-mode . flymake-json-load))
;; (use-package json-navigator
;; :defer t
;; :after json-mode)
;; (use-package jq-format
;; :defer t
;; :after json-mode)
(defun get-anthropic-key ()
"Retrieve the Anthropics API key using 'auth-source'."
(require 'auth-source)
(let* ((auth-source-creation-prompts
'((secret . "API key for %u@%h: ")))
(found (nth 0 (auth-source-search
:max 1
:host "api.anthropic.com"
:user "apikey"
:require '(:secret)
:create t)))
(secret (plist-get found :secret)))
(if (functionp secret)
(funcall secret)
secret)))
(use-package gptel
:bind (("C-c G m" . gptel-menu)
("C-c G n" . gptel)
("C-c G s" . gptel-send))
:custom
(gptel-default-mode 'org-mode)
(gptel-model "gpt-4o")
(gptel-directives
'((default . "You are a large language model living in Emacs and a helpful assistant. Respond concisely.")
(programming . "You are a large language model and a careful programmer. Provide code and only code as output without any additional text, prompt or note.")
(writing . "You are a large language model and a writing assistant. Respond concisely.")
(chat . "You are a large language model and a conversation partner. Respond concisely.")
(ux . "I want you to act as a UX/UI designer. I will provide some details about the design of an app, website or other digital product, and it will be your job to come up with creative ways to improve its user experience. This could involve creating prototypes, testing different designs and providing feedback on what works best.")
(cl . "I want you to act as a common lisp developer. I will provide some specific information about app requirements, and it will be your job to come up with an architecture and code for developing secure app with common lisp.")
(emacser . "You are a Emacs maven. Reply only with the most approriate built-in Emacs command for the task I specify. Do NOT generate any additional description or explanation.")
(elisp . "Consider yourself an experienced Emacs Lisp developer with a deep understanding of Emacs's extensibility and customization capabilities. You're well-versed in creating and modifying Emacs modes, optimizing workflows, and integrating Emacs with other tools and services.")
(cs-professor . "As a computer science professor teaching a high school class, your specialty lies in functional programming concepts. You're introducing your students to the elegance and power of functional programming using Common Lisp as the primary language. Your goal is to engage and educate your students about the beauty of functional programming paradigms.")
(statistics-professor . "You're a math professor teaching a high school class on descriptive statistics. Your task is to explain the concept of descriptive statistics to your students using clear and accessible language. Your goal is to help your students understand how descriptive statistics are used to summarize and analyze data effectively.")
(psychologist . "You're a psychologist specializing in market research, and your role involves creating surveys to gather insights into user behavior and market trends. Your objective is to design surveys that effectively capture the opinions, preferences, and attitudes of respondents, providing valuable data for analysis.")
(webdev . "You are an experienced Common Lisp developer specializing in web development using the Hunchentoot library, with a strong emphasis on functional programming principles. I need your support in building and maintaining web applications. Please provide detailed guidance, examples, and best practices for the following tasks: Explain how to install and configure Hunchentoot in a Common Lisp environment. Provide a sample code snippet to set up a basic Hunchentoot web server. Highlight any functional programming techniques used in the setup. Demonstrate how to define routes in Hunchentoot. Show examples of handling GET and POST requests using functional programming principles, such as pure functions and immutability. Explain how to manage query parameters and request bodies in a functional style. Illustrate how to serve static files (HTML, CSS, JS, images) using Hunchentoot. Provide tips for organizing static files within a project. Discuss how to use functional programming to manage static file serving efficiently. Explain how to generate and return HTML content from handlers. Include examples using Common Lisp templating libraries or techniques to render dynamic content. Emphasize the use of functional programming concepts in rendering and templating. Describe how to implement session management in a Hunchentoot application. Provide code examples for setting, retrieving, and destroying session data using functional approaches. Discuss the benefits of immutability and pure functions in managing sessions. Show how to implement error handling and custom error pages in Hunchentoot. Include examples of logging errors and debugging tips. Explain how functional programming can improve error handling and logging. Explain how to connect a Hunchentoot application to a database (e.g., PostgreSQL, SQLite). Provide a sample CRUD (Create, Read, Update, Delete) application demonstrating database interaction. Highlight functional programming techniques in database operations, such as using higher-order functions and maintaining immutability. Offer advice on securing a Hunchentoot application (e.g., input validation, CSRF protection, HTTPS setup). Include examples and code snippets where applicable. Discuss how functional programming principles can enhance application security. Discuss the deployment process for Hunchentoot applications. Recommend hosting options and provide a basic deployment guide. Emphasize functional programming practices in the deployment process to ensure reliability and maintainability. Feel free to ask for clarification or additional details on any of these topics. Let's get started!.")))
:config
(when (eq system-type 'windows-nt)
(setq gptel-use-curl t))
(gptel-make-anthropic "Claude"
:stream t
:key gptel-api-key))
(use-package gnuplot
:defer t)