Configuring your editor ----------------------- vim ~~~ coc.nvim ======== A coc.nvim extension is available. See https://github.com/jelmer/debian-lsp/tree/main/coc-debian/README.md for installation and configuration instructions. ALE === Source the provided configuration file in your `.vimrc` or `init.vim`: ```vim source /usr/share/doc/debian-lsp/ale-debian-lsp.vim ``` You can trigger code actions in ALE with `:ALECodeAction` when your cursor is on a diagnostic. vim-lsp ======= Add the following configuration to your `.vimrc` or `init.vim`: ```vim " Configure vim-lsp for debian-lsp function! s:config_debian_lsp() if executable('debian-lsp') augroup debian_lsp autocmd! autocmd User lsp_setup call lsp#register_server({ \ 'name': 'debian-lsp', \ 'cmd': {server_info -> ['debian-lsp']}, \ 'allowlist': ['debcontrol', 'debcopyright', 'debchangelog', 'debsources', 'debsourceoptions', 'debwatch', 'debupstream', 'autopkgtest', 'debrules', 'debpatches'], \ 'blocklist': [], \ 'enabled': 1, \ }) augroup END endif endfunction call s:config_debian_lsp() " Set filetypes for Debian packaging files (if not already set by ftdetect) augroup debian_filetypes autocmd! autocmd BufNewFile,BufRead */debian/control setfiletype debcontrol autocmd BufNewFile,BufRead */debian/copyright setfiletype debcopyright autocmd BufNewFile,BufRead */debian/changelog setfiletype debchangelog autocmd BufNewFile,BufRead */debian/changelog.dch setfiletype debchangelog autocmd BufNewFile,BufRead */debian/source/format setfiletype debsources autocmd BufNewFile,BufRead */debian/source/options setfiletype debsourceoptions autocmd BufNewFile,BufRead */debian/source/local-options setfiletype debsourceoptions autocmd BufNewFile,BufRead */debian/watch setfiletype debwatch autocmd BufNewFile,BufRead */debian/upstream/metadata setfiletype debupstream autocmd BufNewFile,BufRead */debian/rules setfiletype debrules autocmd BufNewFile,BufRead */debian/patches/series setfiletype debpatches augroup END ``` Replace `debian-lsp` with the full path to the executable if it's not on your PATH. You can then use vim-lsp commands like: - `:LspDocumentDiagnostics` - Show diagnostics - `:LspCodeAction` - Show code actions - `:LspDefinition` - Go to definition - `:LspHover` - Show hover information neovim ~~~~~~ Neovim 0.11+ with bundled config ================================ A bundled LSP config is provided in the `nvim-lspconfig/` directory. Copy it to your Neovim config: ```sh mkdir -p ~/.config/nvim/lsp cp /usr/share/doc/debian-lsp/debian_lsp.lua ~/.config/nvim/lsp/ ``` Then enable it in your `init.lua`: ```lua vim.lsp.enable('debian_lsp') ``` To use a custom path to the `debian-lsp` binary: ```lua vim.lsp.config('debian_lsp', { cmd = { '/path/to/debian-lsp' }, }) vim.lsp.enable('debian_lsp') ``` Native Neovim LSP (without nvim-lspconfig) ========================================== If you don't use nvim-lspconfig, add the following to your `init.lua`: ```lua vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, { pattern = { '*/debian/control', '*/debian/copyright', '*/debian/changelog', '*/debian/changelog.dch', '*/debian/source/format', '*/debian/source/options', '*/debian/source/local-options', '*/debian/watch', '*/debian/tests/control', '*/debian/upstream/metadata', '*/debian/rules', '*/debian/patches/series', }, callback = function() vim.lsp.start({ name = 'debian-lsp', cmd = {'debian-lsp'}, root_dir = vim.fn.getcwd(), }) end, }) ``` Using with Helix ~~~~~~~~~~~~~~~~ See README.helix-lspconfig for installation and configuration instructions. Using with Emacs ~~~~~~~~~~~~~~~~ See README.emacs-lspconfig for installation and configuration instructions.