|
| 1 | +# LSP Configuration Directory |
| 2 | + |
| 3 | +This directory contains server-specific configurations for the Neovim 0.10+ core LSP system. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +The LSP configuration uses the new Neovim 0.10+ core LSP approach: |
| 8 | + |
| 9 | +- **Global Configuration**: Set via `vim.lsp.config('*', {...})` in the main init.lua |
| 10 | +- **Server Activation**: Done via `vim.lsp.enable(servers)` instead of individual setup calls |
| 11 | +- **Server-Specific Config**: Individual files in this directory that return configuration tables |
| 12 | + |
| 13 | +## File Structure |
| 14 | + |
| 15 | +``` |
| 16 | +lsp/ |
| 17 | +├── README.md # This documentation |
| 18 | +├── _utils.lua # Shared utilities to reduce redundancy |
| 19 | +├── lua_ls.lua # Lua language server config |
| 20 | +├── gopls.lua # Go language server config |
| 21 | +├── tsserver.lua # TypeScript/JavaScript server config |
| 22 | +├── pyright.lua # Python language server config |
| 23 | +├── jsonls.lua # JSON language server config |
| 24 | +├── yamlls.lua # YAML language server config |
| 25 | +└── [other servers].lua # Additional server configurations |
| 26 | +``` |
| 27 | + |
| 28 | +## Configuration Format |
| 29 | + |
| 30 | +Each server configuration file should return a table with server-specific settings: |
| 31 | + |
| 32 | +```lua |
| 33 | +-- Example: lsp/example_server.lua |
| 34 | +local utils = require('lsp._utils') |
| 35 | + |
| 36 | +return { |
| 37 | + cmd = { 'example-language-server', '--stdio' }, |
| 38 | + filetypes = { 'example' }, |
| 39 | + root_dir = utils.root_dir(utils.root_patterns.git), -- Use shared patterns |
| 40 | + settings = { |
| 41 | + example = { |
| 42 | + -- Server-specific settings |
| 43 | + }, |
| 44 | + }, |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Utilities |
| 49 | + |
| 50 | +The `_utils.lua` file provides shared utilities to reduce redundancy: |
| 51 | + |
| 52 | +### Root Directory Patterns |
| 53 | + |
| 54 | +Common root directory patterns are predefined: |
| 55 | +- `utils.root_patterns.js_ts` - JavaScript/TypeScript projects |
| 56 | +- `utils.root_patterns.python` - Python projects |
| 57 | +- `utils.root_patterns.go` - Go projects |
| 58 | +- `utils.root_patterns.git` - Generic git-based projects |
| 59 | + |
| 60 | +### Schema Integration |
| 61 | + |
| 62 | +For JSON/YAML servers with schemastore integration: |
| 63 | +```lua |
| 64 | +schemas = utils.get_schemas('json'), -- or 'yaml' |
| 65 | +``` |
| 66 | + |
| 67 | +## Adding New Servers |
| 68 | + |
| 69 | +1. Create a new file `lsp/server_name.lua` |
| 70 | +2. Return a configuration table with server-specific settings |
| 71 | +3. Add the server name to the `servers` list in `lua/LoneExile/lsp/init.lua` |
| 72 | +4. Use shared utilities from `_utils.lua` when possible |
| 73 | + |
| 74 | +## Migration from Old System |
| 75 | + |
| 76 | +This configuration replaces the previous approach: |
| 77 | + |
| 78 | +**Old (deprecated):** |
| 79 | +```lua |
| 80 | +lspconfig[server].setup({ |
| 81 | + -- configuration |
| 82 | +}) |
| 83 | +``` |
| 84 | + |
| 85 | +**New (current):** |
| 86 | +```lua |
| 87 | +-- Global config in init.lua |
| 88 | +vim.lsp.config('*', { ... }) |
| 89 | + |
| 90 | +-- Server-specific config in lsp/server.lua |
| 91 | +return { ... } |
| 92 | + |
| 93 | +-- Server activation in init.lua |
| 94 | +vim.lsp.enable(servers) |
| 95 | +``` |
| 96 | + |
| 97 | +## Benefits |
| 98 | + |
| 99 | +- **Performance**: Global configuration reduces redundancy and improves startup time |
| 100 | +- **Maintainability**: Server-specific configs are isolated and easier to manage |
| 101 | +- **Consistency**: Shared utilities ensure consistent patterns across servers |
| 102 | +- **Simplicity**: Adding new servers requires minimal configuration |
0 commit comments