lsp

Haskell library for the Microsoft Language Server Protocol

Downloads
61.6K
Stars
354
Committers
66

Bot releases are hidden (Show)

lsp - lsp-test 0.14.0.0 Latest Release

Published by wz1000 over 3 years ago

  • Update for lsp-types-1.2 (@wz1000)
  • Limit diagnostics by range in getCodeActions (@aufarg)
  • Kill timeout thread to avoid building up thousands of old TimeoutMessages (@wz1000)
lsp - lsp, lsp-types 1.2.0.0

Published by wz1000 over 3 years ago

lsp-types 1.2.0.0

  • Prevent crashing when optional fields are missing (@anka-213)
  • Use StrictData (@wz1000)
  • Add MarkupContent in SignatureHelp types (@michaelpj)
  • Add activeParameter support in SignatureInformation (@michaelpj)
  • Add label offset support in SignatureHelp (@michaelpj)
  • Add some documentation comments to SignatureHelp types (@michaelpj)
  • Add support for InsertReplaceEdit (@michaelpj)
  • Add support for InsertTextMode (@michaelpj)
  • Add resolveSupport (@michaelpj)
  • Fix applying a TextEdit past the end of the document (#271) (@michaelpj)
  • Use Empty instead of () as progress create response (#295) (@wz1000)
  • Add tag support for DocumentSymbol, SymbolInformation, and document symbol provider label (#301) (@michaelpj)
  • Support change annotations (#302) (@michaelpj)
  • Add some more missing lenses (#307) (@michaelpj)

lsp 1.2.0.0

  • Parse config from initializeOptions and pass in the old value of config to onConfigurationChange (#285) (wz1000)
  • Break up big TVar record into lots of small TVars (#286) (@wz1000)
  • Add some INLINE pragmas (@wz1000)
  • Make method equality work for CustomMethods (@wz1000)
lsp - 1.1.1.0

Published by wz1000 over 3 years ago

  • Don't send begin progress notification twice (@wz1000)
lsp - 1.1.0.0

Published by lukel97 over 3 years ago

  • 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
data WorkspaceEdit =
  WorkspaceEdit
    { _changes         :: Maybe WorkspaceEditMap
    , _documentChanges :: Maybe (List TextDocumentEdit)
    } deriving (Show, Read, Eq)

It is now replaced by a new type called DocumentChange

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

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)
lsp - 1.0.0.1

Published by lukel97 almost 4 years ago

This contains fixes for building on GHC 8.4.4

lsp - 1.0.0.0

Published by lukel97 almost 4 years ago

1.0.0.0 is a major rework with both internal and external facing changes, and
will require manual migration.

  • The package has been renamed from haskell-lsp to lsp, and similarly for haskell-lsp-types to lsp-types
    • Because of this, all modules are now exported from Language.LSP.X rather than Language.Haskell.X.
  • Both lsp and lsp-types have been reworked to be much more type safe
  • The 3.15 specification should be fully supported now. If you find anything in
    the specification that isn't in lsp-types, please let us know
  • The Capture module has been removed as it will be reworked later on and moved to lsp-test
  • lsp can now handle dynamic registration through the registerCapability and
    unregisterCapability functions

Type safety

There are three types of concrete messages, NotificationMessage,
RequestMessage and ResponseMessage. They are parameterised by their
Method, which determines what type their parameters or response result must be.

data RequestMessage (m :: Method f Request) = RequestMessage
    { _jsonrpc :: Text
    , _id      :: LspId m
    , _method  :: SMethod m
    , _params  :: MessageParams m
    }

A Method in turn is parameterised by whether it originates from the client or
the server, and whether it is used for notifications or requests:

TextDocumentFoldingRange           :: Method FromClient Request
TextDocumentSelectionRange         :: Method FromClient Request
WindowShowMessage                  :: Method FromServer Notification
WindowShowMessageRequest           :: Method FromServer Request

Each Method also has a singleton counterpart which allows it to be used at the
term level, for example in RequestMessage._method:

STextDocumentFoldingRange           :: SMethod TextDocumentFoldingRange
STextDocumentSelectionRange         :: SMethod TextDocumentSelectionRange

SWindowShowMessage                  :: SMethod WindowShowMessage
SWindowShowMessageRequest           :: SMethod WindowShowMessageRequest

The type families MessageParams and ResponseResult map each Method to the
appropriate type to be used in a response:

ResponseResult TextDocumentRename            = WorkspaceEdit
ResponseResult TextDocumentPrepareRename     = Range |? RangeWithPlaceholder

Also new is the |? type which represents union types in
TypeScript
,
and is used throughout the specification where a field can accept several
different types.

As an example of this in action, the types of your handlers will now depend on
whether or not they are a request or a notification. They will pass along the
precise type for the parameters the method you are handling, and in the case of
a request handler, will expect that the response you give back is of the correct
type as well.

type family Handler (f :: Type -> Type) (m :: Method from t) = (result :: Type) | result -> f t m where
  Handler f (m :: Method _from Request)      = RequestMessage m -> (Either ResponseError (ResponseResult m) -> f ()) -> f ()
  Handler f (m :: Method _from Notification) = NotificationMessage m -> f ()

LspT

LspFuncs has been removed and instead functionality is exposed through
functions in the MonadLsp class.

getVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe VirtualFile)
sendRequest :: forall (m :: Method FromServer Request) f config. MonadLsp config f
            => SServerMethod m
            -> MessageParams m
            -> (Either ResponseError (ResponseResult m) -> f ())
            -> f (LspId m)

It is parameterised over the server's LSP configuration type and the underlying
monad.
We recommend that you build your own monad for your server on top of the LspT
transformer, so it will automatically become an instance of MonadLsp.

Inside the new ServerDefinition data type which gets passed to runServer,
you need to specify how to convert from IO to your monad and back in
interpretHandler so that lsp can execute your monad inside the handlers. You
can use the result returned from doInitialize to pass along the
LanguageContextEnv needed to run an LspT, as well as anything else your
monad needs.

type 
ServerDefinition { ...
, doInitialize = \env _req -> pure $ Right env
, interpretHandler = \env -> Iso 
   (runLspT env) -- how to convert from IO ~> m
   liftIO        -- how to convert from m ~> IO
}

Steps to migrate

  1. In your .cabal file change any haskell-lsp dependencies to lsp
  2. Replace your existing imports with Haskell.LSP.Server
  3. If necessary define your own monad and fill in interpretHandler
  4. Migrate your handlers to use notificationHandler and requestHandler,
    passing along the corresponding SMethod (See example/Simple.hs)
  5. Remove any storage/use of LspFuncs and instead call the corresponding
    functions directly from your monad instead of IO
lsp - 0.23.0.0

Published by lukel97 about 4 years ago

  • Add runWith for transporots other than stdio (@paulyoung)
  • Fix race condition in event captures (@bgamari)
  • Tweak the sectionSeparator (@alanz)
  • Add hashWithSaltInstances (@ndmitchell)
  • Fix CompletionItem.tags not being optional (@bubba)
  • Avoid unnecessary normalisation in Binary instance for
    NormalizedFilePath (@cocreature)
  • Fix ordering of TH splices (@fendor)
lsp - 0.22.0.0

Published by lukel97 over 4 years ago

  • ResponseMessage results are now an Either type (@greenhat)
  • Support for GHC 8.10.1
lsp - 0.21.0.0

Published by alanz over 4 years ago

  • Stop getCompletionPrefix from crashing if beforePos is empty
  • Add DidChangeWatchedFilesRegistrationOptions
  • Add NormalizedFilePath from ghcide
  • Add diagnostic and completion tags
  • Fix language server example
  • Correctly fix the problem with '$/' notifications
  • Add azure ci
lsp - 0.17.0.0

Published by lukel97 almost 5 years ago

  • Update progress reporting to match the LSP 3.15 specification (@cocreature)
  • Fix progress cancellation action being retained (@mpickering)
  • Respect both codeActionProvider and codeActionHandler in server capabilities (@fendor)
  • Ensure ResponseMessage has either a result or an error (@cocreature)
lsp - 0.16.0.0

Published by lukel97 about 5 years ago

  • Add support for CodeActionOptions (@thomasjm)
  • Add support for textDocument/prepareRename request (@thomasjm)
  • Fix diagnostic code parsing (@thomasjm)
  • Fix shutdown response type (@bubba)
  • Relax base constraints for GHC 8.8 (@bubba)
lsp - 0.15.0.0

Published by lorenzo over 5 years ago

  • Fix decoding of ResponseMessage to account for null messages (@cocreature)
  • Normalize URIs to avoid issues with percent encoding (@cocreature)
  • Changed the initial callbacks type to also capture initial config (@lorenzo)
  • Improved documentation (@bubba)
lsp - 0.14.0.0

Published by lukel97 over 5 years ago

  • Add support for custom request and notification methods
    (@cocreature)
  • Use attoparsec to parse message headers incrementally (@cocreature)
  • Only build lsp-hello when -fdemo flag is set (@bubba)
lsp - 0.11.0.0

Published by lukel97 over 5 years ago

  • Add support for cancellable requests within withProgress and withIndefiniteProgress
  • Align withProgress and withIndefiniteProgress types to be in IO like the rest of the library (Look at using monad-control and unliftio if you need to use them with a Monad transformer stack)
  • Fix window/progress/cancel notification being a from server notification when it should be a from client notification
lsp - 0.9.0.0

Published by lukel97 over 5 years ago

  • Add MarkupContent to HoverResponse, and (some) json roundtrip tests.
lsp - 0.10.0.0

Published by lukel97 over 5 years ago

  • Add withProgress and withIndefiniteProgress functions for sending window/progress notifications.
lsp - 0.8.2.0

Published by lukel97 over 5 years ago

  • Add applyTextEdit and editTextEdit helpers
  • Set the typedefinitionProvider capability if it has a handler
  • Add stack files for GHC 8.4.4 and 8.6.4
lsp - 0.8.1.0

Published by lukel97 over 5 years ago

  • Update Handler to delegate to typeDefinitionHandler instead of definitionHandler. by @fendor
lsp - Document symbols and goto implementation

Published by lukel97 about 6 years ago

  • Add new DocumentSymbol type and heirarchal support
  • Rename CommandOrCodeAction to CAResult
  • Add handler for 'textDocument/implementation' request from client
  • Bump stack resolvers for lts 11 and lts 12
lsp - 0.5.0.0

Published by lukel97 about 6 years ago

  • Update Command.arguments to match specification
  • Update ClientCapabilities to v3.10
  • Add MarkupContent
  • Add new CompletionKinds
  • Add new SymbolKinds
  • Add preset version capabilities