1 unstable release
new 0.1.0 | Mar 7, 2025 |
---|
#124 in Text editors
32KB
485 lines
Systemd Language Server
A Rust and Language Server Protocol (LSP) based language server for systemd unit files, providing syntax highlighting, auto-completion, error checking, and more.
Features
- Syntax highlighting for systemd unit files
- Intelligent auto-completion suggestions
- Real-time syntax error checking
- Support for jumping to definitions
- Hover documentation tooltips
Installation
Building from Source
Ensure you have the Rust toolchain installed, then run:
git clone https://github.com/10fish/systemd-language-server-rs.git
cd systemd-language-server-rs
cargo build --release
The compiled binary will be located at target/release/systemd-language-server
.
Installing with Cargo
cargo install systemd-language-server
Usage
Running as a Standalone Server
systemd-language-server
Editor Integration
VS Code
- Install the vscode-languageclient extension
- Configure the systemd-language-server path in settings
Neovim
Use nvim-lspconfig configuration:
require'lspconfig'.systemd_ls.setup{
cmd = { "systemd-language-server" },
filetypes = { "systemd" },
root_dir = function() return vim.loop.cwd() end
}
Configuration Options
You can configure the following options in the .systemd-ls.json
file:
{
"systemd": {
"unitSearchPaths": ["/etc/systemd/system", "/usr/lib/systemd/system"],
"diagnostics": {
"enabled": true
}
}
}
Development
Dependencies
- Rust 1.70+
- tokio async runtime
- tower-lsp library
Building and Testing
# Build the project
cargo build
# Run tests
cargo test
# Run linter
cargo clippy
Testing
The project includes several types of tests to ensure code quality and functionality:
Unit Tests
Unit tests verify the core functionality of parsing and validating systemd unit files:
tests/systemd_unit_tests.rs
: Tests for various systemd unit file types (service, socket, timer, mount)tests/diagnostics_tests.rs
: Tests for error detection and validation
Integration Tests
A simplified integration test is included in tests/integration_tests.rs
. This serves as a placeholder and can be expanded in the future when needed.
To run a specific test:
cargo test --test systemd_unit_tests
To run tests with detailed output:
cargo test -- --nocapture
Contributing
Pull Requests and Issues are welcome! Please ensure:
- Add tests for new features
- Update documentation
- Follow the project's code style
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
Dependencies
~8–16MB
~188K SLoC