title | editLink |
---|---|
Releases |
false |
-
Now we published release for Windows platform.
-
Improved the Closure syntax to support write in one line.
let s: string? = "hello"; // Before s.map(|x| { return `${x} world`; }); // After s.map(|x| `${x} world`);
-
spawn
,defer
now support without block.spawn println("hello"); defer println("world");
- And with this support, we have to changed empty map initialization from
{}
to{:}
.
- And with this support, we have to changed empty map initialization from
-
Add
#[track_caller]
annotation for function, see also: Track Caller##[track_caller] fn assert_success(value: bool) { assert value == true; } test "assert_success" { assert_success(true); assert_success(false); }
Will output:
error: thread 'thread 1#' at 'assertion failed: value == true', test.nv:8 stack backtrace: 0: test#0() at test.nv:8
-
Improve init array with rest expr:
let a = [1, 2, 3]; let b = [..a, 4, 5];
-
Add to support unescape in
char
.let c = '\n';
- Add
std.net.tcp
module, and here is a guides: Echo Server - Add
std.fs.copy
. - Add
std.io.BufReader
,std.io.BufWriter
. - Add
flush
method tostd.io.Write
interface. - Add
std.str.Debug
to create debug string with Debug interface.struct MyType {} impl Debug for MyType { fn inspect(self): string { return "MyType"; } } let my_type = MyType{}; assert_eq `${my_type:?}`, "MyType";
- Add
std.backtrace
module to get backtrace info. - Add
std.env.join_paths
method. - Improve
std.net.http
, removedform
,multipart
argument, letbody
support more types. - Improve array's
unique
,reverse
,sort
,sort_by
,resize
,truncate
,clear
to return it self. - Imporve
std.process
to add Command,process.run
now returnsChild
instance. - Imporve
std.fs
,std.process
internal handle for better performance. - Improve
std.path.join
to supports arbitrary argument:path.join("a", "b", "c", "d")
. - Improve
std.crypto
, letupdate
andhmac
function to supportstring | Bytes
. - Fix path join to use
push
avoid cratePath
object. - Rename
std.url.URL
->std.url.Url
.
- Done with
longport
package.
We have rewrote navi test
, navi doc
command, and build a new stdlib docs.
https://navi-lang.org/stdlib/std.crypto
Now, there have more details in the docs, and we will keep improving it.
-
navi doc
is rewritten with new output format for better to generate docs. -
Improve
navi test
with parallel test running and we optimized the test result output.test main2.nv 1/1 ok 0ms test main.nv 2/2 ok 0ms
-
Improve
navi test --doc
to show the correct line number in Markdown file. -
Add Navi info print when run
navi test
,navi bench
command.Navi 0.11.0 (x86_64-apple-darwin, a76be5f7, 2024-06-07 01:12:17 +08:00)
-
Temporary workaround for
apple-darwin-aarch64
to print backtrace.
- fmt: leave comma in multi-line array_list.
- fmt: if there is no code in a closure, just an empty {}, no line breaks.
- fmt: Fix missed the function attributes.
- lsp: use custom display_value_type only for inlay hint.
- lsp: call display on ValueType in autocomplete.
- lsp: find_navi_toml_pathbuf and all
*.nv
thereunder for cache. - lsp: look for immediate parent dir in create_compile_options.
- lsp: find cache's member info to do when cfg debug assertions
- lsp: auto complete global vars of a Module.
- lsp: check the client’s capabilities and returns either a simple code action capability or a detailed set of supported code action kinds.
- lsp: allow retrying in dispatch.
- lsp: skeleton of handle_code_action, handle_code_action_resolve.
- lsp: search cache_stdlib, cache_userlib to generate fix advice.
- Added
expect
,unwrap
,unwrap_or
,or
,or_else
, and,and_then
,is_nil
,map
,map_or
,ok_or
,inspect
,flatten
methods to optional value. - Added
type alias
statement to define a type alias, andtype
statement to define a newtype. - Improved
do/catch
to better handle error. - Added to support call method in union type.
- Added support
tag
attribute for newtype serde. - Added to support overridden the default imported names in code scope. e.g.:
Error
, you can have your ownstruct Error
to override the defaultError
.
- Removed
std.io.Buffer
, instead with newstd.io.Bytes
. - Moved module under
lang
tostd
, and default importstring
,channel
,Any
,Decimal
, removedlang
module. - Improved to default import
print
andprintln
method fromstd
, now we can call it directly withoutuse
. - Added to support log format (full, json, pretty, compact).
- Renamed
URLEncodedForm
toUrlEncodedForm
instd.net.http
. - Added
File.seek
andFile.rewind
method tostd.fs
. - Added to support
flag
andmode
options forfs.open
andFile.open
method. - Added
fs.copy
,fs.copy_dir
,fs.rename
,fs.hard_link
,fs.symlink
,fs.unlink
method. - Improved
assert_throws
, the secondary argument support with a closure to write custom assert.
- Added
csv
package to support read and write CSV file.
- Add
draw
function.
- doc: Added more details doc for array methods.
- doc: Added to support navi-doc to generate method docs in
lang.optional
,lang.int
... - doc: impl Display for Enum, Struct, Interface, and Module.
- doc: show "instance" for nvs object value types.
- fmt: Updated to indent for switch and case with different levels.
- lsp: Added
navi_stream
language match support for Zed editor. - lsp: Added to support goto definition for Navi to Navi Stream source.
- lsp: Added to support show hover info for struct fields.
- lsp: Improved find symbol of TypePathNode::Normal.
- lsp: determine
language_id
by file extension. - lsp: find ImportedModule in current module file symbols first.
- lsp: fix bug of there being always an error message left (nvs).
- lsp: generate diagnostics for Navi Stream.
- lsp: optimize inlay hint padding and improve hover info for Navi Stream.
- Improved the
navi run
andnavi test
commands for searching thenavi.toml
within a subproject.- Added support for finding
navi.toml
to locate the workspace path. - Added the
navi new
command to create a new project. - Removed the
--all-dir
option fromnavi test
, as it is no longer necessary.
- Added support for finding
- Improved the
array
type to include more methods:map
,filter
,filter_map
,concat
,sum
,max
,min
,position_max
,position_min
,max_by
,position_max_by
,min_by
,position_min_by
,product
,index_by
,contains_by
,clone
. - Improved the
map
type by addingclone
methods. - Updated the
spawn
behavior to execute immediately. - Fixed support to assign
closure
toclosure?
. - Fixed a bug where the interface default method's first argument must be
self
error on release. - Improved internal conversion from char to string.
- Added
std.log
. - Added
std.io.Write
as Logger output support and added theprefix
method. - Fixed serialization to support union types.
- Updated the
to_string
methods of JSON, YAML, and TOML to supportany?
and added more tests. - Fixed serialization bugs for some complex cases.
-
We have released the Zed extension for Zed with LSP support. Now code formatting, code completion, hover, go-to-definition, find references, rename, and more features are available in Zed.
- Open your Zed and go to
Extensions
to search fornavi
and install it. - Currently, only available for Zed Preview version.
- Open your Zed and go to
-
doc: Added support to generate
enum
,interface
,type
for thenavi doc
command. -
doc: Fixed
impl
enum
navi doc
generation and included the source code signature by usingnavi-fmt
code generation. -
lsp: Fixed LSP absolute path in Zed and other compatibility fixes for Zed.
-
lsp: Enhanced LSP to support showing hover info on expr nodes.
-
lsp: Fixed LSP inlay hints left padding.
-
fmt: Fixed to ensure that the semicolon comes before for long lines.
- Removed the
--all-dir
option fromnavi test
, as it is no longer needed. - Renamed
error
interface toError
. - Removed
execute_many
from thesql
package because it was deprecated in sqlx.
- Add
decimal
as builtin type. - Fix object pool memory leak.
- Improve stdlib throws errors, now all errors has it's own error type.
- Add
std.time.Instant
. - Fix std.time.DateTime,
iso8601
to use ISO 8601 format,to_string
to use RFC 3339 format. - Add
std.time.Duration
andstd.time.DateTime
,decimal
to support serialize and deserialize. - Fix operator (
>
,>=
,<
,<=
) support forstd.time.Duration
. - Fix
regex.Captures
gc mark leak.
- Add
acquire_timeout
option forsql.Connection.connect
, default is 30s. - Add
extra-engine
support to sql.Extra Engine backend is a experimental feature, it can be used to execute sql with different engine (CSV, Aliyun OSS, AWS S3, MySQL, PostgreSQL, etc).
- Add
close
method tosql.Rows
to close the rows. - Add
longport
SDK basic feature to support LongPort OpenAPI.
- Improve Navi LSP performance, and improve auto-completion details.
- Improve zed-navi syntax highlight v0.0.4
- Improve vscode-navi to support decimal.
-
Add to support arbitrary parameters.
fn foo(a: int, b: int, items: ..string) { }
-
Add top support iterate for channel types.
use std.io; let ch = channel::<int>(); spawn { defer { ch.close(); } for i in 0..10 { ch.send(i); } } for n in ch { io.println(n); }
-
Add to support
impl for
.interface Foo { fn foo(self); } struct User {} impl for User { fn foo(self) { io.println("foo"); } }
-
Add support lazy initialization.
let s: string; s = "hello";
-
Add
char
type.let c: char = 'a';
-
Add to support
while let
.while (let v = ch.recv()) { io.println(v); }
-
Now can iterate over a string.
let s = "hello"; for c in s { io.println(c); }
-
Improve string performance.
-
Improve string interpolation for support
${x:?}
to print debug format. -
Improve implicit conversion to support.
// Option type let a: int? = 10; assert_eq a!, 10; let a: int??? = 10; let b: int? = a; assert_eq b!, 10; let a: int? = 10; let b: int??? = a; assert_eq b!!!, 10; // Union type let a: int | string = "abc"; assert_eq a.(string), "abc"; // Interface let a: ToString = 10; assert_eq a.to_string(), "10";
-
Fix the
break
indo, catch
block can't break the outsideloop
bug.
-
Add
time.sleep
method.use std.time; // sleep 1 second time.sleep(1);
-
Improve
std.io.print
to support arbitrary argument.use std.io; io.println("hello", "world");
-
Update http Headers
apppend
,set
method, not allows nil value. -
Update http
set_basic_auth
theusername
not allows nil.
The pkg
is used to manage packages that many split out of Navi in the future.
-
Add sql module to support SQlite, MySQL, PostgreSQL, etc.
use sql.Connection; struct User { id: int, name: string, } const conn = try! Connection.connect("sqlite::memory:"); try! conn.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)"); try! conn.execute("INSERT INTO users (name) VALUES (?)", "Jason Lee"); let users = try! conn.query("SELECT * FROM users").scan::<User>();
-
Add markdown module to support markdown render to HTML.
use markdown; let html = markdown.to_html("# Hello, World!");
- Fix Navi LSP to better autocomplete and documentations support.
- Add cache support in Navi LSP for better performance.
- Add
format
support in Navi LSP. - fmt: insert a new line after std uses.
- fmt: sort outer-layer use { ... } statements
- New tree-sitter-navi, tree-sitter-navi-stream project for tree-sitter support.
- Add Zed extension support, current only syntax highlight support.
-
Add generic function supports.
-
Add the
enum
syntax.enum Color { Red, Green, Blue, } enum StatusCode { Ok = 200, BadRequest = 400, NotFound = 404, }
-
Add the
const
syntax to define a constant.const PI = 3.1415926;
-
Add the
pub
keyword to define a publicfn
,struct
,struct
field,const
,enum
..., now only thepub
members can be visited from other modules.pub const PI = 3.1415926; pub fn add(a: int, b: int): int { return a + b; } pub struct Loc { pub line: int, pub col: int, }
-
Improve compile error message, and write test case for it.
-
Allows to visit the
const
from other modules. -
Add
r\`raw string\`
syntax to better write Regex rules.use std.regex.Regex; // Before let re = Regex.new("\\d+"); // After let re = Regex.new(r`\d+`);
-
Improvement performance for internal calls, string, Object Ref.
-
Add to support use
_
in a number literal.let n = 1_234_567.89_012;
-
Add interface inheritance support, and support default implementation.
interface A { fn a(): int; } interface B: A { fn b(): int { return 2; } }
-
Improve assignment detect, now array, map can avoid declaring types, if the left side is a known type.
fn foo(items: [string]) {} fn bar(items: <string, int>) {} // Before foo([string] { "a", "b" }); bar(<string, int> { "a": 1, "b": 2 }); // After foo({ "a", "b" }); bar({ "a": 1, "b": 2 });
-
Improve Struct Field and Kw Arguments assignment, if the variable name is the same as the field name, we can use a short syntax.
struct User { name: string, city: string, } impl User { fn new(name: string = "", city: string = ""): User { return User { name: name, city: city, } } } let name = "foo"; let city = "bar"; // Before let user = User { name: name, city: city }; let user = User.new(name: name, city: city); // After let user = User { name, city }; let user = User.new(name:, city:);
-
Add Union Type support.
fn foo(n: int | string) { switch (let n = n.(type)) { case int { println("int: {}", n); } case string { println("string: {}", n); } } } // Also can return a union type fn bar(): int | string { return 1; }
-
Rewrite stdlib by Navi wrapper (internal is Rust Native), for better interface, and error support.
-
Add
std.io.{Read, Write, Close}
interface. -
Rewrite stdlib by using interface
io.Read
,io.Write
instead of[byte]
for support stream, mostly forstd.fs
andstd.net.http
.use std.net.http; use std.fs; let res = try http.get("https://navi-lang.org"); // Before body is a `[byte]` let body = res.body(); // After // Body is a std.io.Read interface /// https://navi-lang.org/stdlib/std.net.http#Response.body let body = res.body.read_to_string();
-
Add
std.net.http.Client
to create an HTTP client. -
Add
std.io.Cursor
for writing a[byte]
orstring
to supportstd.io.Read
interface. -
Add
json.from_reader
to support parse JSON from astd.io.Read
in stream. -
Fix
sort
array incorrect order bug in some cases. -
Add
std.xml
module to support parsing XML. -
Add
std.toml
module to support parsing TOML. -
Add
std.io.StringBuffer
for mutable string likestd.io.Buffer
.
- lsp: Add Go to define support for LSP, and support to visit Navi stdlib source code.
- lsp: Add Hover document for LSP.
- lsp: Add support newline to keep
///
comment in next line. - lsp: Add support a bit of Auto Complete support, still need to improve.
- fmt:
use
statement will be sorted by alphabet, and keepself
in the first. - test: Add
navi test --all-dirs
to test all sub-dir, and default test current dir. - test: Improve
assert
results and use""
to wrap them for a better read. - build: We use Navi to write our internal CI build and publish script now.
-
Add to support error handling, see Error doc.
fn main() throws { let file = try fs.open("file.txt"); // ... }
-
Add Static Method support, and rewrite all stdlib.
struct User {} impl User { fn new() -> User { // ... } }
-
The first argument on the Instance Method now must have a
self
parameter.struct User {} impl User { // Before fn to_string() { // ... } // After fn to_string(self) { // ... } }
-
Add new serialization support for
json
,yaml
module.use std.json; struct User { name: string ##[serde(rename = "_age")] age: int } let user = json.parse::<User>(`{"name":"Navi","_age":1}`); assert_eq user.name, "Navi"; let user = User { name: "Navi", age: 1 }; assert_eq json.to_string(user), `{"name":"Navi","_age":1}`;
- Add also support to deserialize to the
any
type.
let a = json.parse::<any>("1"); assert_eq a.(int), 1; let a = json.parse::<any>(`"hello"`); assert_eq a.(string), "hello";
- Add also support to deserialize to the
-
Add Raw String syntax:
r`this is string`
for better use for the regular expression.use std.regex.{Regex}; // Before let re = Regex.new("[\\w\\d]"); // After let re = Regex.new(r`[\w\d]`);
-
Improve the
use
syntax to supportas
and import multiple items.// Before use std.fs; use std.fs.File; // After use std.fs.{self, File as BaseFile, write};
-
Add
type
keyword to define Type Alias.type Key = string; type Value = int; type MyInfo = <Key, Value>; let info: MyInfo = { "foo": 1, "bar": 2, };
-
Improve syntax to assign an array, or map without type annotation, if the left side has a known type.
let a: [int] = {1, 2, 3}; let b: <string, int> = { "foo": 1, "bar": 2 }; struct Info { headers: <string, string> } let info: Info = { headers: { "Content-Type": "application/json" } };
- Rewrite all stdlib to use Static Method, Error Handling, and the new Serialization support.
- Removed
to_json
,to_yaml
method, usejson.to_string
,yaml.to_stirng
instead. - Add
File.open
,File.create
andfs.write
,fs.write_string
. - Add
replace_with
,replace_all_with
,captures
toregex.Regex
. - Rename
match
,match_all
tofind
andfind_all
forregex.Regex
to avoid keywords. - Add
utc
,to_offset
method totime.DateTime
. - Add
step
method toRange
type. - Add
bytes
method to Buffer. - Add
set_file
method tomultipart.Form
to support file upload, see Multipart doc. - Rename
to_int
,to_float
intoparse_int
,parse_float
for string.
- Publish Navi Learn, Navi Stdlib docs on the website.
- And now use Navi instead of TypeScript to write scripts for website docs generated.
- All stdlib docs have been generated by
navi doc --stdlib
command. - Add Navi Stream doc.
- Add Outline display support for LSP and VS Code extension.
- Add Inlay Hints support for LSP and VS Code extension.
- Add new syntax support for
navi fmt
. - Add
navi doc
command to generate documentation for Navi files. - Add
navi doc --stdlib
command to generate documentation for Navi's standard library. - Add
navi test --doc
command to test the Markdown code blocks in Navi files.
- Add
interface
support. - Add
navi fmt
to format code, and install the VS Code extension. - Add
loop
statement to loop forever. - Add getter, and setter to built-in type.
- Add dotenv support, now will auto load
.env
file in the current directory as environment variables. - Add
if let
statement. - Add
main
function, nownavi run
will run themain
function inmain.nv
file in default. - Add httpbin feature into
testharness
to speedup HTTP test.
- Add
resize
,truncate
,split_off
,chunks
method to array. - Add
weekday
tostd.time
. - Add
std.process
withexit
,abort
,pid
,exec
,run
,args
function. - Add
std.json
,std.yaml
,std.querystring
modules for JSON, YAML, QueryString parse, and stringify. - Add
std.value
module to common value type. - Add
basic_auth
method to HTTPRequest
. - Add
chunk
method to HTTPResponse
. - Add
multipart
,form
,timeout
tohttp.Request
. - Add
read
,read_string
tofs.File
, andread
,read_string
tofs
module. - Add
std.io.stdin
,std.io.stdout
,std.io.stderr
. - Add
join
tostd.url
. - Add
std.env.vars
to get all vars.
- Rewrite string interpolation from
{1 + 2}
to${1 + 2}
like JavaScript. - Kw Arguments now use
:
instead of=
, e.g.:fn(a: 1, b: 2)
, no longer allowed to be passed positionally. - Most struct get method in stdlib now is getter, e.g.:
host
instead ofhost()
forurl.URL
. - Rename
fs.read_string
tofs.read_to_string
. - Rename
io.from_bytes
toio.new_bytes_from_array
. - Move
cwd
,chdir
fromstd.path
tostd.env
.
Like Go, you can define an interface in the following way:
interface Readable {
fn read(): string
}
fn read(r: Readable): string {
return r.read()
}
struct File {
path: string
}
impl File {
fn read(): string {
return "read file"
}
}
struct Body {
content: string
}
impl Body {
fn read(): string {
return "read body"
}
}
fn main() {
file := File{path: "file"}
body := Body{content: "body"}
println(read(file))
println(read(body))
}
use std.io;
fn main() {
let name: string? = "Navi";
if let name = name {
io.println("name is ${name}")
} else {
io.println("name is nil");
}
}
- Add Optional Type and Optional Chaining.
- All Stdlib API will return an optional type if it can be nil, like Rust.
- Now all Object Types can't be nil, but you can use
?
to make it optional.
- Done with the Keywords Arguments support.
- Add
sub
forstd.time.DateTime
with return aDuration
. - Add
std.net.http
with HTTP request methods andHeaders
,Request
,Response
types. - Add
std.net.tcp_conn
,std.net.tcp_listener
,std.net.ip_addr
this is still in development. - Add
std.io.bytes
to the storage bytes array, movestd.buffer
tostd.io.buffer
and base onstd.io.bytes
.- Now all
bytes
methods will returnstd.io.Bytes
type. - Refactor Stdlib API,
std.io.bytes.new
tostd.io.new_bytes
,std.io.buffer.new
tostd.io.new_buffer
.
- Now all
Navi's optional type is similar to Rust's optional type, but it has some differences.
let a: int? = 1;
let b: int? = nil;
struct User {
name: string,
age: int?,
}
let use: User? = User {
name: "John",
age: 20,
};
assert_eq user?.name, "John";
assert_eq user?.age!, 20;
// unwrap
let user: User = user!;
assert_eq user.name, "John";
All optional argument values can be called with keywords argument syntax.
fn hello(name: string, city: string?, done: book?): string {
}
foo("Jason Lee", "Chengdu", true);
foo("Jason Lee", city = "Chengdu", done = true);
foo("Jason Lee", done = true, city = "Chengdu");
foo("Jason Lee", done = true);
- Improve test results to show the test file path.
- Move
std.path.glob
tostd.fs.glob
.
-
Add
closure
statement support.let sub = fn(a: int, b: int): int { return a - b; };
-
Improve the internal objects to map string interpolation call to
to_string
method. -
Fix to assign map element by key:
items["foo"] = 1
. -
Fix comparing object and nil.
- Add
bench
for write benchmark tests, andnavi bench
command. - Allows
navi test
to run all tests in the current folder. - Add
tests
andbenches
statements for wrapper test cases. - Add
assert_eq
,assert_ne
statements for tests. - Improve the test result, and only show diff when it has multiple lines/
- Add
std.time
andstd.time.DateTime
,std.time.Duration
. - Add
std.regex
andstd.regex.Match
, withmatch
,is_match
,replace
,replace_all
methods. - Add
std.crypto
withhash
,hmac
andmd5
,sha1
,sha256
,sha512
algorithms. - Add
std.buffer
. - Add
std.rand
withrand.int
,rand.float
,rand.bytes
methods. - Add module
std.base64
withencode
,decode
,urlsafe_encode
,urlsafe_decode
methods. - Add
std.url
andstd.url.URL
. - Add math functions to
int
andfloat
. - Add
std.path
withextension
,join
,base
,parent
, andexists
methods... - Add
std.fs
withopen
,create
,create_dir
,create_dir_all
,remove_file
,remove_dir
,remove_dir_all
,glob
methods, now we can read and write file. - Add
std.env
to read & write env variables. - Add
keys
,values
method tostd.collection.Map
. - Add
len
,bytes
,contains
,to_lowercase
,to_uppercase
,substring
,split
,replace
,starts_with
,ends_with
,trim
,repeat
,strip_prefix
,strip_suffix
... method tostring
. - Add
to_int
,to_float
tostring
. - Add
unique
,reverse
,sort
methods forarray
.