summaryrefslogtreecommitdiff
path: root/.config/nyxt/config.lisp
blob: 12e6b531adb1700300ddbb21686e30794d833201 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(in-package #:nyxt-user)

#-quicklisp
(let ((quicklisp-init
       (merge-pathnames "quicklisp/setup.lisp" (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))



(load "~/.config/nyxt/style.lisp")
(load "~/.config/nyxt/keys.lisp")
(load "~/.config/nyxt/default-search.lisp")

(defvar *web-buffer-modes*
  '(:emacs-mode
    ;; :blocker-mode :force-https-mode
    :reduce-tracking-mode
    :user-script-mode :bookmarklets-mode)
  "The modes to enable in any web-buffer by default.
Extension files (like dark-reader.lisp) are to append to this list.")

(define-configuration (:modable-buffer :prompt-buffer :editor-buffer)
  "Set up Emacs keybindings everywhere possible."
  ((default-modes `(:emacs-mode ,@%slot-value%))))

(define-configuration :prompt-buffer
  "Make the attribute widths adjust to the content in them.

It's not exactly necessary on master, because there are more or less
intuitive default widths, but these are sometimes inefficient (and
note that I made this feature so I want to have it :P)."
  ((dynamic-attribute-width-p t)))

(define-configuration :web-buffer
  "Basic modes setup for web-buffer."
  ((default-modes `(,@*web-buffer-modes* ,@%slot-value%))))

(define-configuration :hint-mode
  "Set up QWERTY home row as the hint keys."
  ((hints-alphabet "DSJKHLFAGNMXCWEIO")))

(defmethod files:resolve ((profile nyxt:nyxt-profile) (file nyxt/mode/bookmark:bookmarks-file))
  "Reroute the bookmarks to the config directory."
  #p"~/.config/nyxt/bookmarks.lisp")

(define-configuration :reduce-tracking-mode
  ((query-tracking-parameters
    (append '("utm_source" "utm_medium" "utm_campaign" "utm_term" "utm_content")
            %slot-value%)
    :doc "This is to strip UTM-parameters off all the links.
Upstream Nyxt doesn't have it because it may break some websites.")
   (preferred-user-agent
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"
    :doc "Mimic Chrome on MacOS.")))


(defparameter old-reddit-handler
  (url-dispatching-handler
   'old-reddit-dispatcher
   (match-host "www.reddit.com")
   (lambda (url)
     (quri:copy-uri url :host "old.reddit.com"))))


(defun old-reddit-handler (request-data)
  (let ((url (url request-data)))
    (setf (url request-data)
            (if (search "reddit.com" (quri.uri:uri-host url))
                (progn
                 (setf (quri.uri:uri-host url) "old.reddit.com")
                 (log:info "Switching to old Reddit: ~s"
                           (render-url url))
                 url)
                url)))
  request-data)

;; (url-dispatching-handler 'old-reddit-handler )


;; (define-configuration web-buffer
;;   (request-resource-hook
;; 	 (hooks:add-hook %slot-value%
;; 			 (url-dispatching-handler
;; 			  'doi-link-dispatcher
;; 			  (match-scheme "doi")
;; 			  (lambda (url)
;; 			    (quri:uri (format nil "https://www.reddit.com/~a"
;; 					      (quri:uri-path url))))))))

;; (defmethod customize-instance ((buffer web-buffer))
;;   (hooks:add-hook
;;    (request-resource-hook buffer)
;;    (url-dispatching-handler
;;     'transmission-magnet-links
;;     (match-scheme "magnet")
;;     "transmission-remote --add ~a"))
;;   (hooks:add-hook
;;    (request-resource-hook buffer)
;;    (url-dispatching-handler
;;     'emacs-file
;;     (match-scheme "file")
;;     (lambda (url)
;;       (uiop:launch-program
;;        `("emacs" ,(quri:uri-path url)))
;;       nil))))