Giter VIP home page Giter VIP logo

.emacs.d's Introduction

Emacs

介绍

这份 Emacs 配置基于 Centaur Emacs 定制而来,增加了 Vim(Evil) 的支持,使用 Spacemacs 的快捷键绑定。因为之前一直使用 Spacemacs 所以习惯了它的快捷键。

Screenshot

./screenshot.png

安装

mv .emacs.d .emacs.d.bak
git clone --recurse-submodules -j8 https://github.com/devbins/.emacs.d.git

Buffer

快捷键描述对应函数
SPC b b切换 bufferivy-switch-buffer
SPC b d删除 bufferkill-this-buffer
SPC b p上一个 bufferprevious-buffer
SPC b n下一个 buffernext-buffer
SPC b s打开 scratch bufferswitch-to-scratch-buffer
SPC b t打开 imenu-listimenu-list-smart-toggle

文件

快捷键描述对应函数
SPC f d删除当前文件delete-this-file
SPC f R重命名文件rename-this-file
SPC f t打开 treemacstreemacs
SPC f o适用外部程序打开当前文件/文件夹open-file-or-directory-in-external-app
把当前文件转为 UTF-8 编码save-buffer-as-utf8
把 GBK 编码转为 UTF-8 编码save-buffer-gbk-as-utf8
在 finder 中显示(macOS)reveal-in-osx-finder

Git

快捷键描述对应函数
SPC g s选择 Git 仓库magit-status
SPC g tgit 时光机git-timemachine
SPC g bgit blamemagit-blame
SPC g pgit messengergit-messenger:popup-message

Org mode

在 Org-mode 中使用截图功能,并插入到当前文件

org-screenshot

Org Agenda

快捷键描述对应函数
SPC a o a打开 Org Agendaorg-agenda-list
SPC m C p打开 pomodoroorg-pomodoro

Org Mode

快捷键描述对应函数
SPC m p设置优先级org-priority
SPC m i p设置 propertyorg-set-property
SPC m i e设置 effortorg-set-effort
SPC m o T设置 tagsorg-set-tags
SPC a o c捕获内容org-capture

Org protocol

在浏览器中,把下面的网址存为标签,在需要的网页中打开标签,两个选一个就行。

javascript:window.open('org-protocol://capture?template=B'+ '&url='+encodeURIComponent(window.location.href)+ '&title='+encodeURIComponent(document.title)+ '&body='+encodeURIComponent(window.getSelection()));window.resizeTo(0,0); window.moveTo(0,window.screen.availHeight+10);

或者

javascript:location.href='org-protocol://capture?template=B&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&body='+encodeURIComponent(window.getSelection())

Org Archive

快捷键描述对应函数
SPC m s a切换 Archive tagorg-toggle-archive-tag
SPC m s A把有 Archive tag 的移动到 Archive 文件中org-archive-subtree

Org Roam

快捷键描述对应函数
SPC r a同步 org roam 节点org-roam-db-autosync-mode
SPC r f查找 org roam 节点org-roam-node-find
SPC r i插入 org roam 节点org-roam-node-insert
SPC r l给节点设置别名org-roam-alias-add

lsp

C/C++

Server 安装

Mac
brew install ccls

手动安装

brew install cmake llvm
git clone --depth=1 --recursive https://github.com/MaskRay/ccls
cd ccls
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/local/Cellar/llvm/10.0.1/lib/cmake -DUSE_SYSTEM_RAPIDJSON=off
cmake --build Release --target install
Arch
sudo pacman -S ccls
Ubuntu 20.04LTS
sudo apt install cmake zlib1g-dev libncurses-dev clang libclang-dev
git clone --depth=1 --recursive https://github.com/MaskRay/ccls
cd ccls
cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_PREFIX_PATH=/usr/lib/llvm-7 \
      -DLLVM_INCLUDE_DIR=/usr/lib/llvm-7/include \
      -DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-7/
cmake --build Release

debug

sudo pacman -S node unzip gdb lldb

M-x dap-gdb-lldb-setup

format

brew install clang-format

.clang-format example base llvm

---
BasedOnStyle: LLVM
IndentWidth: 4
AccessModifierOffset: -4
---

Go

Server 安装

go install golang.org/x/tools/gopls@latest

debug

go install github.com/go-delve/delve/cmd/dlv@latest

Rust

安装好 Rust 之后,需要安装 RLS(Rust Language Server)

rustup component add rust-anzlyer

Python

Server 安装

basedpyright
pip install basedpyright
pyright
npm i -g pyright
ruff

如果和 Anaconda 一起使用,需要在对应的 env 中安装,也就是每个 env 都要安装一遍。

pip install ruff-lsp

debug

pip install debugpy

CMake

pip install cmake-language-server

Json

npm i -g vscode-json-languageserver

Kotlin

格式化工具

brew install ktlint

Web

Javascript/Typescript

brew install deno
npm -i g typescript typescript-language-server

html/css

npm install -g vscode-langservers-extracted

vue

npm i -g @vue/language-server

YAML

