-
Notifications
You must be signed in to change notification settings - Fork 205
Conversation
Update haskell-lsp
Update diffText to include newer documentChanges field Fix diffText deletions
Needed for code action testing
Backport missing cabal exports on 8.2.2
c251361
to
e3dddc0
Compare
Fix new code action kinds returning a duplicate command on top of workspace edits
ed97d0a
to
32ec0df
Compare
Add a reader for client capabilities in IdeM
…into import-code-actions
…into import-code-actions
…into import-code-actions
deriving Eq | ||
|
||
-- | Generate a 'WorkspaceEdit' value from an original file and text to replace it. | ||
makeDiffResult :: FilePath -> T.Text -> (FilePath -> FilePath) -> IdeM WorkspaceEdit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this functionality move to haskell-lsp, some time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, I imagine this would be useful for both clients and servers.
I'm also thinking we should probably also pass back the lsp funcs/lsp config back to haskell-lsp, so it can handle formatting the workspace edit according to the specification.
flip runReaderT caps $ | ||
ideDispatcher env errorHandler callbackHandler ideChan | ||
|
||
-- TODO: Causes STM deadlock? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is going on here with this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to get the ideDispatcher thread to throw its exceptions onto the main thread instead of dying silently, but it caused other exceptions due to me not doing the async properly. We should probably revisit this some time. I can remove the comment and create a todo for this?
addDep _ = error "Not an array in addDep" | ||
|
||
|
||
-- | Takes a cabal file and a path to a module in the dependency you want to edit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it will lose comments and formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With cabal files it shouldn't. The printed cabal module after editing doesn't contain any formatting, but it tries to only apply the additions in the diff.
For package.yaml I couldn't get makeDiffResult to work with it, so it loses formatting. Interestingly enough there's another GSOC project for format preserving yaml editing: https://github.com/wisn/format-preserving-yaml/
…into import-code-actions
…into import-code-actions
This does some rudimentary string manipulation to read the warnings given out by ghc-mod, and provide contextual code actions for them. In the future we should probably add API in ghc-mod to directly give us the information to create these code actions.
So far it adds these types of code actions:
It also adds support for the new code action types in LSP v3.8, so you can use quick fix and refactor keybindings and such inside VS Code.
Todo
makeRequest
functions inside the reactor into functions in theR
monadAlso
This moves out the code action code (the logic that glues LSP and the various Haskell tools) into a separate module since it was getting pretty big, so some reactor types have also been moved out.
It also introduces
Cabal
as a dependency to mechanically edit the .cabal file, and I'm not sure how much this affects build time.Its used to work out which library/executable should have the dependencies added to based on the module that the quick fix is being applied on.