1
1
mirror of https://github.com/tweag/nickel.git synced 2024-09-11 11:47:03 +03:00
Commit Graph

115 Commits

Author SHA1 Message Date
Yann Hamdaoui
6015c8c0cb
Backport 1.4 release to master (#1755)
* Only update relevant deps in Cargo.lock

The release script needs to update Cargo.lock after having updated
Cargo.toml with the new version of various Nickel crates.

Indeed, we are running some checks via Nix, and Nix builds are sandboxed
without network access. This requires the Nix build to use `cargo
--frozen --offline`, which in turns require the Cargo.lock file to be
up-to-date or it will fail.

The previous version of the release script would do a simple `cargo
update`, which has the default of updating all dependencies. This commit
changes that to only udpate dependencies which we might have bumped.

* Add pause to commit release notes in release script

* Fix release script for LSP

The release script was missing a part: the removal of `lsp-harness` (a
local, unpublished util crates) from the nickel-lang-lsp package priori
to publication to crates.io.

Passing by, other small improvements and fixes are included as well.

* [release.sh] update to 1.4.0

* Specify 'do not commit' when updating release notes

* release guide: add missing step for lsp-harness removal
2024-01-11 09:15:16 +00:00
Yann Hamdaoui
f6227ce18c
Update Topiary to handle (.) curried op (#1753)
The curried version of the field access operator `(.)` wasn't handled
properly by the Nickel tree-sitter grammar, and thus Topiary, and thus
`nickel format`.

This commit simply updates to the latest version of Topiary. We also
switch from using tree-sitter-nickel from crates.io to using the same
version as Topiary (from the repository).
2024-01-09 12:44:17 +00:00
dependabot[bot]
29f4464aa1
chore(deps): bump unsafe-libyaml from 0.2.9 to 0.2.10 (#1747)
Bumps [unsafe-libyaml](https://github.com/dtolnay/unsafe-libyaml) from 0.2.9 to 0.2.10.
- [Release notes](https://github.com/dtolnay/unsafe-libyaml/releases)
- [Commits](https://github.com/dtolnay/unsafe-libyaml/compare/0.2.9...0.2.10)

---
updated-dependencies:
- dependency-name: unsafe-libyaml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-22 09:53:49 +00:00
Yann Hamdaoui
d35baaee1c
Add --error-format flag to serialize err diagnostics (#1740)
* Add --error-format flag to serialize err diagnostics

* Make other CLI errors follow --error-format as well
2023-12-19 15:36:57 +00:00
dependabot[bot]
e1113af368
chore(deps): bump zerocopy from 0.7.18 to 0.7.31 (#1739)
Bumps [zerocopy](https://github.com/google/zerocopy) from 0.7.18 to 0.7.31.
- [Release notes](https://github.com/google/zerocopy/releases)
- [Changelog](https://github.com/google/zerocopy/blob/main/CHANGELOG.md)
- [Commits](https://github.com/google/zerocopy/compare/v0.7.18...v0.7.31)

---
updated-dependencies:
- dependency-name: zerocopy
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-15 12:59:12 +00:00
Yann Hamdaoui
22e94cff46
1.3.0 release (#1714)
* Bump version numbers for 1.3 release

* Add release notes (part 1)

* Bump latest version mentioned in READMEs to 1.3

* Bump latest version mentioned in manual to 1.3

* Update RELEASING guide
2023-11-16 17:52:59 +00:00
Yann Hamdaoui
c0729415e4
Add suggestions when misspelling a record field (#1710)
* Add strsim dependency

* Move error module into its own directory

* Add error::suggest module and fn to find best suggestion

* Add field_names() method to RecordData

* Make find_match more generic

* Add conversion identifier/nickel string

* Add suggestion to missing field errors

* Fix tests and rename item

* Add snapshot test for field suggestion

* Remove debug println and fix code comment

* Review suggestion: improve missing field error message

* Formatting
2023-11-13 17:17:35 +00:00
Yann Hamdaoui
28672ee45b
Update malachite 3.x -> 4.x (and other crates) (#1705) 2023-10-30 09:03:50 +00:00
dependabot[bot]
cde6290b08
chore(deps): bump rustix from 0.37.23 to 0.37.25 (#1688)
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.23 to 0.37.25.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.37.23...v0.37.25)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-19 09:54:03 +00:00
Taeer Bar-Yam
91d63ed611
add %eval_nix% primop (#1465)
* add importing nix files behind a nix-experimental feature flag

* add %eval_nix% builtin to evaluate a nix string

* basic error reporting from nix

* error messages

* use pkg-config to find nix dependency

* nice error message when feature disabled

* better errors

* resolve XXX

* put appropriate dependencies in nativeBuildInputs

* explain -sys crate option

* no %% around builtins in error messages

* clippy needs nativeBuildInputs

* clippy

* fix cargo doc

* use nix master

* c++17 -> c++20

* cargo fmt

* review comments

* fixup after merge

* fix after rebase

* revert to (hopefully) known good nix commit

* try using nix's own nixpkgs

* this worked on build02

* debug for mac CI

* debug doesn't work

* cargo fmt

* debug

* don't fail everything if we can't debug

* debug take N

* nix-version

* remove debug

* disable checks for nix on x86_64-darwin
2023-10-09 15:08:55 +00:00
jneem
221215e48d
Add nls benchmarks (#1659) 2023-10-03 21:31:40 +00:00
Viktor Kleen
924959742d
Version bumps for 1.2.2 (#1655)
* Update to 1.2.2

* Update Cargo.lock
2023-09-29 13:36:02 +00:00
Viktor Kleen
19bed669f9
Track more metrics (#1635)
* Track thunk allocation

* Track `Program::new_from_files` as `Program::new`

* Track environment inserts and gets

* Implement tracking histograms

* Track environment layer size on `get`

* Track number of environment layers traversed on `get`

* Update core/src/environment.rs

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

* Formatting

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-09-28 16:31:16 +00:00
Viktor Kleen
c4b7e0dd5c
Implement a first solution for collecting metrics during a Nickel evaluation (#1633)
* Implement prototype metrics collection and reporting

* Add a few sample metrics

* Document some of the rationale

* Remove unused `metrics-utils`

* Don't enable metrics by default

* Report metrics to stderr
2023-09-27 10:55:03 +00:00
Erin van der Veen
83d189c0c1
Pin and update Topiary (#1624) 2023-09-22 13:44:47 +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
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
Viktor Kleen
28a5e10592
Use std:io::IsTerminal instead of atty (#1540)
The `atty` crate appears to be unmaintained and `std::io::IsTerminal`
provides the same functionality since rust 1.70.
2023-08-23 15:20:19 +00:00
Viktor Kleen
bb410b8aa3
LSP formatting without calling the topiary binary (#1526)
* Introduce nickel_lang_core::format and use it in the CLI

* Use nickel_lang_core::format for formatting in the LSP

* Update lsp/nls/README.md

* Update lsp/nls/README.md

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

* Remove an unused import

* Remove the format feature flag for NLS

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-08-11 18:02:21 +00:00
Yann Hamdaoui
8b4d2d4d80
Update strip-ansi-escape deps, remove corresponding temporary fix (#1521) 2023-08-10 11:06:48 +00:00
jneem
8d092fa36d
Term-based completion (#1504)
* Add terms to the linearization

* Add the reverse map

* Add find_pos

* Remove some panics

* Refactor position-finding

* Small refactor

* Initial version of term-based completion

* oops

* Follow var definitions

* Follow resolved imports

* Fix duplicates, and add some metadata

* Merges

* tests

* Review comments
2023-08-09 14:09:29 +00:00
Viktor Kleen
84da9e78af
Refactor the Nickel CLI (#1502)
* Refactor the Nickel CLI structure

* Add an `Error` enum for the CLI

* Restore the previous user-facing interface

* Make clippy happy

* Restore `nickel format` CLI behaviour

* Change command options naming

* Properly respect feature flags

* WithProgram -> ReportWithProgram

* Remove the unecessary `Files` struct for now

* ReportWithProgram -> ResultErrorExt

* Suggestions from code review
2023-08-08 11:55:03 +00:00
Théophane Hufschmitt
5572b444b0
Disable the colors when stdout isn't a tty (#1508)
Fix https://github.com/tweag/nickel/issues/1500
2023-08-08 08:55:46 +00:00
Yann Hamdaoui
e934796dc6
Restore --version for CLI, include git revision (#1486)
* Restore --version for CLI, include git revision

* Use git revision from nix during the build

* Update flake.nix

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-08-07 11:55:13 +00:00
Jeremy Parker
aa4bb20b3e
Add linker directive for *-darwin to fix PyO3 (#1454)
* Add linker directive for *-darwin to fix PyO3

Without these flags I get linking errors like this when building from
nixpkgs:

  = note: Undefined symbols for architecture arm64:
            "_PyExc_ConnectionResetError", referenced from:
                pyo3::type_object::PyTypeInfo::type_object::hd73bc9c256c52717 in libpyo3-c59aeb8b74bb57e0.rlib(pyo3-c59aeb8b74bb57e0.pyo3.e60578ba-cgu.0.rcgu.o)

See: https://pyo3.rs/main/building_and_distribution#macos

* Move from cargo `config.toml` options to a build script for pyckel

* Use the same revision of tree-sitter-nickel as topiary does

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-07-31 16:16:42 +00:00
Viktor Kleen
997e344f4f
Topiary integration as nickel format (#1371)
* Implement `nickel format` PoC as a topiary wrapper

Improve error reporting for `nickel format`

nix build with topiary

Use upstream topiary query export

* Pin wasm-bindgen version

* Disable `format` feature in nickelStatic for now

* Remove thiserror dependency and make tempfile optional

* Update Cargo.lock

* Disable `nickel format` by default
2023-07-13 10:43:51 +00:00
Yann Hamdaoui
7a01d60270
Backport 1.1.1 (#1439)
* Version bump: 1.0.0 -> 1.1.0

* Add release notes for 1.1

* Bump version - part 2, reset to 0.1 for new crates

* Add missing README to nickel-lang-cli

* Update Cargo.lock, make nickel-wasm-repl's version consistent

* Update releasing instructions for new crate layout

* Fix typo in RELEASES.md

* Update Cargo.lock
2023-07-10 15:31:28 +00:00
jneem
3975ac4fd9
Specify the test harness requests as toml instead of a custom format (#1424)
* Specify the test harness requests as toml instead of a weird custom format

* Update README
2023-06-30 18:46:41 +00:00
Viktor Kleen
78e7a8814b
Rename and move workspace crates (#1399)
* Rename and move workspace crates

nickel-lang -> nickel-lang-cli in cli/
nickel-lang-lib -> nickel-lang-core in core/
nickel-lang-utilities -> nickel-lang-utils in utils/
nickel-repl -> nickel-repl in wasm-repl/

* Finish renaming in rust sources

* Update RELEASING.md

* Move to workspace dependencies

* Rename nickel-repl -> nickel-wasm-repl

* Update RELEASING.md

Co-authored-by: Taeer Bar-Yam <Radvendii@users.noreply.github.com>

* Address suggestions from code review

* Update HACKING.md

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

* Elaborate on the versioning scheme in RELEASING.md

---------

Co-authored-by: Taeer Bar-Yam <Radvendii@users.noreply.github.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-26 16:58:40 +00:00
jneem
ab693c8e4a
In memory imports (#1374)
* Move the nls snapshot tests into the nls crate.

This makes cargo track the dependencies correct, and rebuild nls
before running the tests.

* Add an explicit "in-memory" tag in the file cache.

Entries loaded from in-memory sources will not be auto-refreshed
when an on-disk file changes.

This also changes the path normalization behavior, since the previous
implementation fails for non-existent files.

* Review comments

* Fix the tests.

Prior to this PR, the tests weren't getting run in CI,
and so the import_external_format test was broken.

This is a quick fix to that test, but:
- it seems pretty easy to make NLS panic on invalid input.
  This fixes a panic on invalid import paths, but probably
  invalid line/columns will still cause panics.
- this adds very basic support for server errors to the
  harness, but does not yet support tests that expect certain
  LSP errors.

* Add missing snapshot
2023-06-26 12:57:13 +00:00
Viktor Kleen
3e03cc7909
Move the CLI into its own crate (#1351)
* Fetch the wasm-bindgen-cli version from Cargo.lock instead of Cargo.toml

* Move the Nickel CLI to a separate crate

* Fix snapshot tests

* Rename the nickel flake output to nickel-lang-cli for consistency

* Move the nickel-lang crate into a subdirectory

* Update documentation for the new crate split

* Tweak snapshot test instructions

* Use project_root instead of ad-hoc environment variables

* Remove the library from nickel-lang-cli for now

* Rename nickel-lang to nickel-lang-lib and nickel-lang-cli to nickel-lang

* Apply suggestions from code review

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

* Tweak documentation for nickel_lang_utilities::project_root

* Use MacOS 13 github runner because of https://github.com/cachix/install-nix-action/issues/183

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-16 16:34:13 +00:00
jneem
1676d22a2b
LSP test harness (#1360)
* First working hacky lsp harness

* Refactor

* Add some pretty-printing

* Snapshot tests for the lsp

* clippy

* Update lsp/lsp-harness/src/jsonrpc.rs

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

* Review comments

* ci

* Update lsp/lsp-harness/README.md

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

---------

Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-06-15 11:55:42 +00:00
Kevin K
01bc906b67
Migrate to clap (#1309)
* migrate nls from structopt to clap

* migrate nickel from structopt to clap

* qualify traits coming from clap

* use clap::ColorChoice with ColorOpt as a newtype

* remove explicit default() for value enums

[clap
Documentation](https://docs.rs/clap/latest/clap/_derive/index.html#arg-attributes)
states it will use `Default::default()` so there is no need to
explicitly call it.

* remove manual FromStr implementations and rely on ValueEnum

deriving `clap::ValueEnum` implements `FromStr` for the type, so doing
so manually isn't required any longer.

* Persuade `clap` to use default values

---------

Co-authored-by: Viktor Kleen <vkleen+github@17220103.de>
2023-05-22 09:02:21 +00:00
Yann Hamdaoui
c4da6975b3
Bump version to 1.0 (#1302)
* Bump version number to 1.0

* Add text for 1.0 release
2023-05-17 12:50:43 +00:00
matthew healy
f11b7b09e2
Add test infra to perform arbitrary checks on annotated ncl source files (#1298)
* Add integration test infra to test for errors

* Rewrite eq_fail test as .ncl files

* Parse test expectation from header comment

This ensures that the test input files are still valid Nickel source
code.

* Use file path as thread & program name

* Fix clippy warnings

* Refactor for clarity

* Remove unnecessary Serialize impl

* PoC: annotation-based snapshot tests

* Split utilities crate into modules

* Extract annotated test code to utilities crate

* Use annotations for snapshot tests

* Convert basics_fail.rs to use test annotations

* Disable clippy warning about ErrorExpectation variant names

* Use common annotation parsing code for example tests

* Update tests README

* Remove println

* Update tests/README.md

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

---------

Co-authored-by: Viktor Kleen <viktor.kleen@tweag.io>
2023-05-16 06:56:10 +00:00
Yann Hamdaoui
6a69e076c1
Fix escaping of contracts' custom error message (#1274)
Custom contract errors were escaped too agressively (such as turning
`"` into `\"`), while we only want to escape ANSI escape sequences to
avoid messing up Nickel's error reporting. This commits use a
specialized crate to do that, instead of Rust's std `escape`.
2023-04-21 13:52:08 +00:00
Yann Hamdaoui
d723a3721c
Use indexmap for deterministic behavior (#1235)
This commits use a drop-in replacement for std::collections::HashMap.
The std hashmap has a non-deterministic iteration order, which makes for
a non-deterministic error reporting (when typechecking a file with
multiple errors for example, running Nickel several time on the same
file gives a different output, which is quite bad for the user, who
might think they solved an issue while they didn't).

IndexMap uses the same algorithm and is on par performance-wise, but has
a deterministic iteration order (which is insertion order). Stuff not
related to records or types (other hasmaps used for example in the cache
to map file ids to parsed terms) are left unchanged.
2023-04-07 18:56:45 +02:00
Yann Hamdaoui
53dcc80b1f
Update Nickel dependencies (#1234)
The original motivation is to fix the rustc warning coming from LALRPOP
by updating to 0.19.9. While we're at it, we `cargo update`d.
2023-04-07 17:25:44 +02:00
dependabot[bot]
52511ec5fa
chore(deps): bump comrak from 0.16.0 to 0.17.0 (#1208)
Bumps [comrak](https://github.com/kivikakk/comrak) from 0.16.0 to 0.17.0.
- [Release notes](https://github.com/kivikakk/comrak/releases)
- [Changelog](https://github.com/kivikakk/comrak/blob/main/changelog.txt)
- [Commits](https://github.com/kivikakk/comrak/compare/0.16.0...0.17.0)

---
updated-dependencies:
- dependency-name: comrak
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
2023-03-30 17:03:24 +00:00
matthew healy
828d972fa9
Update stdlib string functions to work on Unicode extended grapheme clusters (#1200)
* Delete dead code from strings.ncl

* Split stdlib_string.ncl into multiple test files

This commit splits the monolithic stdlib string test file into
multiple smaller files, roughly split according to "domain" behaviour.

It also adds some new test cases in places where the coverage seemed
a little thin.

* Maintain extended grapheme cluster abstraction in `string.split`

This commit re-implements `string.split` so that extended grapheme
clusters are never broken up, even if the separator is included
within.

* Return extended grapheme clusters from `string.characters`

* Remove `string.codepoint` and `string.from_codepoint`

These functions break the extended grapheme cluster abstraction,
and don't have equivalents in the Nix language, so we've decided
to remove them.

* Use grapheme cluster indices in string.substring

* Ensure `string.replace` doesn't separate extended grapheme clusters

* `string.contains` should check entire grapheme clusters

This updates the implementation of `string.contains` to avoid returning
true if the string we're searching for only exists as part of a larger
extended grapheme cluster.

* Refactor Nickel string implementation to `term::string` module

* Update stdlib documentation
2023-03-29 10:30:05 +02:00
Yann Hamdaoui
44a97f56d4
Fix serialization/to_string error on rationals 2023-03-14 18:50:42 +01:00
Yann Hamdaoui
61396bb7f7
Use arbitrary precision rationals for numbers
First draft of implementing Nickel numbers using arbitrary precision
rationals instead of 64-bits float. The rationale is to provide exact
precision for common arithmetic operations (understand addition,
division, subtraction, raising to an integer power, modulo), as opposed
to floats, that can incur rounding error on sometimes common decimal
values.

Some operations do need rounding: raising to a non-integer power, as
well as representation as a string (to_string/serialization).
2023-03-14 18:48:01 +01:00
Yann Hamdaoui
b65eb3d72e
Bump rust dependencies, fix breaking changes 2023-03-10 19:18:26 +01:00
dependabot[bot]
ea7836001f
Bump bumpalo from 3.10.0 to 3.12.0
Bumps [bumpalo](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.12.0.
- [Release notes](https://github.com/fitzgen/bumpalo/releases)
- [Changelog](https://github.com/fitzgen/bumpalo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/bumpalo/compare/3.10.0...3.12.0)

---
updated-dependencies:
- dependency-name: bumpalo
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-20 22:07:01 +00:00
Guillaume Desforges
bdb9afc599 pyckel: diagnostics in exception 2023-01-18 18:49:05 +01:00
Guillaume Desforges
768656d75a Move Python bindings to its own crate pyckel 2023-01-16 16:38:24 +01:00
Guillaume Desforges
6e122939ad init Python bindings 2023-01-16 16:38:24 +01:00
matthew healy
bff8451f7e
Add snapshot testing infrastructure (#1034)
* Update regex crate to 1.7

We want to use the regex filtering feature of the insta snapshot testing
library. That has a dependency on a newer version of the regex crate
than Nickel currently does, so this commit updates the Nickel version to
a more recent compatible version.

* Add insta dependency

* Add cargo-insta to dev shells

* Add snapshot testing infrastructure

This uses the insta crate to implement snapshot testing.

Each snapshot test invokes the debug nickel binary with some set of
arguments, then captures the output & compares it to a file in the
snapshots directory

* Add nixpkgs-fmt to dev shell

This makes it possible to easily reformat flake.nix from within a dev
shell.

* Update HACKING.md

* Add snapshot testing README
2023-01-09 11:32:40 +01:00
matthew healy
14aa2e05e9
Return grapheme cluster count from %str_length% primitive (#1005)
Previously `%str_length%` was returning the number of bytes in the Rust
`String` storage, which lead to unexpected results.

This commit uses the `unicode-segmentation` crate to instead count the
number of extended grapheme clusters in the string. This means that even
complex emoji comprised of multiple characters, but visually rendering
as one, get counted as just one character.

One potential downside to this is that this isn't consistent with how
other standard library functions (such as splitting a string) currently
work, however it also wasn't consistent before, and this change at least
moves things in the right direction
2022-12-16 15:45:19 +01:00