1
0
Fork 0

[oni-python] Add treesit configuration

This commit is contained in:
Tom Willemse 2024-07-01 15:07:36 -07:00
parent 75128ffcdf
commit 15181c50d1

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,18 @@ for indentation."
(setq-local whitespace-style '(face tabs))
(whitespace-mode))
(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 +96,14 @@ 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)
(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