* 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
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).
* 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
* 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
* 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
* 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
* 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>
* 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>
* 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>
* 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>
* 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
* 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
* 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
* 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>
* 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>
* 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>
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`.
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.
* 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
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).
* 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
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