diff options
| author | Artem Shush <shushtain@gmail.com> | 2025-11-23 08:52:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-22 22:52:22 -0800 |
| commit | 2664b5fbfff73233404faca7b7e74bbf10b7e236 (patch) | |
| tree | 83bb33f44bf0474adb06bb1a9e19a2a904d3fe00 /README.md | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar.gz nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar.bz2 nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar.lz nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar.xz nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.tar.zst nvim-lspconfig-2664b5fbfff73233404faca7b7e74bbf10b7e236.zip | |
docs(readme): mention after/lsp/ #4212
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -83,8 +83,7 @@ To customize, see: Extra settings can be specified for each LSP server. With Nvim 0.11+ you can [extend a config](https://neovim.io/doc/user/lsp.html#lsp-config) by calling -`vim.lsp.config('…', {…})`. (You can also copy any config directly from -[`lsp/`](./lsp/) and put it in a local `lsp/` directory in your 'runtimepath'). +`vim.lsp.config('…', {…})`. ```lua vim.lsp.config('rust_analyzer', { @@ -95,22 +94,29 @@ vim.lsp.config('rust_analyzer', { }) ``` -## Create a new config +### Config priority -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'. +Configs are sourced in this order: -### Example: define a new config as code +1. `lsp/` in 'runtimepath' +2. `after/lsp/` in 'runtimepath' +3. `vim.lsp.config()` + +If you install nvim-lspconfig or similar plugins, the order that configs are applied depends on the load order. To ensure that your own config "wins" and overrides the others, use `after/lsp/` and/or `vim.lsp.config()` to override/extend the defaults. + +## Creating a 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 +### As a file -1. Create a file `lsp/foo.lua` somewhere on your 'runtimepath'. +1. Create a file `after/lsp/foo.lua` somewhere on your 'runtimepath'. ``` - :exe 'edit' stdpath('config') .. '/lsp/foo.lua' + :exe 'edit' stdpath('config') .. '/after/lsp/foo.lua' ``` 2. Add this code to the file (or copy any of the examples from the [lsp/ directory](./lsp/) in this repo): ``` |
