Skip to content

Commit

Permalink
Support newer lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
fizruk committed Aug 17, 2024
1 parent 15f2508 commit 210730e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
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,9 +1,10 @@
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE RecordWildCards #-}

module Language.Rzk.VSCode.Handlers (
Expand Down Expand Up @@ -255,7 +256,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

0 comments on commit 210730e

Please sign in to comment.