1
0
Fork 0

Compare commits

...

17 commits

Author SHA1 Message Date
c2cf29c8f2 Add a couple of names to watch out for in elfeed 2024-10-24 00:31:05 -07:00
2f90776712 Add a couple of blog feeds 2024-10-24 00:30:52 -07:00
e26750e302 Set up space cycling
Remove newlines along with the rest of the whitespace.
2024-10-24 00:30:20 -07:00
2183877638 Remove keyboard shortcuts
I thought these might make my life easier and my shortcuts a little faster, but
they haven't.
2024-10-24 00:29:50 -07:00
f404ee6032 Autoload needed function 2024-07-08 15:10:02 -07:00
eeca5767e9 Require treesit
`treesit-available-p' is defined in the C source code, but `treesit-ready-p' is defined in `treesit.el'.
2024-07-08 14:53:20 -07:00
89f4dc6234 [oni-org] Add files with tasks in PARA directories
I'm trying out trying out PARA and these files sometimes have tasks in them.
2024-07-01 15:11:25 -07:00
e9214ea7e4 [oni-org] Change org tags column 2024-07-01 15:09:32 -07:00
c74133b68b [oni-org] Fix variable name
I think they must have renamed this variable at some point.
2024-07-01 15:09:14 -07:00
f9ff0da907 [oni-org] Fix indentation 2024-07-01 15:07:54 -07:00
15181c50d1 [oni-python] Add treesit configuration 2024-07-01 15:07:36 -07:00
75128ffcdf [oni-yaml] Autoload the major mode remapping 2024-07-01 15:07:04 -07:00
f4b587f550 [oni-vterm] Add function to open vterm in a project 2024-07-01 15:06:43 -07:00
e917daef5a [oni-org] Slim down
Remove some unused parts of my configuration.
2024-07-01 14:53:27 -07:00
756be72f06 [oni-elfeed] Add Orange Goblin as favourite band 2024-07-01 14:38:34 -07:00
da288e8256 [oni-elfeed] Add some feeds 2024-07-01 14:38:25 -07:00
6747a3693c [oni-org] Add capture template for DONE tasks 2024-05-09 13:08:43 -07:00
6 changed files with 123 additions and 286 deletions

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2024.0205.222004
;; Version: 2024.1014.135848
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr mini-frame)
;; This program is free software; you can redistribute it and/or modify
@ -426,24 +426,7 @@ _s_: String list"
(global-set-key [remap switch-to-buffer] 'consult-buffer)
(global-set-key [remap yank-pop] 'consult-yank-pop)
(global-set-key (kbd "M-0") #'delete-window)
(global-set-key (kbd "C-x 0") (lambda () (interactive) (error "Use M-0 instead")))
(global-set-key (kbd "M-1") #'delete-other-windows)
(global-set-key (kbd "C-x 1") (lambda () (interactive) (error "Use M-1 instead")))
(global-set-key (kbd "M-2") #'split-window-below)
(global-set-key (kbd "C-x 2") (lambda () (interactive) (error "Use M-2 instead")))
(global-set-key (kbd "M-3") #'split-window-right)
(global-set-key (kbd "C-x 3") (lambda () (interactive) (error "Use M-3 instead")))
(global-set-key (kbd "M-4") #'ctl-x-4-prefix)
(global-set-key (kbd "C-x 4") (lambda () (interactive) (error "Use M-4 instead")))
(global-set-key (kbd "M-5") #'ctl-x-5-prefix)
(global-set-key (kbd "C-x 5") (lambda () (interactive) (error "Use M-5 instead")))
(global-set-key (kbd "M-6") #'2C-command)
(global-set-key (kbd "C-x 6") (lambda () (interactive) (error "Use M-6 instead")))
(global-set-key (kbd "M-8") (keymap-lookup global-map "C-x 8"))
(global-set-key (kbd "C-x 8") (lambda () (interactive) (error "Use M-8 instead")))
(global-set-key (kbd "M-8 l") "λ")
(global-set-key (kbd "C-x 8 l") "λ")
(defun oni-core-related-files ()
"Return a list of files related to the current buffer."
@ -545,5 +528,11 @@ which normally have their errors suppressed."
(lambda (d) (string-match-p (rx "/" (or "." ".." "foreign") eos) d))
(directory-files "~/projects/" t))))
;;; Space cycling
;; The - argument to each function makes sure that any newlines are also
;; removed along with the other whitespace.
(setq cycle-spacing-actions '((just-one-space -) (delete-all-space -) restore))
(provide 'oni-core)
;;; oni-core.el ends here

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2024.0408.115427
;; Version: 2024.0822.003002
;; Package-Requires: (elfeed olivetti)
;; This program is free software; you can redistribute it and/or modify
@ -91,7 +91,14 @@
("https://github.com/bharadswami/syncthing-status.el/commits/main.atom" emacs commits)
"https://liliputing.com/feed/"
("https://www.futurile.net/feeds/all.atom.xml" guix)
"https://convolv.es/atom.xml"))
"https://convolv.es/atom.xml"
"https://ianthehenry.com/feed.xml"
"https://funcall.blogspot.com/feeds/posts/default"
"https://tibleiz.net/blog/news.rss"
("https://csscade.com/" css)
"https://ntietz.com/atom.xmlsig"
"https://libreture.com/blog/rss"
"https://jvns.ca/atom.xml"))
(add-hook 'elfeed-new-entry-hook
(elfeed-make-tagger :before "2 weeks ago"
@ -144,7 +151,12 @@
(seq "BLACK" whitespace "SABBATH")
"MEGADETH"
(seq "ZAKK" whitespace "WYLDE")
(seq "BLACK" whitespace "LABEL" whitespace "SOCIETY")))
(seq "BLACK" whitespace "LABEL" whitespace "SOCIETY")
(seq "ORANGE" whitespace "GOBLIN")
(seq "DEEP" whitespace "PURPLE")
(seq "ROB" whitespace "ZOMBIE")
"CLUTCH"
(seq "THE" whitespace "OFFSPRING")))
:add 'favourite)
"Tagger that highlights specific bands from Blabbermouth.")

View file

@ -4,8 +4,8 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2024.0315.155036
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table ob-async org-ql org-super-agenda)
;; Version: 2024.0701.144646
;; Package-Requires: (oni-yasnippet oni-hydra org org-edna diminish olivetti org-pretty-table)
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@ -39,7 +39,6 @@
(require 'diminish)
(require 'hydra)
(require 'ob)
(require 'ob-async)
(require 'org)
(require 'org-clock)
(require 'org-edna)
@ -47,9 +46,7 @@
(require 'org-faces)
(require 'org-habit)
(require 'org-protocol)
(require 'org-ql)
(require 'org-roam)
(require 'org-super-agenda)
(require 'range)
(require 'subr-x)
(require 'yasnippet)
@ -90,90 +87,6 @@
(expand-file-name "tickler.org" oni-org-todo-dir)
"The tickler file for TODO notes of the future.")
;;; Fake org-roam -- oni-org-exocortex
;; I tried using org-roam v2 with Orgro, but it didnt work. Ive only been
;; using org-roam to more easily find and insert strings. The file renaming in
;; v1 always seemed to have some issue, so I never really used that. And I
;; didnt even look any further into any of the functionality. So these
;; functions are my re-implementation of the convenience of org-roam. This way
;; Orgro still works and I can easily build up my knowledge base as well. I call
;; it fake org-roam for now because Im too tired to think of anything else,
;; its not actually enough to be a fake anything.
(eval-when-compile (require 'cl-macs))
(defvar oni-org-exocortex-directory (expand-file-name "~/documents/org"))
;; Expected (I need to turn these into tests):
;; - C++ :: c
;; - Crafting Interpreters - 10 - Fucntions - Native Functions :: crafting_interpreters_10_functions_native_functions
;; This is a helper function to turn the strings into the same kind of slugs
;; that org-roam uses so I stay consistent in my naming.
(defun oni-org--slugify (str)
"Turn STR into a filesystem-safe slug."
(let ((regexp (rx (one-or-more (not alphanumeric)))))
(downcase
(replace-regexp-in-string regexp "_" (string-trim-right str regexp)))))
;; This mimicks the file name pattern of org-roam with a date and time, followed
;; by a filesystem-safe slug of the actual title.
(defun oni-org--create-name (title)
(interactive "MTitle: ")
(format "%s-%s.org"
(format-time-string "%Y%m%d%H%M%S")
(oni-org--slugify title)))
;; Collect all of the files under the oni-org-exocortex-directory. org-roam indexes
;; all of the files in a database, but I really didnt want to recreate that
;; today. For the moment I dont have so many files that parsing all of them
;; like this is a huge problem.
(defun oni-org--get-exocortex-files ()
(cl-labels ((add-titles (file)
(list (with-temp-buffer
(insert-file-contents (expand-file-name file))
(goto-char (point-min))
(let ((line-end-position (line-end-position)))
(when (search-forward ":" line-end-position t)
(buffer-substring-no-properties (1+ (point)) line-end-position))))
file))
(unimportant-file-p (file)
(or (string-prefix-p "." (file-name-nondirectory file))
(string-match-p (rx bos "#" (one-or-more any) "#" eos) (file-name-nondirectory file))))
(unimportant-directory-p (directory)
(not (string-match-p (rx "/.") directory))))
(mapcar #'add-titles
(cl-delete-if #'unimportant-file-p
(directory-files-recursively oni-org-exocortex-directory (rx bos (repeat 14 digit) "-" (one-or-more (any alphanumeric "_")) ".org") nil #'unimportant-directory-p)))))
;; Find and visit a file in the oni-org-exocortex-directory. If the file doesnt
;; exist yet, its created and the title is inserted into it.
(defun oni-org-find-exocortex-file ()
(interactive)
(let* ((default-directory oni-org-exocortex-directory)
(completions (oni-org--get-exocortex-files))
(pick (completing-read "File: " completions))
(file (car (alist-get pick completions nil nil #'string=))))
(if file
(find-file file)
(find-file (oni-org--create-name pick))
(insert "#+TITLE: " pick "\n\n"))))
;; Insert a link to a file in the oni-org-exocortex-directory into the current
;; buffer. Dont visit the file, just insert a link to it.
(defun oni-org-insert-exocortex-link ()
(interactive)
(let* ((completions (oni-org--get-exocortex-files))
(pick (completing-read "File: " completions))
(file (car (alist-get pick completions nil nil #'string=))))
(unless file
(setq file (oni-org--create-name pick))
(with-current-buffer (find-file-noselect file)
(insert "#+TITLE: " pick "\n\n")
(save-buffer)))
(insert "[[file:" (file-relative-name file oni-org-exocortex-directory) "][" pick "]]")))
;;; Functions
(defun oni-org-document-add-inline-images-startup ()
@ -191,7 +104,7 @@
(goto-char (1- header-end))
(insert "#+STARTUP: inlineimages\n")))))
(defun oni-org-document-remove-inline-images-startup ()
(defun oni-org-document-remove-inline-images-startup ()
"Remove a line to the current org buffer that will make it load images inline."
(interactive)
(unless (derived-mode-p 'org-mode)
@ -235,15 +148,6 @@ located at the start of the line."
(setq-local yas-buffer-local-condition
'(looking-back (rx line-start (one-or-more (not space))))))
(defun oni-org-setup-prettify-symbols-mode ()
"Set up prettify symbols mode for org mode."
(setq-local prettify-symbols-alist
'(("[ ]" . ?)
("[X]" . ?)
("#+TITLE: " . "")
("#+title: " . "")))
(prettify-symbols-mode))
(defun oni-org-snippets-initialize ()
"Initialize the snippets for oni-org."
(when (boundp 'yas-snippet-dirs)
@ -352,44 +256,6 @@ _di_: Add inlineimages STARTUP
"^[ \t]*#\\+end"
lim-up lim-down))))
(defun oni-org-at-origin-property-p ()
"Non-nil when point is in an origin property."
(save-match-data
(save-excursion
(goto-char (line-beginning-position))
(and (looking-at org-property-re)
(string= (match-string 2) "ORIGIN")))))
(defun oni-org-dblock-write-backlinks (_params)
"Generate backlinks to org headings."
(let ((current-heading (nth 4 (org-heading-components)))
(current-heading-id
(or (alist-get "CUSTOM_ID" (org-entry-properties) nil nil #'string=)
(org-id-get)))
backlinks)
(save-excursion
(goto-char (point-min))
(while (re-search-forward (rx-to-string `(and "*" ,current-heading "]")) nil t)
(unless (or (oni-org-in-dblock-p)
(oni-org-at-origin-property-p))
(let ((components (org-heading-components)))
(push (cons (nth 2 components) (nth 4 components)) backlinks)))))
(when (not (null current-heading-id))
(save-excursion
(goto-char (point-min))
(while (re-search-forward (rx-to-string `(or (seq "[[id:" ,current-heading-id "]")
(seq "#" ,current-heading-id "]"))) nil t)
(unless (or (oni-org-in-dblock-p)
(oni-org-at-origin-property-p))
(let ((components (org-heading-components)))
(push (cons (nth 2 components) (nth 4 components)) backlinks))))))
(insert (string-join
(mapcar (lambda (link)
(concat "- [[*" (cdr link) "][" (if (car link) (format "%s - " (car link)) "") (cdr link) "]]"))
(sort (seq-uniq backlinks (lambda (a b) (string= (cdr a) (cdr b))))
(lambda (a b) (string< (cdr a) (cdr b)))))
"\n"))))
(defun oni-org-wrap-region-in-block (block-name beginning end)
"Create a block BLOCK-NAME and wrap the text between BEGINNING and END in there."
(interactive "sName: \nr")
@ -403,13 +269,11 @@ _di_: Add inlineimages STARTUP
(insert "#+begin_" block-name)
(unless (looking-at (rx "\n")) (insert "\n"))))
(defalias 'org-dblock-write:oni-backlinks 'oni-org-dblock-write-backlinks)
;; Create a new archive for each year. This way archives don't keep growing
;; indefinitely and opening the archive doesn't load every single language I've
;; ever used because there are code blocks in there.
(setq org-archive-location (format-time-string "%%s_archive_%Y::"))
(setq org-catch-invisible-edits 'error)
(setq org-fold-catch-invisible-edits 'error)
(setq org-clock-in-switch-to-state #'oni-org-maybe-change-todo-state)
(setq org-extend-today-until 2)
(setq org-fontify-whole-heading-line t)
@ -423,7 +287,7 @@ _di_: Add inlineimages STARTUP
(setq org-return-follows-link t)
(setq org-special-ctrl-a/e t)
(setq org-src-fontify-natively t)
(setq org-tags-column -67)
(setq org-tags-column -80)
(setq org-tags-exclude-from-inheritance '("project"))
(setq org-tags-sort-function #'string<)
(setq org-use-fast-todo-selection t)
@ -457,58 +321,6 @@ and not a state update."
(setq org-default-notes-file (expand-file-name "inbox.org" oni-org-todo-dir))
(setq org-bibtex-autogen-keys t)
(defun oni-org-find-heading-in-file (heading file &optional move)
"Try to find HEADING somewhere in FILE.
This function returns nil if HEADING couldnt be found, and the
position where the chapter starts otherwise. If MOVE is non-nil
also move point to the start of the heading."
(let ((buffer (find-file-noselect file)))
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(org-find-exact-headline-in-buffer heading buffer (not move))))))
(defun oni-org-create-book-heading (book-title file)
"Create a new heading for BOOK-TITLE in FILE."
(let ((buffer (find-file file)))
(with-current-buffer buffer
(goto-char (point-max))
(insert "\n* " book-title "\n\n "))))
(defun oni-org-create-chapter-heading (book-title chapter-title file)
"Create a new heading under BOOK-TITLE for CHAPTER-TITLE in FILE."
(let ((buffer (find-file file)))
(with-current-buffer buffer
(goto-char (point-min))
(goto-char (oni-org-find-heading-in-file book-title file t))
(goto-char (org-element-property :end (org-element-at-point)))
(unless (= (point) (point-max))
(open-line 2))
(insert "\n** " chapter-title "\n\n "))))
(defun oni-org-create-chapter-section (chapter-title file)
"Create a new notes section under CHAPTER-TITLE in FILE."
(let ((buffer (find-file file)))
(with-current-buffer buffer
(goto-char (point-min))
(goto-char (oni-org-find-heading-in-file chapter-title file t))
(goto-char (org-element-property :contents-end (org-element-at-point)))
(insert "\n"))))
(defun oni-org-reading-note ()
"Find the org-header associated with the current chapter or page."
(let* ((headers (split-string (format-mode-line header-line-format) ":" t " "))
(book-name (car headers))
(chapter-name (cadr headers))
(notes-file (oni-org-expand-to-home "documents/gtd/reading-notes.org"))
(chapter-start (oni-org-find-heading-in-file chapter-name notes-file)))
(if (not chapter-start)
(let ((book-start (oni-org-find-heading-in-file book-name notes-file)))
(unless book-start
(oni-org-create-book-heading book-name notes-file))
(oni-org-create-chapter-heading book-name chapter-name notes-file))
(oni-org-create-chapter-section chapter-name notes-file))))
(defun oni-org-todo-maybe-hide-body ()
"Hide the current outline body if org-state is a DONE state."
(when (member org-state org-done-keywords)
@ -521,10 +333,7 @@ also move point to the start of the heading."
(org-update-all-dblocks)))
(setq org-todo-keywords
'((sequence "TODO(t)" "WIP" "BLOCKED(b@)" "|" "DONE(d!)")
(sequence "READ(r)" "READING(!)" "|" "FINISHED(!)" "STOPPED(@)")
(sequence "WATCH(w)" "WATCHING" "|" "WATCHED(!)")
(sequence "LISTEN(l)" "LISTENING" "|" "DONE(d!)")
'((sequence "TODO(t)" "WIP" "WAITING(W@)" "|" "DONE(d!)")
(sequence "|" "CANCELLED(c@)")))
(add-hook 'org-after-todo-state-change-hook 'oni-org-todo-maybe-hide-body)
@ -557,12 +366,6 @@ also move point to the start of the heading."
(add-hook 'org-mode-hook 'yas-minor-mode)
(org-edna-mode)
(org-super-agenda-mode)
(unless (eq system-type 'windows-nt)
(require 'org-bullets)
(add-hook 'org-mode-hook 'org-bullets-mode)
(add-hook 'org-mode-hook #'oni-org-setup-prettify-symbols-mode))
;;;###autoload
(global-set-key (kbd "C-c o") '("Org commands" . oni-hydra-org/body))
@ -641,7 +444,24 @@ also move point to the start of the heading."
(org-roam-db-query
[:select :distinct file :from nodes :where (= todo $s1)] "TODO")))
(setq org-agenda-files (list oni-org-todo-main-file))
(defun oni-org-para-todo-files ()
"Collect all task files from my PARA repository."
(delete nil
(mapcar (lambda (dir)
(cond
((string-prefix-p "." (file-name-nondirectory dir)) nil)
(t (let ((file-name (expand-file-name "tasks.org" dir)))
(and (file-exists-p file-name) file-name)))))
(append (directory-files
(expand-file-name "documents/exocortex-para/projects" (getenv "HOME"))
:full)
(directory-files
(expand-file-name "documents/exocortex-para/areas" (getenv "HOME"))
:full)))))
(setq org-agenda-files (append (list oni-org-todo-main-file)
(oni-org-roam-todo-files)
(oni-org-para-todo-files)))
(setq org-agenda-tags-todo-honor-ignore-options t)
(setq org-agenda-todo-ignore-scheduled 'future)
(setq org-agenda-restore-windows-after-quit t)
@ -703,30 +523,6 @@ After running it once remove it from `org-capture-after-finalize-hook'."
(let ((title (oni-org-get-url-title url)))
(format "[[%s][%s]]" url title)))
(defun oni-org-format-months ()
(let* ((time (org-timestamp-to-time
(org-timestamp-from-string (concat "<" (org-read-date) ">"))))
(decoded (decode-time time))
(next-month
(time-add time (days-to-time (date-days-in-month
(decoded-time-year decoded)
(decoded-time-month decoded))))))
(concat (format-time-string "%b " time)
(format-time-string "%b " next-month)
(format-time-string "%Y" time))))
(defun oni-org-ask-names ()
(let ((n 1)
article-name
names)
(while (not (string-empty-p (setq article-name (read-string (format "Article Name %d: " n)))))
(push article-name names)
(cl-incf n))
(reverse names)))
(defun oni-org-format-names (names)
(mapconcat (lambda (n) (format "** READ %s" n)) names "\n"))
(defun org-edna-finder/next-sibling-first-child ()
"A finder for org-edna to find the first child of the next sibling."
(save-excursion
@ -1229,19 +1025,17 @@ same code all the time."
(map-insert ,collection ,key-name ,value-name))
,value-name)))))
(oni-org--map-put org-agenda-custom-commands "P"
'("Stuck projects" ((org-ql-block '(and (todo) (children) (not (children (todo))))))))
(oni-org--map-put org-agenda-custom-commands "o"
'("Overview" ((org-ql-block '(and (todo)
(children)
(not (children (todo))))
((org-ql-block-header "Stuck projects")))
(org-ql-block '(and (todo) (not (children)))
((org-super-agenda-groups '((:auto-parent)))
(org-ql-block-header "Todo")))
(agenda ""
((org-agenda-span 3))))))
(defvar oni-org--capture-D-date nil)
(oni-org--map-put org-capture-templates "D"
'("A DONE item for my to-done list." entry (file oni-org-todo-main-file) "* DONE %?
CLOSED: %(setq oni-org--capture-D-date (format-time-string (org-time-stamp-format t t) (org-read-date t t nil \"Date: \")))
:PROPERTIES:
:CREATED: %(progn oni-org--capture-D-date)
:END:
:LOGBOOK:
- State \"DONE\" from \"TODO\" %(progn oni-org--capture-D-date)
:END:"
:after-finalize (lambda () (setq oni-org--capture-D-date nil))))
(oni-org--map-put org-capture-templates "t"
'("A simple TODO item." entry (file "") "* TODO %?

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0722.222800
;; Version: 2024.0701.150636
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@ -28,6 +28,7 @@
(require 'project)
(declare-function magit-status-setup-buffer "magit-status.el")
(declare-function vterm "vterm.el")
(defun oni-project-magit ()
"Start Magit in the current project's root directory."
@ -38,5 +39,29 @@
(define-key project-prefix-map (kbd "m") #'oni-project-magit)
(add-to-list 'project-switch-commands '(oni-project-magit "Magit status")))
(defun oni-project-vterm ()
"Start Vterm in the current project's root directory.
If a buffer already exists for running Vterm in the project's root,
switch to it. Otherwise, create a new Vterm buffer. With
\\[universal-argument] prefix arg, create a new Vterm buffer even if one
already exists."
(interactive)
(defvar vterm-buffer-name-string)
(let* ((project-root (project-root (project-current t)))
(vterm-buffer (seq-find (lambda (b)
(with-current-buffer b
(and (eq 'vterm-mode major-mode)
(string-prefix-p project-root default-directory))))
(buffer-list)))
(default-directory project-root)
(vterm-buffer-name-string (project-prefixed-buffer-name "vterm")))
(if (and vterm-buffer (not current-prefix-arg))
(pop-to-buffer vterm-buffer (bound-and-true-p display-comint-buffer-action))
(vterm))))
(when (locate-library "vterm")
(define-key project-prefix-map (kbd "t") #'oni-project-vterm)
(add-to-list 'project-switch-commands '(oni-project-vterm "Terminal")))
(provide 'oni-project)
;;; oni-project.el ends here

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2024.0313.112713
;; Version: 2024.0621.092608
;; Package-Requires: (oni-yasnippet oni-company oni-flycheck oni-hydra oni-lsp rainbow-delimiters reformatter)
;; This program is free software; you can redistribute it and/or modify
@ -41,6 +41,9 @@
(require 'whitespace)
(require 'yasnippet)
;; Don't mind if treesit can't be loaded, maybe this Emacs doesn't have it.
(require 'treesit nil t)
(autoload 'hl-indent-mode "hl-indent-mode")
(defconst oni-python-root
@ -73,6 +76,19 @@ for indentation."
(setq-local whitespace-style '(face tabs))
(whitespace-mode))
;;;###autoload
(defun oni-python--enable-hooks (hook)
(add-hook hook 'company-mode)
(add-hook hook 'display-fill-column-indicator-mode)
(add-hook hook 'electric-indent-local-mode)
(add-hook hook 'electric-pair-local-mode)
(add-hook hook 'flycheck-mode)
(add-hook hook 'lsp)
(add-hook hook 'oni-python-set-fill-column)
(add-hook hook 'oni-python-whitespace-mode)
(add-hook hook 'python-black-on-save-mode)
(add-hook hook 'rainbow-delimiters-mode))
(reformatter-define python-black
:program "black"
:args `("--line-length" ,(number-to-string fill-column) "-")
@ -81,16 +97,15 @@ for indentation."
(define-key python-mode-map (kbd "C-c r") 'python-refactor-hydra/body)
(add-hook 'python-mode-hook 'company-mode)
(add-hook 'python-mode-hook 'display-fill-column-indicator-mode)
(add-hook 'python-mode-hook 'electric-indent-local-mode)
(add-hook 'python-mode-hook 'electric-pair-local-mode)
(add-hook 'python-mode-hook 'flycheck-mode)
(add-hook 'python-mode-hook 'lsp)
(add-hook 'python-mode-hook 'oni-python-set-fill-column)
(add-hook 'python-mode-hook 'oni-python-whitespace-mode)
(add-hook 'python-mode-hook 'python-black-on-save-mode)
(add-hook 'python-mode-hook 'rainbow-delimiters-mode)
(oni-python--enable-hooks 'python-mode-hook)
;;;###autoload
(when (and (functionp 'treesit-available-p)
(treesit-available-p)
(require 'treesit)
(treesit-ready-p 'python))
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
(oni-python--enable-hooks 'python-ts-mode-hook))
(with-eval-after-load 'python
(with-eval-after-load 'yasnippet

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2024.0205.164705
;; Version: 2024.0621.092620
;; Package-Requires: (yaml-mode oni-flycheck oni-highlight-indent-guides indent-tools yaml-imenu yaml-pro)
;; This program is free software; you can redistribute it and/or modify
@ -51,8 +51,10 @@
(oni-yaml--enable-hooks 'yaml-mode-hook)
;;;###autoload
(when (and (functionp 'treesit-available-p)
(treesit-available-p)
(require 'treesit)
(treesit-ready-p 'yaml))
(add-to-list 'major-mode-remap-alist '(yaml-mode . yaml-ts-mode))
(oni-yaml--enable-hooks 'yaml-ts-mode-hook))