The features it supports are:
[[file:images/show.gif]]
git clone https://github.com/jadestrong/lsp-copilot.git ./your-directory cd ./your-directory cargo build --release
rm lsp-copilot cp ./target/release/lsp-copilot ./
** Doom Emacs package.el
(package! lsp-copilot :recipe (:host github :repo "jadestrong/lsp-copilot" :files ("lsp-copilot.el" "lsp-copilot") :pre-build (("cargo" "build" "--release") ("cp" "./target/release/lsp-copilot" "./"))))
(use-package lsp-copilot ;; :load-path "/path/to/lsp-copilot" :config (add-hook! '( tsx-ts-mode-hook js-ts-mode-hook typescript-mode-hook typescript-ts-mode-hook rjsx-mode-hook less-css-mode-hook web-mode-hook python-ts-mode-hook rust-mode-hook rustic-mode-hook rust-ts-mode-hook toml-ts-mode-hook conf-toml-mode-hook bash-ts-mode-hook ) #'lsp-copilot-mode))
;; Doom Emacs (set-lookup-handlers! 'lsp-copilot-mode :definition '(lsp-copilot-find-definition :async t) :references '(lsp-copilot-find-references :async t) :implementations '(lsp-copilot-find-implementations :async t) :type-definition '(lsp-copilot-find-type-definition :async t) :documentation '(lsp-copilot-describe-thing-at-point :async t))
The configuration for a new language can refer to the [[https://github.com/helix-editor/helix/blob/master/languages.toml][Helix configuration]]. Supported fields are based on [[https://github.com/jadestrong/lsp-copilot/blob/main/languages.toml][the built-in configuration file]], and only LSP-related fields are supported. Open custom language config file by ~lsp-copilot-open-config-file~ and add your config, then execute ~lsp-copilot-restart~.
The configuration fields for adding language support are: ~name、roots、language-id、file-types、language-servers~ . Other fields in the Helix configuration are not supported.
[languge-server.vls] command = "vls" args = ["--stdio"]
[[language]] name = "vue" roots = ["package.json"] language-id = "vue" file-types = ["vue"] language-servers = ["vls"]
yarn global add @vue/language-server @vue/typescript-plugin
[language-server.typescript-language-server] config.plugins = [ { name = "@vue/typescript-plugin", location = "${your-path}/node_modules/@vue/typescript-plugin", languages = ["vue"]} ]
[language-server.vue-language-server] command = "vue-language-server" args = ["--stdio"] config.typescript = { tsdk = "${your-path}/node_modules/typescript/lib" } config.vue = { hybridMode = false }
[[language]] name = "vue" roots = ["package.json"] language-id = "vue" file-types = ["vue", "ts"] language-servers = ["vue-language-server", "typescript-language-server"]
[[language]] name = "typescript" language-id = "typescript" file-types = ["ts", "mts", "cts"] roots = ["package.json"] language-servers = [ { name = "typescript-language-server", except-features = [ "format", ] }, { name = "eslint", support-workspace = true, config-files = [".eslintrc.js", ".eslintrc.cjs", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc", ".eslintrc.json"] }, ]
~except-features~ can disable server's feature, view the [[https://github.com/jadestrong/lsp-copilot/blob/2ffc7cf0d5e42f66076feabee4c099a36f70997f/src/syntax.rs#L153][supported features]].
Debug ** Server bug
~(setq lsp-copilot-log-level 3)~
M-x ~lsp-copilot-restart~
M-x ~lsp-copilot-open-log-file~ ** Server crash
Open ~lsp-copilot-events~ buffer ** Lsp server message
Open ~lsp-copilot-log~
Commands
Customization
| Variable | Default | Description |
| lsp-copilot-user-languages-config | user-emacs-directory/lsp-copilot/languages.toml
| Where custom language server configurations are stored |
| lsp-copilot-log-file-directory | temporary-file-directory | Log file storage directory |
| lsp-copilot-log-level | 1 | A number indicating the log level. Defaults to 1. Warn = 0, Info = 1, Debug = 2, Trace = 3 |
Recommend config ** Company and Corfu
;; company (setq company-idle-delay 0) ;; If you encounter issues when typing Vue directives (e.g., v-), you can try setting it to 1. I'm not sure if it's a problem with Volar. (setq company-minimum-prefix-length 2) (setq company-tooltip-idle-delay 0)
;; corfu (setq corfu-auto-delay 0) (setq corfu-popupinfo-delay '(0.1 . 0.1))
** company-box
(defun company-box-icons--lsp-copilot (candidate) (-when-let* ((copilot-item (get-text-property 0 'lsp-copilot--item candidate)) (lsp-item (plist-get copilot-item :item)) (kind-num (plist-get lsp-item :kind))) (alist-get kind-num company-box-icons--lsp-alist)))
(setq company-box-icons-functions (cons #'company-box-icons--lsp-copilot company-box-icons-functions))
** flycheck or flymake Currently, only Flycheck is supported. You can refer to the configuration in [[https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-diagnostics.el][lsp-mode]] to add support for others.
Regarding the communication between Emacs and Lsp-Copilot, I would like to especially thank [[https://github.com/copilot-emacs/copilot.el][copilot.el]] and [[https://github.com/rust-lang/rust-analyzer][rust-analyzer]]. The usage of jsonrpc.el was learned from copilot.el, while the approach to receiving and handling Emacs requests was inspired by the implementation in rust-analyzer.
The various methods used to implement LSP-related functionality on the Emacs side were learned from [[https://github.com/emacs-lsp/lsp-mode][lsp-mode]] and [[https://github.com/joaotavora/eglot][eglot]]. Without their guidance, many of these features would have been difficult to implement.
Regarding the communication data format between Emacs and Lsp-Copilot, I would like to especially thank [[https://github.com/blahgeek/emacs-lsp-booster][emacs-lsp-booster]]. The project integrates the implementation of emacs-lsp-booster, which encodes the JSON data returned to Emacs, further reducing the load on Emacs.