feat: emacs - replace smartparens with parinfer

feat: emacs - add emacs-rime
This commit is contained in:
Ryan Yin
2024-01-05 18:37:51 +08:00
parent 3f7c023251
commit d5ef998239
8 changed files with 120 additions and 96 deletions

View File

@@ -162,12 +162,9 @@ test-nvim:
test-nvim-clean:
rm -rf $"($env.HOME)/.config/astronvim/lua/user"
test-emacs:
rm -rf $"($env.HOME)/.config/doom"
rsync -avz --copy-links --chmod=D2755,F744 home/base/desktop/editors/emacs/doom/ $"($env.HOME)/.config/doom"
test-emacs-clean:
rm -rf $"($env.HOME)/.config/doom/"
# =================================================
# Emacs related commands
# =================================================
emacs-plist-path := "~/Library/LaunchAgents/org.nix-community.home.emacs.plist"
@@ -181,5 +178,19 @@ reload-emacs-cmd := if os() == "macos" {
+ "systemctl --user status emacs.service"
}
test-emacs:
rm -rf $"($env.HOME)/.config/doom"
rsync -avz --copy-links --chmod=D2755,F744 home/base/desktop/editors/emacs/doom/ $"($env.HOME)/.config/doom"
doom sync
doom purge
doom clean
doom sync
{{reload-emacs-cmd}}
tail -f $"($env.HOME)//Library/Logs/emacs-daemon.stderr.log"
reload-emacs:
{{reload-emacs-cmd}}
test-emacs-clean:
rm -rf $"($env.HOME)/.config/doom/"

View File

