Skip to content

Commit f7476b9

Browse files
committed
update readme
1 parent 6914b0c commit f7476b9

File tree

2 files changed

+63
-17
lines changed

2 files changed

+63
-17
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,45 @@ Replace:
6969
- Any env variables are passed on to the language server. Some may be necessary for you language server. For example, `gopls` required `GOPATH` and `GOCACHE` in order for me to get it working properly.
7070
- `DEBUG=1` is optional. See below.
7171

72-
For example, for python it might look like
72+
## Development
73+
Clone the repository:
74+
75+
```bash
76+
git clone https://github.com/isaacphi/mcp-language-server.git
77+
cd mcp-language-server
78+
```
79+
80+
Install development dependencies:
81+
82+
```bash
83+
go mod download
84+
```
85+
86+
Build and run directly:
87+
88+
```bash
89+
go run cmd/server/main.go --workspace /path/to/test/workspace --lsp /path/to/language/server
90+
```
91+
92+
Configure your Claude Desktop (or similar) to use the local version:
93+
94+
```json
95+
{
96+
"mcpServers": {
97+
"language-server": {
98+
"command": "go",
99+
"args": [
100+
"run",
101+
"/full/path/to/your/clone/cmd/server",
102+
"--workspace",
103+
"/path/to/workspace",
104+
"--lsp",
105+
"/path/to/language/server"
106+
]
107+
}
108+
}
109+
}
110+
```
73111

74112
## Feedback
75113

internal/watcher/main.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ import (
1515
gitignore "github.com/sabhiram/go-gitignore"
1616
)
1717

18+
var debug = os.Getenv("DEBUG") != ""
19+
1820
// WorkspaceWatcher manages file watching and version tracking
1921
type WorkspaceWatcher struct {
2022
client *lsp.Client
2123
ignore *gitignore.GitIgnore
2224
workspacePath string
2325

24-
// Debouncing related fields
2526
debounceTime time.Duration
2627
debounceMap map[string]*time.Timer
2728
debounceMu sync.Mutex
2829
}
2930

30-
// NewWorkspaceWatcher creates a new instance of WorkspaceWatcher
3131
func NewWorkspaceWatcher(client *lsp.Client) *WorkspaceWatcher {
3232
return &WorkspaceWatcher{
3333
client: client,
34-
debounceTime: 1000 * time.Millisecond, // Configurable debounce duration
34+
debounceTime: 1000 * time.Millisecond,
3535
debounceMap: make(map[string]*time.Timer),
3636
}
3737
}
@@ -42,7 +42,9 @@ func (w *WorkspaceWatcher) loadGitIgnore(workspacePath string) error {
4242
// Read and log the content of .gitignore
4343
content, err := os.ReadFile(gitignorePath)
4444
if err != nil {
45-
log.Printf("DEBUG: Error reading .gitignore: %v", err)
45+
if debug {
46+
log.Printf("DEBUG: Error reading .gitignore: %v", err)
47+
}
4648
return fmt.Errorf("error reading gitignore: %w", err)
4749
}
4850
log.Printf("DEBUG: .gitignore content:\n%s", string(content))
@@ -53,14 +55,15 @@ func (w *WorkspaceWatcher) loadGitIgnore(workspacePath string) error {
5355
}
5456
w.ignore = ignore
5557

56-
log.Printf("DEBUG: Successfully loaded .gitignore")
58+
if debug {
59+
log.Printf("DEBUG: Successfully loaded .gitignore")
60+
}
5761
return nil
5862
}
5963

6064
func (w *WorkspaceWatcher) shouldIgnorePath(path string, workspacePath string) bool {
6165
// Always ignore .git directory
6266
if filepath.Base(path) == ".git" {
63-
log.Printf("DEBUG: Ignoring .git directory: %s", path)
6467
return true
6568
}
6669

@@ -81,13 +84,15 @@ func (w *WorkspaceWatcher) shouldIgnorePath(path string, workspacePath string) b
8184

8285
matches, pattern := w.ignore.MatchesPathHow(relPath)
8386

84-
log.Printf("DEBUG: Path check details:")
85-
log.Printf(" Original path: %s", path)
86-
log.Printf(" Workspace: %s", workspacePath)
87-
log.Printf(" Relative path: %s", relPath)
88-
log.Printf(" Matches? %v", matches)
89-
if pattern != nil {
90-
log.Printf(" Matched pattern: %s (line %d)", pattern.Line, pattern.LineNo)
87+
if debug {
88+
log.Printf("DEBUG: Path check details:")
89+
log.Printf(" Original path: %s", path)
90+
log.Printf(" Workspace: %s", workspacePath)
91+
log.Printf(" Relative path: %s", relPath)
92+
log.Printf(" Matches gitignore? %v", matches)
93+
if pattern != nil {
94+
log.Printf(" Matched pattern: %s (line %d)", pattern.Line, pattern.LineNo)
95+
}
9196
}
9297

9398
return matches
@@ -117,7 +122,6 @@ func (w *WorkspaceWatcher) WatchWorkspace(ctx context.Context, workspacePath str
117122
}
118123

119124
if info.IsDir() {
120-
// Check if directory should be ignored
121125
if w.shouldIgnorePath(path, workspacePath) {
122126
return filepath.SkipDir
123127
}
@@ -151,13 +155,17 @@ func (w *WorkspaceWatcher) WatchWorkspace(ctx context.Context, workspacePath str
151155

152156
// Skip temporary files and backup files
153157
if strings.HasSuffix(event.Name, "~") || strings.HasSuffix(event.Name, ".swp") {
154-
log.Println("Skipping ~")
158+
if debug {
159+
log.Println("Skipping temporary file")
160+
}
155161
continue
156162
}
157163

158164
// Skip ignored paths
159165
if w.shouldIgnorePath(event.Name, workspacePath) {
160-
log.Println("Skipping", event.Name)
166+
if debug {
167+
log.Println("Skipping", event.Name)
168+
}
161169
continue
162170
}
163171

0 commit comments

Comments
 (0)