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
3 changes: 3 additions & 0 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
run: cabal build --project-file cabal.project.release --only-dependencies
- name: Build executables
run: cabal build exe:jbeam-edit --project-file cabal.project.release
- name: Build LSP test server
run: |
cabal install exe:jbeam-lsp-test-server --project-file cabal.project.release || true
- name: Run tests (GHC ${{ matrix.ghc }})
if: "!startsWith(github.ref, 'refs/tags/')"
run: cabal test --project-file cabal.project.release
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,8 @@ jobs:
${{ runner.os }}-cabal-${{ matrix.ghc }}-
- name: Build project (GHC ${{ steps.setup-ghc.outputs.ghc-version }})
run: cabal build --project-file cabal.project.ci all
- name: Build LSP test server
run: |
cabal install exe:jbeam-lsp-test-server --project-file cabal.project.ci || true
- name: Run tests (GHC ${{ steps.setup-ghc.outputs.ghc-version }})
run: cabal test --project-file cabal.project.ci
3 changes: 3 additions & 0 deletions .github/workflows/future-proofing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@ jobs:
${{ runner.os }}-cabal-${{ steps.get-ghc.outputs.ghc-version }}-
- name: Build project (GHC latest)
run: cabal build --project-file cabal.project.ci all
- name: Build LSP test server
continue-on-error: true
run: cabal install exe:jbeam-lsp-test-server --project-file cabal.project.ci
- name: Run tests (GHC latest)
run: cabal test --project-file cabal.project.ci
4 changes: 4 additions & 0 deletions app-extra/jbeam-lsp-server/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
((haskell-mode
. ((haskell-process-type . cabal-repl)
(eval . (setq-local haskell-process-args-cabal-repl
(append '("jbeam-edit:exe:jbeam-lsp-server" "--project-file" "cabal.project.dev") haskell-process-args-cabal-repl))))))
12 changes: 12 additions & 0 deletions app-extra/jbeam-lsp-server/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Main (
main,
) where

import Server (runServer)

import Formatting.Config qualified as FmtCfg

main :: IO ()
main = do
rs <- FmtCfg.readFormattingConfig
void (runServer rs)
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ tests: False

package jbeam-edit
tests: False
flags: -dump-ast -transformation -windows-example-paths
flags: -dump-ast -transformation -lsp-server -windows-example-paths
2 changes: 1 addition & 1 deletion cabal.project.ci
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ program-options

package jbeam-edit
tests: True
flags: +dump-ast +transformation -windows-example-paths
flags: +dump-ast +transformation +lsp-server -windows-example-paths
2 changes: 1 addition & 1 deletion cabal.project.dev
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ package jbeam-edit
tests: True
haddock-executables: True
haddock-internal: True
flags: +dump-ast +transformation -windows-example-paths
flags: +dump-ast +transformation +lsp-server -windows-example-paths
6 changes: 6 additions & 0 deletions hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ cradle:
component: lib:jbeam-edit
- path: ./src-extra/transformation
component: jbeam-edit:lib:jbeam-edit-transformation
- path: ./src-extra/language-server
component: jbeam-edit:lib:jbeam-language-server
- path: ./app
component: exe:jbeam-edit
- path: ./app-extra/jbeam-lsp-server
component: jbeam-edit:exe:jbeam-lsp-server
- path: ./app-extra/jbeam-lsp-test-server
component: jbeam-edit:exe:jbeam-lsp-test-server
- path: ./tools/dump_ast
component: exe:jbeam-edit-dump-ast
- path: ./test
Expand Down
126 changes: 126 additions & 0 deletions jbeam-edit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ flag dump-ast
default: False
manual: True

flag lsp-server
description: Enable LSP server (experimental)
default: False
manual: True

flag transformation
description: Enable transformation (experimental)
default: False
Expand Down Expand Up @@ -152,6 +157,46 @@ library jbeam-edit-transformation
else
buildable: False

library jbeam-language-server
exposed-modules:
Handlers.Formatting
Server
Services.DocumentStore

hs-source-dirs: src-extra/language-server
other-modules: Paths_jbeam_edit
autogen-modules: Paths_jbeam_edit
default-language: Haskell2010
default-extensions: OverloadedStrings ImportQualifiedPost
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-export-lists
-Wmissing-home-modules -Wpartial-fields -Wredundant-constraints

build-depends:
base >=4.17 && <5,
bytestring >=0.12,
containers >=0.6,
directory >=1.3,
filepath >=1.4,
jbeam-edit,
megaparsec >=9.6,
relude >=1.2,
scientific >=0.3,
text >=2.1,
vector >=0.13

mixins:
base hiding (Prelude),
relude (Relude as Prelude),
relude

if (flag(lsp-server) && impl(ghc >=9.6.6))
build-depends: lsp >=2.7

else
buildable: False

executable jbeam-edit
main-is: Main.hs
hs-source-dirs: app
Expand Down Expand Up @@ -232,6 +277,80 @@ executable jbeam-edit-dump-ast
else
buildable: False

executable jbeam-lsp-server
main-is: Main.hs
hs-source-dirs: app-extra/jbeam-lsp-server
other-modules: Paths_jbeam_edit
autogen-modules: Paths_jbeam_edit
default-language: Haskell2010
default-extensions: OverloadedStrings ImportQualifiedPost
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-export-lists
-Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
-threaded -rtsopts -with-rtsopts=-N

build-depends:
base >=4.17 && <5,
bytestring >=0.12,
containers >=0.6,
directory >=1.3,
filepath >=1.4,
jbeam-edit,
megaparsec >=9.6,
relude >=1.2,
scientific >=0.3,
text >=2.1,
vector >=0.13

mixins:
base hiding (Prelude),
relude (Relude as Prelude),
relude

if (flag(lsp-server) && impl(ghc >=9.6.6))
build-depends: jbeam-language-server

else
buildable: False

executable jbeam-lsp-test-server
main-is: Main.hs
hs-source-dirs: tools/lsp-test-server
other-modules: Paths_jbeam_edit
autogen-modules: Paths_jbeam_edit
default-language: Haskell2010
default-extensions: OverloadedStrings ImportQualifiedPost
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wmissing-export-lists
-Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
-threaded -rtsopts -with-rtsopts=-N

build-depends:
base >=4.17 && <5,
bytestring >=0.12,
containers >=0.6,
directory >=1.3,
filepath >=1.4,
jbeam-edit,
megaparsec >=9.6,
relude >=1.2,
scientific >=0.3,
text >=2.1,
vector >=0.13

mixins:
base hiding (Prelude),
relude (Relude as Prelude),
relude

if (flag(lsp-server) && impl(ghc >=9.6.6))
build-depends: jbeam-language-server

else
buildable: False

test-suite jbeam-edit-test
type: exitcode-stdio-1.0
main-is: Spec.hs
Expand All @@ -247,6 +366,7 @@ test-suite jbeam-edit-test
Parsing.JbeamSpec
SpecHelper
TransformationSpec
WorkspaceLspSpec
Paths_jbeam_edit

autogen-modules: Paths_jbeam_edit
Expand Down Expand Up @@ -278,6 +398,12 @@ test-suite jbeam-edit-test
relude (Relude as Prelude),
relude

if (flag(lsp-server) && impl(ghc >=9.6.6))
cpp-options: -DENABLE_LSP_TESTS
build-depends:
lsp >=2.7,
lsp-test

if flag(transformation)
cpp-options: -DENABLE_TRANSFORMATION_TESTS
build-depends: jbeam-edit-transformation
53 changes: 44 additions & 9 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ extra-source-files:
- examples/jbeam/*.jbeam
- examples/formatted_jbeam/*.jbeam


category: Command Line, Jbeam, Beamng

synopsis:
A fast and reliable command-line tool for parsing, formatting, and editing JBeam files, supporting consistent node renaming, reference updating, and JBFL-based formatting.

synopsis: A fast and reliable command-line tool for parsing, formatting, and editing
JBeam files, supporting consistent node renaming, reference updating, and JBFL-based
formatting.
description: >-
jbeam-edit is a Haskell-based CLI utility for BeamNG JBeam files. It parses complete JBeam structures, preserves comments and whitespace, formats files consistently, and can automatically rename nodes and update references. Custom formatting rules are supported via JBFL (JBeam Formatting Language). See the README for usage instructions and examples: https://github.com/webdevred/jbeam-edit#readme
jbeam-edit is a Haskell-based CLI utility for BeamNG JBeam files. It parses complete
JBeam structures, preserves comments and whitespace, formats files consistently,
and can automatically rename nodes and update references. Custom formatting rules
are supported via JBFL (JBeam Formatting Language). See the README for usage instructions
and examples: https://github.com/webdevred/jbeam-edit#readme
tested-with: [GHC == 9.4.7, GHC == 9.6.6]

dependencies:
Expand Down Expand Up @@ -62,6 +64,10 @@ flags:
description: Enable transformation (experimental)
manual: true
default: false
lsp-server:
description: Enable LSP server (experimental)
manual: true
default: false
windows-example-paths:
description: Use executable-relative example paths (for Windows release builds)
default: false
Expand All @@ -77,6 +83,15 @@ internal-libraries:
buildable: false
source-dirs: src-extra/transformation
dependencies: [jbeam-edit]
jbeam-language-server:
when:
condition: flag(lsp-server) && impl(ghc >= 9.6.6)
then:
dependencies: [lsp>=2.7]
else:
buildable: false
source-dirs: src-extra/language-server
dependencies: [jbeam-edit]

library:
source-dirs: src
Expand All @@ -87,6 +102,17 @@ library:
- condition: os(windows) && flag(windows-example-paths)
cpp-options: -DWINDOWS_EXAMPLE_PATHS

_jbeam-lsp-common: &jbeam-lsp-common
main: Main.hs
ghc-options: [-threaded, -rtsopts, -with-rtsopts=-N]
when:
condition: flag(lsp-server) && impl(ghc >= 9.6.6)
then:
dependencies: [jbeam-language-server]
else:
buildable: false
dependencies: [jbeam-edit]

executables:
jbeam-edit:
main: Main.hs
Expand All @@ -99,6 +125,12 @@ executables:
cpp-options: -DENABLE_TRANSFORMATION
- condition: os(windows)
cpp-options: -DENABLE_WINDOWS_NEWLINES
jbeam-lsp-server:
source-dirs: app-extra/jbeam-lsp-server
<<: *jbeam-lsp-common
jbeam-lsp-test-server:
source-dirs: tools/lsp-test-server
<<: *jbeam-lsp-common
jbeam-edit-dump-ast:
when:
condition: (flag(dump-ast) && flag(transformation))
Expand All @@ -119,6 +151,9 @@ tests:
dependencies: [jbeam-edit, hspec>=2.11, hspec-megaparsec>=2.2]
build-tools: [hspec-discover]
when:
condition: flag(transformation)
dependencies: [jbeam-edit-transformation]
cpp-options: -DENABLE_TRANSFORMATION_TESTS
- condition: flag(lsp-server) && impl(ghc >= 9.6.6)
dependencies: [lsp-test, lsp>=2.7]
cpp-options: -DENABLE_LSP_TESTS
- condition: flag(transformation)
dependencies: [jbeam-edit-transformation]
cpp-options: -DENABLE_TRANSFORMATION_TESTS
4 changes: 4 additions & 0 deletions src-extra/language-server/.dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
((haskell-mode
. ((haskell-process-type . cabal-repl)
(eval . (setq-local haskell-process-args-cabal-repl
(append '("jbeam-edit:lib:jbeam-language-server" "--project-file" "cabal.project.dev") haskell-process-args-cabal-repl))))))
Loading
Loading