From 45d581c42dfb051c453a8793c060bb9572975827 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 03:53:08 -0300 Subject: [PATCH 1/9] add tests --- .github/workflows/pull-request.yml | 9 +- Makefile | 3 + test/syntax/highlight.res | 99 ++++++++++++++ test/syntax/highlight.res.txt | 210 +++++++++++++++++++++++++++++ test/test-syntax.lua | 47 +++++++ 5 files changed, 363 insertions(+), 5 deletions(-) create mode 100644 test/syntax/highlight.res create mode 100644 test/syntax/highlight.res.txt create mode 100644 test/test-syntax.lua diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index ee49f51..3b6e4e1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,11 +6,9 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - name: Install packages - run: | - sudo add-apt-repository ppa:neovim-ppa/stable - sudo apt update - sudo apt install neovim + - uses: rhysd/action-setup-vim@v1 + with: + neovim: true - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: @@ -22,3 +20,4 @@ jobs: nvim --version vim --version make test + make test-syntax diff --git a/Makefile b/Makefile index 34452e2..582e450 100644 --- a/Makefile +++ b/Makefile @@ -7,3 +7,6 @@ export INMAKE test: @$(MYVIM) -u ./test/test_all.vim + +test-syntax: + nvim -l test/test-syntax.lua diff --git a/test/syntax/highlight.res b/test/syntax/highlight.res new file mode 100644 index 0000000..817614b --- /dev/null +++ b/test/syntax/highlight.res @@ -0,0 +1,99 @@ +@@warning("-27") +//^ + +%%raw(`console.log("Hello")`) +//^ + +@deprecated +//^ +let _ = %raw(`1`) + +let a = 1 +//^ + +let _ = 1 + //^ + +let _ = true + //^ +let _ = false + //^ + +let _ = "hello!" + //^ +let _ = `Hello World 👋 ${name}` + //^ +let _ = 'a' + //^ + +let _ = j`Today` + //^ + +let _ = %re("/b/g") + //^ +let _ = true && true + //^ + +let _ = true || false + //^ + +let _ = !true + //^ + +let _ = 2 <= 3 + //^ + +let _ = 2 <= 3 + //^ + +type t +//^ + +type r + //^ + +type t = { + age: int + //^ +} + +let _ = {...me, age: me.age + 1} + //^ + +let _ = Some("My Name") + //^ + +let _ = #red + //^ + +let _ = if true { + //^ + "Good morning!" +} else { + //^ + "Hello!" +} + +for i in 1 to 10 { +//^ + Js.log(i) + //^ +} + +while true { +//^ + Js.log(true) +} + +exception InputClosed(string) +//^ + + +try { +//^ + someJSFunctionThatThrows() +} catch { + //^ +| Not_found => assert false + //^ +} diff --git a/test/syntax/highlight.res.txt b/test/syntax/highlight.res.txt new file mode 100644 index 0000000..68d9565 --- /dev/null +++ b/test/syntax/highlight.res.txt @@ -0,0 +1,210 @@ +{ { + col = 3, + line = 1, + syntax = {} + }, { + col = 3, + line = 4, + syntax = {} + }, { + col = 3, + line = 7, + syntax = { { + hl_group = "resAttribute", + hl_group_link = "PreProc" + } } + }, { + col = 3, + line = 11, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 9, + line = 14, + syntax = { { + hl_group = "resFloat", + hl_group_link = "Constant" + } } + }, { + col = 11, + line = 17, + syntax = { { + hl_group = "resBoolean", + hl_group_link = "Constant" + } } + }, { + col = 11, + line = 19, + syntax = { { + hl_group = "resBoolean", + hl_group_link = "Constant" + } } + }, { + col = 13, + line = 22, + syntax = { { + hl_group = "resString", + hl_group_link = "Constant" + } } + }, { + col = 21, + line = 24, + syntax = { { + hl_group = "resString", + hl_group_link = "Constant" + } } + }, { + col = 10, + line = 26, + syntax = { { + hl_group = "resChar", + hl_group_link = "Constant" + } } + }, { + col = 13, + line = 29, + syntax = { { + hl_group = "resString", + hl_group_link = "Constant" + } } + }, { + col = 10, + line = 32, + syntax = {} + }, { + col = 14, + line = 34, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 14, + line = 37, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 9, + line = 40, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 11, + line = 43, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 11, + line = 46, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 49, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 6, + line = 52, + syntax = {} + }, { + col = 9, + line = 56, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } + }, { + col = 13, + line = 60, + syntax = {} + }, { + col = 11, + line = 63, + syntax = { { + hl_group = "resModuleOrVariant", + hl_group_link = "Identifier" + } } + }, { + col = 11, + line = 66, + syntax = { { + hl_group = "resPolyVariant", + hl_group_link = "Identifier" + } } + }, { + col = 9, + line = 69, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 5, + line = 72, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 77, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 4, + line = 79, + syntax = { { + hl_group = "resModuleChain", + hl_group_link = "PreProc" + } } + }, { + col = 3, + line = 83, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 88, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 92, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 5, + line = 95, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 19, + line = 97, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + } } diff --git a/test/test-syntax.lua b/test/test-syntax.lua new file mode 100644 index 0000000..127a70b --- /dev/null +++ b/test/test-syntax.lua @@ -0,0 +1,47 @@ +local cwd = vim.fn.getcwd() +local dir = '/test/syntax/' + +local function main(file) + -- Load syntax file + local path = cwd .. dir .. file + vim.cmd.edit(path) + vim.cmd.source(cwd .. '/syntax/rescript.vim') + + local bufnr = vim.api.nvim_get_current_buf() + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, true) + + local pattern = '//^' + local locations = {} + + for number, line in ipairs(lines) do + local is_start_pattern = vim.startswith(vim.trim(line), pattern) + local is_valid = number - 1 > 0 + and not vim.startswith(vim.trim(lines[number - 1]), pattern) + + if is_start_pattern and is_valid then + local start_match, _ = string.find(line, pattern) + + local col = start_match - 1 + string.len(pattern) + + local loc = { line = number - 1, col = col } + + table.insert(locations, loc) + end + end + + for _, loc in ipairs(locations) do + local item = + vim.inspect_pos(bufnr, loc.line - 1, loc.col - 1, { syntax = true }) + loc.syntax = item.syntax + end + + local fd = vim.loop.fs_open(path .. '.txt', 'w', 438) + assert(vim.loop.fs_write(fd, vim.inspect(locations), 0)) + assert(vim.loop.fs_close(fd)) +end + +local files = { 'highlight.res' } + +for _, file in ipairs(files) do + main(file) +end From 9aed21700251a751f4bb5839c06765d2b25b4fd9 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 03:55:51 -0300 Subject: [PATCH 2/9] update ci --- .github/workflows/pull-request.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3b6e4e1..5ff9548 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,4 +20,5 @@ jobs: nvim --version vim --version make test - make test-syntax + - name: Test syntax + run: make test-syntax From ef08698f357883d0da5f616ae3a07d731c988c56 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 03:59:09 -0300 Subject: [PATCH 3/9] update ci --- Makefile | 1 + test/syntax/highlight.res.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 582e450..05d5cd1 100644 --- a/Makefile +++ b/Makefile @@ -10,3 +10,4 @@ test: test-syntax: nvim -l test/test-syntax.lua + git diff --name-only --exit-code -- 'test/syntax/*.res.txt' diff --git a/test/syntax/highlight.res.txt b/test/syntax/highlight.res.txt index 68d9565..e94c61c 100644 --- a/test/syntax/highlight.res.txt +++ b/test/syntax/highlight.res.txt @@ -207,4 +207,4 @@ hl_group = "resKeyword", hl_group_link = "Statement" } } - } } + } } \ No newline at end of file From 02633d1c8c8d6e982836252e05e5578c3eced0bc Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 04:15:55 -0300 Subject: [PATCH 4/9] update CONTRIBUTING.md --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8797070..1c36955 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,6 +5,7 @@ - Clone the repo - `npm install` dependencies - `make test` to run the tests +- `make test-syntax`, require Neovim >= 0.9.0 **Working within VIM** @@ -21,6 +22,20 @@ Plug ~/Projects/vim-rescript **Integration Specs:** For all the informal specs about editor integration & the ReScript platform, check out the [CONTRIBUTING](https://github.com/rescript-lang/rescript-vscode/blob/master/CONTRIBUTING.md) file of the rescript-vscode reference implementation. +### Syntax Tests + +Syntax tests require Neovim >= 0.9.0 + +#### Adding new tests + +- Create or edit a file at `test/syntax/` directory. +- Write some code and add a comment in the following format: `//^` below the code. The `^` indicates the capture location. Example: + ```rescript + let a = true + //^ + ``` +- Run `make test-syntax` + ### Use custom rescript-editor-support.exe > Note: Don't do this as a ReScript user. This is only intended for extension development purposes only. From 3088d954177144cc07b9ba280a2f28dccfb4e7a9 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 04:51:15 -0300 Subject: [PATCH 5/9] more tests --- test/syntax/highlight.res | 33 +++++++++ test/syntax/highlight.res.txt | 136 ++++++++++++++++++++++++++-------- 2 files changed, 140 insertions(+), 29 deletions(-) diff --git a/test/syntax/highlight.res b/test/syntax/highlight.res index 817614b..9f49f89 100644 --- a/test/syntax/highlight.res +++ b/test/syntax/highlight.res @@ -7,6 +7,7 @@ @deprecated //^ let _ = %raw(`1`) + //^ let a = 1 //^ @@ -57,6 +58,14 @@ type t = { //^ } +type t = { + a: promise + //^ +} + +let _ = list{1, 2} + //^ + let _ = {...me, age: me.age + 1} //^ @@ -97,3 +106,27 @@ try { | Not_found => assert false //^ } + +open Js.Array2 +//^ + +include Js +//^ + + +switch [1, 2, 3] { +//^ + | [] => true +//^ + | _ => false + //^ +} + +let list = 2 + //^ +let array = [1] + //^ +let catch = 1 + //^ +let ref = ref(false) + //^ diff --git a/test/syntax/highlight.res.txt b/test/syntax/highlight.res.txt index e94c61c..abd6e25 100644 --- a/test/syntax/highlight.res.txt +++ b/test/syntax/highlight.res.txt @@ -13,198 +13,276 @@ hl_group = "resAttribute", hl_group_link = "PreProc" } } + }, { + col = 11, + line = 9, + syntax = {} }, { col = 3, - line = 11, + line = 12, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 9, - line = 14, + line = 15, syntax = { { hl_group = "resFloat", hl_group_link = "Constant" } } }, { col = 11, - line = 17, + line = 18, syntax = { { hl_group = "resBoolean", hl_group_link = "Constant" } } }, { col = 11, - line = 19, + line = 20, syntax = { { hl_group = "resBoolean", hl_group_link = "Constant" } } }, { col = 13, - line = 22, + line = 23, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { col = 21, - line = 24, + line = 25, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { col = 10, - line = 26, + line = 27, syntax = { { hl_group = "resChar", hl_group_link = "Constant" } } }, { col = 13, - line = 29, + line = 30, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { col = 10, - line = 32, + line = 33, syntax = {} }, { col = 14, - line = 34, + line = 35, syntax = { { hl_group = "resOperator", hl_group_link = "Statement" } } }, { col = 14, - line = 37, + line = 38, syntax = { { hl_group = "resOperator", hl_group_link = "Statement" } } }, { col = 9, - line = 40, + line = 41, syntax = { { hl_group = "resOperator", hl_group_link = "Statement" } } }, { col = 11, - line = 43, + line = 44, syntax = { { hl_group = "resOperator", hl_group_link = "Statement" } } }, { col = 11, - line = 46, + line = 47, syntax = { { hl_group = "resOperator", hl_group_link = "Statement" } } }, { col = 3, - line = 49, + line = 50, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 6, - line = 52, + line = 53, syntax = {} }, { col = 9, - line = 56, + line = 57, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } + }, { + col = 9, + line = 62, + syntax = {} + }, { + col = 11, + line = 66, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { col = 13, - line = 60, + line = 69, syntax = {} }, { col = 11, - line = 63, + line = 72, syntax = { { hl_group = "resModuleOrVariant", hl_group_link = "Identifier" } } }, { col = 11, - line = 66, + line = 75, syntax = { { hl_group = "resPolyVariant", hl_group_link = "Identifier" } } }, { col = 9, - line = 69, + line = 78, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 5, - line = 72, + line = 81, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 3, - line = 77, + line = 86, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 4, - line = 79, + line = 88, syntax = { { hl_group = "resModuleChain", hl_group_link = "PreProc" } } }, { col = 3, - line = 83, + line = 92, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 3, - line = 88, + line = 97, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 3, - line = 92, + line = 101, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 5, - line = 95, + line = 104, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { col = 19, - line = 97, + line = 106, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 110, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } + }, { + col = 3, + line = 113, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 117, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 3, + line = 119, + syntax = { { + hl_group = "resOperator", + hl_group_link = "Statement" + } } + }, { + col = 7, + line = 121, + syntax = { { + hl_group = "resArrowPipe", + hl_group_link = "Statement" + } } + }, { + col = 7, + line = 125, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } + }, { + col = 7, + line = 127, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } + }, { + col = 7, + line = 129, + syntax = { { + hl_group = "resKeyword", + hl_group_link = "Statement" + } } + }, { + col = 6, + line = 131, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } } } \ No newline at end of file From 31871b55ac5874c45b3edb645b466bf3f62cdb9d Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 5 May 2023 04:53:40 -0300 Subject: [PATCH 6/9] more tests --- test/syntax/highlight.res | 2 ++ test/syntax/highlight.res.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/test/syntax/highlight.res b/test/syntax/highlight.res index 9f49f89..6bd1e5a 100644 --- a/test/syntax/highlight.res +++ b/test/syntax/highlight.res @@ -130,3 +130,5 @@ let catch = 1 //^ let ref = ref(false) //^ +let option = None + //^ diff --git a/test/syntax/highlight.res.txt b/test/syntax/highlight.res.txt index abd6e25..da36a85 100644 --- a/test/syntax/highlight.res.txt +++ b/test/syntax/highlight.res.txt @@ -285,4 +285,11 @@ hl_group = "resType", hl_group_link = "Type" } } + }, { + col = 7, + line = 133, + syntax = { { + hl_group = "resType", + hl_group_link = "Type" + } } } } \ No newline at end of file From 7fa71d9d326d1deba2676466765f5abd63b7d397 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 9 Nov 2023 19:55:04 -0300 Subject: [PATCH 7/9] update --- .github/workflows/pull-request.yml | 8 +- Makefile | 2 +- test/syntax/{ => expected}/highlight.res.txt | 230 +++++++++---------- test/test-syntax.lua | 28 +-- 4 files changed, 124 insertions(+), 144 deletions(-) rename test/syntax/{ => expected}/highlight.res.txt (66%) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5ff9548..c345b81 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,9 +6,11 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: rhysd/action-setup-vim@v1 - with: - neovim: true + - name: Install packages + run: | + sudo add-apt-repository ppa:neovim-ppa/stable + sudo apt update + sudo apt install neovim - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: diff --git a/Makefile b/Makefile index 05d5cd1..43a01e0 100644 --- a/Makefile +++ b/Makefile @@ -10,4 +10,4 @@ test: test-syntax: nvim -l test/test-syntax.lua - git diff --name-only --exit-code -- 'test/syntax/*.res.txt' + git diff --name-only --exit-code -- 'test/syntax/expected/*.res.txt' diff --git a/test/syntax/highlight.res.txt b/test/syntax/expected/highlight.res.txt similarity index 66% rename from test/syntax/highlight.res.txt rename to test/syntax/expected/highlight.res.txt index da36a85..3446a6e 100644 --- a/test/syntax/highlight.res.txt +++ b/test/syntax/expected/highlight.res.txt @@ -1,293 +1,269 @@ { { - col = 3, - line = 1, - syntax = {} + col = 1, + row = 0, + syntax = { { + hl_group = "resArrowPipe", + hl_group_link = "Statement" + } } }, { - col = 3, - line = 4, + col = 1, + row = 3, syntax = {} }, { - col = 3, - line = 7, + col = 1, + row = 6, syntax = { { hl_group = "resAttribute", hl_group_link = "PreProc" } } }, { - col = 11, - line = 9, + col = 9, + row = 8, syntax = {} }, { - col = 3, - line = 12, + col = 1, + row = 11, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 9, - line = 15, - syntax = { { - hl_group = "resFloat", - hl_group_link = "Constant" - } } + col = 7, + row = 14, + syntax = {} }, { - col = 11, - line = 18, + col = 9, + row = 17, syntax = { { hl_group = "resBoolean", hl_group_link = "Constant" } } }, { - col = 11, - line = 20, + col = 9, + row = 19, syntax = { { hl_group = "resBoolean", hl_group_link = "Constant" } } }, { - col = 13, - line = 23, + col = 11, + row = 22, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { - col = 21, - line = 25, + col = 19, + row = 24, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { - col = 10, - line = 27, + col = 8, + row = 26, syntax = { { hl_group = "resChar", hl_group_link = "Constant" } } }, { - col = 13, - line = 30, + col = 11, + row = 29, syntax = { { hl_group = "resString", hl_group_link = "Constant" } } }, { - col = 10, - line = 33, + col = 8, + row = 32, syntax = {} }, { - col = 14, - line = 35, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 12, + row = 34, + syntax = {} }, { - col = 14, - line = 38, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 12, + row = 37, + syntax = {} }, { - col = 9, - line = 41, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 7, + row = 40, + syntax = {} }, { - col = 11, - line = 44, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 9, + row = 43, + syntax = {} }, { - col = 11, - line = 47, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 9, + row = 46, + syntax = {} }, { - col = 3, - line = 50, + col = 1, + row = 49, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 6, - line = 53, + col = 4, + row = 52, syntax = {} }, { - col = 9, - line = 57, + col = 7, + row = 56, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { - col = 9, - line = 62, + col = 7, + row = 61, syntax = {} }, { - col = 11, - line = 66, + col = 9, + row = 65, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { - col = 13, - line = 69, + col = 11, + row = 68, syntax = {} }, { - col = 11, - line = 72, + col = 9, + row = 71, syntax = { { hl_group = "resModuleOrVariant", hl_group_link = "Identifier" } } }, { - col = 11, - line = 75, + col = 9, + row = 74, syntax = { { hl_group = "resPolyVariant", hl_group_link = "Identifier" } } }, { - col = 9, - line = 78, - syntax = { { - hl_group = "resKeyword", - hl_group_link = "Statement" - } } + col = 7, + row = 77, + syntax = {} }, { - col = 5, - line = 81, + col = 3, + row = 80, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 86, + col = 1, + row = 85, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 4, - line = 88, + col = 2, + row = 87, syntax = { { hl_group = "resModuleChain", hl_group_link = "PreProc" } } }, { - col = 3, - line = 92, + col = 1, + row = 91, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 97, + col = 1, + row = 96, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 101, + col = 1, + row = 100, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 5, - line = 104, + col = 3, + row = 103, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 19, - line = 106, + col = 17, + row = 105, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 110, + col = 1, + row = 109, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 113, + col = 1, + row = 112, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 117, + col = 1, + row = 116, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 3, - line = 119, - syntax = { { - hl_group = "resOperator", - hl_group_link = "Statement" - } } + col = 1, + row = 118, + syntax = {} }, { - col = 7, - line = 121, - syntax = { { - hl_group = "resArrowPipe", - hl_group_link = "Statement" - } } + col = 5, + row = 120, + syntax = {} }, { - col = 7, - line = 125, + col = 5, + row = 124, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { - col = 7, - line = 127, + col = 5, + row = 126, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { - col = 7, - line = 129, + col = 5, + row = 128, syntax = { { hl_group = "resKeyword", hl_group_link = "Statement" } } }, { - col = 6, - line = 131, + col = 4, + row = 130, syntax = { { hl_group = "resType", hl_group_link = "Type" } } }, { - col = 7, - line = 133, + col = 5, + row = 132, syntax = { { hl_group = "resType", hl_group_link = "Type" diff --git a/test/test-syntax.lua b/test/test-syntax.lua index 127a70b..269a6c0 100644 --- a/test/test-syntax.lua +++ b/test/test-syntax.lua @@ -1,9 +1,13 @@ local cwd = vim.fn.getcwd() local dir = '/test/syntax/' +local expected_dir = '/test/syntax/expected' + +local FILES = { 'highlight.res' } local function main(file) -- Load syntax file local path = cwd .. dir .. file + vim.cmd.edit(path) vim.cmd.source(cwd .. '/syntax/rescript.vim') @@ -23,25 +27,23 @@ local function main(file) local col = start_match - 1 + string.len(pattern) - local loc = { line = number - 1, col = col } + local item = + vim.inspect_pos(bufnr, number - 2, col - 2, { syntax = true }) - table.insert(locations, loc) + table.insert( + locations, + { row = item.row, col = item.col, syntax = item.syntax } + ) end end - for _, loc in ipairs(locations) do - local item = - vim.inspect_pos(bufnr, loc.line - 1, loc.col - 1, { syntax = true }) - loc.syntax = item.syntax - end + local output_file = cwd .. expected_dir .. '/' .. file .. '.txt' - local fd = vim.loop.fs_open(path .. '.txt', 'w', 438) - assert(vim.loop.fs_write(fd, vim.inspect(locations), 0)) - assert(vim.loop.fs_close(fd)) + local fd = vim.loop.fs_open(output_file, 'w', 438) + vim.loop.fs_write(fd, vim.inspect(locations), 0) + vim.loop.fs_close(fd) end -local files = { 'highlight.res' } - -for _, file in ipairs(files) do +for _, file in ipairs(FILES) do main(file) end From 25f63b7891f6b343af71c71bb33f4fe1068cd2e2 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 9 Nov 2023 19:59:06 -0300 Subject: [PATCH 8/9] rm ppa repo --- .github/workflows/pull-request.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c345b81..e2116d6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,7 +8,6 @@ jobs: steps: - name: Install packages run: | - sudo add-apt-repository ppa:neovim-ppa/stable sudo apt update sudo apt install neovim - uses: actions/checkout@v1 From 193dcc7a03c721b73449edc6216dbf0842164e80 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 9 Nov 2023 20:01:34 -0300 Subject: [PATCH 9/9] use action-setup-vim --- .github/workflows/pull-request.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e2116d6..5ff9548 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,10 +6,9 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - name: Install packages - run: | - sudo apt update - sudo apt install neovim + - uses: rhysd/action-setup-vim@v1 + with: + neovim: true - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: