@@ -131,7 +131,7 @@ func (c *Client) InitializeLSPClient(ctx context.Context, workspaceDir string) (
131 WorkspaceFoldersInitializeParams: protocol.WorkspaceFoldersInitializeParams{
131 WorkspaceFoldersInitializeParams: protocol.WorkspaceFoldersInitializeParams{
132 WorkspaceFolders: []protocol.WorkspaceFolder{
132 WorkspaceFolders: []protocol.WorkspaceFolder{
134− URI: protocol.URI("file://" + workspaceDir),
134+ URI: protocol.URI(protocol.URIFromPath(workspaceDir)),
135 Name: workspaceDir,
135 Name: workspaceDir,
@@ -144,7 +144,7 @@ func (c *Client) InitializeLSPClient(ctx context.Context, workspaceDir string) (
144 Version: "0.1.0",
144 Version: "0.1.0",
146 RootPath: workspaceDir,
146 RootPath: workspaceDir,
147− RootURI: protocol.DocumentUri("file://" + workspaceDir),
147+ RootURI: protocol.URIFromPath(workspaceDir),
148 Capabilities: protocol.ClientCapabilities{
148 Capabilities: protocol.ClientCapabilities{
149 Workspace: protocol.WorkspaceClientCapabilities{
149 Workspace: protocol.WorkspaceClientCapabilities{
150 Configuration: true,
150 Configuration: true,
@@ -448,7 +448,7 @@ func (c *Client) pingTypeScriptServer(ctx context.Context) error {
449 // If we have any open files, try to get document symbols for one
449 // If we have any open files, try to get document symbols for one
450 for uri := range c.openFiles {
450 for uri := range c.openFiles {
451− filePath := strings.TrimPrefix(uri, "file://")
451+ filePath := protocol.DocumentUri(uri).Path()
452 if strings.HasSuffix(filePath, ".ts") || strings.HasSuffix(filePath, ".js") ||
452 if strings.HasSuffix(filePath, ".ts") || strings.HasSuffix(filePath, ".js") ||
453 strings.HasSuffix(filePath, ".tsx") || strings.HasSuffix(filePath, ".jsx") {
453 strings.HasSuffix(filePath, ".tsx") || strings.HasSuffix(filePath, ".jsx") {
454 var symbols []protocol.DocumentSymbol
454 var symbols []protocol.DocumentSymbol
@@ -586,7 +586,7 @@ type OpenFileInfo struct {
588func (c *Client) OpenFile(ctx context.Context, filepath string) error {
588func (c *Client) OpenFile(ctx context.Context, filepath string) error {
589− uri := fmt.Sprintf("file://%s", filepath)
589+ uri := string(protocol.URIFromPath(filepath))
591 c.openFilesMu.Lock()
591 c.openFilesMu.Lock()
592 if _, exists := c.openFiles[uri]; exists {
592 if _, exists := c.openFiles[uri]; exists {
@@ -625,7 +625,7 @@ func (c *Client) OpenFile(ctx context.Context, filepath string) error {
627func (c *Client) NotifyChange(ctx context.Context, filepath string) error {
627func (c *Client) NotifyChange(ctx context.Context, filepath string) error {
628− uri := fmt.Sprintf("file://%s", filepath)
628+ uri := string(protocol.URIFromPath(filepath))
630 content, err := os.ReadFile(filepath)
630 content, err := os.ReadFile(filepath)
631 if err != nil {
631 if err != nil {
@@ -665,7 +665,7 @@ func (c *Client) NotifyChange(ctx context.Context, filepath string) error {
666func (c *Client) CloseFile(ctx context.Context, filepath string) error {
666func (c *Client) CloseFile(ctx context.Context, filepath string) error {
667 cnf := config.Get()
667 cnf := config.Get()
668− uri := fmt.Sprintf("file://%s", filepath)
668+ uri := string(protocol.URIFromPath(filepath))
670 c.openFilesMu.Lock()
670 c.openFilesMu.Lock()
671 if _, exists := c.openFiles[uri]; !exists {
671 if _, exists := c.openFiles[uri]; !exists {
@@ -695,7 +695,7 @@ func (c *Client) CloseFile(ctx context.Context, filepath string) error {
697func (c *Client) IsFileOpen(filepath string) bool {
697func (c *Client) IsFileOpen(filepath string) bool {
698− uri := fmt.Sprintf("file://%s", filepath)
698+ uri := string(protocol.URIFromPath(filepath))
699 c.openFilesMu.RLock()
699 c.openFilesMu.RLock()
700 defer c.openFilesMu.RUnlock()
700 defer c.openFilesMu.RUnlock()
701 _, exists := c.openFiles[uri]
701 _, exists := c.openFiles[uri]
@@ -710,8 +710,8 @@ func (c *Client) CloseAllFiles(ctx context.Context) {
711 // First collect all URIs that need to be closed
711 // First collect all URIs that need to be closed
712 for uri := range c.openFiles {
712 for uri := range c.openFiles {
713− // Convert URI back to file path by trimming "file://" prefix
713+ // Convert URI back to file path using proper URI handling
714− filePath := strings.TrimPrefix(uri, "file://")
714+ filePath := protocol.DocumentUri(uri).Path()
715 filesToClose = append(filesToClose, filePath)
715 filesToClose = append(filesToClose, filePath)
717 c.openFilesMu.Unlock()
717 c.openFilesMu.Unlock()
@@ -756,8 +756,7 @@ func (c *Client) OpenFileOnDemand(ctx context.Context, filepath string) error {
756// GetDiagnosticsForFile ensures a file is open and returns its diagnostics
756// GetDiagnosticsForFile ensures a file is open and returns its diagnostics
757// This is useful for on-demand diagnostics when using lazy loading
757// This is useful for on-demand diagnostics when using lazy loading
758func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]protocol.Diagnostic, error) {
758func (c *Client) GetDiagnosticsForFile(ctx context.Context, filepath string) ([]protocol.Diagnostic, error) {
759− uri := fmt.Sprintf("file://%s", filepath)
760− documentUri := protocol.DocumentUri(uri)
759+ documentUri := protocol.URIFromPath(filepath)
762 // Make sure the file is open
761 // Make sure the file is open
763 if !c.IsFileOpen(filepath) {
762 if !c.IsFileOpen(filepath) {