1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
# debian-lsp
[](https://github.com/jelmer/debian-lsp/actions/workflows/ci.yml)
[](https://github.com/jelmer/debian-lsp/actions/workflows/test.yml)
Language Server Protocol implementation for Debian control files.
At the moment this is fairly basic, but the goal is to provide a useful LSP server for editing Debian control files (`debian/control`) with features like:
- Field name completion
- Common package name suggestions
- Diagnostics for common issues
- Quick fixes for common issues
- Integration with lintian-brush, apply-multiarch-hints, etc
## Features
- Field name completion for Debian control files
- Common package name suggestions
- Works with debian/control files
- Diagnostic analysis for Debian control files
- Quick fixes for common issues
### Diagnostics
The LSP provides the following diagnostic capabilities:
- **Field casing validation**: Detects incorrectly cased field names (e.g., `source` instead of `Source`)
- **Parse error reporting**: Reports parsing errors in control file syntax
### Quick Fixes
The LSP offers automatic fixes for detected issues:
- **Field casing corrections**: Automatically fix field names to use proper Debian control file casing
- Example: `source` → `Source`, `maintainer` → `Maintainer`
- Available as code actions in your editor
## Installation
### Building the LSP server
```bash
cargo build --release
```
The binary will be available at `target/release/debian-lsp`.
### Using with VS Code
Add the following configuration to your VS Code `settings.json`:
```json
{
"languageServerProtocols.debian-lsp.command": [
"/path/to/debian-lsp/target/release/debian-lsp"
],
"languageServerProtocols.debian-lsp.filetypes": [
"debcontrol"
],
"files.associations": {
"control": "debcontrol",
"**/debian/control": "debcontrol"
}
}
```
Alternatively, you can use the generic LSP client extension:
1. Install the "Generic LSP Client" extension
2. Add to your `settings.json`:
```json
{
"genericLanguageServer.configurations": {
"debian-lsp": {
"command": ["/path/to/debian-lsp/target/release/debian-lsp"],
"filePatterns": ["**/debian/control", "control"],
"languageId": "debcontrol"
}
}
}
```
### Using with Vim/Neovim
#### coc.nvim
1. Build the coc plugin:
```bash
cd coc-debian
npm install
npm run build
```
2. Install the plugin in Vim with coc.nvim:
```vim
:CocInstall /path/to/debian-lsp/coc-debian
```
3. Configure the LSP path in your coc-settings.json:
```json
{
"debian.serverPath": "/path/to/debian-lsp/target/release/debian-lsp"
}
```
#### ALE
Add the following configuration to your `.vimrc` or `init.vim`:
```vim
" Register debian-lsp with ALE
let g:ale_linters = get(g:, 'ale_linters', {})
let g:ale_linters.debcontrol = ['debian-lsp']
" Configure the debian-lsp executable
call ale#linter#Define('debcontrol', {
\ 'name': 'debian-lsp',
\ 'lsp': 'stdio',
\ 'executable': expand('~/src/debian-lsp/target/release/debian-lsp'),
\ 'command': '%e',
\ 'project_root': function('ale#handlers#lsp#GetProjectRoot'),
\})
```
Note: Adjust the `executable` path to match your installation location. You can trigger code actions in ALE with `:ALECodeAction` when your cursor is on a diagnostic.
#### Native Neovim LSP
Add the following configuration to your Neovim config (init.lua):
```lua
-- Configure debian-lsp
vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
pattern = {'*/debian/control', 'control'},
callback = function()
vim.lsp.start({
name = 'debian-lsp',
cmd = {vim.fn.expand('~/src/debian-lsp/target/release/debian-lsp')},
root_dir = vim.fn.getcwd(),
})
end,
})
```
Or if you prefer using lspconfig:
```lua
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
-- Define the debian-lsp configuration
if not configs.debian_lsp then
configs.debian_lsp = {
default_config = {
cmd = {vim.fn.expand('~/src/debian-lsp/target/release/debian-lsp')},
filetypes = {'debcontrol'},
root_dir = lspconfig.util.root_pattern('debian/control', '.git'),
settings = {},
},
}
end
-- Enable debian-lsp
lspconfig.debian_lsp.setup{}
```
Note: Adjust the `cmd` path to match your installation location.
## Usage
Open any `debian/control` or `control` file in your configured editor. The LSP will automatically provide completions for:
- Field names (Source, Package, Depends, etc.)
- Common package names
## Development
To run the LSP in development mode:
```bash
cargo run
```
To watch and rebuild the coc plugin:
```bash
cd coc-debian
npm run watch
```
|