From 236c0e1c4fe0796173993c546d701c1a2af7049f Mon Sep 17 00:00:00 2001 From: Willem van den Ende Date: Mon, 15 Dec 2025 00:53:34 -0800 Subject: [PATCH] refactor config for multi-machine support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move gptel backend configuration to config-local.el (gitignored) so each machine can have its own LLM setup. Add config-local.example.el as a template with options for Ollama, remote llama.cpp, and local llama.cpp. Also make OS-specific paths portable: - Use ~ instead of hardcoded /Users/willem for elixir-ls - Wrap macOS TeX path in system-type conditional 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 1 + config-local.example.el | 72 +++++++++++++++++++++++++++++++++++++++++ config.el | 55 +++++++------------------------ 3 files changed, 85 insertions(+), 43 deletions(-) create mode 100644 config-local.example.el diff --git a/.gitignore b/.gitignore index 8260995..3927bb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /README.tex custom.el flycheck* +config-local.el diff --git a/config-local.example.el b/config-local.example.el new file mode 100644 index 0000000..d870ea9 --- /dev/null +++ b/config-local.example.el @@ -0,0 +1,72 @@ +;;; config-local.example.el --- Template for machine-specific config -*- lexical-binding: t; -*- +;; +;; Copy this file to config-local.el and uncomment/modify the section for your setup. +;; config-local.el is gitignored, so each machine can have its own configuration. + +;;; ============================================================================ +;;; OPTION 1: Linux with Ollama (local models) +;;; ============================================================================ + +;; (setq gptel-backend (gptel-make-ollama "Ollama" +;; :host "localhost:11434" +;; :stream t +;; :models '(qwen2.5-coder:7b +;; qwen3:32b +;; llama3.2:latest)) +;; gptel-model 'qwen2.5-coder:7b) +;; +;; (setq-default gptel-model 'qwen2.5-coder:7b) +;; +;; (gptel-make-preset 'explain +;; :system "Explain what this code does to a novice programmer." +;; :model 'qwen2.5-coder:7b +;; :backend "Ollama") + +;;; ============================================================================ +;;; OPTION 2: macOS connecting to remote Linux server +;;; ============================================================================ + +;; (setq gptel-backend (gptel-make-openai "remote-llama" +;; :host "linux-server.local:8000" ; your server's hostname +;; :protocol "http" +;; :stream t +;; :models '(Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf)) +;; gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) +;; +;; (setq-default gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) +;; +;; (gptel-make-preset 'explain +;; :system "Explain what this code does to a novice programmer." +;; :model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf +;; :backend "remote-llama") + +;;; ============================================================================ +;;; OPTION 3: Linux with local llama.cpp server +;;; ============================================================================ + +;; (setq gptel-backend (gptel-make-openai "llama.cpp" +;; :host "localhost:8000" +;; :protocol "http" +;; :stream t +;; :models '(Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf)) +;; gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) +;; +;; (setq-default gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) +;; +;; ;; Also add Ollama as secondary backend +;; (gptel-make-ollama "Ollama" +;; :host "localhost:11434" +;; :stream t +;; :models '(qwen2.5-coder:7b qwen3:0.6B)) +;; +;; (gptel-make-preset 'explain +;; :system "Explain what this code does to a novice programmer." +;; :model 'Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf +;; :backend "llama.cpp") +;; +;; (gptel-make-preset 'elixir +;; :system "You are an expert programmer, specialising in Elixir and TDD, you live in Emacs" +;; :model 'Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf +;; :backend "llama.cpp") + +;;; config-local.example.el ends here diff --git a/config.el b/config.el index 60b5b36..cbd3579 100644 --- a/config.el +++ b/config.el @@ -73,7 +73,7 @@ ) (with-eval-after-load 'eglot - (add-to-list 'eglot-server-programs '(elixir-ts-mode . ("sh" "/Users/willem/.elixir-ls/release/language_server.sh" )))) + (add-to-list 'eglot-server-programs '(elixir-ts-mode . ("sh" "~/.elixir-ls/release/language_server.sh")))) (use-package elixir-ts-mode @@ -94,8 +94,9 @@ ;;(add-hook 'after-init-hook #'global-mise-mode) -;; fix pdflatex for pdf export -(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin")) +;; fix pdflatex for pdf export (macOS-specific path) +(when (eq system-type 'darwin) + (setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))) ;; html export configuration, assuming use in a CMS or static site gerator that ;; takes care of the layout ;; https://stackoverflow.com/questions/47508315/emacs-org-mode-export-to-html-without-syntax-highlighting @@ -318,49 +319,17 @@ (require 'qwan-blog) (require 'qwan-refactor) -;; https://github.com/karthink/gptel?tab=readme-ov-file#chatgpt -;; (setq gptel-models - ;; '(("Ollama" "localhost:11434" nil "http" t "/api/chat" nil - ;; (qwen3:0.6B qwen3:32b hf.co/unsloth/Qwen3-30B-A3B-GGUF:Q5_K_M) "http://localhost:11434/api/chat" nil nil))) -;; https://yannesposito.com/posts/0029-ai-assistants-in-doom-emacs-31-on-macos-with-clojure-mcp-server/index.html -;; LLM +;; LLM configuration with gptel +;; Machine-specific backends are configured in config-local.el +;; This file contains shared settings only (use-package! gptel :init - ;; declare the default llm configuration - ;; for me this is co-pilot with claude-sonnet-4 - (setq gptel-default-mode 'org-mode ;; I want the llm to reply to me with org-mode format. - gptel-backend (gptel-make-openai "llama.cpp" - :host "localhost:8000" - :protocol "http" - :stream t - :models '(Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf)) - gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) - ;; Do not use chatgpt as default. took long to find. - (setq-default gptel-model 'Qwen3-30B-A3B-Thinking-2507-Q6_K.gguf) - (require 'gptel-integrations) ;; <- for mcp - ;; declare another llm configuration, 11434 is for llmacpp. I also use ollama fore smaller models that don't require - ;; max speed or the latest API. - (gptel-make-ollama "Ollama" - :host "localhost:11434" - :stream t + (setq gptel-default-mode 'org-mode) ;; LLM replies in org-mode format + (require 'gptel-integrations)) ;; <- for mcp - :models '(qwen2.5-coder:7b - qwen3:0.6B - (qwen2.5-coder:32b ;Full spec - :description - "qwen2.5 coder 32b: large coding model " - :capabilities (tools media) - :mime-types ("image/jpeg" "image/png" "image/svg")))) - - (gptel-make-preset 'explain - :system "Explain what this code does to a novice programmer." - :model 'Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf - :backend "llama.cpp") - (gptel-make-preset 'elixir - :system "You are an expert programmer, specialising in Elixir and TDD, you live in Emacs" - :model 'Qwen3-Coder-30B-A3B-Instruct-Q6_K.gguf - :backend "llama.cpp") -) +;; Load machine-specific configuration (gptel backends, etc.) +;; Create config-local.el with your machine's gptel-backend, gptel-model, and backends +(load! "config-local.el" doom-user-dir t) ;; org-roam v1 port to v2, insert node without opening buffer