Note: This subcommand needs optional dependencies to work from Recommends or Suggests
Start the debputy language server (per Language Server Protocol specification).
Many modern editors can delegate language support to a Language Server or indirectly via other features like supporting youcompleteme (which in turn can delegate to a language server). The debputy tool provides one for many common packaging formats via the lsp server subcommand for file formats such as debian/control, debian/changelog and debian/copyright (DEP-5).
You will often need some editor specific glue configuration to link a given file format or name to the language server. The debputy lsp editor-config might provide an example glue snippet for your editor. In that glue configuration, you will need to provide a command. Often, debputy lsp server will suffice (using the stdio transport). See debputy lsp server --help for other integration options such as TCP (--tcp) or websocket (--ws) plus related supporting options.
The debputy lsp server command provides several features including a form of static analysis in the form of "as-you-type" diagnostics. For the diagnostics, is debputy lsp server not allowed load nor execute code from the code it is scanning. It is a security bug for debputy lsp server to violate this principle directly or indirectly. Therefore, debputy can only provide diagnostics from libraries and tools that takes this principle seriously. It also means that debputy will likely have false-positives for self-hosting code, since it is not allowed to load the self-hosted code.
This security principle also applies to hover docs, completion suggestions and other trivial code editing or viewing features. However, it is not universal, since certain LSP features are deliberately designed to run the code you are viewing. As an example, debputy lsp server can provide a "code lens" (LSP term) for building the current package. On activation of the code lens, debputy will trigger code from the package to be run and that is expected. The critical points here are that the user must explicitly trigger the feature and it must use terms commonly associated with running code such as build, run or execute (non-exhaustive list).
If you need to debug an issue with the language server, the TCP integration (--tcp) can be quite helpful. In this mode, you run debputy lsp server --tcp in a terminal before starting your editor. This means you have direct and unfiltered access to the debputy command and its output. Remember to update your editor to use TCP integration rather than stdio integration (and remember to swap back when you are done). Check the debputy lsp server --help if you need a different bind address for the language server.
If you can choose the language ID for a given file, you are recommended to use the file name relative to the source root (such as debian/control). The service does account for some known variations such as debian-control (as used by eglot from emacs) and debcontrol (as used by vim). See debputy lsp features for a list of known language IDs along with their aliases.
When properly set up, the language server will offer a variety of features such as completion suggestions, hover documentation, "as you type" diagnostics, quickfixes, etc. Please see debputy lsp features for the full list of features per format. That command will also help identify mandatory and optional dependencies for the debputy lsp server command.
Note many of the features are subject to the editor supporting them, correct language IDs being passed to debputy, etc.
Options for this subcommand
-
--ignore-language-ids
-
When provided, debputy will ignore any language ID that the editor provides for any file. Instead, debputy will only rely on the file name for determining how to interpret the file content.
Since debputy supports multiple file formats, it is needs to know what kind of file it is working with. The editor is supposed to provide this via a "Language ID" attribute. This enables you as a user in the editor to override the file format and have proper editor support no matter the filename. Unfortunately, most Debian packaging files do not have a language ID assigned in the LSP specification, so editors either provide a custom language ID or no custom language ID at all (that is, an empty string).
When the editor does not provide a language ID for file, debputy will since 0.1.25 automatically attempt to derive the language from the filename. With this option (introduced in 0.1.29), debputy will always derive the language from the filename even if the editor provided a language ID. This can be helpful if your editor is providing language IDs that debputy does not recognize.
As an example, in emacs with eglot the language ID is derived from the name of the buffer's major mode. If you tried to use debputy lsp server with a major mode that debputy does not recognize then without this option, debputy would "silently" do nothing. With this option, it would have worked provided the filename matched debputy's expectation no matter the major mode.
On the downside, debputy will not provide correct advice unless the paths matches .../debian/filename. This can provide issues with some setups where the debian directory is implicit such as some "packaging-only" repos or some editor scratch pads.
-
--force-locale=XX
-
When provided, debputy will always use the provided locale code for deciding the localization.
By default, the editor may provide a locale, which is then used. Alternatively, debputy will attempt to guess the desired localization from defaults (like the LC_ALL variable). With this option, you can override both of these and instead directly pick the locale you want.
Note that debputy will default to using US English for strings that are not translated into the desired locale (no matter how that locale was chosen). If you still see untranslated strings with this options, check you have the relevant translations installed and that the locale code is correct.
-
--tcp or --ws
-
By default, the debputy language server will use stdio for communication with the editor. These options provide either the TCP integration mode (--tcp) or the websocket integration mode (--ws). In this mode, the --host and --port options can be used to choose the bind address.
These options are mutually exclusive.
The --ws option requires python3-websockets Debian package.
-
--host HOSTNAME, --port PORT
-
With --tcp or --ws, these option determines the bind address. The default is 127.0.0.1 for host and 2087 for the port.
In integration modes that does not need a bind address (such as the stdio mode), this option is ignored.