haskell / haskell/haskell-language-server

Make haskell-language-server work with `NormalizedUri` instead of `NormalizedFilePath`

Open
#4,504 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

Currently, hls assumes that everything that it is working with are files. This is true even for the VFS.

This is a problem because it prevents hls to work with URIs like `inmemory://`, which would be useful when trying to deploy haskell-language-server on an online-playground-like webpage (as an example).

The interesting bit is that there are very few places where the knowledge that something is a filepath (vs an URI) is actually required, (probably) non-exhaustive list
- `FileExists.getFileExistsVFS` (we need to load the file if the file is not part of the virtual file system)
- `FileStore.addWatchedFileRule` (we need to register file watchers, I think there should be an error here, if the uri is not a file)
- `FileStore.getModificationTimeImpl` (we need to get the last modified date of the file, we can just assume that the last modified date is the current time, or annotate this as an optional information)
- `IdeConfiguration.isWorkspaceFile` (we need to check if the path is relative, but I think that can be worked around by just assuming that an URI that is not a filepath is part of the workspace)

I know that changing `NormalizedFilePath` to `NormalizedUri` quickly is possible and I also know that it works, but I think that would leave HLS with a lot of kind of "ad hoc" logic where

- you check that the thing if that thing is a file
- you do something with the filepath

I think this is an option because it seems as if this is done quite a lot in `Notifications` with `whenUriFile` but maybe someone has an idea of how to create a better interface of "things that are only supported if the uri is a file"

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing NormalizedFilePath and NormalizedUri through FileExists.getFileExistsVFS, FileStore.addWatchedFileRule, FileStore.getModificationTimeImpl, and IdeConfiguration.isWorkspaceFile. Review the existing Notifications.whenUriFile handling and determine an interface for URI operations that require filesystem paths. Done means HLS supports non-file URIs without ad hoc checks while preserving file watching, loading, modification-time, and workspace behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.