Skip to content

Commit f2f4fc2

Browse files
PanAeonGabriella439
authored andcommitted
Add dhall-lsp-server (#843)
1 parent e392657 commit f2f4fc2

20 files changed

+1044
-2
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ environment:
1111
STACK_VERSION: 1.9.3
1212

1313
matrix:
14-
- STACK_YAML: stack.yaml
14+
- STACK_YAML: stack-nightly-2018-12-17.yaml
1515
- STACK_YAML: stack-lts-6.yaml
1616

1717
install:

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-text
1+
packages: ./dhall ./dhall-bash ./dhall-json ./dhall-text ./dhall-lsp-server

dhall-lsp-server/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog for dhall-lsp-server
2+
3+
## Unreleased changes

dhall-lsp-server/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 PanAeon
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

dhall-lsp-server/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# dhall-lsp-server
3+
```[![Travis](https://travis-ci.org/PanAeon/dhall-lsp-server.svg?branch=master)](https://travis-ci.org/PanAeon/dhall-lsp-server)```
4+
5+
**This project is in alpha state !!!**
6+
7+
This is a [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) server implementation for the [Dhall](https://dhall-lang.org) programming language.
8+
9+
10+
## Installation
11+
12+
### From source
13+
14+
[Haskell Tool Stack](https://docs.haskellstack.org/en/stable/README/) should be installed.
15+
16+
```bash
17+
cd ./dhall-lsp-server
18+
stack install
19+
```
20+
21+
Stack will copy executables to the current user's executable directory. On macOS this is `/Users/<username>/.local/bin`. On linux this should be `/Home/<username>/.local/bin`.
22+
If you are using VSCode there's also an option in the [VSCode Dhall plugin](https://github.com/PanAeon/vscode-dhall-lsp-server) to specify the path to the executable directly, which might be useful if you have multiple executables or you can't use global PATH for some reason.
23+
24+

dhall-lsp-server/Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

dhall-lsp-server/app/Main.hs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
module Main (main) where
3+
4+
5+
6+
7+
import Data.Default
8+
import qualified Data.HashMap.Strict as H
9+
import qualified Data.Text as T
10+
import qualified System.Exit
11+
import qualified System.Log.Logger as L
12+
13+
14+
15+
import qualified Data.Text.IO
16+
import qualified System.IO
17+
import qualified Data.Map as Map
18+
import Options.Applicative (Parser, ParserInfo)
19+
import qualified Options.Applicative
20+
21+
import qualified System.IO.Unsafe
22+
23+
import LSP.Server(run)
24+
25+
data Options = Options {
26+
command :: Command
27+
, logFile :: Maybe String -- file where the server process debug log should be written
28+
}
29+
30+
data Command = CmdVersion | Default
31+
32+
parseOptions :: Parser Options
33+
parseOptions = Options <$> parseMode
34+
<*> Options.Applicative.optional parseLogFile
35+
where
36+
parseLogFile = Options.Applicative.strOption
37+
(
38+
Options.Applicative.long "log"
39+
<> Options.Applicative.help "If present writes debug output to the specified file")
40+
41+
42+
subcommand :: String -> String -> Parser a -> Parser a
43+
subcommand name description parser =
44+
Options.Applicative.hsubparser
45+
( Options.Applicative.command name parserInfo
46+
<> Options.Applicative.metavar name
47+
)
48+
where
49+
parserInfo =
50+
Options.Applicative.info parser
51+
( Options.Applicative.fullDesc
52+
<> Options.Applicative.progDesc description
53+
)
54+
55+
parseMode :: Parser Command
56+
parseMode =
57+
subcommand
58+
"version"
59+
"Display version"
60+
(pure CmdVersion)
61+
<|> pure Default
62+
63+
parserInfoOptions :: ParserInfo Options
64+
parserInfoOptions =
65+
Options.Applicative.info
66+
(Options.Applicative.helper <*> parseOptions)
67+
( Options.Applicative.progDesc "Interpreter for the Dhall language"
68+
<> Options.Applicative.fullDesc
69+
)
70+
71+
runCommand :: Options -> IO ()
72+
runCommand Options{..} = case command of
73+
CmdVersion -> putStrLn "0.0.1.0" -- TODO: read from build
74+
Default ->
75+
run logFile (pure ()) >>= \case
76+
0 -> exitSuccess
77+
c -> exitWith . System.Exit.ExitFailure $ c
78+
79+
main :: IO ()
80+
main = Options.Applicative.execParser parserInfoOptions >>= runCommand
81+
82+

dhall-lsp-server/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(import ../nix/shared.nix {}).possibly-static.dhall
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
cabal-version: 1.12
2+
name: dhall-lsp-server
3+
version: 0.1.0.0
4+
description: Please see the README on GitHub at <https://github.com/githubuser/dhall-lsp-server#readme>
5+
homepage: https://github.com/dhall-lang/dhall-haskell/dhall-lsp-server#readme
6+
bug-reports: https://github.com/dhall-lang/dhall-haskell/issues
7+
author: panaeon
8+
maintainer: panaeon
9+
copyright: 2019 panaeon
10+
license: MIT
11+
license-file: LICENSE
12+
build-type: Simple
13+
extra-source-files:
14+
README.md
15+
ChangeLog.md
16+
17+
source-repository head
18+
type: git
19+
location: https://github.com/dhall-lang/dhall-haskell
20+
21+
library
22+
exposed-modules:
23+
Backend.Dhall.DhallErrors
24+
Backend.Dhall.Diagnostics
25+
LSP.Common
26+
LSP.Dispatcher
27+
LSP.Handlers.Diagnostics
28+
LSP.Server
29+
Prelude
30+
other-modules:
31+
Paths_dhall_lsp_server
32+
hs-source-dirs:
33+
src
34+
default-extensions: LambdaCase OverloadedStrings FlexibleInstances TypeApplications RecordWildCards ScopedTypeVariables
35+
build-depends:
36+
aeson
37+
, base-noprelude >=4.7 && <5
38+
, containers
39+
, data-default
40+
, dhall
41+
, filepath
42+
, haskell-lsp
43+
, hslogger
44+
, lens
45+
, lens-family-core
46+
, megaparsec
47+
, mtl
48+
, optparse-applicative
49+
, prettyprinter
50+
, relude
51+
, sorted-list
52+
, stm
53+
, text
54+
, transformers
55+
, unordered-containers
56+
, yi-rope
57+
default-language: Haskell2010
58+
59+
executable dhall-lsp-server
60+
main-is: Main.hs
61+
other-modules:
62+
Paths_dhall_lsp_server
63+
hs-source-dirs:
64+
app
65+
default-extensions: LambdaCase OverloadedStrings FlexibleInstances TypeApplications RecordWildCards ScopedTypeVariables
66+
ghc-options: -rtsopts
67+
build-depends:
68+
aeson
69+
, base-noprelude >=4.7 && <5
70+
, containers
71+
, data-default
72+
, dhall
73+
, dhall-lsp-server
74+
, filepath
75+
, haskell-lsp
76+
, hslogger
77+
, lens
78+
, lens-family-core
79+
, megaparsec
80+
, mtl
81+
, optparse-applicative
82+
, prettyprinter
83+
, relude
84+
, sorted-list
85+
, stm
86+
, text
87+
, transformers
88+
, unordered-containers
89+
, yi-rope
90+
default-language: Haskell2010
91+
92+
test-suite dhall-lsp-server-test
93+
type: exitcode-stdio-1.0
94+
main-is: Spec.hs
95+
other-modules:
96+
Paths_dhall_lsp_server
97+
hs-source-dirs:
98+
test
99+
default-extensions: LambdaCase OverloadedStrings FlexibleInstances TypeApplications RecordWildCards ScopedTypeVariables
100+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
101+
build-depends:
102+
aeson
103+
, base-noprelude >=4.7 && <5
104+
, containers
105+
, data-default
106+
, dhall
107+
, dhall-lsp-server
108+
, filepath
109+
, haskell-lsp
110+
, hslogger
111+
, lens
112+
, lens-family-core
113+
, megaparsec
114+
, mtl
115+
, optparse-applicative
116+
, prettyprinter
117+
, relude
118+
, sorted-list
119+
, stm
120+
, tasty
121+
, tasty-discover
122+
, tasty-hspec
123+
, tasty-quickcheck
124+
, text
125+
, transformers
126+
, unordered-containers
127+
, yi-rope
128+
default-language: Haskell2010

dhall-lsp-server/shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(import ../nix/shared.nix { coverage = true; }).shell-dhall

0 commit comments

Comments
 (0)