npm install -g yaml-language-server

go

go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/zmb3/gogetdoc@latest
go install github.com/josharian/impl@latest
go install github.com/cweill/gotests/...@latest
go install github.com/davidrjenni/reftools/cmd/fillstruct@latest
go install github.com/fatih/gomodifytags@latest

vterm

sudo pacman -S libvterm

ctags

Mac

brew install --HEAD universal-ctags/universal-ctags/universal-ctags

Linux

git clone https://github.com/universal-ctags/ctags.git
cd ctags
./autogen.sh
./configure --prefix=/usr/local # defaults to /usr/local
make
make install # may require extra privileges depending on where to install

rtags

Mac

brew install llvm
export PATH=/usr/local/opt/llvm/bin:$PATH
git clone --recursive https://github.com/Andersbakken/rtags.git
cd rtags
mkdir build && cd build
CC=clang CXX=clang++ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on ..
make

Linux(Manjaro)

git clone --recursive https://github.com/Andersbakken/rtags.git
cd rtags
mkdir build && cd build
export GCC_VERSION=11.1.0 # 需要根据你的版本修改,可以使用 g++ --version 查看
export CXXFLAGS="-include /usr/include/c++/${GCC_VERSION}/limits"
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=on ..
make

flymake

shell

brew install shellcheck

gptel

gptel 启动一个 buffer 用来对话,标题就是提示词,写好后使用 C-c RET 来发送给大模型进行推理 使用 C-u 前缀,然后再调用,可以进行参数设置,包括选择大模型,设置指令,系统消息等等。 gptel-send 会在当前 buffer 进行推理,然后在当前光标出进行插入推理结果

播放音乐

音乐播放依赖 mplayer ,使用之前需要安装,可以通过如下方式安装

sudo pacman -S mplayer # arch
brew install mplayer # mac

设置代理

~/.emacs.d/custom.el 中加入

(setq http-proxy "127.0.0.1:1080"
      socks-proxy "127.0.0.1"
      socks-port 1086)

PDF

快捷键描述对应函数
C-w复制选中的内容到剪切板pdf-view-kill-ring-save
j往下滚动pdf-view-next-line-or-next-page
k往上滚动pdf-view-previous-line-or-previous-page

安装字体

Mac

brew tap homebrew/cask-fonts
brew install --cask font-jetbrains-mono

Manjaro

sudo pacman -S --noconfirm ttf-jetbrains-mono ttf-fira-code ttf-symbola

native-comp 支持

Mac

brew reinstall gcc libgccgit
brew install emacs-plus@28 --with-ctags --with-dbus --with-mailutils --with-no-frame-refocus --with-xwidgets --with-no-titlebar --with-native-comp

如果启动直接报错,需要使用 emacs -Q 打开,让后通过 load-library 把配置文件加载进来,等待编译完成,就可以使用了。 也可以手动调用 (native-compile-async "~/.emacs.d" 'recursively) 进行编译

error invoke gcc driver

使用如下代码设置环境变量,然后使用 load-library 加载配置文件。

(setenv "LIBRARY_PATH" "/usr/local/opt/gcc/lib/gcc/10:/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0")

ArchLinux

sudo pacman -S emacs-git
# gcc emacs
sudo pacman -S emacs-native-comp-git

Ubuntu

sudo snap install emacs --edge --classic

最小启动配置

emacs -Q -l init-mini.el

sbcl

Mac

brew install sbcl

使用 Emacs 编辑浏览器 TextArea

替换与搜索

  1. SPC s p 搜索内容,这时候按下 M-n 可以获取光标下的单词
  2. C-c C-e 导出搜索结果到 grep buffer embark-export
  3. C-c C-w 切换 grep-modewgrep-mode
  4. 替换
  5. C-c C-c 保存更改, C-c C-k 取消更改

【傻瓜教程】Emacs 定身术之 consult+embark+wgrep 跨文件批量搜索替换 - Emacs-general - Emacs China

consult-ripgrep

过滤文件/目录

text -- -g *.py 只显示 py 中匹配的 text -- -g !*.py 显示除了 py 中匹配的

consult-line

排除不要的

text !text1text1 的不显示

FAQ

json-read: JSON readtable error: 84

需要把 Python 降到 3.10 ,不能使用 3.11

json-readtable-error 122

在 path 中没有找到 Python ,更新 env

void-function org-outline-overlay-data

进入 ~/.emacs.d/elpa/ 删除 expand-region 后重启两次 Emacs , 第一次会碰到 smart-region 的问题

org-copy-subtree: Invalid function: org-preserve-local-variables

cd ~/.emacs.d/elpa
find org*/*.elc -print0 | xargs -0 rm

Failed to verify signature memory-usage-0.2.el.sig

执行以下两条指令 M-: (setq package-check-signature nil) RET M-x package-install memory-usage RET

Thanks

  • Centaur Emacs A Fancy and Fast Emacs Configuration
  • Spacemacs A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it’s Emacs and Vim!

.emacs.d's People

Contributors

devbins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zkcarter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.