lsp 1.0.0.1 → 1.1.0.0
raw patch · 6 files changed
+79/−20 lines, 6 filesdep ~lsp-typesdep ~unliftio-core
Dependency ranges changed: lsp-types, unliftio-core
Files
- ChangeLog.md +33/−0
- README.md +3/−2
- example/Reactor.hs +1/−1
- lsp.cabal +5/−5
- src/Language/LSP/Server/Core.hs +9/−4
- src/Language/LSP/Server/Processing.hs +28/−8
ChangeLog.md view
@@ -1,5 +1,38 @@ # Revision history for lsp +## 1.1.0.0++* Fix prepareRename reponse and prepareProvider (@kirelagin)+* Fix deriving instance of MonadUnliftIO (@banacorn)+* Add support for file and folder operations in WorkspaceEdit (@banacorn)+Instead of having TextDocumentEdit in WorkspaceEdit++```haskell+data WorkspaceEdit =+ WorkspaceEdit+ { _changes :: Maybe WorkspaceEditMap+ , _documentChanges :: Maybe (List TextDocumentEdit)+ } deriving (Show, Read, Eq)+```+It is now replaced by a new type called DocumentChange++```haskell+data WorkspaceEdit =+ WorkspaceEdit+ { _changes :: Maybe WorkspaceEditMap+ , _documentChanges :: Maybe (List DocumentChange)+ } deriving (Show, Read, Eq)+```+Which is just a synonym of union of WorkspaceEdit and other operations++```haskell+type DocumentChange = TextDocumentEdit |? CreateFile |? RenameFile |? DeleteFile+```+* Add new CodeAction features (isPreferred, disabled) (@pepeiborra)+* Respond to requests with missing handlers (@wz1000)+* Use Text over String in more places (@wz1000)+* Add missing lenses (@wz1000, @bubba)+ ## 1.0.0.0 1.0.0.0 is a major rework with both internal and external facing changes, and
README.md view
@@ -1,5 +1,6 @@-[](https://circleci.com/gh/alanz/lsp/tree/master)-[](https://hackage.haskell.org/package/lsp)++[](https://hackage.haskell.org/package/lsp)+[](https://hackage.haskell.org/package/lsp-types) # lsp Haskell library for the Microsoft Language Server Protocol.
example/Reactor.hs view
@@ -225,7 +225,7 @@ let edit = J.TextEdit (J.mkRange l c l (c + T.length newName)) newName tde = J.TextDocumentEdit vdoc (J.List [edit]) -- "documentChanges" field is preferred over "changes"- rsp = J.WorkspaceEdit Nothing (Just (J.List [tde]))+ rsp = J.WorkspaceEdit Nothing (Just (J.List [J.InL tde])) responder (Right rsp) , requestHandler J.STextDocumentHover $ \req responder -> do
lsp.cabal view
@@ -1,6 +1,6 @@-cabal-version: 2.4+cabal-version: 2.2 name: lsp-version: 1.0.0.1+version: 1.1.0.0 synopsis: Haskell library for the Microsoft Language Server Protocol description: An implementation of the types, and basic message server to@@ -15,7 +15,7 @@ license-file: LICENSE author: Alan Zimmerman maintainer: alan.zimm@gmail.com-copyright: Alan Zimmerman, 2016-2020+copyright: Alan Zimmerman, 2016-2021 category: Development build-type: Simple extra-source-files: ChangeLog.md, README.md@@ -42,7 +42,7 @@ , filepath , hslogger , hashable- , lsp-types == 1.0.*+ , lsp-types == 1.1.* , dependent-map , lens >= 4.15.2 , mtl@@ -54,7 +54,7 @@ , transformers >= 0.5.6 && < 0.6 , time , unordered-containers- , unliftio-core+ , unliftio-core >= 0.2.0.0 -- used for generating random uuids for dynamic registration , random , uuid >= 1.3
src/Language/LSP/Server/Core.hs view
@@ -20,6 +20,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RecursiveDo #-}+{-# LANGUAGE RoleAnnotations #-} {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} {-# OPTIONS_GHC -fprint-explicit-kinds #-} @@ -74,6 +75,9 @@ newtype LspT config m a = LspT { unLspT :: ReaderT (LanguageContextEnv config) m a } deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadUnliftIO, MonadFix) +-- for deriving the instance of MonadUnliftIO+type role LspT representational representational nominal+ runLspT :: LanguageContextEnv config -> LspT config m a -> m a runLspT env = flip runReaderT env . unLspT @@ -740,15 +744,16 @@ cs' :: Maybe J.WorkspaceEditMap cs' = (fmap . fmap ) sortTextEdits cs - dcs' :: Maybe (J.List J.TextDocumentEdit)- dcs' = (fmap . fmap ) sortTextDocumentEdits dcs+ dcs' :: Maybe (J.List J.DocumentChange)+ dcs' = (fmap . fmap) sortOnlyTextDocumentEdits dcs sortTextEdits :: J.List J.TextEdit -> J.List J.TextEdit sortTextEdits (J.List edits) = J.List (L.sortBy down edits) - sortTextDocumentEdits :: J.TextDocumentEdit -> J.TextDocumentEdit- sortTextDocumentEdits (J.TextDocumentEdit td (J.List edits)) = J.TextDocumentEdit td (J.List edits')+ sortOnlyTextDocumentEdits :: J.DocumentChange -> J.DocumentChange+ sortOnlyTextDocumentEdits (J.InL (J.TextDocumentEdit td (J.List edits))) = J.InL $ J.TextDocumentEdit td (J.List edits') where edits' = L.sortBy down edits+ sortOnlyTextDocumentEdits (J.InR others) = J.InR others down (J.TextEdit r1 _) (J.TextEdit r2 _) = r2 `compare` r1
src/Language/LSP/Server/Processing.hs view
@@ -153,7 +153,7 @@ , _documentFormattingProvider = supportedBool STextDocumentFormatting , _documentRangeFormattingProvider = supportedBool STextDocumentRangeFormatting , _documentOnTypeFormattingProvider = documentOnTypeFormattingProvider- , _renameProvider = supportedBool STextDocumentRename+ , _renameProvider = renameProvider , _documentLinkProvider = supported' STextDocumentDocumentLink $ DocumentLinkOptions (Just False) (supported SDocumentLinkResolve)@@ -192,8 +192,8 @@ | supported_b STextDocumentCompletion = Just $ CompletionOptions Nothing- (map singleton <$> completionTriggerCharacters o)- (map singleton <$> completionAllCommitCharacters o)+ (map T.singleton <$> completionTriggerCharacters o)+ (map T.singleton <$> completionAllCommitCharacters o) (supported SCompletionItemResolve) | otherwise = Nothing @@ -212,8 +212,8 @@ | supported_b STextDocumentSignatureHelp = Just $ SignatureHelpOptions Nothing- (List . map singleton <$> signatureHelpTriggerCharacters o)- (List . map singleton <$> signatureHelpRetriggerCharacters o)+ (List . map T.singleton <$> signatureHelpTriggerCharacters o)+ (List . map T.singleton <$> signatureHelpRetriggerCharacters o) | otherwise = Nothing documentOnTypeFormattingProvider@@ -233,6 +233,17 @@ error "executeCommandCommands needs to be set if a executeCommandHandler is set" | otherwise = Nothing + clientSupportsPrepareRename = fromMaybe False $+ clientCaps ^? LSP.textDocument . _Just . LSP.rename . _Just . LSP.prepareSupport . _Just++ renameProvider+ | clientSupportsPrepareRename+ , supported_b STextDocumentRename+ , supported_b STextDocumentPrepareRename = Just $+ InR . RenameOptions Nothing . Just $ True+ | supported_b STextDocumentRename = Just (InL True)+ | otherwise = Just (InL False)+ sync = case textDocumentSync o of Just x -> Just (InL x) Nothing -> Nothing@@ -283,13 +294,18 @@ Just h -> liftIO $ h msg Nothing | SExit <- m -> liftIO $ exitNotificationHandler msg- | otherwise -> reportMissingHandler+ | otherwise -> do+ reportMissingHandler IsClientReq -> case pickHandler dynReqHandlers reqHandlers of Just h -> liftIO $ h msg (mkRspCb msg) Nothing | SShutdown <- m -> liftIO $ shutdownRequestHandler msg (mkRspCb msg)- | otherwise -> reportMissingHandler+ | otherwise -> do+ let errorMsg = T.pack $ unwords ["haskell-lsp:no handler for: ", show m]+ err = ResponseError MethodNotFound errorMsg Nothing+ sendToClient $+ FromServerRsp (msg ^. LSP.method) $ ResponseMessage "2.0" (Just (msg ^. LSP.id)) (Left err) IsClientEither -> case msg of NotMess noti -> case pickHandler dynNotHandlers notHandlers of@@ -297,7 +313,11 @@ Nothing -> reportMissingHandler ReqMess req -> case pickHandler dynReqHandlers reqHandlers of Just h -> liftIO $ h req (mkRspCb req)- Nothing -> reportMissingHandler+ Nothing -> do+ let errorMsg = T.pack $ unwords ["haskell-lsp:no handler for: ", show m]+ err = ResponseError MethodNotFound errorMsg Nothing+ sendToClient $+ FromServerRsp (req ^. LSP.method) $ ResponseMessage "2.0" (Just (req ^. LSP.id)) (Left err) where -- | Checks to see if there's a dynamic handler, and uses it in favour of the -- static handler, if it exists.