added some treesitter setup stuff

master
John Turner 2 years ago
parent fac3f7e4a2
commit 4a7824f864
No known key found for this signature in database
GPG Key ID: 422FE10CC41A94A2

@ -80,6 +80,8 @@
(when (require? 'pixel-scroll) (when (require? 'pixel-scroll)
(require 'init-pixel-scroll)) (require 'init-pixel-scroll))
(when (and (require? 'treesit) (treesit-available-p))
(require 'init-treesit))
(require 'man-completion) (require 'man-completion)
(require 'license-boilerplate) (require 'license-boilerplate)

@ -0,0 +1,55 @@
;; -*- lexical-binding: t; -*-
(defvar -languages `((python-ts-mode
((:langs . python)
(:file-ext . ,(rx ".py"))
(:interpreter . "python")))
(rust-ts-mode
((:langs . rust)
(:file-ext . ,(rx ".rs"))))
(bash-ts-mode
((:langs . bash)
(:file-ext . ,(rx ".sh"))
(:interpreter . "bash")))
(c-ts-mode
((:langs . c)
(:file-ext . ,(rx ".c"))))
(c++-ts-mode
((:langs . c++)
(:file-ext . ,(rx (or ".c++" ".cpp" ".cxx"
".h++" ".hpp" ".hxx")))))
(c-or-c++-ts-mode
((:langs . (c c++))
(:file-ext . ,(rx ".h"))))
(toml-ts-mode
((:langs . toml)
(:file-ext . ,(rx ".toml"))))))
(defun -ready-quiet-p (language)
(treesit-ready-p language t))
(cl-defun -load-language? (&key ts-mode
required-languages
file-extension
interpreter?)
(let ((ready? (if (listp required-languages)
(seq-every-p '-ready-quiet-p required-languages)
(-ready-quiet-p required-languages))))
(when ready?
(add-to-list 'auto-mode-alist (cons file-extension ts-mode))
(when interpreter?
(add-to-list 'interpreter-mode-alist (cons interpreter? ts-mode))))))
(seq-map (lambda (item)
(-load-language?
:ts-mode (car item)
:required-languages (alist-get :langs (cadr item))
:file-extension (alist-get :file-ext (cadr item))
:interpreter? (alist-get :interpreter (cadr item))))
-languages)
(provide 'init-treesit-setup-available-languages)
;; Local Variables:
;; read-symbol-shorthands: (("-" . "init-treesit-setup-available-languages-"))
;; End:

@ -0,0 +1,3 @@
(require 'init-treesit-setup-available-languages)
(provide 'init-treesit)
Loading…
Cancel
Save