1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-06 08:07:37 +03:00
Commit Graph

3927 Commits

Author SHA1 Message Date
jneem
86fb2fa961
Hover support without the linearizer (#1629)
* Convert hover

* Clean up some warnings

* Review comments
2023-09-26 22:41:38 +00:00
Viktor Kleen
0433886d11
Make eval an explicit subcommand and restructure the CLI somewhat (#1632)
* Make `eval` CLI explicit and remove `-f`

* Implement multiple file inputs as merging

* Use `add_string` instead of `add_term`

* `format` cannot create files anymore

* Update snapshot tests

* Separate customize mode from the `export` subcommand

* Decouple customize mode from export and make it available for every evaluation

* Disable an `unused_mut` warning

* Apply suggestions from code review

Co-authored-by: jneem <joeneeman@gmail.com>

* Add a short option for `export --format`

* Update cli/src/eval.rs

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>

---------

Co-authored-by: jneem <joeneeman@gmail.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-26 20:31:30 +00:00
Yann Hamdaoui
7dd104667a
flake.lock: Update (#1628)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/8b4f7a4dab2120cf41e7957a28a853f45016bd9d' (2023-09-04)
  → 'github:ipetkov/crane/3de322e06fc88ada5e3589dc8a375b73e749f512' (2023-09-23)
• Updated input 'crane/flake-utils':
    'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/98ccb73e6eefc481da6039ee57ad8818d1ca8d56' (2023-09-03)
  → 'github:oxalica/rust-overlay/b87a14abea512d956f0b89d0d8a1e9b41f3e20ff' (2023-09-18)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/ace5093e36ab1e95cb9463863491bee90d5a4183' (2023-09-15)
  → 'github:NixOS/nixpkgs/e35dcc04a3853da485a396bdd332217d0ac9054f' (2023-09-22)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/f84bb1621574473d05e6ed79ba57a371d8ad8259' (2023-09-16)
  → 'github:oxalica/rust-overlay/c0ad320f9aadcc3cb1e62794cb950fe243e077d6' (2023-09-23)
• Updated input 'topiary':
    'github:tweag/topiary/7e6cb4f8b505eacee57aaf3c1ab0f3cf539da159' (2023-09-14)
  → 'github:tweag/topiary/8299a04bf83c4a2774cbbff7a036c022efa939b3' (2023-09-21)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-25 08:17:09 +00:00
Taeer Bar-Yam
9aa519f607
More CI speed (#1626)
* speed up nickelWasm

* build packages separately so all dependencies get cached

* comment
2023-09-23 23:41:06 +00:00
Erin van der Veen
83d189c0c1
Pin and update Topiary (#1624) 2023-09-22 13:44:47 +00:00
Viktor Kleen
f3d7430476
Remove the double contract application introduced in #1194 (#1625)
Because of #1228 we syntactically forbid contracts from containing free
type variables. This was implemented in #1271 and #1272. As a result,
the double contract application in #1194 became dead code. This PR
removes the `%dualize%` primop, the `dualize` field in `Label` and the
double application logic when constructing recursive environments for
records.
2023-09-22 13:44:10 +00:00
jneem
bcb0f71caa
Convert symbols request away from the linearizer (#1623) 2023-09-22 12:12:36 +00:00
Viktor Kleen
17adb43f87
Run a REPL session for nickel #repl snippets (#1615)
* Run a REPL session when checking `nickel #repl` snippets

* Adjust examples in the manual for new checks

* Fix some leftover error messages

* Address code review
2023-09-22 11:35:30 +00:00
Yann Hamdaoui
71d62de379
Assume -> ApplyContract (#1617)
* Assume -> ApplyContract

At the very beginning of Nickel, the duality between a type annotation and
contract annotation was reflected in their original naming, the assume
construct (contract annotation) and the promise construct (a type
annotation).

This terminology isn't used anymore, and isn't very telling for new
contributors. This PR get rid of old references to `Assume` and
`Promise`, and rename the `Assume` primitive operation to the more
boring but more explicit `ApplyContract`.

* Formatting
2023-09-21 17:33:53 +00:00
jneem
df15becc5d
Context completion (#1584)
* Add context completion

* Review comments

* Use either record completion or env completion, but not both

* Add test case for env completion

* Fix compilation
2023-09-21 14:33:53 +00:00
jneem
7937e5a175
Move goto away from the linearizer (#1610)
* Move goto away from the linearizer

* Add regression test for 881

* Add tests, add ident lookup

* Review comments

* Better name
2023-09-19 20:30:56 +00:00
Viktor Kleen
b02961324d
Testing Nickel snippets in the manual (#1611)
* First pass on testing snippets in `manual/syntax.md`

* Remove explicit `TestCase`

* Remove explicit panic

* Add test annotations to the manual

* Stop filtering markdown files

* Update `typing.md` example

* Apply suggestions from code review

Co-authored-by: jneem <joeneeman@gmail.com>

* Some tweaks to multi line string examples

* Move from `nickel-...` info strings to `nickel #...`

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-19 13:09:58 +00:00
gtsiam
365e14da36
Cleanup the code a bit (a lot) (#1595)
* Removed explicit state from Traverse trait

* Make clippy happy

* Consistent whitespace between documented items

I kept running into this while going through the codebase,
so I thought I'd fix it once and for all.

And no, I did not do this by hand. So I might have missed some cases.

* More formatting.

Mainly includes wrapping of comments to the 100 column mark,
as well as some more formatting on macros and strings.

* restore try_map_state in Traverse impl

* Removed IdentKind

It was technically only used in the PartialEq implmentation of Thunk.
Still, I don't think that had any effect.

* Fix doc comment

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>

---------

Co-authored-by: Taeer Bar-Yam <taeer.bar-yam@tweag.io>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-18 11:38:33 +00:00
Yann Hamdaoui
c1a2cb78a7
flake.lock: Update (#1612)
Flake lock file updates:

• Updated input 'flake-utils':
    'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
  → 'github:numtide/flake-utils/ff7b65b44d01cf9ba6a71320833626af21126384' (2023-09-12)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b' (2023-09-08)
  → 'github:NixOS/nixpkgs/ace5093e36ab1e95cb9463863491bee90d5a4183' (2023-09-15)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa' (2023-08-17)
  → 'github:cachix/pre-commit-hooks.nix/4f883a76282bc28eb952570afc3d8a1bf6f481d7' (2023-09-10)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/1b4fad9dccece45c25b9ebda607427d69a8f1eae' (2023-09-09)
  → 'github:oxalica/rust-overlay/f84bb1621574473d05e6ed79ba57a371d8ad8259' (2023-09-16)
• Updated input 'topiary':
    'github:tweag/topiary/fe6083d2b7c762f5e8c63b9c79a8bd3ced12ea5d' (2023-09-09)
  → 'github:tweag/topiary/7e6cb4f8b505eacee57aaf3c1ab0f3cf539da159' (2023-09-14)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-18 08:02:11 +00:00
jneem
b2459d3172
Type-based completion in the new completer (#1577)
* Collect types into a table

* Type-based completion

This also adds a feature flag for turning off the old completer.

* Remove bogus file

* Explicitly visit type annotations

* Add a test for annotated types

* Only do one linearization traversal

* Fix docs, and avoid some clones

* Combine, and resolve metadata

* Add a test

* Slight improvements to the lsp spec

* Refactor

* Remove commented-out code

* Remove the confusing initial-env thing

* Complete the refactor, and document a little better

* Fix some rebase issues

* Clean up some unused code

* Remove obsolete doc

* Review comments
2023-09-15 19:19:45 +00:00
Yann Hamdaoui
508c492bfd
Update VSCode extension to 0.3 (#1609)
* Update VSCode extension to 0.3

* Formatting yarn.nix
2023-09-15 18:15:31 +00:00
Viktor Kleen
f28797ebf0
Update the version number in the manual introduction (#1607)
Update the version number to `1.2` and add a note to `RELEASING.md` so
we don't forget quite as often.
2023-09-15 09:11:14 +00:00
Yann Hamdaoui
fcde9ba0ad
[REVIEW & CI] 1.2.1 release (#1606)
* Tentative fix for 1.2.0 not installing

* Update to 1.2.1 (fix cargo install)

* Update Cargo.lock
2023-09-14 19:53:55 +00:00
Yann Hamdaoui
27b8c0ede5
Backport 1.2.0 release to master (#1603)
* Bump versions for 1.2.0 release

* Update Cargo.lock

* Update RELEASING guide

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Add 1.2.0 release notes

* Depend from published tree-sitter-nickel

* Add warning about crates.io and format feature in READMEs

* Fix formatting_external borrowing issue

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-09-14 18:14:32 +00:00
Viktor Kleen
ee6369af8b
Fix an off-by-one error in the LSP formatter (#1605)
* Fix an off-by-one error in the LSP formatter

According to [the LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range)
the end of a text range in the protocol is exclusive. When executing
a formatting request in the language server we want to replace the
entire document with the formatted result, including any trailing
newlines. This means we need to specify the beginning of the line after
the very last line in the document as the end of the range of text to
be replaced.

This also fixes an annoying behaviour when formatting with NLS in Helix.
Previously, Helix would insist on selecting (what looked like) the
entire document on every formatting request. With this change, Helix
refrains from doing this.

* Update LSP snapshot test
2023-09-14 14:34:21 +00:00
Viktor Kleen
fca5046c43
Put embedded topiary formatting behind a feature flag for NLS (#1604)
* Prevent unused import warnings when building without `doc`

* Put embedded topiary formatting behind a feature flag for NLS, as well

* Stop sending a formatting edit if nothing changed
2023-09-14 12:59:53 +00:00
Yann Hamdaoui
0eb45e8feb
Remove recursive priorities (#1600)
Recursive priorites were added pre-RFC005, where their semantics was
straightforward. Because metadata could appear anywhere, recursive
priorities (or also called push priorities) just amounted to have a
primop that pushed the priorities down a term, in one lazy step.

Since RFC005, this isn't possible anymore, because only record field can
hold metadata. It's now much more intricate to implement, because when
encountering a `rec force` at the field level, we first need to know if
there's any value able to receive it underneath this field to know if we
should attach it to the field or no. To know that, we might need to
evaluate the field first, and then decide.

Before sorting out both the new semantics and implementation, this
commit disable the syntax (but keep the rest of the machinery) from
1.2.0 so that we can do some design before shipping new recursive
priorities or scraping them entirely. Recursive priorities were
undocumented, and should have been disabled from 1.0.0, so it's not
considered a breaking change.
2023-09-13 13:04:19 +00:00
Viktor Kleen
7c9e771ddd
Statically merge partial record definitions (#1599)
* Use `try_str_chunk_as_static_str` instead of duplicating the logic

* Simplify `merge_fields`

* Statically merge piecewise record definitions

* Replicate the behaviour of `eval::merge::merge_fields` more closely
2023-09-13 08:51:26 +00:00
Taeer Bar-Yam
aa1d9335c7
print nice logs without losing speedup (#1594)
* print nice logs without losing speedup

* forgot stderr (the important one)
2023-09-12 15:54:11 +00:00
dependabot[bot]
e95ab85e79
chore(deps): bump aws-actions/configure-aws-credentials from 3 to 4 (#1596)
Bumps [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) from 3 to 4.
- [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases)
- [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md)
- [Commits](https://github.com/aws-actions/configure-aws-credentials/compare/v3...v4)

---
updated-dependencies:
- dependency-name: aws-actions/configure-aws-credentials
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-12 07:36:10 +00:00
Yann Hamdaoui
c79bc9e6f6
Fix LSP regression (#1583)
* Fix LSP not showing hover information

After the bidirectional refactoring (better separating the rules between
`infer` and `check`), the LSP was experiencing regressions, not showing
hover information in some cases, in particular within statically typed
blocks.

It turns out the separation between `infer` and `check` makes less clear
which function is responsible for adding the term to the linearizer:
sometimes it's `check`, sometimes it's `infer`, and it really depends on
the call graph and where each function is called from.

It turns out the previous implementation was adding many terms in
double, and this caused the initial regression observed.

Morever, fixing is made hard by the fact that `infer` now doesn't have a
type to provide right now for the linearizer: it first need to, well,
infer it. But the linearizer currently relies on AST nodes being visited
in order, so we can't either call to it whenever we want.

The situation seemed intricate enough that it was easier to separate
"visiting the term" from "amending the type of the term". This commit
thus adds a `retype` method to the `Linearizer` trait, plus some
id-related signature changes. Now, the typechecking code can add a term
to the linearizer as soon as it visits it, and set the type later. More
discipline has been introduced so that `check` and `infer` don't repeat
the same term visits anymore.

Doing so, this commit also cleans a bit the LSP implementation which was
very hard to change getting it right: `IdGen` in particular is gone
(which was maintaining a counter by hand in parallel to the
linearization's size, which was very error-prone, and if any mismatch
occurred, anything could happen). The truth is, the refactor should be
much more involved to make the code maintainable, but this commit is
just a fix for the 1.2.0 release to get out, and the linearizer is a
legacy component that will be scraped soon when the AST-based LSP will
reach feature parity with the linearizer.

* Add Hover capability to tests

* Add regression test for hover after bidir pull request

* Formatting and code clean-up

* Apply suggestions from code review

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Make retype calls less verbose

* Fix documentation dangling link

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-09-11 15:35:04 +00:00
Yann Hamdaoui
e412993ad8
flake.lock: Update (#1593)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/80432e15452e55a72403da3bc91837508a4ccae3' (2023-09-01)
  → 'github:ipetkov/crane/8b4f7a4dab2120cf41e7957a28a853f45016bd9d' (2023-09-04)
• Updated input 'crane/flake-utils':
    'github:numtide/flake-utils/919d646de7be200f3bf08cb76ae1f09402b6f9b4' (2023-07-11)
  → 'github:numtide/flake-utils/f9e7cf818399d17d347f847525c5a5a8032e4e44' (2023-08-23)
• Updated input 'crane/rust-overlay':
    'github:oxalica/rust-overlay/b520a3889b24aaf909e287d19d406862ced9ffc9' (2023-08-07)
  → 'github:oxalica/rust-overlay/98ccb73e6eefc481da6039ee57ad8818d1ca8d56' (2023-09-03)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/aa8aa7e2ea35ce655297e8322dc82bf77a31d04b' (2023-09-01)
  → 'github:NixOS/nixpkgs/db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b' (2023-09-08)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/cdf3b15af70f2db17d5f47822f12016f1a89bd73' (2023-09-02)
  → 'github:oxalica/rust-overlay/1b4fad9dccece45c25b9ebda607427d69a8f1eae' (2023-09-09)
• Updated input 'topiary':
    'github:tweag/topiary/577fe940aa0b9dae478b463bddd1238e20f86e3a' (2023-08-24)
  → 'github:tweag/topiary/fe6083d2b7c762f5e8c63b9c79a8bd3ced12ea5d' (2023-09-09)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-11 09:04:33 +00:00
Taeer Bar-Yam
f0bf0beba9
Cache more (#1580)
* cache most of the work even if rev changes

* longer string for more reliable search.

* more recognizable dummyRev

* nickel-lang-static needs env

* appease nixpkgs-fmt

* copy meta to new derivation

* add comment
2023-09-11 08:53:20 +00:00
Viktor Kleen
be9269a443
Fix the release artifacts workflow (#1573)
* Fix a typo in the release workflow

This changes `os.matrix` into the correct `matrix.os`.

* Use `nodeRuntimes` as required by nixpkgs master, now

* Add nix settings to github-runner.nix

* Disable diffutils tests on arm64 musl

* Add dependencies on `start-runner` in `release-artifacts.yaml`

* Use `--log-format raw-with-logs` like in the CI workflow

* Use the correct cargo package for `nickel-static`

* Adjust linker flags on arm64 musl

* Add github cli and docker to `github-runner.nix`

* Combine static binary and docker image building jobs for caching

* Allow docker access for github jobs

* Use `docker buildx` to assemble the multiplatform image
2023-09-06 09:14:59 +00:00
Yuriy Taraday
c4bda4945e
Add meta.mainProgram to packages where appropriate (#1579)
Allows to `nix run github:tweag/nickel#...` to work as expected
with all packages as well as `pkgs.lib.getExe` returning proper paths.

Also switch to `getExe` with nickel packages in flake.nix
to demonstrate how nice it looks.
2023-09-06 08:49:31 +00:00
suimong
20ae8e4bdf
Implement curried dot operator (#1578)
* display icon for nickel file in vscode explorer

* implemented with DynAccess.

* added tests.

* Update grammar.lalrpop

move implementation inside CurriedOp

---------

Co-authored-by: Ben Yang <ben@ya.ng>
2023-09-06 07:43:04 +00:00
Viktor Kleen
c557118f8a
Exit with nonzero exit code on failure (#1576)
We previously just reported the error and then pretended to exit
successfully. With this change the process returns `ExitCode::FAILURE`
whenever it needed to report an error, and `ExitCode::SUCCESS`
otherwise.

Fixes #1575
2023-09-05 15:09:24 +00:00
dependabot[bot]
795e2677fe
chore(deps): bump actions/checkout from 3 to 4 (#1572)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 08:52:35 +00:00
dependabot[bot]
46860193a3
chore(deps): bump cachix/install-nix-action from 22 to 23 (#1571)
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 22 to 23.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Commits](https://github.com/cachix/install-nix-action/compare/v22...v23)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 08:51:10 +00:00
Viktor Kleen
4b9062690d
Add a note about an AWS provider bug into infra/README.md (#1570)
I had forgot about this issue when writing the README originally.
2023-09-04 16:46:00 +00:00
Viktor Kleen
0dd1e10863
Add infrastructure for on-demand ARM64 runners on AWS (#1569)
* Add infrastructure for on-demand ARM64 runners on AWS

With this change, ARM64 release artifacts will be built automatically by
a GitHub workflow. Since GitHub doesn't offer hosted runners running on
ARM64, we're spinning up an EC2 spot instance on demand and run the jobs
building ARM64 artifacts there.

As a fun side note, the Terraform infrastructure code is written
entirely in Nickel.

* Remove unused `update-github` script

* Address comments from code review

* Address comments from code review
2023-09-04 15:41:23 +00:00
Viktor Kleen
305d1a4488
Normalize line endings in string literals during parsing (#1562)
* Remove unused `strip_indent_doc`

* Replace `\r\n` by `\n` in the string literal parser

* `mk_strchunk_literal` -> `StrChunk::normalized_literal`

* Move string normalizing into the lexer

* Remove leftover debug print
2023-09-04 15:11:32 +00:00
Yann Hamdaoui
80e9abe2a0
Handle override and help inputs in customize mode (#1563)
* customize mode conflicts: improve help messages

* Enablze overriding input fields with --override

* Fix unescaped [ in rustdoc
2023-09-04 15:10:23 +00:00
Yann Hamdaoui
72cd17ca47
flake.lock: Update (#1567)
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/ef5d11e3c2e5b3924eb0309dba2e1fea2d9062ae' (2023-08-23)
  → 'github:ipetkov/crane/80432e15452e55a72403da3bc91837508a4ccae3' (2023-09-01)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5690c4271f2998c304a45c91a0aeb8fb69feaea7' (2023-08-25)
  → 'github:NixOS/nixpkgs/aa8aa7e2ea35ce655297e8322dc82bf77a31d04b' (2023-09-01)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/e90223633068a44f0fb62374e0fa360ccc987292' (2023-08-26)
  → 'github:oxalica/rust-overlay/cdf3b15af70f2db17d5f47822f12016f1a89bd73' (2023-09-02)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-09-04 11:16:39 +00:00
Yann Hamdaoui
d2316b6588
Revert to special casing the parsing of "%...%{ in multiline strings (#1566)
* Revert "[Fix] Fix bad lexing of mutline string closing delimiter (#1435)"

This reverts commit 664c397aad.

After more investigation, it turns out the original change made it very
annoying to interpolate something between double quotes, because it
conflicts with the multiline string end delimiter:

m%" "%{hello}" "%

After the reverted change, this wouldn't parse correctly anymore. One
can escape the first quote, but it's verbose and harder to read:

m%" %{"\""}%{hello}" "%

Although, we can't see any case where an interpolation sequence with a
heading quotes would have a valid meaning in the reverted commit's
model: it's always an error (applying a string to something). Thus, if
there's a sequence `"%{` in a string, there is no other meaningful
interpretation than this is a quote followed by an interpolation
sequence.

We thus decided to revert this change, although it derives a bit from
the most simple interpretation of parsing multiline string.

* Post-revert fixup: restore some comments and renamings

* Document multiline string parsing special case

* Update core/src/parser/lexer.rs

Co-authored-by: jneem <joeneeman@gmail.com>

* Fix interpolation sequence in pretty printer

---------

Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-04 10:12:22 +00:00
deotime
0080bf5266
Render hover documentation as Markdown in LSP (#1559)
* Render documentation as markdown in LSP

* Use unindent crate to retain code indentation

* Render contracts seperate from documentation

* Remove usages of unindent

* Remove unindent from `Cargo.lock`

---------

Co-authored-by: BuildTools <DeoTimeTheGithubUser@users.noreply.github.com>
2023-09-04 09:00:36 +00:00
jneem
8f2def66ff
Make an enum for different input sources (#1560)
* Make an enum for different input sources

* Fix doc link

* Review comments

* Add a comment
2023-09-01 17:26:09 +00:00
Yann Hamdaoui
b687ea3322
Get rid of uninformative generic notes (#1564)
Upon the failure of a higher-order contracts, we used to include quite
generic notes showing a plain illustration of the kind of higher-order
violation that happened. However, this text was totally generic (the
example didn't relate to the source code at all), quite verbose (around
4-5 lines of notes), and to be honest, not very helpful.

We now have good mechanisms to underline the right part of the function
contract that failed, together with customized label (e.g. "broken by the
caller"), which makes look like the original generic note aren't very
valuable.

This patch ditches those notes altogether.
2023-09-01 17:24:14 +00:00
deotime
f03213c997
(LSP) Import completion (#1561)
* Import completion

* Use `cache::normalize_path` instead of `fs::canonicalize`

* Add cached files as candidates for import autocompletion

* Rename `InputFormat::from_path_buf` to `InputFormat::from_path`

* Deduplication between server cached files and disk files

---------

Co-authored-by: deotime <89555032+DeoTimeTheGithubUser@users.noreply.github.com>
2023-09-01 16:18:41 +00:00
Yann Hamdaoui
3891689a43
Fix incomplete check of row constraints (#1558)
In an attempt to free the allocation of the constraints of a record row
unification variable that is being assigned to some record rows, the
code checking that row constraints are satisfied was removing the
constraints from the global state. Since rows are defined as linked
list, if the constraint wasn't violated on the first row, this function
would recursively call itself. But then the subsequent recursive calls
would try to get the constraints from the state again, to only find an
empty set constraints, as it has been removed just before. The function
thus wouldn't detect constraint violations happening in the tail of the
record rows.

This patch defines a subfunction which passes the initial constraints
along recursive calls, such that they aren't lost during recursion,
instead of trying to get them from the state again at each recursive
call.
2023-09-01 14:40:52 +00:00
Taeer Bar-Yam
b8e292d44b
set record arguments with -- (#1475)
* set arguments with --

Create term that merges command line arguments with program

* Move building the override term into `Program`
* instead of immediately evaluating argument values, use
`ImportResolver::add_string` to make them separate imports.
* Move CLI export into its own file
* Integrate record builder interface
* Make record field paths work correctly
* Evaluate annotations, too, for record normal form
* Make term interfaces a first class concept
* Stop printing terms on export

* Rename eval_for_doc to be less doc-specific

And expand the documentation at the same time.

* Augment FieldInterface with more data

Augment the field interface type - for freeform argument passing in the
CLI - with additional metadata, such as being optional or defined, taken
directly from the original field's metadata. Add a somehow heuristic
(but simple) `is_input` method, which decides if a field is an input and
should have a dedicated argument.

Minor reworking/renaming of other part of the CLI export code around
freeform arguments.

* Restore the path argument, add more documentation

* Use Field/FieldMetadata instead of custom types

In the CLI export function, instead of using a structure that mostly
mirror record fields, we directly use record fields to avoid code
duplication, although fields do carry a bit more information that what
we exactly need.

* Use query printer to render freeform args help

* Continue proper handling of overrides/inputs in CLI

* Fix eval_record_spine, add sources for CLI arguments

* Remove debug println, improve CLI freeform output

* Move around reporting code to error module

* Actually implement --override, add custom error messages

* Make overrides have a `force` priority

* Add some untested tests

* Small rewording of Ident documentation

* Post-rebase fixups + get rid of Merge trait

* Fix snapshot test runner for freeform args

* Fix CLI freeform snapshot tests

* Fix unused import warning

* Formatting

* Review pass, smallfixes and clippy fix

* Fix cargo doc warnings

* Fix 1.72 new clippy warnings

* Update snapshots after extra-args -> customize mode

* Move the Combine trait in its own mod

* Apply suggestions from code review

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Update core/src/term/make/builder.rs

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Remove questionable Option<> layer

* Update cli/src/export.rs

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>

* Update cli/src/export.rs

Co-authored-by: jneem <joeneeman@gmail.com>

* Apply suggestions from code review

Co-authored-by: jneem <joeneeman@gmail.com>

* Add warning about usage of Label::default

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
Co-authored-by: jneem <joeneeman@gmail.com>
2023-09-01 09:57:30 +00:00
Taeer Bar-Yam
6764f23710
Speed up CI (#1549)
* cargo doc cache dependencies

* simplified version string (better caching)

* remove double suffixes (e.g. nickel-lang-doc-doc)

* partially revert pname changes

* buffer CI output

* speedup log printing without jank

* revert reverting some pname changes (+ fix)
2023-08-30 15:23:10 +00:00
suimong
c984a4a18a
display icon for nickel file in vscode explorer (#1556)
Co-authored-by: Ben Yang <ben@ya.ng>
2023-08-30 08:06:14 +00:00
deotime
dad9e54c43
Add multiline string support for VSCode autoclosing pairs (#1553)
* Add multiline string support for VSCode autoclosing pairs

* Support up to 4 % symbols

---------

Co-authored-by: BuildTools <DeoTimeTheGithubUser@users.noreply.github.com>
2023-08-29 16:06:05 +00:00
jneem
028695d91d
Two issues with incomplete input (#1550)
This fixes an off-by-one error in the handling of incomplete input.
It also makes import resolution in incomplete input more reliable --
previously it would only work when the file being opened is in the
current working directory.
2023-08-29 15:06:42 +00:00