Skip to content

Commit

Permalink
Use our normal auto-incrementing ids instead of UUIDs
Browse files Browse the repository at this point in the history
The spec just says they have to be unique IDs, not UUIDs, and we already
have a tool for generating such things.
  • Loading branch information
michaelpj committed May 17, 2024
1 parent c15fa82 commit 5d5d76b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion lsp/lsp.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ library
, unliftio ^>=0.2
, unliftio-core ^>=0.2
, unordered-containers ^>=0.2
, uuid >=1.3

executable lsp-demo-reactor-server
import: warnings
Expand Down
8 changes: 3 additions & 5 deletions lsp/src/Language/LSP/Server/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import Data.Monoid (Ap (..))
import Data.Ord (Down (Down))
import Data.Text (Text)
import Data.Text qualified as T
import Data.UUID qualified as UUID
import Language.LSP.Diagnostics
import Language.LSP.Protocol.Capabilities
import Language.LSP.Protocol.Lens qualified as L
Expand All @@ -61,7 +60,6 @@ import Language.LSP.Protocol.Utils.SMethodMap (SMethodMap)
import Language.LSP.Protocol.Utils.SMethodMap qualified as SMethodMap
import Language.LSP.VFS hiding (end)
import Prettyprinter
import System.Random hiding (next)

-- ---------------------------------------------------------------------
{-# ANN module ("HLint: ignore Eta reduce" :: String) #-}
Expand Down Expand Up @@ -590,10 +588,10 @@ trySendRegistration logger method regOpts = do
-- First, check to see if the client supports dynamic registration on this method
if dynamicRegistrationSupported method clientCaps
then do
uuid <- liftIO $ UUID.toText <$> getStdRandom random
let registration = L.TRegistration uuid method (Just regOpts)
rid <- T.pack . show <$> freshLspId
let registration = L.TRegistration rid method (Just regOpts)
params = L.RegistrationParams [toUntypedRegistration registration]
regId = RegistrationId uuid
regId = RegistrationId rid

-- TODO: handle the scenario where this returns an error
_ <- sendRequest SMethod_ClientRegisterCapability params $ \_res -> pure ()
Expand Down

0 comments on commit 5d5d76b

Please sign in to comment.