Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3de973b

Browse files
committed
feat: add Go LSP configuration and code navigation documentation
Change-Id: I994c8ee8fa2c246808a9f68a86e83a6a3db6f8acSigned-off-by: Thomas Kosiewski <tk@coder.com>
1 parentabbe929 commit3de973b

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

‎.claude/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [],
4+
"deny": [
5+
"mcp__go-language-server__edit_file"
6+
]
7+
}
8+
}

‎.mcp.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"mcpServers": {
3+
"go-language-server": {
4+
"type":"stdio",
5+
"command":"go",
6+
"args": [
7+
"run",
8+
"github.com/isaacphi/mcp-language-server@latest",
9+
"-workspace",
10+
"./",
11+
"-lsp",
12+
"go",
13+
"--",
14+
"run",
15+
"golang.org/x/tools/gopls@latest"
16+
],
17+
"env": {}
18+
}
19+
}
20+
}

‎CLAUDE.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,114 @@ if errors.Is(err, errInvalidPKCE) {
270270
-Test both positive and negative cases
271271
-Use`testutil.WaitLong`for timeouts in tests
272272

273+
##CodeNavigation andInvestigation
274+
275+
###UsingGoLSPTools (STRONGLYRECOMMENDED)
276+
277+
**IMPORTANT**:Always useGoLSP toolsfor code navigation and understanding.These tools provide accurate, real-time analysis of the codebase and should be your first choicefor code investigation.
278+
279+
When working with theCoder codebase, leverageGoLanguageServerProtocol toolsfor efficient code navigation:
280+
281+
1. **Find function definitions** (USETHISFREQUENTLY):
282+
283+
```none
284+
mcp__go-language-server__definition symbolName
285+
```
286+
287+
-Example:`mcp__go-language-server__definition getOAuth2ProviderAppAuthorize`
288+
-Example:`mcp__go-language-server__definition ExtractAPIKeyMW`
289+
-Quickly jump to function implementations across packages
290+
- **Use this when**:You see a function call and want to understand its implementation
291+
- **Tip**:Includepackage prefixif symbol isambiguous (e.g.,`httpmw.ExtractAPIKeyMW`)
292+
293+
2. **Find symbol references** (ESSENTIALFORUNDERSTANDINGIMPACT):
294+
295+
```none
296+
mcp__go-language-server__references symbolName
297+
```
298+
299+
-Example:`mcp__go-language-server__references APITokenFromRequest`
300+
-Locate all usages of functions, types, or variables
301+
-Understand code dependencies and call patterns
302+
- **Use this when**:Making changes to understand what code might be affected
303+
- **Criticalfor**:Refactoring, deprecating functions, or understanding data flow
304+
305+
3. **Get symbol information** (HELPFULFORTYPEINFO):
306+
307+
```none
308+
mcp__go-language-server__hover filePath line column
309+
```
310+
311+
-Example:`mcp__go-language-server__hover /Users/thomask33/Projects/coder/coderd/httpmw/apikey.go 560 25`
312+
-Gettype information and documentation at specific positions
313+
- **Use this when**:You need to understand thetype of a variable orreturn value
314+
315+
4. **Edit files usingLSP** (WHENMAKINGTARGETEDCHANGES):
316+
317+
```none
318+
mcp__go-language-server__edit_file filePath edits
319+
```
320+
321+
-Make precise edits using line numbers
322+
- **Use this when**:You need to make small, targeted changes to specific lines
323+
324+
5. **Get diagnostics** (ALWAYSCHECKAFTERCHANGES):
325+
326+
```none
327+
mcp__go-language-server__diagnostics filePath
328+
```
329+
330+
-Checkfor compilation errors, unused imports, etc.
331+
- **Use this when**:After making changes to ensure code is still valid
332+
333+
###LSPToolUsagePriority
334+
335+
**ALWAYSUSETHESETOOLSFIRST**:
336+
337+
- **UseLSP`definition`** instead of manual searchingfor function implementations
338+
- **UseLSP`references`** instead of grep when lookingfor function/type usage
339+
- **UseLSP`hover`** to understand types and signatures
340+
- **UseLSP`diagnostics`** after making changes to checkfor errors
341+
342+
**When to use other tools**:
343+
344+
- **UseGrepfor**:Text-based searches, finding patterns across files, searching comments
345+
- **UseBashfor**:Running tests, git commands, build operations
346+
- **UseRead toolfor**:Reading configuration files, documentation, non-Go files
347+
348+
###InvestigationStrategy (LSP-FirstApproach)
349+
350+
1. **Start with route registration** in`coderd/coderd.go` to understandAPI endpoints
351+
2. **UseLSP`definition` lookup** to trace from route handlers to actual implementations
352+
3. **UseLSP`references`** to understand how functions are called throughout the codebase
353+
4. **Follow the middleware chain** usingLSP tools to understand request processing flow
354+
5. **Check test files**for expected behavior anderror patterns
355+
6. **UseLSP`diagnostics`** to ensure your changes don't break compilation
356+
357+
### Common LSP Workflows
358+
359+
**Understanding a new feature**:
360+
361+
1. Use `grep` to find the main entry point (e.g., route registration)
362+
2. Use LSP `definition` to jump to handler implementation
363+
3. Use LSP `references` to see how the handler is used
364+
4. Use LSP `definition` on each function call within the handler
365+
366+
**Making changes to existing code**:
367+
368+
1. Use LSP `references` to understand the impact of your changes
369+
2. Use LSP `definition` to understand the current implementation
370+
3. Make your changes using `Edit` or LSP `edit_file`
371+
4. Use LSP `diagnostics` to verify your changes compile correctly
372+
5. Run tests to ensure functionality still works
373+
374+
**Debugging issues**:
375+
376+
1. Use LSP `definition` to find the problematic function
377+
2. Use LSP `references` to trace how the function is called
378+
3. Use LSP `hover` to understand parameter types and return values
379+
4. Use `Read` to examine the full context around the issue
380+
273381
## Testing Scripts
274382
275383
### OAuth2 Test Scripts

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp