Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support newer lsp #188

Merged
merged 1 commit into from
Aug 17, 2024
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
Support newer lsp
  • Loading branch information
fizruk committed Aug 17, 2024
commit 5b347b7ebbd941658d1a90bafda982ba4fe31526
4 changes: 2 additions & 2 deletions rzk/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Control.Monad (forM, forM_, unless, when,
(>=>))
import Data.Version (showVersion)

#ifdef LSP
#ifdef LSP_ENABLED
import Language.Rzk.VSCode.Lsp (runLsp)
#endif

Expand Down Expand Up @@ -66,7 +66,7 @@ main = do
Right _decls -> putStrLn "Everything is ok!"

Lsp ->
#ifdef LSP
#ifdef LSP_ENABLED
void runLsp
#else
error "rzk lsp is not supported with this build"
Expand Down
2 changes: 1 addition & 1 deletion rzk/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ flags:

when:
- condition: flag(lsp) && !impl(ghcjs)
cpp-options: -DLSP
cpp-options: -DLSP_ENABLED

custom-setup:
dependencies:
Expand Down
8 changes: 4 additions & 4 deletions rzk/rzk.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ library
, yaml >=0.11.0.0
default-language: Haskell2010
if flag(lsp) && !impl(ghcjs)
cpp-options: -DLSP
cpp-options: -DLSP_ENABLED
if flag(lsp) && !impl(ghcjs)
exposed-modules:
Language.Rzk.VSCode.Config
Expand Down Expand Up @@ -121,7 +121,7 @@ executable rzk
, yaml >=0.11.0.0
default-language: Haskell2010
if flag(lsp) && !impl(ghcjs)
cpp-options: -DLSP
cpp-options: -DLSP_ENABLED
if !impl(ghcjs)
build-depends:
optparse-generic >=1.4.0
Expand Down Expand Up @@ -153,7 +153,7 @@ test-suite doctests
, yaml >=0.11.0.0
default-language: Haskell2010
if flag(lsp) && !impl(ghcjs)
cpp-options: -DLSP
cpp-options: -DLSP_ENABLED

test-suite rzk-test
type: exitcode-stdio-1.0
Expand Down Expand Up @@ -185,4 +185,4 @@ test-suite rzk-test
, yaml >=0.11.0.0
default-language: Haskell2010
if flag(lsp) && !impl(ghcjs)
cpp-options: -DLSP
cpp-options: -DLSP_ENABLED
7 changes: 6 additions & 1 deletion rzk/src/Language/Rzk/VSCode/Handlers.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE RecordWildCards #-}

module Language.Rzk.VSCode.Handlers (
Expand Down Expand Up @@ -279,7 +280,11 @@ formatDocument req res = do
let edits = formatTextEdits (filter (/= '\r') $ T.unpack sourceCode)
return (Right $ map formattingEditToTextEdit edits)
case possibleEdits of
#if MIN_VERSION_lsp(2,7,0)
Left err -> res $ Left $ TResponseError (InR ErrorCodes_InternalError) err Nothing
#else
Left err -> res $ Left $ ResponseError (InR ErrorCodes_InternalError) err Nothing
#endif
Right edits -> do
res $ Right $ InL edits
else do
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resolver: nightly-2023-12-08
resolver: nightly-2024-08-17
packages:
- rzk
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
packages: []
snapshots:
- completed:
sha256: 4bd22736896cecf9e1f3f6193e82b065d06c2bf5b5ec97d0079409d6d35f1f82
size: 710668
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2023/12/8.yaml
original: nightly-2023-12-08
sha256: c93fb97219f317bdba82c69b4388665268c1964d9636a6ecdc9a58f8771f0bc0
size: 658092
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2024/8/17.yaml
original: nightly-2024-08-17
Loading