Use built-in tree-sitter on emacs >=29, minor cleanup

This commit is contained in:
Erwin Boskma 2023-03-31 14:41:09 +02:00
parent 4099bfa07d
commit 68c02950ea
Signed by: erwin
SSH key fingerprint: SHA256:Vw4O4qA0i5x65Y7yyjDpWDCSMSXAhqT4X7cJ3frdnLY
2 changed files with 11 additions and 16 deletions

View file

@ -866,14 +866,15 @@ Visualise git changes in the gutter, next to the line numbers
*** Tree-sitter
[[https://tree-sitter.github.io/][tree-sitter]] is a new development in parsing and syntax highlighting. There is [[https://www.reddit.com/r/emacs/comments/pxpq8d/rfc_emacs_treesitter_integration/][an effort underway]] to get it into Emacs core, but for now we're using the [[https://emacs-tree-sitter.github.io/][emacs-tree-sitter]] package.
[[https://tree-sitter.github.io/][tree-sitter]] is a new development in parsing and syntax highlighting. It has been merged into Emacs 29, but until that's released we're using the [[https://emacs-tree-sitter.github.io/][emacs-tree-sitter]] package while on Emacs 28.
#+begin_src emacs-lisp
(when (< emacs-major-version 29)
(use-package tree-sitter
:config
(global-tree-sitter-mode)
:ghook
('tree-sitter-after-on-hook #'tree-sitter-hl-mode))
('tree-sitter-after-on-hook #'tree-sitter-hl-mode)))
#+end_src
[[https://github.com/emacs-tree-sitter/tree-sitter-langs][tree-sitter-langs]] provides =tree-sitter= support for a bunch of languages.
@ -976,12 +977,14 @@ Visualise git changes in the gutter, next to the line numbers
(find-file-existing filename))))
#+end_src
*** Snippets
** Snippets
Snippets are predefined pieces of code that can be inserted and filled in. [[https://github.com/joaotavora/yasnippet][YASnippet]] uses syntax inspired by TextMate is the most popular, for good reason.
#+begin_src emacs-lisp
(use-package yasnippet
:init
(load "yasnippet.el")
:diminish t
:general
(:keymaps 'yas-minor-mode-map
@ -990,8 +993,7 @@ Snippets are predefined pieces of code that can be inserted and filled in. [[htt
"<C-tab>" 'yas-expand)
:config
(add-to-list 'yas-snippet-dirs my/snippets-dir)
(yas-global-mode)
:diminish yas-minor-mode)
(yas-global-mode))
(use-package yasnippet-snippets)
#+end_src

View file

@ -7,7 +7,6 @@ with lib; let
cfg = config.eboskma.programs.emacs;
emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage {
# config = ./config.org;
config =
let
tangledOrgConfig = pkgs.runCommand "tangled-emacs-config" { } ''
@ -35,7 +34,6 @@ with lib; let
categories = [ "Development" "TextEditor" ];
keywords = [ "org-protocol" ];
type = "Application";
# exec = "${cfg.package}/bin/emacsclient -- %u";
exec = "${emacsWithPackages}/bin/emacsclient -- %u";
terminal = false;
mimeTypes = [ "x-scheme-handler/org-protocol" ];
@ -46,11 +44,7 @@ in
options.eboskma.programs.emacs = {
enable = mkEnableOption "activate emacs";
package = mkOption {
description = "The emacs package to install";
type = types.package;
default = pkgs.emacs;
};
package = mkPackageOption pkgs "emacs" { };
daemon = mkOption {
description = "Whether to enable emacs daemon";
@ -63,13 +57,11 @@ in
config = mkIf cfg.enable {
programs.emacs = {
enable = true;
# package = cfg.package;
package = emacsWithPackages;
};
services.emacs = mkIf cfg.daemon {
enable = true;
# package = cfg.package;
package = emacsWithPackages;
client.enable = true;
socketActivation.enable = true;
@ -86,7 +78,8 @@ in
python3
lldb
] ++
(with aspellDicts; [ en en-computers en-science fy nl ]);
(with aspellDicts; [ en en-computers en-science fy nl ]) ++
(lib.optional (versionOlder cfg.package.version "29") (tree-sitter.withPlugins builtins.attrValues));
};
}