Skip to content

Commit a295c4e

Browse files
authored
feat: add LSP server support for code intelligence (#16)
Install language servers in base and intermediate images: - Base: typescript-language-server, pyright, bash-language-server, vscode-langservers-extracted (json/css/html), clangd, marksman - Rust intermediate: rust-analyzer via rustup - Go intermediate: gopls via go install Add default /etc/opencode/opencode.config.json with LSP configurations for all supported languages. The sidecar config-loader will use this as a fallback when no workspace config exists. Supported languages: typescript, javascript, python, rust, go, bash, json, css, html, markdown, c/cpp
1 parent 9c8bc35 commit a295c4e

4 files changed

Lines changed: 348 additions & 100 deletions

File tree

base/base-system.Dockerfile

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,85 @@ RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
2020
&& npm install -g opencode-ai \
2121
&& rm -rf /var/lib/apt/lists/*
2222

23+
# LSP servers for code intelligence
24+
# These enable language server protocol support in the agent IDE
25+
RUN npm install -g \
26+
typescript-language-server \
27+
bash-language-server \
28+
vscode-langservers-extracted \
29+
pyright
30+
31+
# Install clangd for C/C++ support
32+
RUN apt-get update && \
33+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends clangd && \
34+
rm -rf /var/lib/apt/lists/*
35+
36+
# Install marksman for Markdown LSP support
37+
RUN MARKSMAN_VERSION="2024-12-18" && \
38+
arch="$(uname -m)" && \
39+
case "$arch" in \
40+
x86_64) marksman_arch="marksman-linux-x64" ;; \
41+
aarch64) marksman_arch="marksman-linux-arm64" ;; \
42+
*) echo "Unsupported architecture: $arch" && exit 1 ;; \
43+
esac && \
44+
curl -fsSL "https://github.com/artempyanykh/marksman/releases/download/${MARKSMAN_VERSION}/${marksman_arch}" -o /usr/local/bin/marksman && \
45+
chmod +x /usr/local/bin/marksman
46+
47+
# Create default LSP configuration for agents
48+
# This provides baseline language server support when no user config exists
49+
# Languages with binaries not installed will gracefully fail to start
50+
RUN mkdir -p /etc/opencode && \
51+
cat > /etc/opencode/opencode.config.json << 'EOFCONFIG'
52+
{
53+
"lsp": {
54+
"typescript": {
55+
"command": ["typescript-language-server", "--stdio"],
56+
"extensions": ["ts", "tsx"]
57+
},
58+
"javascript": {
59+
"command": ["typescript-language-server", "--stdio"],
60+
"extensions": ["js", "jsx", "mjs", "cjs"]
61+
},
62+
"python": {
63+
"command": ["pyright-langserver", "--stdio"],
64+
"extensions": ["py"]
65+
},
66+
"rust": {
67+
"command": ["rust-analyzer"],
68+
"extensions": ["rs"]
69+
},
70+
"go": {
71+
"command": ["gopls", "serve"],
72+
"extensions": ["go"]
73+
},
74+
"bash": {
75+
"command": ["bash-language-server", "start"],
76+
"extensions": ["sh", "bash"]
77+
},
78+
"json": {
79+
"command": ["vscode-json-language-server", "--stdio"],
80+
"extensions": ["json", "jsonc"]
81+
},
82+
"css": {
83+
"command": ["vscode-css-language-server", "--stdio"],
84+
"extensions": ["css", "scss", "sass", "less"]
85+
},
86+
"html": {
87+
"command": ["vscode-html-language-server", "--stdio"],
88+
"extensions": ["html", "htm"]
89+
},
90+
"markdown": {
91+
"command": ["marksman", "server"],
92+
"extensions": ["md", "mdx"]
93+
},
94+
"cpp": {
95+
"command": ["clangd"],
96+
"extensions": ["c", "cc", "cpp", "cxx", "h", "hpp"]
97+
}
98+
}
99+
}
100+
EOFCONFIG
101+
23102
# Pre-warm npm cache with commonly used packages
24103
# This populates the npm cache so first `npm install` for these packages is instant
25104
# These packages cover: React ecosystem, build tools, testing, styling, utilities

0 commit comments

Comments
 (0)