Skip to content

Commit

Permalink
Simplify nix setup (#531)
Browse files Browse the repository at this point in the history
* Simplify nix setup

This doesn't try to build the dependencies, just provides GHC/cabal/HLS.

* Add cabal-fmt and fourmolu

* Updated fourmolu

* Use the default GHC
  • Loading branch information
michaelpj authored Nov 26, 2023
1 parent 418c878 commit 483e641
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 50 deletions.
1 change: 1 addition & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
indentation: 2
single-constraint-parens: auto
8 changes: 4 additions & 4 deletions lsp-test/src/Language/LSP/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -753,15 +753,15 @@ executeCodeAction action = do
let req = TRequestMessage "" (IdInt 0) SMethod_WorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing e)
in updateState (FromServerMess SMethod_WorkspaceApplyEdit req)

-- |Resolves the provided code action.
-- | Resolves the provided code action.
resolveCodeAction :: CodeAction -> Session CodeAction
resolveCodeAction ca = do
rsp <- request SMethod_CodeActionResolve ca
case rsp ^. L.result of
Right ca -> return ca
Left er -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L.id) er)

{- |If a code action contains a _data_ field: resolves the code action, then
{- | If a code action contains a _data_ field: resolves the code action, then
executes it. Otherwise, just executes it.
-}
resolveAndExecuteCodeAction :: CodeAction -> Session ()
Expand Down Expand Up @@ -821,7 +821,7 @@ getAndResolveCompletions doc pos = do
items <- getCompletions doc pos
for items $ \item -> if isJust (item ^. L.data_) then resolveCompletion item else pure item

-- |Resolves the provided completion item.
-- | Resolves the provided completion item.
resolveCompletion :: CompletionItem -> Session CompletionItem
resolveCompletion ci = do
rsp <- request SMethod_CompletionItemResolve ci
Expand Down Expand Up @@ -956,7 +956,7 @@ getAndResolveCodeLenses tId = do
codeLenses <- getCodeLenses tId
for codeLenses $ \codeLens -> if isJust (codeLens ^. L.data_) then resolveCodeLens codeLens else pure codeLens

-- |Resolves the provided code lens.
-- | Resolves the provided code lens.
resolveCodeLens :: CodeLens -> Session CodeLens
resolveCodeLens cl = do
rsp <- request SMethod_CodeLensResolve cl
Expand Down
3 changes: 2 additions & 1 deletion lsp-test/src/Language/LSP/Test/Replay.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
and validating that the server output matches up with another log.
-}
module Language.LSP.Test.Replay (
)

)
where

