Language Server for RPM spec files
Project description
RPM Spec File Language Server
This is a proof of concept implementation of a server implementing the Language Server Protocol for RPM Spec files.
Please share your feature requests with us by opening an issue, creating a discussion or chat with us on matrix in #rpm-spec-language-server:matrix.org.
Supported LSP endpoints
autocompletion of macro names, spec sections and preamble keywords
jump to macro definition
expand macros on hover
breadcrumbs/document sections
Requirements
Python >= 3.9
Running the server
Install the dependencies via poetry install
Launch the server in tcp mode (binds to `127.0.0.1:2087 by default) via poetry run rpm_lsp_server
Alternatively, you can build the python package, install the wheel and run the module directly:
poetry build
pip install --user dist/rpm_spec_language_server-*.whl
python -m rpm_spec_language_server
The server requires the spec.md file. It can either use the locally installed copy from the rpm package or (if the documentation has not been installed) from a locally cached version in ~/.cache/rpm/spec.md. The language server will fetch the spec.md from the upstream github repository if neither of the previous options.
Container Mode
The rpm-spec-language-server is a server that supports an experimental container mode. In this mode, the server is launched inside a container with the package directory mounted into the running container. This allows you to have access to a different distribution than your current one.
The container mode can currently handle only one package open. The RPM spec file must be in the top-level directory. Additionally, the server must communicate via TCP. This means that you might have to reconfigure your lsp-client, if it assumes to communicate via stdio.
To enable the container mode with Podman, proceed as follows:
$ cd ~/path/to/my/package
$ # ensure that the spec file is in the current working directory!
$ podman container runlabel run \
ghcr.io/dcermak/rpm-spec-lang-server:$distri
where you replace $distri with one of tumbleweed, leap-15.5, leap-15.6, fedora or centos.
To use Docker, get the exact launch command as shown below:
$ docker inspect -f '{{index .Config.Labels "run"}}' \
ghcr.io/dcermak/rpm-spec-lang-server:$distri | \
sed -e 's/podman/docker/' -e 's|$IMAGE|ghcr.io/dcermak/rpm-spec-lang-server:$distri|'
In the example above, replace $distri with the desired distribution.
Clients
VSCode
A very simple VSCode client is available in clients/vscode/. Building requires nodejs and the npm package manager:
$ npm install
$ npm run package
Install the created rpm-spec-language-server-$VERSION.vsix and launch the language server in tcp mode.
vis with vis-lspci
Add to your ~/.config/vis/visrc.lua this code:
lsp = require('plugins/vis-lspc')
lsp.ls_map['rpmspec'] = {
name = 'RPMSpec',
cmd = 'python3 -mrpm_spec_language_server --stdio'
}
Neovim with built-in LSP client
local lspconfig = require("lspconfig")
local util = require("lspconfig.util")
local configs = require("lspconfig.configs")
configs.rpmspec = {
default_config = {
cmd = { 'python3', '-mrpm_spec_language_server', '--stdio' },
filetypes = { 'spec' },
single_file_support = true,
root_dir = util.find_git_ancestor,
settings = {},
},
docs = {
description = [[
https://github.com/dcermak/rpm-spec-language-server
Language server protocol (LSP) support for RPM Spec files.
]],
},
}
lspconfig["rpmspec"].setup({})
Neovim with coc.nvim plugin
Open nvim, run :CocConfig, and merge the following JSON into your configuration
{
"languageserver": {
"spec": {
"command": "rpm_lsp_server",
"args": ["--stdio"],
"filetypes": ["spec"]
}
}
}
Emacs with lsp-mode.el
lsp-mode has builtin support for the rpm-spec-language-server. All you have to do is to require 'lsp-rpm-spec and launching lsp-mode. With use-package, this can be implemented as follows utilizing rpm-spec-mode:
(use-package lsp-mode
:ensure t
:commands (lsp lsp-deferred)
:hook ((rpm-spec-mode . lsp-deferred)))
(use-package rpm-spec-mode
:ensure t
:mode "\\.spec'"
:config (require 'lsp-rpm-spec))
Emacs with eglot.el
eglot is the builtin LSP Client for Emacs. Support for the rpm-spec-language-server can be added by evaluating the following snippet (e.g. in your init.el or directly in the scratch buffer):
(require 'eglot)
(add-to-list 'eglot-server-programs
'(rpm-spec-mode . ("localhost" 2087)))
Then start the language server in tcp mode and invoke eglot via M-x eglot.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rpm_spec_language_server-0.0.2.tar.gz.
File metadata
- Download URL: rpm_spec_language_server-0.0.2.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86998305c03c0d1396475a735756b699a15433ee4d705733b828ec18091e7073
|
|
| MD5 |
7030667fbf1c84b0339b60d2a0b3940a
|
|
| BLAKE2b-256 |
37b5eab4519a6e646f84ca99a3e1ddf416ce94a88b889e38ed55f5e02ac16ed8
|
Provenance
The following attestation bundles were made for rpm_spec_language_server-0.0.2.tar.gz:
Publisher:
release.yml on dcermak/rpm-spec-language-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rpm_spec_language_server-0.0.2.tar.gz -
Subject digest:
86998305c03c0d1396475a735756b699a15433ee4d705733b828ec18091e7073 - Sigstore transparency entry: 623280212
- Sigstore integration time:
-
Permalink:
dcermak/rpm-spec-language-server@f64d20da0c90bf1027bb704036795466f1c53c56 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/dcermak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f64d20da0c90bf1027bb704036795466f1c53c56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rpm_spec_language_server-0.0.2-py3-none-any.whl.
File metadata
- Download URL: rpm_spec_language_server-0.0.2-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6e195ea850dccc183b4708649eb994222e89c476da8da805822dc5ce1ee1e09
|
|
| MD5 |
bd19c51d94ed3705260ca5d094fa10a7
|
|
| BLAKE2b-256 |
5d7d27a0e7338067df6a11138f7b579215fb660e7785805ff3ff5b358692e22c
|
Provenance
The following attestation bundles were made for rpm_spec_language_server-0.0.2-py3-none-any.whl:
Publisher:
release.yml on dcermak/rpm-spec-language-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rpm_spec_language_server-0.0.2-py3-none-any.whl -
Subject digest:
a6e195ea850dccc183b4708649eb994222e89c476da8da805822dc5ce1ee1e09 - Sigstore transparency entry: 623280213
- Sigstore integration time:
-
Permalink:
dcermak/rpm-spec-language-server@f64d20da0c90bf1027bb704036795466f1c53c56 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/dcermak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f64d20da0c90bf1027bb704036795466f1c53c56 -
Trigger Event:
push
-
Statement type: