Code Monkey home page Code Monkey logo

tree-sitter-odin's Introduction

tree-sitter-odin's People

Contributors

amaanq avatar github-actions[bot] avatar laytan avatar player01osu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tree-sitter-odin's Issues

Weird highlighting of fields

Some fields are getting randomly highlighted. I say randomly because I couldn't make any sense of the pattern.

It seems to me that the cause for the bug is the way how I format my code. By putting the '{' on the same line as the procedure declaration the problem disappears,

Another way I've found that eliminates the problems is putting a semicolon at the end of the first line with a field highlighted with the white color, by doing that the following lines of the procedure would get fixed. Putting the semicolon at the end of line with a red highlighted field doesn`t do anything.

The code is from the Odin's Idiomatic Examples collection and it can be found here. All images presents valid Odin code.

Does not recognize closing quotes for strings in several scenarios

Lately I've noticed that most of my projects are having syntax highlighting issues with strings being highlighted as not closed despite having clear end markers. I didn't notice it being at all this bad until recently, which I think coincides with an upgrade (unexpected downgrade) of the nvim-treesitter plugin which bundles this repository as the Odin parser by default.

Some examples:

	testing.expect_value(t, s, "foo")
	testing.expect(
		t,
		slice.equal(remaining_arguments, expected_arguments),
		fmt.tprintf("Expected remaining arguments to equal %v, got: %v", remaining_arguments),
	)

	i: int
	expected_arguments = []string{}
	i, remaining_arguments, error = parse_arguments_as_type({"123"}, int, context.allocator)
	testing.expect_value(t, error, nil)
	testing.expect_value(t, i, 123)
	testing.expect(
		t,
		slice.equal(remaining_arguments, expected_arguments),
		fmt.tprintf("Expected remaining arguments to equal %v, got: %v", remaining_arguments),
	)

image

What actually seems to close the example above is yet another missed closing quote:

	ts: TestStruct
	expected_arguments = []string{"rest", "of", "arguments"}
	ts, remaining_arguments, error = parse_arguments_as_type(
		 {
			"-2",
			"123",
			"--field-one",
			"foo",
			"--no-tag",
			"123.456",
			"--field-three",
			"true",
			"rest",
			"of",
			"arguments",
		},
		TestStruct,
		context.allocator,
	)
	testing.expect_value(t, error, nil)
	testing.expect_value(
		t,
		ts,
		TestStruct{field_one = "foo", field_two = 123, field_three = true, no_tag = 123.456},
	)

image

@(test, private = "package")
test_parse_argument_as_type :: proc(t: ^testing.T) {
	context.logger = log.create_console_logger()

	tid: typeid

	tid = string
	bytes, error := parse_argument_as_type("foo", tid, context.allocator)
	s := mem.reinterpret_copy(string, raw_data(bytes))
	testing.expect_value(t, error, nil)
	testing.expect(t, s == "foo", fmt.tprintf("Expected 'foo', got '%s'", s))

	tid = int
	bytes, error = parse_argument_as_type("123", tid, context.allocator)
	i := mem.reinterpret_copy(int, raw_data(bytes))
	testing.expect_value(t, error, nil)
	testing.expect(t, i == 123, fmt.tprintf("Expected 123, got %d", i))

image

The above one goes on for several procedures and type definitions until we reach this:

@(test, private = "package")
test_struct_decoding_info :: proc(t: ^testing.T) {
	cli_info, allocator_error := struct_decoding_info(TestStruct)
	if allocator_error != nil {
		fmt.panicf("Allocator error: %s", allocator_error)
	}
	fields := []FieldCliInfo {
		 {
			name = "field_one",
			type = string,
			cli_short_name = "1",
			cli_long_name = "field-one",
			offset = 0,
			required = false,
			size = 16,
		},
		 {
			name = "field_two",
			type = int,
			cli_short_name = "2",
			cli_long_name = "field-two",
			offset = 16,
			required = true,
			size = 8,
		},
		 {
			name = "field_three",
			type = bool,
			cli_short_name = "",
			cli_long_name = "field-three",
			offset = 24,
			required = true,
			size = 1,
		},

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.