-- replaySession
Expand Down
8 changes: 4 additions & 4 deletions lsp-types/src/Language/LSP/Protocol/Types/WatchKinds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ import Language.LSP.Protocol.Types.LspEnum (fromOpenEnumBaseType, toEnumBaseType
-- WatchKind is better represented as a Set than as enum. As the lsp spec
-- defines them as an enum, these helper functions help bridge the difference.

-- |Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
-- | Tests whether `WatchKind_Create` is contained in the provided WatchKind enum
containsCreate :: WatchKind -> Bool
containsCreate WatchKind_Create = True
containsCreate (WatchKind_Custom 3) = True
containsCreate (WatchKind_Custom 5) = True
containsCreate (WatchKind_Custom 7) = True
containsCreate _ = False

-- |Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
-- | Tests whether `WatchKind_Change` is contained in the provided WatchKind enum
containsChange :: WatchKind -> Bool
containsChange WatchKind_Change = True
containsChange (WatchKind_Custom 3) = True
containsChange (WatchKind_Custom 6) = True
containsChange (WatchKind_Custom 7) = True
containsChange _ = False

-- |Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
-- | Tests whether `WatchKind_Delete` is contained in the provided WatchKind enum
containsDelete :: WatchKind -> Bool
containsDelete WatchKind_Delete = True
containsDelete (WatchKind_Custom 5) = True
containsDelete (WatchKind_Custom 6) = True
containsDelete (WatchKind_Custom 7) = True
containsDelete _ = False

{- |Combine a set of WatchKind types into a new WatchKind type that accurately
{- | Combine a set of WatchKind types into a new WatchKind type that accurately
represents the set
-}
combineWatchKinds :: Set WatchKind -> WatchKind
Expand Down
6 changes: 3 additions & 3 deletions lsp/src/Language/LSP/VFS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ getCompletionPrefix pos@(J.Position l c) (VirtualFile _ _ ropetext) =
beforePos <- Rope.toText . fst <$> Rope.splitAt (fromIntegral c) curRope
curWord <-
if
| T.null beforePos -> Just ""
| T.last beforePos == ' ' -> Just "" -- don't count abc as the curword in 'abc '
| otherwise -> lastMaybe (T.words beforePos)
| T.null beforePos -> Just ""
| T.last beforePos == ' ' -> Just "" -- don't count abc as the curword in 'abc '
| otherwise -> lastMaybe (T.words beforePos)

let parts =
T.split (== '.') $
Expand Down
22 changes: 1 addition & 21 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
{ sources ? import ./sources.nix }:

let
overlay = self: super:
let
inherit (import sources."gitignore.nix" { inherit (super) lib; })
gitignoreSource;
ourSources = {
lsp = gitignoreSource ../lsp;
lsp-test = gitignoreSource ../lsp-test;
lsp-types = gitignoreSource ../lsp-types;
};

in {
inherit gitignoreSource;
inherit ourSources;
ourHaskellPackages = with super.haskell.lib;
super.haskellPackages.extend (packageSourceOverrides ourSources);
};
in (import sources.nixpkgs {
overlays = [ overlay ];
config = { allowBroken = true; };
})
import sources.nixpkgs { }
18 changes: 9 additions & 9 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": "",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"sha256": "07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh",
"rev": "9e21c80adf67ebcb077d75bd5e7d724d21eeafd6",
"sha256": "1lbkgn94y8850g7idqnbji12pscxjwrspnzmx8fmm7xmy9ablk5y",
"type": "tarball",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/9e21c80adf67ebcb077d75bd5e7d724d21eeafd6.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"niv": {
Expand All @@ -17,10 +17,10 @@
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "7225521219f64df00de86c3b946a26f608f3b4dc",
"sha256": "04w9c06f70n0k9c4xhma4nfrkxxg7d039xd3v9dak8xd7avjb7v0",
"rev": "723f0eeb969a730db3c30f977c2b66b9dce9fe4a",
"sha256": "0016l7230gd2kdh0g2w573r9a2krqb7x4ifcjhhsn4h1bwap7qr0",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/7225521219f64df00de86c3b946a26f608f3b4dc.tar.gz",
"url": "https://github.com/nmattia/niv/archive/723f0eeb969a730db3c30f977c2b66b9dce9fe4a.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
Expand All @@ -29,10 +29,10 @@
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b969a89c3e84a121c9b3af2e4ef277cd822b988a",
"sha256": "0qib8p3iscj7l3i6y03x1f5fhmn8336nbk7lg2hwvx44cpy63jvz",
"rev": "9ea24fc7e02b65c150c88e1412400b70087bd382",
"sha256": "002abgrz7gdj99gzyhmkpxx8j3x5grapmal9i0r580phvin9g2r5",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/b969a89c3e84a121c9b3af2e4ef277cd822b988a.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/9ea24fc7e02b65c150c88e1412400b70087bd382.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
21 changes: 13 additions & 8 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{ withHoogle ? false, nixpkgs ? import ./nix { } }:
{ nixpkgs ? import ./nix { } }:
with nixpkgs;
with ourHaskellPackages;
shellFor {
inherit withHoogle;
doBenchmark = true;
doTest = true;
packages = p: with builtins; map (name: p.${name}) (attrNames ourSources);
buildInputs = [ cabal-install nixpkgs.haskellPackages.haskell-language-server nixpkgs.haskellPackages.fourmolu ];
let
hsPkgs = haskellPackages;
ghc = haskellPackages.ghc;
in mkShell {
nativeBuildInputs = [
hsPkgs.ghc
hsPkgs.haskell-language-server
haskellPackages.cabal-fmt
haskellPackages.fourmolu
cabal-install
zlib
pkg-config ];
}

0 comments on commit 483e641

Please sign in to comment.