Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

[WIP] Use haskell-lsp with VFS race condition fix #1446

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@
# url = /~https://github.com/bubba/ghc-mod.git
url = /~https://github.com/alanz/ghc-mod.git

[submodule "submodules/haskell-lsp"]
path = submodules/haskell-lsp
url = /~https://github.com/alanz/haskell-lsp.git
[submodule "submodules/lsp-test"]
path = submodules/lsp-test
url = /~https://github.com/alanz/lsp-test.git
3 changes: 3 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ packages:
./submodules/ghc-mod/
./submodules/ghc-mod/core/
./submodules/ghc-mod/ghc-project-types
./submodules/haskell-lsp
./submodules/haskell-lsp/haskell-lsp-types
./submodules/lsp-test

tests: true

Expand Down
2 changes: 1 addition & 1 deletion hie-plugin-api/Haskell/Ide/Engine/PluginUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ readVFS :: (MonadIde m, MonadIO m) => Uri -> m (Maybe T.Text)
readVFS uri = do
mvf <- getVirtualFile uri
case mvf of
Just (VirtualFile _ txt _) -> return $ Just (Rope.toText txt)
Just (VirtualFile _ txt) -> return $ Just (Rope.toText txt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make VirtualFile more abstract and provide an accessor to get the text out (I have this on my dejafu branch).

Nothing -> return Nothing

getRangeFromVFS :: (MonadIde m, MonadIO m) => Uri -> Range -> m (Maybe T.Text)
Expand Down
45 changes: 32 additions & 13 deletions src/Haskell/Ide/Engine/Transport/LspStdio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import qualified Data.ByteString.Lazy as BL
import Data.Coerce (coerce)
import Data.Default
import Data.Foldable
import Data.List.NonEmpty ( nonEmpty )
import qualified Data.Map as Map
import Data.Maybe
import Data.Semigroup (Semigroup(..), Option(..), option)
Expand Down Expand Up @@ -219,8 +220,8 @@ mapFileFromVfs tn vtdi = do
vfsFunc <- asksLspFuncs Core.getVirtualFileFunc
mvf <- liftIO $ vfsFunc (J.toNormalizedUri uri)
case (mvf, uriToFilePath uri) of
(Just (VFS.VirtualFile _ yitext _), Just fp) -> do
let text' = Rope.toString yitext
(Just (VFS.VirtualFile _ rope), Just fp) -> do
let text' = Rope.toString rope
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

-- text = "{-# LINE 1 \"" ++ fp ++ "\"#-}\n" <> text'
let req = GReq tn (Just uri) Nothing Nothing (const $ return ())
$ IdeResultOk <$> do
Expand Down Expand Up @@ -798,7 +799,7 @@ withDocumentContents reqId uri f = do
(J.responseId reqId)
J.InvalidRequest
"Document was not open"
Just (VFS.VirtualFile _ txt _) -> f (Rope.toText txt)
Just (VFS.VirtualFile _ txt) -> f (Rope.toText txt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here..


-- | Get the currently configured formatter provider.
-- The currently configured formatter provider is defined in @Config@ by PluginId.
Expand Down Expand Up @@ -966,16 +967,34 @@ syncOptions = J.TextDocumentSyncOptions
hieOptions :: [T.Text] -> Core.Options
hieOptions commandIds =
def { Core.textDocumentSync = Just syncOptions
, Core.completionProvider = Just (J.CompletionOptions (Just True) (Just ["."]))
-- As of 2018-05-24, vscode needs the commands to be registered
-- otherwise they will not be available as codeActions (will be
-- silently ignored, despite UI showing to the contrary).
--
-- Hopefully the end May 2018 vscode release will stabilise
-- this, it is a major rework of the machinery anyway.
, Core.executeCommandProvider = Just (J.ExecuteCommandOptions (J.List commandIds))
, Core.renameProvider = Just (J.RenameOptions (Just True))
, Core.implementationProvider = Just (J.GotoOptionsStatic True)
-- The characters that trigger completion automatically.
, Core.completionTriggerCharacters = Just ['.']

-- The list of all possible characters that commit a completion. This field can be used
-- if clients don't support individual commmit characters per completion item. See
-- `_commitCharactersSupport`.
-- , completionAllCommitCharacters :: Maybe [Char]

-- The characters that trigger signature help automatically.
-- , signatureHelpTriggerCharacters :: Maybe [Char]

-- List of characters that re-trigger signature help.
-- These trigger characters are only active when signature help is already showing. All trigger characters
-- are also counted as re-trigger characters.
-- , signatureHelpRetriggerCharacters :: Maybe [Char]

-- CodeActionKinds that this server may return.
-- The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
-- may list out every specific kind they provide.
-- , codeActionKinds :: Maybe [J.CodeActionKind]

-- The list of characters that triggers on type formatting.
-- If you set `documentOnTypeFormattingHandler`, you **must** set this.
, Core.documentOnTypeFormattingTriggerCharacters = nonEmpty []

-- The commands to be executed on the server.
-- If you set `executeCommandHandler`, you **must** set this.
, Core.executeCommandCommands = Just commandIds
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if these are set up correctly, please provide input.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know either is this @bubba who changed it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a branch for these options, I'll apply it on top of this after this is merged /~https://github.com/bubba/haskell-ide-engine/tree/new-haskell-lsp-options

}


Expand Down
9 changes: 6 additions & 3 deletions stack-8.4.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- brittany-0.12.1.0
- base-compat-0.9.3
Expand All @@ -19,14 +22,14 @@ extra-deps:
- ghc-lib-parser-8.8.1
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- pretty-show-1.8.2
- rope-utf16-splay-0.3.1.0
Expand Down
9 changes: 6 additions & 3 deletions stack-8.4.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- base-compat-0.9.3
- brittany-0.12.1.0
Expand All @@ -19,14 +22,14 @@ extra-deps:
- ghc-lib-parser-8.8.1
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- pretty-show-1.8.2
- rope-utf16-splay-0.3.1.0
Expand Down
9 changes: 6 additions & 3 deletions stack-8.4.4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- brittany-0.12.1.0
- cabal-plan-0.4.0.0
Expand All @@ -18,14 +21,14 @@ extra-deps:
- ghc-lib-parser-8.8.1
- haddock-api-2.20.0
- haddock-library-1.6.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- optparse-simple-0.1.0
- pretty-show-1.9.5
Expand Down
9 changes: 6 additions & 3 deletions stack-8.6.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- apply-refact-0.6.0.0
- brittany-0.12.1.0
Expand All @@ -22,14 +25,14 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.21.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- monoid-subclasses-0.4.6.1
Expand Down
9 changes: 6 additions & 3 deletions stack-8.6.2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- brittany-0.12.1.0
- butcher-1.3.2.3
Expand All @@ -18,14 +21,14 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.21.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- multistate-0.8.0.1
Expand Down
9 changes: 6 additions & 3 deletions stack-8.6.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- brittany-0.12.1.0
- butcher-1.3.2.1
Expand All @@ -17,14 +20,14 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.21.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- haskell-src-exts-util-0.2.5
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2
- monad-memo-0.4.1
- multistate-0.8.0.1
Expand Down
9 changes: 6 additions & 3 deletions stack-8.6.4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- brittany-0.12.1.0
- butcher-1.3.2.1
Expand All @@ -17,13 +20,13 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.22.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- haskell-src-exts-1.21.1
- hlint-2.2.3
- hoogle-5.0.17.11
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- monad-memo-0.4.1
- multistate-0.8.0.1
Expand Down
9 changes: 6 additions & 3 deletions stack-8.6.5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- ansi-terminal-0.8.2
- ansi-wl-pprint-0.6.8.2
Expand All @@ -18,12 +21,12 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.22.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- hlint-2.2.3
- hsimport-0.11.0
- hoogle-5.0.17.11
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- syz-0.2.0.0
- temporary-1.2.1.1
Expand Down
9 changes: 6 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extra-deps:
- ./submodules/ghc-mod
- ./submodules/ghc-mod/core
- ./submodules/ghc-mod/ghc-project-types
- ./submodules/haskell-lsp
- ./submodules/haskell-lsp/haskell-lsp-types
- ./submodules/lsp-test

- ansi-terminal-0.8.2
- ansi-wl-pprint-0.6.8.2
Expand All @@ -18,11 +21,11 @@ extra-deps:
- floskell-0.10.1
- ghc-lib-parser-8.8.1
- haddock-api-2.22.0
- haskell-lsp-0.17.0.0
- haskell-lsp-types-0.17.0.0
# - haskell-lsp-0.17.0.0
# - haskell-lsp-types-0.17.0.0
- hlint-2.2.3
- hsimport-0.11.0
- lsp-test-0.8.0.0
# - lsp-test-0.8.0.0
- monad-dijkstra-0.1.1.2@rev:1
- syz-0.2.0.0
- temporary-1.2.1.1
Expand Down
1 change: 1 addition & 0 deletions submodules/haskell-lsp
Submodule haskell-lsp added at ea1dba
1 change: 1 addition & 0 deletions submodules/lsp-test
Submodule lsp-test added at 6f6933