eglot-booster 项目使用教程
eglot-boosterBoost eglot using lsp-booster项目地址:https://gitcode.com/gh_mirrors/eg/eglot-booster
1. 项目的目录结构及介绍
eglot-booster/
├── LICENSE
├── README.md
├── eglot-booster.el
- LICENSE: 项目的许可证文件,采用 GPL-3.0 许可证。
- README.md: 项目的说明文档,包含项目的基本介绍和使用方法。
- eglot-booster.el: 项目的主要文件,用于增强 eglot 的功能。
2. 项目的启动文件介绍
项目的主要启动文件是 eglot-booster.el
。该文件包含了增强 eglot 功能的代码。以下是文件的主要内容和功能介绍:
;; eglot-booster.el
(eval-when-compile (require 'cl-lib))
(require 'seq)
(require 'eglot)
(require 'jsonrpc)
(defun eglot-server-programs)
(cond ((functionp (cdr entry))
(cl-incf cnt)
(let ((fun (cdr entry)))
(setcdr entry (lambda (&rest r)
(let ((res (apply fun r)))
(if (eglot-booster-plain-command res)
(append boost res)
res))))))
((eglot-booster-plain-command (cdr entry))
(cl-incf cnt)
(setcdr entry (append boost (cdr entry)))))
(defalias 'jsonrpc--json-read (lambda ()
(or (and (= (following-char) #)
(let ((bytecode (read (current-buffer))))
(when (byte-code-function-p bytecode)
(funcall bytecode))))
(funcall orig-read))))
(message "Boosted %d eglot-server-programs" cnt))
(put 'eglot-server-programs 'lsp-booster-p t)))
(defun eglot-booster-reset ()
(put 'eglot-server-programs 'lsp-booster-p nil))
(provide 'eglot-booster)
- eval-when-compile: 用于在编译时加载
cl-lib
库。 - require: 加载
seq
,eglot
,jsonrpc
库。 - defun eglot-server-programs: 定义了增强 eglot 服务器程序的函数。
- defalias jsonrpc--json-read: 重定义了
jsonrpc--json-read
函数,用于增强 JSON-RPC 的读取功能。 - message: 输出增强的 eglot 服务器程序数量。
- provide: 提供
eglot-booster
模块。
3. 项目的配置文件介绍
项目的配置文件主要是 eglot-booster.el
中的配置项。以下是一些关键的配置项:
(use-package eglot-booster
:ensure t
:straight (:type git :host github :repo "jdtsmith/eglot-booster")
:after eglot
:config (eglot-booster-mode))
- use-package eglot-booster: 使用
use-package
宏来加载和配置eglot-booster
。 - :ensure t: 确保包被安装。
- :straight: 使用
straight.el
来管理包的安装。 - :after eglot: 确保在
eglot
加载后加载eglot-booster
。 - :config (eglot-booster-mode): 启用
eglot-booster
模式。
通过以上配置,可以确保 eglot-booster
在 eglot
加载后被正确加载和启用,从而增强 eglot 的功能。
eglot-boosterBoost eglot using lsp-booster项目地址:https://gitcode.com/gh_mirrors/eg/eglot-booster