wsl下载ubuntu
1 2 3 4
| wsl --list --online
wsl --install Ubuntu-20.04
|
迁移到D盘
在D盘创建一个目录用来存放新的WSL,比如D:\WSL\Ubuntu-20.04
1 2 3 4 5 6 7
| wsl --export Ubuntu-20.04 D:\WSL\Ubuntu-20.04.tar
wsl --unregister Ubuntu-20.04
wsl --import Ubuntu-20.04 D:\WSL\Ubuntu-20.04 D:\WSL\Ubuntu-20.04.tar
|
如果这时候启动WSL,发现好像已经恢复正常了,但是用户变成了root。用以下命令恢复:
1
| Ubuntu2004 config --default-user username
|
安装最新版emacs
1 2 3 4 5 6 7 8 9 10
| sudo apt-get purge snapd
wget https://mirrors.ustc.edu.cn/gnu/emacs/emacs-30.2.tar.xz cd emacs sudo apt install zlib1g-dev libgccjit-9-dev pkg-config libgnutls28-dev ./configure --without-x --without-ns --without-pgtk --with-native-compilation --with-threads --prefix=/usr/local make -j$(nproc) sudo make install
|
--without-x emacs-nox,不使用 X11(Xorg),只能用 emacs -nw(终端)
--without-ns 禁用 macOS 的 Cocoa / NS 窗口系统,只是防止 configure 自动探测到 macOS GUI
--without-pgtk 禁用 Pure GTK(Wayland 下的新 GUI 后端)
--with-native-compilation 启用 native-comp(.eln)将Elisp 编译成机器码
--with-threads启用 多线程支持
--prefix=/usr/local安装到 /usr/local
treesitter问题
参考下面这个修改,主要是ABI版本不匹配的问题,降低版本即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| (use-package tree-sitter :ensure t :config (setq treesit-font-lock-level 4) (setq treesit-language-source-alist '((bash . ("https://github.com/tree-sitter/tree-sitter-bash" "v0.20.0")) (c . ("https://github.com/tree-sitter/tree-sitter-c" "v0.21.3")) (cpp . ("https://github.com/tree-sitter/tree-sitter-cpp")) (python . ("https://github.com/tree-sitter/tree-sitter-python" "v0.20.4")) (rust . ("https://github.com/tree-sitter/tree-sitter-rust" "v0.20.3")) (toml . ("https://github.com/tree-sitter/tree-sitter-toml")) ;; (elisp . ("https://github.com/Wilfred/tree-sitter-elisp")) (cmake . ("https://github.com/uyha/tree-sitter-cmake")) (dockerfile . ("https://github.com/camdencheek/tree-sitter-dockerfile")) (make . ("https://github.com/alemuller/tree-sitter-make")) (yaml . ("https://github.com/ikatyang/tree-sitter-yaml")) (json . ("https://github.com/tree-sitter/tree-sitter-json")) ))
(add-to-list 'auto-mode-alist '("\\.c\\.[^/]*\\'" . c-ts-mode)) (add-to-list 'auto-mode-alist '("\\.include\\.[^/]*\\'" . c-ts-mode)) (add-to-list 'auto-mode-alist '("\\.y[a]?ml\\'" . yaml-ts-mode)) (add-to-list 'auto-mode-alist '("\\(?:Dockerfile\\(?:\\..*\\)?\\|\\.[Dd]ockerfile\\)\\'" . dockerfile-ts-mode)) (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-ts-mode)) )
(setq major-mode-remap-alist '((bash-mode . bash-ts-mode) (sh-mode . bash-ts-mode) (c-mode . c-ts-mode) (c++-mode . c++-ts-mode) (python-mode . python-ts-mode) ;;(rust-mode . rust-ts-mode) (conf-toml-mode . toml-ts-mode) (cmake-mode . cmake-ts-mode) ;;(dockerfile-mode . dockerfile-ts-mode) (json-mode . json-ts-mode) (java-mode . java-ts-mode) ;;(yaml-mode . yaml-ts-mode) (makefile-mode . makefile-ts-mode) ))
|
另外通过apt下载的clangd版本比较老,可能不支持某些配置项,参考下面修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| (use-package eglot :ensure t :defer 1 :config (setq eglot-server-programs '(((c++-mode c-mode c++-ts-mode c-ts-mode) . ("clangd" ;;"-j=4" ;; "--enable-config" "--background-index" ;; "--background-index-priority=low" "--clang-tidy" "--completion-style=detailed" "--header-insertion=never" "--all-scopes-completion" "--pretty" "--fallback-style=none" ;;"--query-driver=aarch64-linux-gnu-*" ;;"--query-driver=gcc,g++" )) ((rust-mode rust-ts-mode) . ("rust-analyzer" :initializationOptions (:cargo (:buildScripts (:enable t)) :procMacro (:enable t))))
((python-mode python-ts-mode) . ("pyright-langserver" "--stdio"))
;;((bash-mode bash-ts-mode sh-mode sh-ts-mode) . ("bash-language-server" "start")) ((toml-mode toml-ts-mode) . ("taplo" "lsp" "stdio")) ((yaml-mode yaml-ts-mode) . ("yaml-language-server" "--stdio")) ((markdown-mode markdown-ts-mode) . ("marksman"))
))
(setq eglot-ignored-server-capabilities '(:documentOnTypeFormattingProvider)) )
|
参考