Skip to main content

SSH config formatter

Python badge PyPI MIT License

Packager: uv Linter/Formatter: ruff Type checker: ty

Little side project to start learning Rust and explore LSP.

✨ Features

  • Formatting of SSH config files via the sshls format command
  • Language server started with sshls server, following the LSP protocol
  • Basic completions of keywords through the language server

📦 Installation

You can install the tool easily with pipx or uv:

uv tool install ssh-config-ls

🔧 Configuration

The language server accepts the following options from the client (e.g. Neovim):

{
    formatter = {
        indent = "    ",  -- Indentation for directives inside Host and Match blocks
        separator = " ",  -- Separator between a keyword and its arguments
        sort_directives = true, -- Sort directives within blocks
    }
}

Formateur de config SSH — Plan de projet

Étape 1 — Prototype Python

Objectif : valider la logique de parsing et de formatage sans se battre contre un nouveau langage.

Note : Couvrir les cas limites (commentaires inline, blocs Host/Match, lignes vides multiples) et garder les tests sur le comportement observable (entrée/sortie texte) — ils serviront de spec pour la réécriture Rust.

Fonctionnalités à implémenter :

Lexer :

  • Ajouter des tests sur le tokenizer
  • Implémenter un tokenizer pour le cœur de la config
  • Ajouter les commentaires dans le tokenizer
  • Écrire tous les tests vicieux imaginables

Parser :

  • Ajouter des tests sur le parser
  • Implémenter un parser
  • Parser les blocs Host et Match
  • Écrire tous les tests vicieux imaginables

Formatage :

  • Préserver les commentaires et automatises les lignes vides
  • Normaliser l'indentation (4 espaces)
  • Canonicaliser la casse des clés (hostnameHostname)
  • Écrire tous les tests vicieux imaginables

CLI :

  • sshls format <file> — formate en place
  • sshls format --check <file> — exit code non-zéro si non formaté (CI)
  • sshls format --diff <file> — affiche le diff

LSP :

  • Lib : pygls
  • Créer le serveur
  • Ajouter textDocument/formatting

Hors scope pour l'instant :

  • Gérer les directives Include
  • Trier les blocs (* en dernier)

Étape 2 — Apprentissage Rust

Avant de réécrire, poser les bases du langage.

  • Lire les chapitres fondamentaux de The Book, en particulier sur l'ownership et les enums
  • Faire quelques exercices Rustlings pour la syntaxe
  • Libs à connaître pour ce projet : pest ou winnow (parsing), clap (CLI)

Étape 3 — Réécriture en Rust

Réécrire le formateur en Rust en s'appuyant sur les tests Python comme spec.

  • Reprendre exactement les mêmes fonctionnalités et la même interface CLI
  • Les tests Python guident l'implémentation et valident la parité de comportement

Étape 4 — Serveur LSP

Transformer le formateur en serveur LSP avec uniquement la capacité de formatage (textDocument/formatting).

  • Lib : tower-lsp pour abstraire le protocole JSON-RPC
  • Intégration Neovim via vim.lsp.start() ou nvim-lspconfig — pas de plugin dédié nécessaire

Références

Release files for ssh-config-ls 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssh-config-ls 0.8.0
File Size Uploaded
ssh_config_ls-0.8.0.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ssh-config-ls 0.8.0
File Interpreter ABI Platform
ssh_config_ls-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / ssh_config_ls-0.8.0.tar.gz

Download URL ssh_config_ls-0.8.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d98202302ab8b5cc503301f50a901322e132aa9aa28b6ed9e6174b02814c8385
BLAKE2b-256 checksum
How to use checksums
b85b14057038e4df3056cf070bef52b69cf94bdbad5a801248d9bd8f17da4f38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.5","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ssh_config_ls-0.8.0-py3-none-any.whl

Download URL ssh_config_ls-0.8.0-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
adbf0ecca208f66637cf2f4d25846da346d2714fb1a2e4034407f11da0187141
BLAKE2b-256 checksum
How to use checksums
6dbf0c485fb6869121dea0ff1f43e1ed639f7199e604c629da28772bfc319dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.5","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.10.1

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

This release

0.8.0 This release

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page