@@ -3,7 +3,7 @@
## S-expression data(Lisp)
- paredit/[lispy](https://github.com/doomemacs/doomemacs/tree/master/modules/editor/lispy): too complex.
- [evil-smartparens](https://github.com/expez/evil-smartparens): simple and useful.
- [evil-cleverparens](https://github.com/emacs-evil/evil-cleverparens): simple and useful.
- [parinfer(par-in-fer)](https://shaunlebron.github.io/parinfer/): morden, simple, elegant and useful, but works not well with some other completion plugins...
- to make parinfer works, you should disable sexp & smartparens in any lisp mode.
@@ -14,6 +14,8 @@ Some plugins:
- Neovim
- [parinfer-rust](https://github.com/eraserhd/parinfer-rust)
- <https://github.com/Olical/conjure>
- Helix
- [parinfer #4090 - Helix](https://github.com/helix-editor/helix/discussions/4090)
## Other Languages

View File

@@ -21,23 +21,18 @@ with lib; let
shellAliases = {
e = "emacsclient --create-frame --tty";
};
librime-dir = "${config.xdg.dataHome}/librime/";
parinfer-rust-lib-dir = "${config.xdg.dataHome}/parinfer-rust/";
in {
options.modules.editors.emacs = {
enable = mkEnableOption "Emacs Editor";
doom = {
enable = mkEnableOption "Doom Emacs";
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = with pkgs;
let
epkgs = emacsPackages;
in
[
home.packages = with pkgs; [
emacs-all-the-icons-fonts
# epkgs.parinfer-rust-mode
# epkgs.rime
## Doom dependencies
@@ -74,46 +69,55 @@ in {
force = true;
};
home.activation = mkIf cfg.doom.enable {
installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
'';
};
home.activation.installDoomEmacs = lib.hm.dag.entryAfter ["writeBoundary"] ''
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
# librime for emacs-rime
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.librime}/ ${librime-dir}
# libparinfer_rust for emacs' parinfer-rust-mode
mkdir -p ${parinfer-rust-lib-dir}
cp ${pkgs.vimPlugins.parinfer-rust}/lib/libparinfer_rust.* ${parinfer-rust-lib-dir}/parinfer-rust.so
'';
}
(mkIf pkgs.stdenv.isLinux (
# Do not use emacs-nox here, which makes the mouse wheel work abnormally in terminal mode.
let emacsPkg = pkgs.emacs29; in
{
home.packages = [emacsPkg];
services.emacs = {
enable = true;
package = emacsPkg;
startWithUserSession = true;
};
}))
# Do not use emacs-nox here, which makes the mouse wheel work abnormally in terminal mode.
let
emacsPkg = pkgs.emacs29;
in {
home.packages = [emacsPkg];
services.emacs = {
enable = true;
package = emacsPkg;
startWithUserSession = true;
};
}
))
(mkIf pkgs.stdenv.isDarwin (
# Do not use emacs-nox here, which makes the mouse wheel work abnormally in terminal mode.
let emacsPkg = pkgs.emacs29; in
{
home.packages = [emacsPkg];
launchd.enable = true;
launchd.agents.emacs = {
enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"-l"
"-c"
"${emacsPkg}/bin/emacs --fg-daemon"
];
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stderr.log";
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stdout.log";
RunAtLoad = true;
KeepAlive = true;
# Do not use emacs-nox here, which makes the mouse wheel work abnormally in terminal mode.
let
emacsPkg = pkgs.emacs29;
in {
home.packages = [emacsPkg];
launchd.enable = true;
launchd.agents.emacs = {
enable = true;
config = {
ProgramArguments = [
"${pkgs.bash}/bin/bash"
"-l"
"-c"
"${emacsPkg}/bin/emacs --fg-daemon"
];
StandardErrorPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stderr.log";
StandardOutPath = "${config.home.homeDirectory}/Library/Logs/emacs-daemon.stdout.log";
RunAtLoad = true;
KeepAlive = true;
};
};
};
}))
}
))
]);
}

View File

@@ -74,28 +74,7 @@
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook
(prog-mode . copilot-mode)
:bind
(:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word))
:config
(copilot-mode +1))
(use-package super-save
:ensure t
:config
(super-save-mode +1))
(after! super-save
(setq super-save-auto-save-when-idle t)
(setq super-save-all-buffers t)
(setq super-save-delete-trailing-whitespace t))
(use-package wakatime-mode
:ensure t)
(use-package! wakatime-mode :ensure t)
;; fully enable tree-sitter highlighting
(after! tree-sitter
(setq +tree-sitter-hl-enabled-modes t))
@@ -106,7 +85,7 @@
(global-font-lock-mode 0))
;; use alejandra to format nix files
(use-package lsp-nix
(use-package! lsp-nix
:ensure lsp-mode
:after
(lsp-mode)
@@ -114,14 +93,50 @@
:custom
(lsp-nix-nil-formatter
["alejandra"]))
(use-package nushell-mode
(use-package! nushell-mode
:config
(setq nushell-enable-auto-indent 1))
;; https://github.com/doomemacs/doomemacs/issues/4374
(use-package! smartparens
:init (add-hook 'smartparens-enabled-hook #'evil-smartparens-mode)
:hook ((clojure-mode . smartparens-strict-mode)
(scheme-mode . smartparens-strict-mode)
(lisp-mode . smartparens-strict-mode)
(emacs-lisp-mode . smartparens-strict-mode)))
;; emacs-rime
(use-package! rime
:custom
(default-input-method "rime")
(rime-librime-root "~/.local/share/librime"))
;; use parinfer for lisp editing
(use-package! parinfer-rust-mode
:hook ((emacs-lisp-mode
clojure-mode
scheme-mode
lisp-mode
racket-mode
fennel-mode
hy-mode) . parinfer-rust-mode)
:init
;; parinfer-rust library do not provide a apple silicon binary.
;; fix: https://github.com/doomemacs/doomemacs/issues/6163
(setq parinfer-rust-auto-download 0)
;; we need to download it manually and put it in this path
(setq parinfer-rust-library "~/.local/share/parinfer-rust/parinfer-rust.so")
:config
(map! :map parinfer-rust-mode-map
:localleader
"p" #'parinfer-rust-switch-mode
"P" #'parinfer-rust-toggle-disable))
;; disable smatparens-mode here to void conflict with parinfer
;; https://discourse.doomemacs.org/t/disable-smartparens-or-parenthesis-completion/134
(add-hook 'clojure-mode-hook #'turn-off-smartparens-mode)
(add-hook 'scheme-mode-hook #'turn-off-smartparens-mode)
(add-hook 'lisp-mode-hook #'turn-off-smartparens-mode)
(add-hook 'racket-mode-hook #'turn-off-smartparens-mode)
(add-hook 'fennel-mode-hook #'turn-off-smartparens-mode)
(add-hook 'hy-mode-hook #'turn-off-smartparens-mode)

View File

@@ -17,7 +17,7 @@
(doom! :input
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
chinese ; TODO: use (chinese +rime)
chinese
;;japanese
;;layout ; auie,ctsrnm is the superior home row
@@ -61,8 +61,8 @@
(format +onsave)
; automated prettiness
;; multiple-cursors ; editing in many places at once
objed ; text object editing for the innocent
;; parinfer ; turn lisp into python, sort of
;; objed ; text object editing for the innocent
parinfer ; turn lisp into python, sort of, conflict with copilot/objed/smartparens
;;rotate-text ; cycle region at point between text candidates
snippets ; my elves. They type so I don't have to
word-wrap ; soft wrapping with language-aware indent

View File

@@ -4,21 +4,15 @@
;; To install a package with Doom you must declare them here and run 'doom sync'
;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'.
(package! copilot
:recipe
(:host github :repo "copilot-emacs/copilot.el" :files
("*.el" "dist")))
(package! super-save
:recipe
(:host github :repo "bbatsov/super-save" :files
("*.el" "dist")))
(package! wakatime-mode
:recipe
(:host github :repo "wakatime/wakatime-mode" :files
("*.el" "dist")))
(package! nushell-mode :recipe
(:host github :repo "mrkkrp/nushell-mode"))
(package! evil-smartparens)
(package! rime)
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package)

View File

@@ -14,6 +14,5 @@
modules.editors.emacs = {
enable = true;
doom.enable = true;
};
}

View File

@@ -15,7 +15,6 @@
};
modules.editors.emacs = {
enable = true;
doom.enable = true;
};
programs.ssh = {