diff --git a/CHANGELOG.md b/CHANGELOG.md index e14e7bc..ccbacde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix bare unit type applications ([#225](https://github.com/JustusAdam/language-haskell/issue/225)), thanks to [@mixphix](https://github.com/mixphix) - Fix qualified type operators in export lists ([#191](https://github.com/JustusAdam/language-haskell/issue/191)), thanks to [@mixphix] - Add support for `elif` in Cabal files (`cabal-version` >= 2.2) ([#236](https://github.com/JustusAdam/language-haskell/pull/236)) +- Add support for cabal.project files ([#237] (https://github.com/JustusAdam/language-haskell/issues/237)), thanks to [@rm41339] ## 3.6.0 - 15.03.2022 diff --git a/Makefile b/Makefile index 002c73c..40d8ca9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CONVERT=npx js-yaml VSCE=npx vsce -SYNTAXES=haskell cabal literateHaskell alex happy +SYNTAXES=haskell cabal cabalProject literateHaskell alex happy JSON_TARGETS=$(addsuffix .json,$(addprefix syntaxes/,$(SYNTAXES))) SCOPE_LISTS=$(addsuffix .md,$(addprefix scope-lists/,$(SYNTAXES))) @@ -31,4 +31,4 @@ package: all $(VSCE) package clean: - rm $(JSON_TARGETS) \ No newline at end of file + rm $(JSON_TARGETS) diff --git a/package.json b/package.json index ab5a73c..c35304b 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,19 @@ ], "configuration": "./cabal-configuration.json" }, + { + "id": "cabal project", + "aliases": [ + "CabalProject", + "cabal-project", + "cabal project" + ], + "extensions": [ + ".project", + ".project.local" + ], + "configuration": "./cabal-configuration.json" + }, { "id": "C2Hs", "aliases": [ @@ -168,6 +181,11 @@ "scopeName": "source.cabal", "path": "./syntaxes/cabal.json" }, + { + "language": "cabal project", + "scopeName": "cabal.source.project", + "path": "./syntaxes/cabalProject.json" + }, { "language": "C2Hs", "scopeName": "source.c2hs", @@ -242,4 +260,4 @@ "webpack": "^5.75.0", "webpack-cli": "^5.0.1" } -} \ No newline at end of file +} diff --git a/scope-lists/cabalProject.md b/scope-lists/cabalProject.md new file mode 100644 index 0000000..e9ad412 --- /dev/null +++ b/scope-lists/cabalProject.md @@ -0,0 +1,10 @@ +| Scope Name | Description | Example | +|-|-|-| +| comment.line.double-dash | | | +| constant.numeric.cabal | | | +| entity.name.function.cabal | | | +| entity.name.section.cabal | | | +| keyword.control.cabal | | | +| keyword.operator.cabal | | | +| keyword.other.cabal | | | +| markup.underline.link.cabal | | | diff --git a/scope-lists/cabalProject.yaml b/scope-lists/cabalProject.yaml new file mode 100644 index 0000000..d8ac58c --- /dev/null +++ b/scope-lists/cabalProject.yaml @@ -0,0 +1,10 @@ +- scope: CabalProject + hide: true +- scope: comment.line.double-dash +- scope: constant.numeric.cabal +- scope: entity.name.function.cabal +- scope: entity.name.section.cabal +- scope: keyword.control.cabal +- scope: keyword.operator.cabal +- scope: keyword.other.cabal +- scope: markup.underline.link.cabal diff --git a/syntax-examples/cabal.project b/syntax-examples/cabal.project new file mode 100644 index 0000000..29dc0b0 --- /dev/null +++ b/syntax-examples/cabal.project @@ -0,0 +1,25 @@ +-- A comment + +packages: test-name +import: file +verbose: 0 +allow-older: False +haddock-keep-temp-files: False + +package example + flags: +flags + tests: False + benchmarks: False + extra-lib-dirs: test + +source-repository repo + type: git + location: test + tag: test + subdir: test + +program-options + shared: False + ghc-options: -test + + diff --git a/syntaxes/cabalProject.YAML-tmLanguage b/syntaxes/cabalProject.YAML-tmLanguage new file mode 100644 index 0000000..3d309da --- /dev/null +++ b/syntaxes/cabalProject.YAML-tmLanguage @@ -0,0 +1,149 @@ +fileTypes: + - project + - project.local +name: CabalProject +patterns: + - name: keyword.other.cabal + match: | + (?ix)(\n|^) + ( tests + | import + | (optional-|extra-)?packages + | benchmarks + | verbose + | build-(summary|log) + | remote-build-reporting + | report-planning-failure + | symlink-bindir + | jobs + | semaphore + | keep-going + | offline + | haddock-keep-temp-files + | http-transport + | ignore-(expiry|project) + | remote-repo-cache + | (logs-|project-|build|store-)dir + | (doc-index|project)-file + | (with-)?compiler + | with-hc-pkg + | package-dbs + | active-repositories + | index-state + | constraints + | preferences + | cabal-lib-version + | solver + | allow-(older|newer|boot-library-installs) + | write-ghc-environment-files + | max-backjumps + | reorder-goals + | (count|fine-grained)-conflicts + | minimize-conflict-set + | (strong-)?flags + | reject-unconstrained-dependencies + | per-component + | independent-goals + | prefer-oldest + | extra-prog-path-shared-only + | multi-repl + | test-((machine-)?log|show-details|keep-tix-files + |wrapper|fail-when-no-test-suites|options) + ): + - name: keyword.other.cabal + match: | + (?ix)^[ \t]+ + ( haddock-(all|hoogle|html|foreign-libraries|executables + |tests|benchmarks|internal|(hscolour-)?css + |hyperlink-source|quickjump|(contents|index|html)-location + |base-url|(resources|output)-dir|use-unicode|for-hackage + |keep-temp-files) + | extra-prog-path + | (strong-)?flags + | library-(vanilla|for-ghci|stripping) + | shared + | static + | executable-(dynamic|static|stripping) + | ((library|executable)-)?profiling(-(shared|detail))? + | optimization + | program-(prefix|suffix) + | extra-(lib|framework|include)-dirs(-static)? + | split-(sections|objs) + | (run-)?tests + | benchmarks + | relocatable + | (debug|build)-info + | documentation + | test-((machine-)?log|show-details|keep-tix-files + |wrapper|fail-when-no-test-suites|options) + | coverage + | (benchmark|ghc|test|configure)-options + | type + | location + | tag + | subdir + | import + | (optional-|extra-)?packages + | verbose + | build-(summary|log) + | remote-build-reporting + | report-planning-failure + | symlink-bindir + | jobs + | semaphore + | keep-going + | offline + | http-transport + | ignore-(expiry|project) + | remote-repo-cache + | (logs-|project-|build|store-)dir + | (with-)?compiler + | with-hc-pkg + | (doc-index|project)-file + | package-dbs + | active-repositories + | index-state + | constraints + | preferences + | cabal-lib-version + | solver + | allow-(older|newer|boot-library-installs) + | write-ghc-environment-files + | max-backjumps + | reorder-goals + | (count|fine-grained)-conflicts + | minimize-conflict-set + | reject-unconstrained-dependencies + | per-component + | independent-goals + | prefer-oldest + | extra-prog-path-shared-only + | multi-repl + | x-\w[1-9\w_-]* + ): + - name: keyword.operator.cabal + match: '(==|>=|<=|<|>|^>=|\|\||&&|!)' + - name: constant.numeric.cabal + match: '(?<=[^\w])\d+(.\d+)*(.*)?|[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}(:[0-9]{2}){2}Z)?' + - name: markup.underline.link.cabal + match: '\w+:/(/[\w._\-\d%])+(\?[\w.+_\-\d%]+)(&[\w._+\-\d%]+)*' + - name: entity.name.section.cabal + match: | + ^(?ix: + ( program-options ) + )$ + - match: | + ^(?ix: + ( package + | source-repository + ) + )( |\t)+([\w\-_]+)$ + captures: + '1': {name: entity.name.section.cabal} + '3': {name: entity.name.function.cabal} + - name: keyword.control.cabal + match: '^[ \t]*(if|elif|else)' + - name: comment.line.double-dash + match: '^\s*--.*$' +scopeName: cabal.source.project +uuid: 5eb56f02-df11-40b2-b6d5-fa444522416c diff --git a/syntaxes/cabalProject.json b/syntaxes/cabalProject.json new file mode 100644 index 0000000..d06875a --- /dev/null +++ b/syntaxes/cabalProject.json @@ -0,0 +1,54 @@ +{ + "fileTypes": [ + "project", + "project.local" + ], + "name": "CabalProject", + "patterns": [ + { + "name": "keyword.other.cabal", + "match": "(?ix)(\\n|^)\n ( tests\n | import\n | (optional-|extra-)?packages\n | benchmarks\n | verbose\n | build-(summary|log)\n | remote-build-reporting\n | report-planning-failure\n | symlink-bindir\n | jobs\n | semaphore\n | keep-going\n | offline\n | haddock-keep-temp-files \n | http-transport\n | ignore-(expiry|project)\n | remote-repo-cache\n | (logs-|project-|build|store-)dir \n | (doc-index|project)-file \n | (with-)?compiler\n | with-hc-pkg \n | package-dbs\n | active-repositories \n | index-state\n | constraints\n | preferences\n | cabal-lib-version\n | solver \n | allow-(older|newer|boot-library-installs)\n | write-ghc-environment-files \n | max-backjumps\n | reorder-goals \n | (count|fine-grained)-conflicts\n | minimize-conflict-set \n | (strong-)?flags\n | reject-unconstrained-dependencies\n | per-component\n | independent-goals \n | prefer-oldest\n | extra-prog-path-shared-only\n | multi-repl \n | test-((machine-)?log|show-details|keep-tix-files\n |wrapper|fail-when-no-test-suites|options)\n ):\n" + }, + { + "name": "keyword.other.cabal", + "match": "(?ix)^[ \\t]+\n ( haddock-(all|hoogle|html|foreign-libraries|executables\n |tests|benchmarks|internal|(hscolour-)?css|hyperlink-source\n |quickjump|(contents|index|html)-location|base-url\n |(resources|output)-dir|use-unicode|for-hackage\n |keep-temp-files)\n | extra-prog-path \n | (strong-)?flags \n | library-(vanilla|for-ghci|stripping)\n | shared \n | static \n | executable-(dynamic|static|stripping)\n | ((library|executable)-)?profiling(-(shared|detail))?\n | optimization \n | program-(prefix|suffix)\n | extra-(lib|framework|include)-dirs(-static)?\n | split-(sections|objs)\n | (run-)?tests \n | benchmarks \n | relocatable\n | (debug|build)-info\n | documentation\n | test-((machine-)?log|show-details|keep-tix-files\n |wrapper|fail-when-no-test-suites|options)\n | coverage \n | (benchmark|ghc|test|configure)-options\n | type \n | location \n | tag \n | subdir\n | tests\n | import\n | (optional-|extra-)?packages\n | benchmarks\n | verbose\n | build-(summary|log)\n | remote-build-reporting\n | report-planning-failure\n | symlink-bindir\n | jobs\n | semaphore\n | keep-going\n | offline \n | http-transport\n | ignore-(expiry|project)\n | remote-repo-cache\n | (logs-|project-|build|store-)dir \n | (with-)?compiler\n | with-hc-pkg \n | (doc-index|project)-file \n | package-dbs\n | active-repositories \n | index-state\n | constraints\n | preferences\n | cabal-lib-version\n | solver \n | allow-(older|newer|boot-library-installs)\n | write-ghc-environment-files \n | max-backjumps\n | reorder-goals \n | (count|fine-grained)-conflicts\n | minimize-conflict-set \n | reject-unconstrained-dependencies\n | per-component\n | independent-goals \n | prefer-oldest\n | extra-prog-path-shared-only\n | multi-repl \n | x-\\w[1-9\\w_-]*\n ):\n" + }, + { + "name": "keyword.operator.cabal", + "match": "(==|>=|<=|<|>|^>=|\\|\\||&&|!)" + }, + { + "name": "constant.numeric.cabal", + "match": "(?<=[^\\w])\\d+(.\\d+)*(.*)?|[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}(:[0-9]{2}){2}Z)?" + }, + { + "name": "markup.underline.link.cabal", + "match": "\\w+:/(/[\\w._\\-\\d%])+(\\?[\\w.+_\\-\\d%]+)(&[\\w._+\\-\\d%]+)*" + }, + { + "name": "entity.name.section.cabal", + "match": "^(?ix:\n ( program-options )\n)$\n" + }, + { + "match": "^(?ix:\n ( package\n | source-repository\n )\n)( |\\t)+([\\w\\-_]+)$\n", + "captures": { + "1": { + "name": "entity.name.section.cabal" + }, + "3": { + "name": "entity.name.function.cabal" + } + } + }, + { + "name": "keyword.control.cabal", + "match": "^[ \\t]*(if|elif|else)" + }, + { + "name": "comment.line.double-dash", + "match": "^\\s*--.*$" + } + ], + "scopeName": "cabal.source.project", + "uuid": "5eb56f02-df11-40b2-b6d5-fa444522416c" +}