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 *** 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 #+begin_src emacs-lisp
(use-package tree-sitter (when (< emacs-major-version 29)
(use-package tree-sitter
:config :config
(global-tree-sitter-mode) (global-tree-sitter-mode)
:ghook :ghook
('tree-sitter-after-on-hook #'tree-sitter-hl-mode)) ('tree-sitter-after-on-hook #'tree-sitter-hl-mode)))
#+end_src #+end_src
[[https://github.com/emacs-tree-sitter/tree-sitter-langs][tree-sitter-langs]] provides =tree-sitter= support for a bunch of languages. [[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)))) (find-file-existing filename))))
#+end_src #+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. 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 #+begin_src emacs-lisp
(use-package yasnippet (use-package yasnippet
:init
(load "yasnippet.el")
:diminish t :diminish t
:general :general
(:keymaps 'yas-minor-mode-map (: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) "<C-tab>" 'yas-expand)
:config :config
(add-to-list 'yas-snippet-dirs my/snippets-dir) (add-to-list 'yas-snippet-dirs my/snippets-dir)
(yas-global-mode) (yas-global-mode))
:diminish yas-minor-mode)
(use-package yasnippet-snippets) (use-package yasnippet-snippets)
#+end_src #+end_src

View file

@ -7,7 +7,6 @@ with lib; let
cfg = config.eboskma.programs.emacs; cfg = config.eboskma.programs.emacs;
emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage { emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage {
# config = ./config.org;
config = config =
let let
tangledOrgConfig = pkgs.runCommand "tangled-emacs-config" { } '' tangledOrgConfig = pkgs.runCommand "tangled-emacs-config" { } ''
@ -35,7 +34,6 @@ with lib; let
categories = [ "Development" "TextEditor" ]; categories = [ "Development" "TextEditor" ];
keywords = [ "org-protocol" ]; keywords = [ "org-protocol" ];
type = "Application"; type = "Application";
# exec = "${cfg.package}/bin/emacsclient -- %u";
exec = "${emacsWithPackages}/bin/emacsclient -- %u"; exec = "${emacsWithPackages}/bin/emacsclient -- %u";
terminal = false; terminal = false;
mimeTypes = [ "x-scheme-handler/org-protocol" ]; mimeTypes = [ "x-scheme-handler/org-protocol" ];
@ -46,11 +44,7 @@ in
options.eboskma.programs.emacs = { options.eboskma.programs.emacs = {
enable = mkEnableOption "activate emacs"; enable = mkEnableOption "activate emacs";
package = mkOption { package = mkPackageOption pkgs "emacs" { };
description = "The emacs package to install";
type = types.package;
default = pkgs.emacs;
};
daemon = mkOption { daemon = mkOption {
description = "Whether to enable emacs daemon"; description = "Whether to enable emacs daemon";
@ -63,13 +57,11 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.emacs = { programs.emacs = {
enable = true; enable = true;
# package = cfg.package;
package = emacsWithPackages; package = emacsWithPackages;
}; };
services.emacs = mkIf cfg.daemon { services.emacs = mkIf cfg.daemon {
enable = true; enable = true;
# package = cfg.package;
package = emacsWithPackages; package = emacsWithPackages;
client.enable = true; client.enable = true;
socketActivation.enable = true; socketActivation.enable = true;
@ -86,7 +78,8 @@ in
python3 python3
lldb 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));
}; };
} }