feat: emacs - replace company/lsp with lsp-bridge, add fonts

This commit is contained in:
Ryan Yin
2024-01-05 20:41:53 +08:00
parent d5ef998239
commit 292809783d
9 changed files with 80 additions and 35 deletions

View File

@@ -172,6 +172,8 @@ reload-emacs-cmd := if os() == "macos" {
"launchctl unload " + emacs-plist-path "launchctl unload " + emacs-plist-path
+ "\n" + "\n"
+ "launchctl load " + emacs-plist-path + "launchctl load " + emacs-plist-path
+ "\n"
+ "tail -f ~/Library/Logs/emacs-daemon.stderr.log"
} else { } else {
"systemctl --user restart emacs.service" "systemctl --user restart emacs.service"
+ "\n" + "\n"
@@ -186,7 +188,6 @@ test-emacs:
doom clean doom clean
doom sync doom sync
{{reload-emacs-cmd}} {{reload-emacs-cmd}}
tail -f $"($env.HOME)//Library/Logs/emacs-daemon.stderr.log"
reload-emacs: reload-emacs:
{{reload-emacs-cmd}} {{reload-emacs-cmd}}

View File

@@ -30,7 +30,7 @@ when in doubt, run `doom sync`!
## Why emacs? ## Why emacs?
1. Explore the unknown, just for fun! 1. Explore the unknown, just for fun!
3. Org Mode 2. Org Mode
## Cheetsheet ## Cheetsheet
@@ -41,6 +41,8 @@ Here is the cheetsheet related to my DoomEmacs configs. Please read vim's common
| Action | Shortcut | | Action | Shortcut |
| ---------------------- | ------------- | | ---------------------- | ------------- |
| Open file tree sidebar | `SPC + o + p` | | Open file tree sidebar | `SPC + o + p` |
| Popup Terminal | `SPC + o + t` |
| Open Terminal | `SPC + o + T` |
| Exit | `M-x C-c` | | Exit | `M-x C-c` |
### Window Navigation ### Window Navigation

View File

@@ -21,8 +21,8 @@ with lib; let
shellAliases = { shellAliases = {
e = "emacsclient --create-frame --tty"; e = "emacsclient --create-frame --tty";
}; };
librime-dir = "${config.xdg.dataHome}/librime/"; librime-dir = "${config.xdg.dataHome}/librime";
parinfer-rust-lib-dir = "${config.xdg.dataHome}/parinfer-rust/"; parinfer-rust-lib-dir = "${config.xdg.dataHome}/parinfer-rust";
in { in {
options.modules.editors.emacs = { options.modules.editors.emacs = {
enable = mkEnableOption "Emacs Editor"; enable = mkEnableOption "Emacs Editor";
@@ -31,10 +31,6 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
emacs-all-the-icons-fonts
# epkgs.rime
## Doom dependencies ## Doom dependencies
git git
(ripgrep.override {withPCRE2 = true;}) (ripgrep.override {withPCRE2 = true;})
@@ -73,11 +69,11 @@ in {
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/ ${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${doomemacs}/ ${config.xdg.configHome}/emacs/
# librime for emacs-rime # librime for emacs-rime
${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.librime}/ ${librime-dir} ${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.librime}/ ${librime-dir}/
# libparinfer_rust for emacs' parinfer-rust-mode # libparinfer_rust for emacs' parinfer-rust-mode
mkdir -p ${parinfer-rust-lib-dir} mkdir -p ${parinfer-rust-lib-dir}
cp ${pkgs.vimPlugins.parinfer-rust}/lib/libparinfer_rust.* ${parinfer-rust-lib-dir}/parinfer-rust.so ${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F744 ${pkgs.vimPlugins.parinfer-rust}/lib/libparinfer_rust.* ${parinfer-rust-lib-dir}/parinfer-rust.so
''; '';
} }

View File

@@ -21,8 +21,10 @@
;; See 'C-h v doom-font' for documentation and more examples of what they ;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example: ;; accept. For example:
;; ;;
;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light) (setq doom-font (font-spec :family "JetBrainsMono Nerd Font" :size 15 :weight 'light)
;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13)) doom-variable-pitch-font (font-spec :family "DejaVu Sans" :size 16)
doom-symbol-font (font-spec :family "JuliaMono")
doom-big-font (font-spec :family "JetBrainsMono Nerd Font" :size 26))
;; ;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them ;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to ;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
@@ -74,6 +76,19 @@
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented. ;; they are implemented.
(use-package! nerd-icons
;; :custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
;; (nerd-icons-font-family "Symbols Nerd Font Mono")
)
(use-package! lsp-bridge
:config
(setq lsp-bridge-enable-log nil)
(global-lsp-bridge-mode))
(use-package! wakatime-mode :ensure t) (use-package! wakatime-mode :ensure t)
;; fully enable tree-sitter highlighting ;; fully enable tree-sitter highlighting
(after! tree-sitter (after! tree-sitter

View File

@@ -22,7 +22,7 @@
;;layout ; auie,ctsrnm is the superior home row ;;layout ; auie,ctsrnm is the superior home row
:completion :completion
(company +childframe) ;; (company +childframe) ; conflict with lsp-bridge
; the ultimate code completion backend ; the ultimate code completion backend
;;helm ; the *other* search engine for love and life ;;helm ; the *other* search engine for love and life
;;ido ; the other *other* search engine... ;;ido ; the other *other* search engine...
@@ -92,19 +92,19 @@
;;collab ; buffers with friends ;;collab ; buffers with friends
;;debugger ; FIXME stepping through code, to help you add bugs ;;debugger ; FIXME stepping through code, to help you add bugs
;;direnv ;;direnv
(docker +lsp) (docker)
editorconfig ; let someone else argue about tabs vs spaces editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs ;;ein ; tame Jupyter notebooks with emacs
(eval +overlay) (eval +overlay)
; run code, run (also, repls) ; run code, run (also, repls)
lookup ; navigate your code and its documentation lookup ; navigate your code and its documentation
lsp ; M-x vscode ;; lsp ; lsp-mode, conflict with lsp-bridge
magit ; a git porcelain for Emacs magit ; a git porcelain for Emacs
;;make ; run make tasks from Emacs ;;make ; run make tasks from Emacs
;;pass ; password manager for nerds ;;pass ; password manager for nerds
pdf ; pdf enhancements pdf ; pdf enhancements
;;prodigy ; FIXME managing external services & code builders ;;prodigy ; FIXME managing external services & code builders
(terraform +lsp) (terraform)
; infrastructure as code ; infrastructure as code
tree-sitter ; syntax and parsing, sitting in a tree... tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp ;;upload ; map local to remote projects via ssh/ftp
@@ -117,7 +117,7 @@
:lang :lang
;;agda ; types of types of types of types... ;;agda ; types of types of types of types...
;;beancount ; mind the GAAP ;;beancount ; mind the GAAP
(cc +lsp +tree-sitter) (cc +tree-sitter)
; C > C++ == 1 ; C > C++ == 1
;;clojure ; java with a lisp ;;clojure ; java with a lisp
;;common-lisp ; if you've seen one lisp, you've seen them all ;;common-lisp ; if you've seen one lisp, you've seen them all
@@ -138,37 +138,37 @@
;;fsharp ; ML stands for Microsoft's Language ;;fsharp ; ML stands for Microsoft's Language
;;fstar ; (dependent) types and (monadic) effects and Z3 ;;fstar ; (dependent) types and (monadic) effects and Z3
;;gdscript ; the language you waited for ;;gdscript ; the language you waited for
(go +lsp +tree-sitter) (go +tree-sitter)
; the hipster dialect ; the hipster dialect
;;(graphql +lsp) ; Give queries a REST ;;(graphql) ; Give queries a REST
;;(haskell +lsp) ; a language that's lazier than I am ;;(haskell) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python ;;hy ; readability of scheme w/ speed of python
;;idris ; a language you can depend on ;;idris ; a language you can depend on
(json +lsp +tree-sitter) (json +tree-sitter)
; At least it ain't XML ; At least it ain't XML
(java +lsp +tree-sitter) (java +tree-sitter)
; the poster child for carpal tunnel syndrome ; the poster child for carpal tunnel syndrome
(javascript +lsp +tree-sitter) (javascript +tree-sitter)
; all(hope(abandon(ye(who(enter(here)))))) ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB ;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script) ;;kotlin ; a better, slicker Java(Script)
(latex +lsp) (latex)
; writing papers in Emacs has never been so fun ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove ;;lean ; for folks with too much to prove
;;ledger ; be audit you can be ;;ledger ; be audit you can be
(lua +lsp +tree-sitter) (lua +tree-sitter)
; one-based indices? one-based indices ; one-based indices? one-based indices
(markdown +grip) (markdown +grip)
; writing docs for people to ignore ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c ;;nim ; python + lisp at the speed of c
(nix +lsp +tree-sitter) (nix +tree-sitter)
; I hereby declare "nix geht mehr!" ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel ;;ocaml ; an objective camel
org ; organize your plain life in plain text org ; organize your plain life in plain text
;;php ; perl's insecure younger brother ;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more ;;plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional ;;purescript ; javascript, but functional
(python +lsp +tree-sitter +pyright) (python +tree-sitter +pyright)
; beautiful is better than ugly ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever ;;qt ; the 'cutest' gui framework ever
racket ; a DSL for DSLs racket ; a DSL for DSLs
@@ -176,20 +176,20 @@
;;rest ; Emacs as a REST client ;;rest ; Emacs as a REST client
;;rst ; ReST in peace ;;rst ; ReST in peace
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
(rust +lsp +tree-sitter) (rust +tree-sitter)
; Fe2O3.unwrap().unwrap().unwrap().unwrap() ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good ;;scala ; java, but good
(scheme +guile) (scheme +guile)
; a fully conniving family of lisps ; a fully conniving family of lisps
(sh +lsp +tree-sitter) (sh +tree-sitter)
; she sells {ba,z,fi}sh shells on the C xor ; she sells {ba,z,fi}sh shells on the C xor
;;sml ;;sml
;;solidity ; do you need a blockchain? No. ;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables? ;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance. ;;terra ; Earth and Moon in alignment for performance.
(web +lsp +tree-sitter) (web +tree-sitter)
; support for various web languages, including HTML5, CSS, SASS/SCSS, Pug/Jade/Slim, and more ; support for various web languages, including HTML5, CSS, SASS/SCSS, Pug/Jade/Slim, and more
(yaml +lsp +tree-sitter) (yaml +tree-sitter)
; JSON, but readable ; JSON, but readable
;;zig ; C, but simpler ;;zig ; C, but simpler

View File

@@ -4,6 +4,9 @@
;; To install a package with Doom you must declare them here and run 'doom sync' ;; 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 ;; on the command line, then restart Emacs for the changes to take effect -- or
;; use 'M-x doom/reload'. ;; use 'M-x doom/reload'.
(package! nerd-icons)
(package! rime)
(package! wakatime-mode (package! wakatime-mode
:recipe :recipe
(:host github :repo "wakatime/wakatime-mode" :files (:host github :repo "wakatime/wakatime-mode" :files
@@ -12,7 +15,15 @@
(package! nushell-mode :recipe (package! nushell-mode :recipe
(:host github :repo "mrkkrp/nushell-mode")) (:host github :repo "mrkkrp/nushell-mode"))
(package! rime) (when (package! lsp-bridge
:recipe (:host github
:repo "manateelazycat/lsp-bridge"
:branch "master"
:files ("*.el" "*.py" "acm" "core" "langserver" "multiserver" "resources")
;; do not perform byte compilation or native compilation for lsp-bridge
:build (:not compile)))
(package! markdown-mode)
(package! yasnippet))
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package) ;; (package! some-package)

View File

@@ -12,18 +12,26 @@
#-- python #-- python
nodePackages.pyright # python language server nodePackages.pyright # python language server
python3Packages.black # python formatter
python3Packages.ruff-lsp
(python310.withPackages ( (python310.withPackages (
ps: ps:
with ps; [ with ps; [
pynvim # Python client and plugin host for Nvim ruff-lsp
black # python formatter
ipython ipython
pandas pandas
requests requests
pyquery pyquery
pyyaml pyyaml
## emacs's lsp-bridge dependenciesge
epc
orjson
sexpdata
six
setuptools
paramiko
rapidfuzz
] ]
)) ))

View File

@@ -188,13 +188,19 @@
source-han-serif # 思源宋体 source-han-serif # 思源宋体
# nerdfonts # nerdfonts
# https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/data/fonts/nerdfonts/shas.nix
(nerdfonts.override { (nerdfonts.override {
fonts = [ fonts = [
# symbols icon only
"NerdFontsSymbolsOnly"
# Characters
"FiraCode" "FiraCode"
"JetBrainsMono" "JetBrainsMono"
"Iosevka" "Iosevka"
]; ];
}) })
julia-mono
dejavu_fonts
]; ];
}; };
} }

View File

@@ -25,13 +25,19 @@
source-han-serif # 思源宋体 source-han-serif # 思源宋体
# nerdfonts # nerdfonts
# https://github.com/NixOS/nixpkgs/blob/nixos-23.11/pkgs/data/fonts/nerdfonts/shas.nix
(nerdfonts.override { (nerdfonts.override {
fonts = [ fonts = [
# symbols icon only
"NerdFontsSymbolsOnly"
# Characters
"FiraCode" "FiraCode"
"JetBrainsMono" "JetBrainsMono"
"Iosevka" "Iosevka"
]; ];
}) })
julia-mono
dejavu_fonts
]; ];
# user defined fonts # user defined fonts