Skip to content

Commit dcacac8

Browse files
authored
Merge pull request #6 from code-input/lsp-server
feat: add LSP server for IDE integration
2 parents 72fbd45 + 137ea85 commit dcacac8

File tree

20 files changed

+860
-37
lines changed

20 files changed

+860
-37
lines changed

.github/workflows/release-lsp.yml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Release LSP
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
name: Release LSP - ${{ matrix.os }} (${{ matrix.arch }})
11+
runs-on: ${{ matrix.runner }}
12+
strategy:
13+
matrix:
14+
include:
15+
- os: linux
16+
arch: x64
17+
runner: ubuntu-latest
18+
target: x86_64-unknown-linux-gnu
19+
binary_name: ci
20+
asset_name: ci-lsp-linux-x64
21+
- os: linux
22+
arch: arm64
23+
runner: ubuntu-latest
24+
target: aarch64-unknown-linux-gnu
25+
binary_name: ci
26+
asset_name: ci-lsp-linux-arm64
27+
- os: windows
28+
arch: x64
29+
runner: windows-latest
30+
target: x86_64-pc-windows-msvc
31+
binary_name: ci.exe
32+
asset_name: ci-lsp-windows-x64.exe
33+
- os: windows
34+
arch: arm64
35+
runner: windows-latest
36+
target: aarch64-pc-windows-msvc
37+
binary_name: ci.exe
38+
asset_name: ci-lsp-windows-arm64.exe
39+
- os: darwin
40+
arch: x64
41+
runner: macos-latest
42+
target: x86_64-apple-darwin
43+
binary_name: ci
44+
asset_name: ci-lsp-darwin-x64
45+
- os: darwin
46+
arch: arm64
47+
runner: macos-latest
48+
target: aarch64-apple-darwin
49+
binary_name: ci
50+
asset_name: ci-lsp-darwin-arm64
51+
52+
steps:
53+
- name: Checkout Source
54+
uses: actions/checkout@v4
55+
56+
- name: Set variables
57+
id: vars
58+
shell: bash
59+
run: |
60+
echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT
61+
echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
62+
63+
- name: Install Rust toolchain
64+
uses: dtolnay/rust-toolchain@stable
65+
with:
66+
targets: ${{ matrix.target }}
67+
68+
- name: Install cross-compilation tools (Linux ARM64)
69+
if: matrix.target == 'aarch64-unknown-linux-gnu'
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y gcc-aarch64-linux-gnu
73+
74+
- name: Configure cross-compilation (Linux ARM64)
75+
if: matrix.target == 'aarch64-unknown-linux-gnu'
76+
run: |
77+
echo "[target.aarch64-unknown-linux-gnu]" >> ~/.cargo/config.toml
78+
echo "linker = \"aarch64-linux-gnu-gcc\"" >> ~/.cargo/config.toml
79+
80+
- name: Cache cargo registry and build
81+
uses: actions/cache@v4
82+
with:
83+
path: |
84+
~/.cargo/registry
85+
~/.cargo/git
86+
target
87+
key: ${{ runner.os }}-${{ matrix.target }}-cargo-lsp-${{ hashFiles('**/Cargo.lock') }}
88+
restore-keys: |
89+
${{ runner.os }}-${{ matrix.target }}-cargo-lsp-
90+
91+
- name: Build release binary with LSP feature
92+
run: cargo build --release --features lsp --target ${{ matrix.target }}
93+
94+
- name: Upload binary as artifact
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: ${{ matrix.asset_name }}
98+
path: target/${{ matrix.target }}/release/${{ matrix.binary_name }}
99+
100+
create-release:
101+
name: Create LSP Release
102+
runs-on: ubuntu-latest
103+
needs: release
104+
steps:
105+
- name: Checkout Source
106+
uses: actions/checkout@v4
107+
108+
- name: Set variables
109+
id: vars
110+
run: |
111+
echo "package_name=$(sed -En 's/name[[:space:]]*=[[:space:]]*"([^"]+)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_OUTPUT
112+
echo "package_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
113+
114+
- name: Download all artifacts
115+
uses: actions/download-artifact@v4
116+
with:
117+
path: artifacts
118+
119+
- name: Remove Same Release
120+
uses: omarabid-forks/action-rollback@stable
121+
continue-on-error: true
122+
with:
123+
tag: ${{ steps.vars.outputs.package_version }}
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: Create Release
128+
id: create-release
129+
uses: actions/create-release@latest
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
with:
133+
tag_name: ${{ steps.vars.outputs.package_version }}
134+
release_name: LSP Server ${{ steps.vars.outputs.package_version }}
135+
body: ${{ steps.vars.outputs.package_name }} LSP Server - ${{ steps.vars.outputs.package_version }}
136+
draft: false
137+
prerelease: false
138+
139+
- name: Upload Linux x64 binary
140+
uses: actions/upload-release-asset@v1
141+
env:
142+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
with:
144+
upload_url: ${{ steps.create-release.outputs.upload_url }}
145+
asset_path: artifacts/ci-lsp-linux-x64/ci
146+
asset_name: ci-lsp-linux-x64
147+
asset_content_type: application/octet-stream
148+
149+
- name: Upload Linux arm64 binary
150+
uses: actions/upload-release-asset@v1
151+
env:
152+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153+
with:
154+
upload_url: ${{ steps.create-release.outputs.upload_url }}
155+
asset_path: artifacts/ci-lsp-linux-arm64/ci
156+
asset_name: ci-lsp-linux-arm64
157+
asset_content_type: application/octet-stream
158+
159+
- name: Upload Windows x64 binary
160+
uses: actions/upload-release-asset@v1
161+
env:
162+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
with:
164+
upload_url: ${{ steps.create-release.outputs.upload_url }}
165+
asset_path: artifacts/ci-lsp-windows-x64.exe/ci.exe
166+
asset_name: ci-lsp-windows-x64.exe
167+
asset_content_type: application/octet-stream
168+
169+
- name: Upload Windows arm64 binary
170+
uses: actions/upload-release-asset@v1
171+
env:
172+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
173+
with:
174+
upload_url: ${{ steps.create-release.outputs.upload_url }}
175+
asset_path: artifacts/ci-lsp-windows-arm64.exe/ci.exe
176+
asset_name: ci-lsp-windows-arm64.exe
177+
asset_content_type: application/octet-stream
178+
179+
- name: Upload macOS x64 binary
180+
uses: actions/upload-release-asset@v1
181+
env:
182+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183+
with:
184+
upload_url: ${{ steps.create-release.outputs.upload_url }}
185+
asset_path: artifacts/ci-lsp-darwin-x64/ci
186+
asset_name: ci-lsp-darwin-x64
187+
asset_content_type: application/octet-stream
188+
189+
- name: Upload macOS arm64 binary
190+
uses: actions/upload-release-asset@v1
191+
env:
192+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193+
with:
194+
upload_url: ${{ steps.create-release.outputs.upload_url }}
195+
asset_path: artifacts/ci-lsp-darwin-arm64/ci
196+
asset_name: ci-lsp-darwin-arm64
197+
asset_content_type: application/octet-stream
198+
199+
- name: Purge artifacts
200+
uses: omarabid-forks/purge-artifacts@v1
201+
with:
202+
token: ${{ secrets.GITHUB_TOKEN }}
203+
expire-in: 0

Cargo.toml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,42 @@ resolver = "2"
44

55
[workspace.dependencies]
66
# Shared dependencies
7-
rand = { version = "0.9.1", default-features = false }
8-
rayon = "1.10.0"
9-
human-panic = "2.0.2"
7+
rand = { version = "0.10.0", default-features = false }
8+
rayon = "1.11.0"
9+
human-panic = "2.0.6"
1010
better-panic = "0.3.0"
11-
log = "0.4.27"
12-
clap_complete = "4.5.54"
13-
ignore = "0.4.23"
14-
serde = { version = "1.0.219", features = ["derive"] }
15-
serde_json = "1.0.140"
11+
log = "0.4.29"
12+
clap_complete = "4.5.66"
13+
ignore = "0.4.25"
14+
serde = { version = "1.0.228", features = ["derive"] }
15+
serde_json = "1.0.149"
1616
bincode = { version = "2.0.1", features = ["serde"] }
17-
git2 = { version = "0.20.2", default-features = false }
17+
git2 = { version = "0.20.4", default-features = false }
1818
sha2 = { version = "0.10.9" }
19-
thiserror = "2.0.12"
20-
backtrace = "0.3.75"
21-
color-backtrace = "0.7.0"
22-
config = "0.15.11"
19+
thiserror = "2.0.18"
20+
backtrace = "0.3.76"
21+
color-backtrace = "0.7.2"
22+
config = "0.15.19"
2323
lazy_static = "1.5.0"
24-
slog = "2.7.0"
24+
slog = "2.8.2"
2525
slog-syslog = "0.13.0"
26-
slog-term = "2.9.1"
27-
slog-scope = "4.4.0"
26+
slog-term = "2.9.2"
27+
slog-scope = "4.4.1"
2828
slog-async = "2.8.0"
2929
slog-stdlog = "4.1.1"
3030
tabled = "0.20.0"
31-
terminal_size = "0.4.2"
32-
clap = { version = "4.5.40", features = ["cargo", "derive"] }
33-
chrono = { version = "0.4.41", features = ["serde"] }
31+
terminal_size = "0.4.3"
32+
clap = { version = "4.5.60", features = ["cargo", "derive"] }
33+
chrono = { version = "0.4.44", features = ["serde"] }
34+
tower-lsp = "0.20"
35+
tokio = { version = "1.49.0", features = ["full"] }
36+
url = "2.5.8"
3437

3538
# Dev dependencies
36-
assert_cmd = "2.0.17"
37-
predicates = "3.1.3"
38-
tempfile = "3.20"
39-
criterion = { version = "0.6.0", features = ["html_reports"] }
39+
assert_cmd = "2.1.2"
40+
predicates = "3.1.4"
41+
tempfile = "3.26.0"
42+
criterion = { version = "0.8.2", features = ["html_reports"] }
4043

4144
[profile.dev]
4245
opt-level = 0

ci/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ default = ["termlog"]
2121
termlog = ["codeinput/termlog"]
2222
journald = ["codeinput/journald"]
2323
syslog = ["codeinput/syslog"]
24+
lsp = ["codeinput/tower-lsp", "codeinput/tokio", "tokio"]
2425

2526
[dependencies]
2627
codeinput = { version = "0.0.4", path = "../codeinput" }
@@ -34,6 +35,7 @@ thiserror = { workspace = true }
3435
tabled = { workspace = true }
3536
terminal_size = { workspace = true }
3637
clap = { workspace = true }
38+
tokio = { workspace = true, optional = true }
3739

3840
[dev-dependencies]
3941
assert_cmd = { workspace = true }

ci/src/cli/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use codeinput::utils::app_config::AppConfig;
1616
use codeinput::utils::error::Result;
1717
use codeinput::utils::types::LogLevel;
1818

19+
1920
#[derive(Parser, Debug)]
2021
#[command(
2122
name = "codeinput",
@@ -45,6 +46,10 @@ pub struct Cli {
4546
)]
4647
pub log_level: Option<LogLevel>,
4748

49+
/// Suppress progress output
50+
#[arg(short, long)]
51+
pub quiet: bool,
52+
4853
/// Subcommands
4954
#[clap(subcommand)]
5055
command: Commands,
@@ -76,6 +81,21 @@ enum Commands {
7681
long_about = None,
7782
)]
7883
Config,
84+
#[cfg(feature = "lsp")]
85+
#[clap(
86+
name = "lsp",
87+
about = "Start LSP server for IDE integration",
88+
long_about = "Starts a Language Server Protocol (LSP) server that provides CODEOWNERS information to supported editors"
89+
)]
90+
Lsp {
91+
/// Use stdio for communication (default, flag exists for client compatibility)
92+
#[arg(long, hide = true)]
93+
stdio: bool,
94+
95+
/// Port for TCP communication (if not specified, uses stdio)
96+
#[arg(long, value_name = "PORT")]
97+
port: Option<u16>,
98+
},
7999
}
80100

