aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-07-19 12:28:39 -0400
committerJustin M. Keyes <justinkz@gmail.com>2025-07-19 12:28:39 -0400
commitcf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa (patch)
treea9233adbe1e1b4803d696c26efdd238b8af5bd7c /README.md
parentdocs: readme (diff)
downloadnvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar.gz
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar.bz2
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar.lz
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar.xz
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.tar.zst
nvim-lspconfig-cf8b8e8438fded3be8c1fc18d26a66ef7d97d8fa.zip
docs: how to create a config
fix #3941
Diffstat (limited to 'README.md')
-rw-r--r--README.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/README.md b/README.md
index 16b218e2..dc045551 100644
--- a/README.md
+++ b/README.md
@@ -85,6 +85,39 @@ vim.lsp.config('rust_analyzer', {
})
```
+## Create a new config
+
+To create a new config you can either (1) use `vim.lsp.config` or (2) create
+a file `lsp/<config-name>.lua` somewhere on your 'runtimepath'.
+
+### Example: define a new config as code
+
+1. Run `:lua vim.lsp.config('foo', {cmd={'true'}})`
+2. Run `:lua vim.lsp.enable('foo')`
+3. Run `:checkhealth vim.lsp`, the new config is listed under "Enabled Configurations". 😎
+
+### Example: define a new config as a file
+
+1. Create a file `lsp/foo.lua` somewhere on your 'runtimepath'.
+ ```
+ :exe 'edit' stdpath('config') .. '/lsp/foo.lua'
+ ```
+2. Add this code to the file (or copy any of the examples from the [lsp/ directory](./lsp/) in this repo):
+ ```
+ return {
+ cmd = { 'true' },
+ }
+ ```
+3. Save the file (with `++p` to ensure its parent directory is created).
+ ```
+ :write ++p
+ ```
+4. Enable the config.
+ ```
+ :lua vim.lsp.enable('foo')
+ ```
+5. Run `:checkhealth vim.lsp`, the new config is listed under "Enabled Configurations". 🌈
+
## Troubleshooting
Start with `:checkhealth vim.lsp` to troubleshoot. The most common reasons a language server does not start or attach are: