From a5c7893bb9705b37eb2f12b62018691e8269e508 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Wed, 7 Jan 2026 17:35:04 -0800 Subject: [PATCH 1/3] Get on latest lsp-test 0.17.1.1 with our monad upgrades --- tests/app/Spec/Tests/Rust/Changes.hs | 3 +- tests/app/Spec/Tests/Typst.hs | 6 +-- tests/flake.nix | 2 +- tests/src/TestLib/LSP.hs | 29 ++++++------ tests/stack.yaml | 13 ++---- tests/stack.yaml.lock | 66 ++++++++-------------------- 6 files changed, 39 insertions(+), 80 deletions(-) diff --git a/tests/app/Spec/Tests/Rust/Changes.hs b/tests/app/Spec/Tests/Rust/Changes.hs index 2141f32f..5d21181a 100644 --- a/tests/app/Spec/Tests/Rust/Changes.hs +++ b/tests/app/Spec/Tests/Rust/Changes.hs @@ -5,7 +5,6 @@ module Spec.Tests.Rust.Changes (tests) where import Control.Lens import Data.Function import qualified Data.List as L -import Data.Row.Records import Data.String.Interpolate import qualified Language.LSP.Protocol.Lens as LSP import Language.LSP.Protocol.Types @@ -27,7 +26,7 @@ tests = describe "Changes" $ do , (Range (Position 0 7) (Position 0 7), Just (InR "E0423"), "use `!` to invoke the macro: `!`") ] - changeDoc ident [TextDocumentContentChangeEvent $ InL (#range .== (Range (p 0 7) (p 0 7)) .+ #rangeLength .== Nothing .+ #text .== "z")] + changeDoc ident [TextDocumentContentChangeEvent $ InL $ TextDocumentContentChangePartial (Range (p 0 7) (p 0 7)) Nothing "z"] waitUntil 120.0 $ do waitForDiagnostics >>= \diags -> do diff --git a/tests/app/Spec/Tests/Typst.hs b/tests/app/Spec/Tests/Typst.hs index e704cfbc..b5f1cbe7 100644 --- a/tests/app/Spec/Tests/Typst.hs +++ b/tests/app/Spec/Tests/Typst.hs @@ -4,20 +4,15 @@ module Spec.Tests.Typst (tests) where -import Control.Lens hiding (List) import Control.Monad import Data.String.Interpolate import Data.Text as T -import Language.LSP.Protocol.Lens hiding (diagnostics, hover, text) import Language.LSP.Protocol.Types -import Language.LSP.Test hiding (message) import Test.Sandwich as Sandwich import TestLib.JupyterRunnerContext import TestLib.LSP import TestLib.NixEnvironmentContext -import TestLib.NixTypes import TestLib.TestBuilding -import TestLib.TestSearchers import TestLib.Types @@ -71,6 +66,7 @@ lsName = "tinymist" -- ] -- } +config :: [Text] config = [ "exporters.typst.enable = true;" , "exporters.typst.lsp.tinymist.enable = true;" diff --git a/tests/flake.nix b/tests/flake.nix index ec6d84a6..c42c2576 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -19,7 +19,7 @@ postgresql.pg_config zlib - haskell.compiler.ghc96 + haskell.compiler.ghc9122 ]; NIX_PATH = "nixpkgs=${pkgs.path}"; diff --git a/tests/src/TestLib/LSP.hs b/tests/src/TestLib/LSP.hs index 7e142f47..ac3f34e1 100644 --- a/tests/src/TestLib/LSP.hs +++ b/tests/src/TestLib/LSP.hs @@ -23,11 +23,10 @@ import qualified Data.List as L import Data.Map (Map) import qualified Data.Map as M import Data.Maybe -import Data.Row.Records hiding (Map) import qualified Data.Set as S import Data.String.Interpolate import qualified Data.Text as T hiding (filter) -import Data.Text hiding (filter) +import Data.Text hiding (filter, show) import qualified Data.Text.IO as T import GHC.Int import GHC.Stack @@ -66,7 +65,7 @@ data LanguageServerConfig = LanguageServerConfig { , lspConfigPrimary :: Maybe Bool , lspConfigArgs :: [Text] , lspConfigLanguageId :: Maybe Text - , lspConfigInitializationOptions :: Maybe A.Value + , lspConfigInitializationOptions :: Maybe A.Object , lspConfigNotebookSuffix :: Text , lspConfigKernelName :: Maybe Text , lspConfigEnv :: Maybe (Map Text Text) @@ -103,20 +102,20 @@ doSession' filename lsName codeToUse cb = do testDiagnostics :: ( LspContext ctx m - ) => Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () + ) => Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () testDiagnostics name filename maybeLanguageId codeToTest = testDiagnostics' name filename maybeLanguageId codeToTest [] testDiagnostics' :: ( LspContext ctx m - ) => Text -> FilePath -> Maybe Text -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () + ) => Text -> FilePath -> Maybe LanguageKind -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () testDiagnostics' name filename maybeLanguageId codeToTest = testDiagnostics'' [i|#{name}, #{filename} with #{show codeToTest} (diagnostics)|] name filename maybeLanguageId codeToTest testDiagnosticsLabelDesired :: ( LspContext ctx m - ) => String -> Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> Bool) -> SpecFree ctx m () + ) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> Bool) -> SpecFree ctx m () testDiagnosticsLabelDesired label name filename maybeLanguageId codeToTest cb = it label $ withLspSession' id name filename codeToTest [] $ \_homeDir -> do - _ <- openDoc filename (fromMaybe name maybeLanguageId) + _ <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId) lastSeenDiagsVar <- newTVarIO mempty @@ -137,15 +136,15 @@ testDiagnosticsLabelDesired label name filename maybeLanguageId codeToTest cb = testDiagnosticsLabel :: ( LspContext ctx m - ) => String -> Text -> FilePath -> Maybe Text -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () + ) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () testDiagnosticsLabel label name filename maybeLanguageId codeToTest = testDiagnostics'' label name filename maybeLanguageId codeToTest [] testDiagnostics'' :: ( LspContext ctx m - ) => String -> Text -> FilePath -> Maybe Text -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () + ) => String -> Text -> FilePath -> Maybe LanguageKind -> Text -> [(FilePath, B.ByteString)] -> ([Diagnostic] -> ExampleT ctx m ()) -> SpecFree ctx m () testDiagnostics'' label name filename maybeLanguageId codeToTest extraFiles cb = it label $ do withLspSession' id name filename codeToTest extraFiles $ \_homeDir -> do - _ <- openDoc filename (fromMaybe name maybeLanguageId) + _ <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId) lastSeenDiagsVar <- newIORef mempty @@ -158,10 +157,10 @@ testDiagnostics'' label name filename maybeLanguageId codeToTest extraFiles cb = itHasHoverSatisfying :: ( LspContext ctx m - ) => Text -> FilePath -> Maybe Text -> Text -> Position -> (Hover -> ExampleT ctx m ()) -> SpecFree ctx m () + ) => Text -> FilePath -> Maybe LanguageKind -> Text -> Position -> (Hover -> ExampleT ctx m ()) -> SpecFree ctx m () itHasHoverSatisfying name filename maybeLanguageId codeToTest pos cb = it [i|#{name}: #{show codeToTest} (hover)|] $ do withLspSession name filename codeToTest [] $ \_homeDir -> do - ident <- openDoc filename (fromMaybe name maybeLanguageId) + ident <- openDoc filename (fromMaybe (LanguageKind_Custom name) maybeLanguageId) getHover ident pos >>= \case Nothing -> expectationFailure [i|Expected a hover.|] Just x -> lift $ cb x @@ -204,7 +203,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do -- Comment this and use openDoc' to simulate an unsaved document liftIO $ T.writeFile (homeDir filename) codeToTest - let sessionConfig = def { lspConfig = lspConfigInitializationOptions config + let sessionConfig = def { lspConfig = fromMaybe mempty (lspConfigInitializationOptions config) , logStdErr = True , logMessages = True , messageTimeout = 120 @@ -251,7 +250,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do info [i|LSP command: #{cp}|] -- We don't support certain server-to-client requests, since the waitForDiagnostics doesn't handle them - let caps = fullCaps + let caps = fullLatestClientCaps & set (workspace . _Just . workspaceFolders) Nothing & set (workspace . _Just . configuration) Nothing & set (workspace . _Just . didChangeWatchedFiles . _Just . dynamicRegistration) (Just False) @@ -314,7 +313,7 @@ allHoverContentsText (InR markedStrings) = case markedStrings of InR mss -> mconcat $ fmap markedStringToText mss where markedStringToText (MarkedString (InL t)) = t - markedStringToText (MarkedString (InR thing)) = thing .! #value + markedStringToText (MarkedString (InR thing)) = thing ^. LSP.value containsAll :: Text -> [Text] -> Bool containsAll haystack = Prelude.all (`T.isInfixOf` haystack) diff --git a/tests/stack.yaml b/tests/stack.yaml index 256c8cb1..1b4dd057 100644 --- a/tests/stack.yaml +++ b/tests/stack.yaml @@ -1,5 +1,5 @@ -resolver: lts-22.44 +resolver: nightly-2025-12-25 packages: - . @@ -11,21 +11,14 @@ system-ghc: true extra-deps: - git: https://github.com/codedownio/lsp.git - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + # upgrade-monads-newest-jan2026 branch + commit: d920b28aa25d454812d8d9bbd922e893574d45bc subdirs: - lsp - lsp-test - lsp-types -- sandwich-0.3.0.3 -- sandwich-contexts-0.3.0.1 - -# Needed by newer sandwich -- vty-windows-0.2.0.0 - - ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293 -- crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581 - - git: https://github.com/codedownio/minio-hs commit: 768665c90321d118fdd3cde2c6ac6c01310d76a0 diff --git a/tests/stack.yaml.lock b/tests/stack.yaml.lock index f41ff60a..6ccde934 100644 --- a/tests/stack.yaml.lock +++ b/tests/stack.yaml.lock @@ -5,65 +5,44 @@ packages: - completed: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git name: lsp pantry-tree: - sha256: 9d8370277cc83f157edf368042479b89a770aba92b8aa4072b3426b6b489c12b - size: 1043 + sha256: 0463d2462d7690aa877cf2f79279cc1902be006ca7bfcae34da1a56b46c7d00c + size: 1121 subdir: lsp - version: 2.0.0.0 + version: 2.7.0.1 original: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git subdir: lsp - completed: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git name: lsp-test pantry-tree: - sha256: ae5d36c3d41b027768f7f62c55a8885ba28c2d9674a135c4c98394778a6a06e3 - size: 2225 + sha256: 3671570067b55febf7903af85164d35aa515851318e69b31f048998e64362c6a + size: 2304 subdir: lsp-test - version: 0.15.0.0 + version: 0.17.1.1 original: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git subdir: lsp-test - completed: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git name: lsp-types pantry-tree: - sha256: f8617d8aaa142ecc8ce62e0b2d930669d4969b6b9143368d20b1680874b8077c - size: 45522 + sha256: 08d01a9208540b71e038e6fb85793a42785b37fa390f6f57df2eba0a5e87fe8e + size: 52176 subdir: lsp-types - version: 2.0.0.1 + version: 2.3.0.1 original: - commit: 673ff007ce08aed7cf3cf8a5050b4066948afa91 + commit: d920b28aa25d454812d8d9bbd922e893574d45bc git: https://github.com/codedownio/lsp.git subdir: lsp-types -- completed: - hackage: sandwich-0.3.0.3@sha256:1cd757d3e7af7aaaa68cf91b125aace3fde87a1a347c25e14e3cbf78282eea99,9221 - pantry-tree: - sha256: a583451e9d393700383654d8ab631bf22d246184d29ffdde0745fdc8e549496e - size: 6145 - original: - hackage: sandwich-0.3.0.3 -- completed: - hackage: sandwich-contexts-0.3.0.1@sha256:de63f120457c084035313f85fe323bc61a172c99a600b134b9322e26ac42a790,3085 - pantry-tree: - sha256: f6cad8a7d1ba25e6d602dc67d5ef06243b139c818f2b11cd0fa369b106cdb444 - size: 1665 - original: - hackage: sandwich-contexts-0.3.0.1 -- completed: - hackage: vty-windows-0.2.0.0@sha256:91a11bab7bb79f8ee0d4a8166824ed855251cbac101eed3fdf607ad519a13557,2815 - pantry-tree: - sha256: 50d343eb4df5d1901b1773baeaff8ae7c6a88204d0997430e26f0dc50a1a63eb - size: 2160 - original: - hackage: vty-windows-0.2.0.0 - completed: hackage: ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293 pantry-tree: @@ -71,13 +50,6 @@ packages: size: 253 original: hackage: ex-pool-0.2.1@sha256:c8249338ced27bc4d6395ad9c3069eec394fb111813d6ec736814d095f7e6a24,1293 -- completed: - hackage: crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581 - pantry-tree: - sha256: e35ac3a35611afab9fafac633d0c4e6328b9cce4c8262378671d6c5a739e7e70 - size: 394 - original: - hackage: crypton-connection-0.3.1@sha256:4d0958537197956b536ea91718b1749949757022532f50b8f683290056a19021,1581 - completed: commit: 768665c90321d118fdd3cde2c6ac6c01310d76a0 git: https://github.com/codedownio/minio-hs @@ -91,7 +63,7 @@ packages: git: https://github.com/codedownio/minio-hs snapshots: - completed: - sha256: 238fa745b64f91184f9aa518fe04bdde6552533d169b0da5256670df83a0f1a9 - size: 721141 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/44.yaml - original: lts-22.44 + sha256: 671a94f04c2cb37457b71c66134242d4b12ab703597c19fad769df2d5e1e5659 + size: 715416 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2025/12/25.yaml + original: nightly-2025-12-25 From e6573e5b995211d8801fe84bce9095b6f987ce3f Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Thu, 8 Jan 2026 17:55:33 -0800 Subject: [PATCH 2/3] Pyright test passes when we cap LSP version at 3.15? --- tests/src/TestLib/LSP.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/TestLib/LSP.hs b/tests/src/TestLib/LSP.hs index ac3f34e1..11d1259b 100644 --- a/tests/src/TestLib/LSP.hs +++ b/tests/src/TestLib/LSP.hs @@ -30,6 +30,7 @@ import Data.Text hiding (filter, show) import qualified Data.Text.IO as T import GHC.Int import GHC.Stack +import Language.LSP.Protocol.Capabilities import Language.LSP.Protocol.Lens as LSP hiding (diagnostics, hover, id, label, name, ranges) import Language.LSP.Protocol.Types import Language.LSP.Test @@ -250,7 +251,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do info [i|LSP command: #{cp}|] -- We don't support certain server-to-client requests, since the waitForDiagnostics doesn't handle them - let caps = fullLatestClientCaps + let caps = fullClientCapsForVersion (LSPVersion 3 15) & set (workspace . _Just . workspaceFolders) Nothing & set (workspace . _Just . configuration) Nothing & set (workspace . _Just . didChangeWatchedFiles . _Just . dynamicRegistration) (Just False) From a85673b4f57d9b4ef6e2139252863ed4c187fbb5 Mon Sep 17 00:00:00 2001 From: Tom McLaughlin Date: Thu, 8 Jan 2026 18:09:04 -0800 Subject: [PATCH 3/3] Pyright also works with 3.16 --- tests/src/TestLib/LSP.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/TestLib/LSP.hs b/tests/src/TestLib/LSP.hs index 11d1259b..c9532605 100644 --- a/tests/src/TestLib/LSP.hs +++ b/tests/src/TestLib/LSP.hs @@ -251,7 +251,7 @@ withLspSession' handleFn name filename codeToTest extraFiles session = do info [i|LSP command: #{cp}|] -- We don't support certain server-to-client requests, since the waitForDiagnostics doesn't handle them - let caps = fullClientCapsForVersion (LSPVersion 3 15) + let caps = fullClientCapsForVersion (LSPVersion 3 16) & set (workspace . _Just . workspaceFolders) Nothing & set (workspace . _Just . configuration) Nothing & set (workspace . _Just . didChangeWatchedFiles . _Just . dynamicRegistration) (Just False)