81101
#[derive(Subcommand, PartialEq, Debug)]
@@ -279,6 +299,8 @@ pub fn cli_match() -> Result<()> {
279299
}
280300
}
281301
Commands::Config => commands::config::run()?,
302+
#[cfg(feature = "lsp")]
303+
Commands::Lsp { port, .. } => commands::lsp::run(*port)?,
282304
}
283305

284306
Ok(())

codeinput/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ full = [
5757
"clap",
5858
"chrono",
5959
"utoipa",
60+
"url",
6061
]
6162
nightly = []
6263
termlog = ["slog-term"]
@@ -67,7 +68,7 @@ types = []
6768
[dependencies]
6869
# Core dependencies always needed
6970
serde = { workspace = true }
70-
utoipa = { version = "4.2.3", optional = true }
71+
utoipa = { version = "5.4.0", optional = true }
7172

7273
# Full feature dependencies
7374
rayon = { workspace = true, optional = true }
@@ -85,14 +86,17 @@ config = { workspace = true, optional = true }
8586
lazy_static = { workspace = true, optional = true }
8687
slog = { workspace = true, optional = true }
8788
slog-syslog = { version = "0.13.0", optional = true }
88-
slog-term = { version = "2.9.1", optional = true }
89+
slog-term = { version = "2.9.2", optional = true }
8990
slog-scope = { workspace = true, optional = true }
9091
slog-async = { workspace = true, optional = true }
9192
slog-stdlog = { workspace = true, optional = true }
9293
tabled = { workspace = true, optional = true }
9394
terminal_size = { workspace = true, optional = true }
9495
clap = { workspace = true, optional = true }
95-
chrono = { version = "0.4.41", features = ["serde"], optional = true }
96+
chrono = { version = "0.4.44", features = ["serde"], optional = true }
97+
tower-lsp = { workspace = true, optional = true }
98+
tokio = { workspace = true, optional = true }
99+
url = { workspace = true, optional = true }
96100

97101
[target.'cfg(target_os = "linux")'.dependencies]
98102
slog-journald = { version = "2.2.0", optional = true }

0 commit comments

Comments
 (0)