emacs-lsp-proxy 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +185 -34
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # LSP-PROXY (formerly LSP-COPILOT)
2
2
 
3
- *This project has been renamed from lsp-copilot to lsp-proxy to better reflect its core functionality as a communication proxy and aggregator between Emacs and multiple LSP servers. The name change does not affect the project's features or goals.*
4
-
5
3
  ## Introduction
6
4
  Lsp-Proxy is an LSP (Language Server Protocol) client for Emacs, implemented in Rust and inspired by [lsp-bridge](https://github.com/manateelazycat/lsp-bridge). It uses `jsonrpc.el` to facilitate communication between Emacs and the Lsp-Proxy Server. The Lsp-Proxy Server acts as an intermediary between Emacs and various language servers, handling communication with the language servers, processing the responses, and returning them to Emacs.
7
5
 
@@ -35,6 +33,7 @@ This will automatically install the appropriate binary for your platform (Linux
35
33
 
36
34
  ### Manually
37
35
  Before installing LSP-PROXY manually, you should install rust and cargo first.
36
+
38
37
  ```bash
39
38
  git clone https://github.com/jadestrong/emacs-lsp-proxy.git ./your-directory
40
39
  cd ./your-directory
@@ -50,6 +49,7 @@ You can download the prebuilt binary from [releases](https://github.com/jadestro
50
49
  > The application cannot be opened because it is from an unidentified developer. You can allow this app to run by going to System Settings > Privacy & Security and selecting 'Allow Anyway' for this app.
51
50
 
52
51
  ## How to use
52
+
53
53
  ```emacs-lisp
54
54
  (use-package lsp-proxy
55
55
  ;; :load-path "/path/to/lsp-proxy"
@@ -60,31 +60,184 @@ You can download the prebuilt binary from [releases](https://github.com/jadestro
60
60
  (add-hook 'typescript-ts-mode-hook #'lsp-proxy-mode))
61
61
  ```
62
62
 
63
+ ### DOOM Emacs
64
+ - Recommend
65
+ ``` elisp
66
+ (package! lsp-proxy :recipe (:host github :repo "jadestrong/lsp-proxy"
67
+ :files ("lsp-proxy.el"))
68
+ ```
69
+ - Manually
63
70
  ```elisp
64
- ;; Doom Emacs
71
+
65
72
  (package! lsp-proxy :recipe (:host github :repo "jadestrong/lsp-proxy"
66
73
  :files ("lsp-proxy.el" "emacs-lsp-proxy")
67
74
  :pre-build (("cargo" "build" "--release") ("cp" "./target/release/emacs-lsp-proxy" "./"))))
75
+ ```
68
76
 
69
- (set-lookup-handlers! 'lsp-proxy-mode
77
+ ``` elisp
78
+ (use-package! lsp-proxy
79
+ :config
80
+ (set-lookup-handlers! 'lsp-proxy-mode
70
81
  :definition '(lsp-proxy-find-definition :async t)
71
82
  :references '(lsp-proxy-find-references :async t)
72
83
  :implementations '(lsp-proxy-find-implementations :async t)
73
84
  :type-definition '(lsp-proxy-find-type-definition :async t)
74
- :documentation '(lsp-proxy-describe-thing-at-point :async t))
85
+ :documentation '(lsp-proxy-describe-thing-at-point :async t)))
86
+
75
87
  ```
76
88
 
77
- ## Add a new language
78
- Performed simple tests on Windows 11 and Arch Linux, it works properly. I have tested it on macOS and use it for daily development in JavaScript, Rust, etc. Therefore, tools like vtsls, typescript-language-server, eslint, tailwindcss, css, and others work fine
79
- - JavaScript/Typescript: [vtsls](https://github.com/yioneko/vtsls) (built-in)、[typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
80
- - eslint、html、css、html: [vscode-langservers-extracted](https://github.com/hrsh7th/vscode-langservers-extracted) +the latest vscode-eslint has removed the publishDiagnostics method and only supports the pullDiagnostics method, so currently we can only use `vscode-langservers-extracted@4.8`+.
81
- - tailwindcss: [@tailwindcss/language-server](https://www.npmjs.com/package/@tailwindcss/language-server)
89
+ ## How to add a new language
90
+
91
+ ### Supported Language Servers
92
+
93
+ **Built-in Support:**
94
+ - **JavaScript/TypeScript**: [vtsls](https://github.com/yioneko/vtsls), [typescript-language-server](https://github.com/typescript-language-server/typescript-language-server)
95
+ - **Web Technologies**: [vscode-langservers-extracted](https://github.com/hrsh7th/vscode-langservers-extracted) (eslint, html, css)
96
+ - **CSS Framework**: [@tailwindcss/language-server](https://www.npmjs.com/package/@tailwindcss/language-server)
97
+ - **Rust**: rust-analyzer
98
+ - **Python**: basedpyright, pylsp
99
+ - **Go**: gopls
100
+ - And many more in the built-in configuration
101
+
102
+ ### Quick Setup Guide
103
+
104
+ 1. **Open configuration file**
105
+ ```elisp
106
+ M-x lsp-proxy-open-config-file
107
+ ```
108
+
109
+ 2. **Add language server definition**
110
+ ```toml
111
+ [language-server.your-server]
112
+ command = "your-language-server" # Required: executable command
113
+ args = ["--stdio"] # Optional: command arguments
114
+ environment = { VAR = "value" } # Optional: environment variables
115
+ timeout = 20 # Optional: request timeout (default: 20s)
116
+ config = { key = "value" } # Optional: initializationOptions
117
+ experimental = { key = "value" } # Optional: experimental client capabilities., e.g. rust-analyzer
118
+ ```
119
+
120
+ 3. **Define language mapping**
121
+ ```toml
122
+ [[language]]
123
+ name = "your-language" # Required: unique language name
124
+ language-id = "your-language" # Required: LSP language identifier
125
+ file-types = ["ext1", "ext2"] # Required: file extensions
126
+ roots = ["project-file.json"] # Optional: project root detection files
127
+ language-servers = ["your-server"] # Required: associated servers
128
+ ```
129
+
130
+ The `language-servers` field can be a simple string array containing the server names you configured above. It can also be configured with detailed options. See the **Advanced Configuration** section for more information.
131
+
132
+ **Note:** The language's name can be customized, but the `language-id` should correspond to the `file-types`. For example:
133
+ - `["js", "mjs", "cjs"]` files correspond to `javascript` language ID
134
+ - `[jsx]` files correspond to `javascriptreact` language ID
135
+ - `[tsx]` files correspond to `typescriptreact` language ID
136
+
137
+ 4. **Restart LSP-Proxy**
138
+ ```elisp
139
+ M-x lsp-proxy-restart
140
+ ```
141
+
142
+ ### Advanced Configuration
143
+
144
+ #### Multi-Server Setup
145
+ Configure multiple language servers for a single language:
146
+ ```toml
147
+ [[language]]
148
+ name = "typescript"
149
+ language-servers = [
150
+ { name = "vtsls", except-features = ["format"] },
151
+ { name = "eslint", support-workspace = true }
152
+ ]
153
+ ```
154
+
155
+ You can configure multiple language servers together for a single file type. For example, you can use `vtsls`, `eslint`, and `tailwindcss` for TypeScript/JSX files, or `eslint`, `vue-language-server`, and `tailwindcss` for Vue files.
156
+
157
+ When multiple language servers support the same feature, you can control which server provides specific functionality by using `except-features` or `only-features`. For example, you can disable the `format` feature from the `vtsls` language server while keeping it enabled for other servers.
158
+
159
+ #### Feature Control Options
160
+ - **`except-features`**: Disable specific server capabilities. See the **Supported LSP Features** section for available features.
161
+ - **`only-features`**: Enable only specified features (whitelist). See the **Supported LSP Features** section for available features.
162
+ - **`support-workspace`**: Enable multi-workspace support, allowing language servers like `eslint` to share a single server instance across multiple projects.
163
+ - **`library-directories`**: Additional library search paths for external dependencies. Some language servers manage libraries outside the project directory (e.g., rust-analyzer uses `~/.cargo/registry/src` and `~/.rustup/toolchains`, Dart uses `~/.pub-cache`). Since these libraries are shared across multiple projects, LSP-Proxy needs to send proper notifications (like `didOpen`) to the associated language server when navigating to files in these directories.
164
+ - **`config-files`**: Optional configuration files for server activation. When configured, the language server will only activate if at least one of the specified configuration files exists in the workspace root (e.g., `eslint.config.ts` for ESLint server, `vue.config.ts` for vue-language-server).
165
+
166
+ #### Server Configuration Examples
82
167
 
83
- The configuration for a new language can refer to the [Helix configuration](https://github.com/helix-editor/helix/blob/master/languages.toml). Supported fields are based on [the built-in configuration file](https://github.com/jadestrong/lsp-copilot/blob/main/languages.toml), and only LSP-related fields are supported.
84
- Open custom language config file by `lsp-proxy-open-config-file` and add your config, then execute `lsp-proxy-restart`.
168
+ There are two syntaxes for setting a language server's configuration. Your configured values will be passed to the language server in the `initialize` request's `initializationOptions` and will also be used for `workspace/configuration` requests.
85
169
 
86
- 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.
170
+ **Python with advanced configuration:**
171
+ ```toml
172
+ [language-server.basedpyright]
173
+ command = "basedpyright-langserver"
174
+ args = ["--stdio"]
175
+ config.basedpyright.analysis.typeCheckingMode = "basic"
87
176
 
177
+ [[language]]
178
+ name = "python"
179
+ language-servers = [
180
+ { name = "basedpyright", library-directories = ["~/.local/lib/python3.*/site-packages"] }
181
+ ]
182
+ ```
183
+
184
+ The following syntax is different from the above example, but achieves the same effect as long as it follows valid TOML syntax:
185
+ ``` toml
186
+ [language-server.basedpyright.config.basedpyright]
187
+ analysis.typeCheckingMode = "basic"
188
+ ```
189
+
190
+ ### Supported LSP Features
191
+
192
+ LSP-Proxy supports all major Language Server Protocol features:
193
+
194
+ **Navigation & References:**
195
+ - `goto-declaration` - Jump to symbol declarations
196
+ - `goto-definition` - Jump to symbol definitions
197
+ - `goto-type-definition` - Jump to type definitions
198
+ - `goto-reference` - Find all references
199
+ - `goto-implementation` - Find implementations
200
+
201
+ **Code Intelligence:**
202
+ - `completion` - Auto-completion with snippets
203
+ - `inline-completion` - Inline completion suggestions
204
+ - `completion-resolve` - Detailed completion information
205
+ - `signature-help` - Function signature assistance
206
+ - `hover` - Symbol documentation on hover
207
+ - `document-highlight` - Symbol highlighting
208
+ - `inlay-hints` - Inline type and parameter hints
209
+
210
+ **Code Quality:**
211
+ - `diagnostics` - Error and warning reporting
212
+ - `pull-diagnostics` - On-demand diagnostic retrieval
213
+ - `code-action` - Quick fixes and refactoring
214
+ - `rename-symbol` - Symbol renaming across workspace
215
+ - `format` - Code formatting
216
+
217
+ **Workspace Features:**
218
+ - `document-symbols` - File outline and structure
219
+ - `workspace-symbols` - Project-wide symbol search
220
+ - `workspace-command` - Execute workspace-specific commands
221
+
222
+ ### Configuration Sources
223
+
224
+ LSP-Proxy uses a layered configuration system:
225
+
226
+ 1. **Built-in configuration**: Default language servers and settings
227
+ 2. **User configuration**: Custom overrides in `${user-emacs-directory}/lsp-proxy/languages.toml`, opened by `M-x lsp-proxy-open-config-file`
228
+ 3. **Deep merging**: User config merges with built-in defaults (3 levels deep)
229
+
230
+ The configuration format is compatible with [Helix editor](https://github.com/helix-editor/helix/blob/master/languages.toml) language definitions, focusing on LSP-related fields only.
231
+
232
+ ### Troubleshooting
233
+
234
+ - **Server not starting**: Check `command` path and `args` correctness
235
+ - **No completions**: Verify `language-id` matches server expectations
236
+ - **Project not detected**: Ensure `roots` files exist in your project
237
+ - **Features missing**: Check server capabilities and `except-features` configuration
238
+ - **Debug**: Use `M-x lsp-proxy-open-log-file` and set `(setq lsp-proxy-log-level 3)`
239
+
240
+ ## Example
88
241
 
89
242
  - Vue2:
90
243
  ```toml
@@ -102,46 +255,44 @@ language-servers = ["vls"]
102
255
 
103
256
  - Vue3
104
257
  ```sh
105
- yarn global add @vue/language-server @vue/typescript-plugin
258
+ yarn global add @vue/language-server @vue/typescript-plugin typescript
106
259
  ```
107
260
 
108
261
  ```toml
262
+ # typescript-language-server
109
263
  [language-server.typescript-language-server]
110
264
  config.plugins = [
111
- { name = "@vue/typescript-plugin", location = "${your-path}/node_modules/@vue/typescript-plugin", languages = ["vue"]}
265
+ { name = "@vue/typescript-plugin", location = "${YOUR-PATH}/node_modules/@vue/typescript-plugin", languages = ["vue"], enableForWorkspaceTypeScriptVersions = true, configNamespace = "typescript" }
266
+ ]
267
+
268
+ # or vtsls
269
+ [language-server.vtsls.config.vtsls.tsserver]
270
+ globalPlugins = [
271
+ { name = "@vue/typescript-plugin", location = "${YOUR-PATH}/node_modules/@vue/typescript-plugin", languages = ["vue"], enableForWorkspaceTypeScriptVersions = true, configNamespace = "typescript" }
112
272
  ]
113
273
 
114
274
  [language-server.vue-language-server]
115
275
  command = "vue-language-server"
116
276
  args = ["--stdio"]
117
- config.typescript = { tsdk = "${your-path}/node_modules/typescript/lib" }
118
- config.vue = { hybridMode = false }
119
277
 
120
278
  [[language]]
121
279
  name = "vue"
122
280
  roots = ["package.json"]
123
281
  language-id = "vue"
124
- file-types = ["vue", "ts"]
125
- language-servers = ["vue-language-server", "typescript-language-server"]
126
-
127
- # Override the build-in config. The built-in configuration uses vtsls, but it seems incompatible with vue-language-server. It could also be that my configuration is incorrect.
128
- # Others, such as JavaScript and TSX, can be added as needed.
129
- [[language]]
130
- name = "typescript"
131
- language-id = "typescript"
132
- file-types = ["ts", "mts", "cts"]
133
- roots = ["package.json"]
282
+ file-types = ["vue"]
134
283
  language-servers = [
135
- { name = "typescript-language-server", except-features = [
136
- "format",
137
- ] },
138
- { name = "eslint", support-workspace = true, config-files = [".eslintrc.js", ".eslintrc.cjs", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc", ".eslintrc.json", , "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "eslint.config.mts", "eslint.config.cts"] },
284
+ { name = "vue-language-server", except-features = ["goto-definition", "goto-implementation", "goto-type-definition", "goto-declaration", "goto-reference"] },
285
+ "vtsls"
139
286
  ]
287
+ # or
288
+ # language-servers = [
289
+ # { name = "vue-language-server", except-features = ["goto-definition", "goto-implementation", "goto-type-definition", "goto-declaration", "goto-reference"] },
290
+ # "typescript-language-server"
291
+ # ]
140
292
  ```
141
293
 
142
- - `except-features` can disable server's feature, view the [supported features](https://github.com/jadestrong/lsp-copilot/blob/c3d314d9bc1778b35c6ad2a046fa8b76cad94db4/src/syntax.rs#L150-L168).
143
-
144
294
  ## Debug
295
+
145
296
  ### Server bug
146
297
  - `(setq lsp-proxy-log-level 3)`
147
298
  - M-x `lsp-proxy-restart`
@@ -229,4 +380,4 @@ Regarding the communication between Emacs and Lsp-Proxy, I would like to especia
229
380
 
230
381
  The various methods used to implement LSP-related functionality on the Emacs side were learned from [lsp-mode](https://github.com/emacs-lsp/lsp-mode) and [eglot](https://github.com/joaotavora/eglot). Without their guidance, many of these features would have been difficult to implement.
231
382
 
232
- Regarding the communication data format between Emacs and Lsp-Proxy, I would like to especially thank [emacs-lsp-booster](https://github.com/blahgeek/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.
383
+ Regarding the communication data format between Emacs and Lsp-Proxy, I would like to especially thank [emacs-lsp-booster](https://github.com/blahgeek/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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emacs-lsp-proxy",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "scripts": {
5
5
  "postinstall": "node ./install.js"
6
6
  },
@@ -17,11 +17,11 @@
17
17
  ],
18
18
  "author": "jadestrong",
19
19
  "optionalDependencies": {
20
- "@emacs-lsp-proxy/darwin-x64": "0.5.5",
21
- "@emacs-lsp-proxy/darwin-arm64": "0.5.5",
22
- "@emacs-lsp-proxy/linux-x64": "0.5.5",
23
- "@emacs-lsp-proxy/linux-arm64": "0.5.5",
24
- "@emacs-lsp-proxy/win32-x64": "0.5.5"
20
+ "@emacs-lsp-proxy/darwin-x64": "0.5.7",
21
+ "@emacs-lsp-proxy/darwin-arm64": "0.5.7",
22
+ "@emacs-lsp-proxy/linux-x64": "0.5.7",
23
+ "@emacs-lsp-proxy/linux-arm64": "0.5.7",
24
+ "@emacs-lsp-proxy/win32-x64": "0.5.7"
25
25
  },
26
26
  "license": "ISC",
27
27
  "description": "An LSP client for Emacs implemented in Rust."