Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ handleStdin wrappedIn clientReqMap serverReqMap = do
modifyMVar_ clientReqMap $ \m -> case updateClientRequestMap m msgId (SMethodAndParams meth (msg ^. Lens.params)) of
Just m' -> return m'
Nothing -> return m
transformClientReq meth msg >>= liftIO . writeToHandle wrappedIn . A.encode
transformClientReq rustNotebookConfig meth msg >>= liftIO . writeToHandle wrappedIn . A.encode
Right (ClientToServerNot meth msg) ->
transformClientNot rustNotebookConfig sendExtraNotification meth msg >>= (liftIO . writeToHandle wrappedIn . A.encode)
where
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ library:
dependencies:
- containers
- filepath
- lens
- mtl
- notebook-language-server-core
- pcre-light
Expand Down
1 change: 1 addition & 0 deletions rust-notebook-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ library
base >=4.7 && <5
, containers
, filepath
, lens
, lsp-types >=2.0.0.1
, monad-logger
, mtl
Expand Down
19 changes: 19 additions & 0 deletions src/Transform/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Transform.Config (rustNotebookConfig) where

import Control.Lens hiding ((<.>))
import Control.Monad.IO.Class
import Control.Monad.Logger
import Control.Monad.Reader
Expand All @@ -14,6 +15,7 @@ import Language.LSP.Notebook
import Language.LSP.NotebookLanguageServer.Config
import Language.LSP.NotebookLanguageServer.Transform.ServerRsp.Hover (mkDocRegex)
import Language.LSP.NotebookLanguageServer.Transform.Util
import Language.LSP.Protocol.Lens
import Language.LSP.Protocol.Types
import Language.LSP.Transformer (Doc)
import Text.Regex.PCRE.Light (Regex)
Expand All @@ -29,9 +31,26 @@ rustNotebookConfig = NotebookConfig {
, notebookConfigMakeShadowDocument = makeShadowDocument
, notebookConfigUnopenedUri = addExtensionToUri ".rs"
, notebookConfigOnDocumentsChanged = updateLibRs
, notebookConfigTransformInitialize = transformInitialize
, notebookConfigCustomUriMethods = ["rust-analyzer/analyzerStatus"]
, notebookConfigLanguageName = "rust"
}

-- | rust-analyzer gets pointed at the shadow crate rather than the notebook's directory, and
-- we need didSave notifications to keep the crate on disk up to date.
transformInitialize :: TransformerMonad RustNotebookTransformer n => InitializeParams -> n InitializeParams
transformInitialize params = do
dir <- asks transformerShadowDir
pure $ params
& set rootPath (Just (InL (T.pack dir)))
& set rootUri (InL (filePathToUri dir))
& set (capabilities . textDocument . _Just . synchronization) (Just $ TextDocumentSyncClientCapabilities {
_dynamicRegistration = Just False
, _willSave = Just True
, _willSaveWaitUntil = Just False
, _didSave = Just True
})

makeShadowDocument :: TransformerMonad RustNotebookTransformer n => Uri -> Doc -> n (Uri, FilePath, Regex)
makeShadowDocument _origUri projected = do
TransformerState {transformerShadowDir} <- ask
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ system-ghc: true

extra-deps:
- git: https://github.com/codedownio/notebook-language-server-core.git
commit: db16c415168a1f150d43d1bf1f388d6e6272ec72
commit: b474d01835bb175c5564b931bcec32424551fccd

# - language-rust-0.2.0.27

Expand Down
6 changes: 3 additions & 3 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

packages:
- completed:
commit: db16c415168a1f150d43d1bf1f388d6e6272ec72
commit: b474d01835bb175c5564b931bcec32424551fccd
git: https://github.com/codedownio/notebook-language-server-core.git
name: notebook-language-server-core
pantry-tree:
sha256: 8008b9ad9e853f1d819cb66c4bd01a5d0fc3bab7acd0f4549bfed09f1445f910
sha256: 554c2a636ed5e2dac188feae84770503a5fb70824cac9d45c8ffe6a41e0d268b
size: 1919
version: 0.1.0.0
original:
commit: db16c415168a1f150d43d1bf1f388d6e6272ec72
commit: b474d01835bb175c5564b931bcec32424551fccd
git: https://github.com/codedownio/notebook-language-server-core.git
snapshots:
- completed:
Expand Down
Loading