[oni-python] Add treesit configuration
This commit is contained in:
parent
75128ffcdf
commit
15181c50d1
1 changed files with 24 additions and 11 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: local
|
;; 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)
|
;; 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
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -41,6 +41,9 @@
|
||||||
(require 'whitespace)
|
(require 'whitespace)
|
||||||
(require 'yasnippet)
|
(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")
|
(autoload 'hl-indent-mode "hl-indent-mode")
|
||||||
|
|
||||||
(defconst oni-python-root
|
(defconst oni-python-root
|
||||||
|
@ -73,6 +76,18 @@ for indentation."
|
||||||
(setq-local whitespace-style '(face tabs))
|
(setq-local whitespace-style '(face tabs))
|
||||||
(whitespace-mode))
|
(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
|
(reformatter-define python-black
|
||||||
:program "black"
|
:program "black"
|
||||||
:args `("--line-length" ,(number-to-string fill-column) "-")
|
: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)
|
(define-key python-mode-map (kbd "C-c r") 'python-refactor-hydra/body)
|
||||||
|
|
||||||
(add-hook 'python-mode-hook 'company-mode)
|
(oni-python--enable-hooks 'python-mode-hook)
|
||||||
(add-hook 'python-mode-hook 'display-fill-column-indicator-mode)
|
|
||||||
(add-hook 'python-mode-hook 'electric-indent-local-mode)
|
;;;###autoload
|
||||||
(add-hook 'python-mode-hook 'electric-pair-local-mode)
|
(when (and (functionp 'treesit-available-p)
|
||||||
(add-hook 'python-mode-hook 'flycheck-mode)
|
(treesit-available-p)
|
||||||
(add-hook 'python-mode-hook 'lsp)
|
(treesit-ready-p 'python))
|
||||||
(add-hook 'python-mode-hook 'oni-python-set-fill-column)
|
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
|
||||||
(add-hook 'python-mode-hook 'oni-python-whitespace-mode)
|
(oni-python--enable-hooks 'python-ts-mode-hook))
|
||||||
(add-hook 'python-mode-hook 'python-black-on-save-mode)
|
|
||||||
(add-hook 'python-mode-hook 'rainbow-delimiters-mode)
|
|
||||||
|
|
||||||
(with-eval-after-load 'python
|
(with-eval-after-load 'python
|
||||||
(with-eval-after-load 'yasnippet
|
(with-eval-after-load 'yasnippet
|
||||||
|
|
Loading…
Reference in a new issue