Giter VIP home page Giter VIP logo

tree-sitter-viml's Introduction

This project is not maintained anymore, see the official nvim fork

Tree-sitter VimL parser

A parser for VimL using treesitter.

Any contribution is greatly appreciated, so please look here for more information. Don't forget that reporting and issue is already a contribution, and will greatly help, so please do report issues!

tree-sitter-viml's People

Contributors

akmadan23 avatar bk1603 avatar dundargoc avatar fymyte avatar jchros avatar monaqa avatar observeroftime avatar reegnz avatar stsewd avatar vigoux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tree-sitter-viml's Issues

String literal argument for "syntax match" command is parsed as comment

how it looks:
image

codesnippet + tree:

syn match MatchGroup "this should be a string literal" skipwhite
command [0, 0] - [1, 0]                 | syn
  command_name [0, 0] - [0, 3]          | match MatchGroup1
  arguments [0, 4] - [0, 20]
    command_argument [0, 4] - [0, 9]
    command_argument [0, 10] - [0, 20]
  comment [0, 21] - [0, 64]             | "this should be a string literal" skipwhite

found this bug while looking at the tags.vim syntax file

Add support for optional function arguments

VimL has optional function arguments, but the current grammar doesn't seem to support it.

See :h optional-function-argument for details.

tl;dr:

  function Something(key, value = 10)
     echo a:key .. ": " .. a:value
  endfunction
  call Something('empty')	"empty: 10"
  call Something('key', 20)	"key: 20"

Parse error for inline "if | map [...] | endif" statement

if a | nnoremap b c | endif

parses to

ERROR [1, 0] - [2, 0]
  identifier [1, 3] - [1, 4]
  map_statement [1, 7] - [2, 0]
    lhs: map_side [1, 16] - [1, 17]
    rhs: map_side [1, 17] - [1, 27]

This works fine:

if a | nnoremap b c
endif

=>

if_statement [1, 0] - [3, 0]
  condition: identifier [1, 3] - [1, 4]
  body [1, 7] - [2, 0]
    map_statement [1, 7] - [2, 0]
      lhs: map_side [1, 16] - [1, 17]
      rhs: map_side [1, 17] - [1, 19]

Sorry, made the issue then tested more things.

Seems to be an issue with mapping, it doesn't happen with, for example, echo.

Syntax highlighting not done for else and endif

Describe the bug

Syntax highlighter does not highlight else and endif in some cases.

To Reproduce

Steps to reproduce the behavior:

  1. Make a viml file: test-vim.vim
  2. Type following
" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe'  " default location
if has('unix') && !has('nvim') && executable(s:clip) && has('patch8.0.1394')
    augroup WSLYank
        autocmd!
        autocmd TextYankPost * call system('echo '.shellescape(join(v:event.regcontents, "\<CR>")).' | '.s:clip)
    augroup END
    noremap "+p :exe 'norm a'.system('/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command Get-Clipboard')<CR>
endif

" C Compile settings. F5 to compile with GCC and F8 to execute
let compile_cmdline='gcc % -g -Wall -Wextra -pedantic -o %<'
if has('nvim')
    nnoremap <F5> :w! <BAR> execute 'terminal '.compile_cmdline<CR>
else
    nnoremap <F5> :w! <BAR> execute '!'.compile_cmdline<CR>
endif
if !has("unix")
    if has('nvim')
        noremap <F8> :terminal %<<Enter>
    else
        noremap <F8> :!%<<Enter>
    endif
elseif has("unix")
    if has('nvim')
        noremap <F8> :terminal ./%<<Enter>
    else
        noremap <F8> :!./%<<Enter>
    endif
endif

" loop through subdirectory and source .vim files
" https://johngrib.github.io/wiki/vim-configure-split/
for include_file in uniq(sort(globpath(&rtp, 'vim-include/*.vim', 0, 1)))
    execute "source " . include_file
endfor
  1. Some else, endif statements are not highlighted

See lines 97, 103, 105, 109, 115 in this screenshot
화면 캡처 2021-08-23 133900

Expected behavior

All else and endif statements should be highlighted.

Parsing hangs for files that don't end in `EOL`, but `EOF`

Looks like the parser depends on lines ending in \n (EOL), but sometimes, like in injections, the EOL isn't present, but the EOF always is. To reproduce

$ echo -n 'a b " c' > test.vim
$ npm run parse -- test.vim
# hangs!

Adding the EOL works

$ echo 'a b " c' > test.vim
$ npm run parse -- test.vim

(script_file [0, 0] - [1, 0]
  (autocmd_statement [0, 0] - [0, 1])
  (command [0, 2] - [1, 0]
    (command_name [0, 2] - [0, 3])
    (comment [0, 4] - [0, 7])))

lua statement with endmarker cannot be parsed correctly

Describe the bug

On a buffer of vim file type, lua statement with endmarker(e.g. <<EOF) is parsed wrongly.

To Reproduce

  1. Open a new buffer in nvim, set filetype to vim.

  2. Write a lua statement on the buffer, for example:

    lua << EOF
    local test
    EOF
  3. Running :TSPlaygroundToggle output:

    lua_statement [0, 0] - [2, 3]
      script [0, 7] - [2, 3]
        ERROR [0, 7] - [0, 10]
          identifier [0, 7] - [0, 10]
        local_declaration: variable_declaration [1, 0] - [1, 10]
          variable_list [1, 6] - [1, 10]
            name: identifier [1, 6] - [1, 10]
        ERROR [2, 0] - [2, 3]
          identifier [2, 0] - [2, 3]
        chunk [1, 0] - [1, 10]
    

Expected behavior

No syntax errors in the parsing tree.

Invalid position of comment node after `user_command` when next line starts with a whitespace

I've noticed some of comments in my vimrc where I subscribe to plugins via vim-plug are not highlighted. I managed to find a minimal scenario where the problem is apparent.

Consider the listing below. If 2nd line starts with a whitespace (empty line is fine) then the comment in the 1st line will not be detected.

Plug 'x/y' "this wont appear as a comment node
 "if this line starts with a space

Above listing will result in this tree:

user_command [0, 0] - [0, 10]
  command_name [0, 0] - [0, 4]
  arguments [0, 5] - [0, 10]
    command_argument [0, 5] - [0, 10]
      string_literal [0, 5] - [0, 10]
comment [1, 1] - [1, 1]
comment [1, 1] - [1, 34]

As you can see there is 0-length node for comment (comment [1, 1] - [1, 1]) and its on wrong line. Instead a correct node in this scenario should be: comment [0, 11] - [0, 46].

Screenshot:

image

Does not support `curly-braces-names`

let foo_{bar}_baz = "text"

results in the following parse (in playground)

ERROR [0, 0] - [0, 9]
  "let" [0, 0] - [0, 3]
  ERROR [0, 4] - [0, 8]
    identifier [0, 4] - [0, 8]
  "{" [0, 8] - [0, 9]
ERROR [0, 9] - [0, 21]
  identifier [0, 9] - [0, 12]
  "}" [0, 12] - [0, 13]
  identifier [0, 13] - [0, 17]
  "=" [0, 18] - [0, 19]
  ERROR [0, 20] - [0, 21]
comment [0, 21] - [0, 28]
  "text" [0, 21] - [0, 27]
  "text" [0, 27] - [0, 28]

Error when trying to install

I tried to install it like here

what I did exactly:
git clone https://github.com/vigoux/tree-sitter-viml.git
cd tree-sitter-viml
tree-sitter generate
Then I added this to my init.vim:

local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.vim = {
  install_info = {
    url = "~/tree-sitter-viml", -- local path or git repo
    files = {"src/parser.c"}
  },
}
EOF

when I run:
:TSInstall vim

I get this:
Screen Shot 2021-07-02 at 17 27 42

(my first issue, so please write when I should send more info)

The :let-heredoc feature isn't supported

Using the example from help:

let var1 =<< END
Sample text 1
    Sample text 2
Sample text 3
END

let data =<< trim DATA
	1 2 3 4
	5 6 7 8
DATA

Possible output syntax tree

(let_statement
  (identifier)
  (heredoc
    (heredoc_endmarker)
    (heredoc_body)
    (heredoc_endmarker)))

(let_statement
  (identifier)
  (heredoc
    (heredoc_options)
    (heredoc_endmarker)
    (heredoc_body)
    (heredoc_endmarker)))

Or as an output of tree-sitter's playground:

let_statement [0, 0] - [4, 3]
  identifier [0, 4] - [0, 8]
  heredoc [0, 13] - [4, 3]
    heredoc_endmarker [0, 13] - [0, 16]
    heredoc_body [1, 0] - [3, 13]
    heredoc_endmarker [4, 0] - [4, 3]
let_statement [6, 0] - [9, 4]
  identifier [6, 4] - [6, 8]
  heredoc_options [6, 13] - [6, 17]
  heredoc_endmarker [6, 18] - [6, 22]
  heredoc_body [7, 0] - [8, 8]
  heredoc_endmarker [9, 0] - [9, 4]

Current output syntax tree

let_statement [0, 0] - [0, 3]
ERROR [0, 4] - [0, 16]
  identifier [0, 4] - [0, 8]
  keyword [0, 13] - [0, 16]
user_command [1, 0] - [1, 13]
  command_name [1, 0] - [1, 6]
  arguments [1, 7] - [1, 13]
    command_argument [1, 7] - [1, 11]
    command_argument [1, 12] - [1, 13]
user_command [2, 4] - [2, 17]
  command_name [2, 4] - [2, 10]
  arguments [2, 11] - [2, 17]
    command_argument [2, 11] - [2, 15]
    command_argument [2, 16] - [2, 17]
user_command [3, 0] - [3, 13]
  command_name [3, 0] - [3, 6]
  arguments [3, 7] - [3, 13]
    command_argument [3, 7] - [3, 11]
    command_argument [3, 12] - [3, 13]
user_command [4, 0] - [4, 3]
  command_name [4, 0] - [4, 3]
let_statement [6, 0] - [6, 3]
ERROR [6, 4] - [8, 8]
  identifier [6, 4] - [6, 8]
  keyword [6, 13] - [6, 17]
  keyword [6, 18] - [6, 22]
user_command [9, 0] - [9, 4]
  command_name [9, 0] - [9, 4]

Highlighting seems broken

It looks like the syntax highlighting in some parts of the file got messed up. Changing the color scheme doesn't fix it, and I've no idea if this was caused by an update or another plugin. Here are some examples:

image
image
image

I'm running the release Neovim version 0.6.0-1 on Linux.

Syntax highlighting does not work for multiline strings

Hi, not sure if this is a bug(since vimL allows multiline \ even outside strings)
But it highlighting does not seem to work for multiline strings correctly:

let var = '
\ long multiline string
\ "with nested quotes" '

1633883877

Normal command is not parsed correctly

As stated in the docs :

This command cannot be followed by another command, since any '|' is considered part of the command.

In the current implementation, normal f| foo will not be parsed correctly.

Perser error on mapping `<`

vnoremap < <gv
vnoremap > >gv
map_statement [120, 0] - [122, 0]
  ERROR [120, 9] - [120, 10]
  lhs: map_side [120, 11] - [120, 14]
  rhs: map_side [121, 0] - [121, 14]

Inject regex grammar

Would be nice if this grammar would inject the regex grammar in instances like:

function CheckRegexp()
  let l:count = 0
  g/^[^$,\"]/let l:count +=1
endfunction

such that ^[^$,\"] would parse up with the regex grammar.

Currently, it is monolithically a "pattern" node, with no embedded nodes.
Screen Shot 2022-04-17 at 17 26 47

Invalid parsing on `signcolumn=no`

set signcolumn=no
set spell
set_statement [181, 0] - [183, 0]
  set_item [181, 4] - [181, 15]
    option: option_name [181, 4] - [181, 14]
  set_item [181, 15] - [182, 3]
    option: no_option [181, 15] - [182, 3]
      option_name [182, 0] - [182, 3]
  set_item [182, 4] - [182, 9]
    option: option_name [182, 4] - [182, 9]

note: this works as expected:

set signcolumn=yes
set spell
set_statement [183, 0] - [184, 0]
  set_item [183, 4] - [183, 18]
    option: option_name [183, 4] - [183, 14]
    value: set_value [183, 15] - [183, 18]
set_statement [184, 0] - [185, 0]
  set_item [184, 4] - [184, 9]
    option: option_name [184, 4] - [184, 9]

error on `set foldexpr`

set foldexpr=nvim_treesitter#foldexpr()
set_statement [26, 0] - [27, 0]
  set_item [26, 4] - [26, 39]
    option: option_name [26, 4] - [26, 12]
    value: set_value [26, 13] - [26, 39]
      ERROR [26, 13] - [26, 39]
        identifier [26, 13] - [26, 37]

Note: other values mentioned in :h fold-expr examples also produce errors

Parsing error: `noremap` with `<cmd>`

The following (valid) mappings are not parsed correctly:

  • noremap cc :cnext:
ERROR [0, 0] - [0, 17]
  map_side [0, 8] - [0, 10]
  keyword [0, 12] - [0, 17]
  • noremap cc <cmd>cnext:
ERROR [0, 0] - [0, 21]
  map_side [0, 8] - [0, 10]
  keycode [0, 11] - [0, 16]
  keyword [0, 16] - [0, 21]

error on `hilight link`

hi link LspReferenceText CursorLine
ERROR [178, 0] - [178, 7]
  hl_group [178, 3] - [178, 7]
command [178, 8] - [179, 0]
  command_name [178, 8] - [178, 24]
  arguments [178, 25] - [178, 35]
    command_argument [178, 25] - [178, 35]

No highlighting for special keys in keybindings

Keys such as <leader>, <C-m> and <CR> aren't highlighted while setting keybindings, such as in:

" set leader key
let mapleader = ','

" telescope keybindings
nnoremap <leader>ff 	<cmd>Telescope find_files<cr>
nnoremap <leader>fg 	<cmd>Telescope live_grep<cr>
nnoremap <leader>fb 	<cmd>Telescope buffers<cr>
nnoremap <leader>fd 	<cmd>Telescope file_browser<cr>

" switch between buffers quickly
nnoremap <C-N> :bn<cr>
nnoremap <C-P> :bp<cr>

" zenmode and twilight toggles
nnoremap <leader>zm 	<cmd>ZenMode<cr>
nnoremap <leader>tw 	<cmd>Twilight<cr>

" nvim-tree keybindings
nnoremap <leader>nt	<cmd>NvimTreeToggle<cr>

These are highlighted with treesitter disabled.

[Bug Report] Some commands are broken

Problem Summary

  • t_.. options are not recognized
  • autocmd command with [group] is broken
  • setfiletype, scriptencoding, vimgrep command are not recognized

To Reproduce

Please use this scripts:

" highlight correctly
set termguicolors
" highlight broken
if !has('nvim')
  set t_Co=256
  let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
  let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
endif

" highlight correctly
augroup vimrc
  autocmd!
  autocmd VimEnter *
        \ : if some#condition() == v:true
        \ |   echo 'vim started!'
        \ | endif
augroup END
" highlight broken
autocmd vimrc ColorScheme *
      \ echo 'ColorScheme is changed!'

" highlight broken
setfiletype foo
scriptencoding utf-8
vimgrep 'bar' **/*.txt
playground queries
comment [1, 0] - [1, 21]
set_statement [2, 0] - [2, 17]
  set_item [2, 4] - [2, 17]
    option: option_name [2, 4] - [2, 17]
comment [3, 0] - [3, 18]
if_statement [4, 0] - [8, 5]
  condition: unary_operation [4, 3] - [4, 15]
    call_expression [4, 4] - [4, 15]
      function: identifier [4, 4] - [4, 7]
      string_literal [4, 8] - [4, 14]
  body [5, 2] - [8, 0]
    set_statement [5, 2] - [5, 7]
      set_item [5, 6] - [5, 7]
        option: option_name [5, 6] - [5, 7]
    ERROR [5, 7] - [5, 14]
      identifier [5, 7] - [5, 10]
    ERROR [6, 2] - [6, 40]
      option [6, 6] - [6, 8]
        option_name [6, 7] - [6, 8]
      keyword [6, 17] - [6, 20]
      keyword [6, 28] - [6, 30]
      keyword [6, 32] - [6, 34]
      keyword [6, 36] - [6, 39]
    ERROR [7, 2] - [7, 40]
      option [7, 6] - [7, 8]
        option_name [7, 7] - [7, 8]
      keyword [7, 17] - [7, 20]
      keyword [7, 28] - [7, 30]
      keyword [7, 32] - [7, 34]
      keyword [7, 36] - [7, 39]
comment [10, 0] - [10, 21]
augroup_statement [11, 0] - [11, 13]
  augroup_name [11, 8] - [11, 13]
autocmd_statement [12, 2] - [12, 10]
  bang [12, 9] - [12, 10]
autocmd_statement [13, 2] - [16, 17]
  au_event_list [13, 10] - [13, 18]
    au_event [13, 10] - [13, 18]
  pattern [13, 19] - [13, 20]
  command: if_statement [14, 12] - [16, 17]
    condition: binary_operation [14, 15] - [14, 41]
      left: call_expression [14, 15] - [14, 31]
        function: identifier [14, 15] - [14, 29]
      right: scoped_identifier [14, 35] - [14, 41]
        scope [14, 35] - [14, 37]
        identifier [14, 37] - [14, 41]
    body [15, 14] - [16, 11]
      echo_statement [15, 14] - [15, 33]
        string_literal [15, 19] - [15, 33]
augroup_statement [17, 0] - [17, 11]
  augroup_name [17, 8] - [17, 11]
comment [18, 0] - [18, 18]
autocmd_statement [19, 0] - [19, 7]
ERROR [19, 8] - [20, 38]
  option_name [19, 8] - [19, 13]
  keyword [19, 14] - [19, 25]
  keyword [20, 8] - [20, 12]
  keyword [20, 14] - [20, 25]
  keyword [20, 26] - [20, 28]
  keyword [20, 29] - [20, 36]
comment [22, 0] - [22, 18]
ERROR [23, 0] - [23, 15]
  keyword [23, 0] - [23, 11]
  keyword [23, 12] - [23, 15]
ERROR [24, 0] - [24, 20]
  keyword [24, 0] - [24, 14]
  keyword [24, 15] - [24, 18]
ERROR [25, 0] - [25, 22]
  keyword [25, 0] - [25, 7]
  keyword [25, 9] - [25, 12]
  keyword [25, 19] - [25, 22]

No highlighting with modifiers without spaces in maps

Hi!

This looks simple to improve, when there are multiple modifiers in the map (such as <script>, <expr>, etc) them are not highlighted.
When there is one, all ok.
I put here an example to illustrate it:

nmap <silent> <M-CR> doSomething() " highlighted
nmap <silent><expr> <M-CR> doSomething() " not highlighted

Thanks, and nice work with the tree-sitter plugin!

Error with colon between range and command

According to the documentation (hidden and not in the doc of :range)

A colon is allowed between the range and the command name.  It is ignored
(this is Vi compatible).  For example: >
	:1,$:s/pat/string

This comment is in :h :bar, line 630 of the cmdline.txt help page

Many commands break highlight

  1. colorscheme

image

  1. autocmd VimResized * wincmd =

image

  1. xnoremap < <gv

image

  1. runtime macros/matchit.vim

image

  1. command!

image

Thank you very much.

fold markers are ERROR

func Foo() "{{{
  echo 'foo'
endf "}}}

playground:

function_definition [0, 0] - [2, 4]
  function_declaration [0, 5] - [0, 10]
    name: identifier [0, 5] - [0, 8]
    parameters: parameters [0, 8] - [0, 10]
  ERROR [0, 11] - [0, 15]
  body [1, 2] - [2, 0]
    echo_statement [1, 2] - [1, 12]
      string_literal [1, 7] - [1, 12]
comment [2, 5] - [2, 9]

`end` keywords will be difficult to query

The current implementation is fragile (relies on the grammar itself) and creates a bunch of terminals for end keywords.

A better solution would be to use the scanner, and emit correct tokens.

`sign` not supported

sign define DiagnosticSignError text=✖ texthl=DiagnosticSignError linehl= numhl=
sign define DiagnosticSignWarn text=⚠ texthl=DiagnosticSignWarn linehl= numhl=
sign define DiagnosticSignInfo text=ℹ texthl=DiagnosticSignInfo linehl= numhl=
sign define DiagnosticSignHint text=💡 texthl=DiagnosticSignHint linehl= numhl=
ERROR [254, 0] - [257, 81]
  identifier [254, 0] - [254, 4]
  identifier [254, 5] - [254, 11]
  identifier [254, 12] - [254, 31]
  identifier [254, 32] - [254, 36]
  ERROR [254, 37] - [254, 40]
  identifier [254, 41] - [254, 47]
  identifier [254, 48] - [254, 67]
  identifier [254, 68] - [254, 74]
  identifier [254, 76] - [254, 81]
  identifier [255, 0] - [255, 4]
  identifier [255, 5] - [255, 11]
  identifier [255, 12] - [255, 30]
  identifier [255, 31] - [255, 35]
  ERROR [255, 36] - [255, 39]
  identifier [255, 40] - [255, 46]
  identifier [255, 47] - [255, 65]
  identifier [255, 66] - [255, 72]
  identifier [255, 74] - [255, 79]
  identifier [256, 0] - [256, 4]
  identifier [256, 5] - [256, 11]
  identifier [256, 12] - [256, 30]
  identifier [256, 31] - [256, 35]
  ERROR [256, 36] - [256, 39]
  identifier [256, 40] - [256, 46]
  identifier [256, 47] - [256, 65]
  identifier [256, 66] - [256, 72]
  identifier [256, 74] - [256, 79]
  identifier [257, 0] - [257, 4]
  identifier [257, 5] - [257, 11]
  identifier [257, 12] - [257, 30]
  identifier [257, 31] - [257, 35]
  ERROR [257, 36] - [257, 40]
  identifier [257, 41] - [257, 47]
  identifier [257, 48] - [257, 66]
  identifier [257, 67] - [257, 73]
  identifier [257, 75] - [257, 80]

How To Install This

How to I install this in nvim. Or is it recommended not to do so? If so, why?

Parser error in valid map with bar in cmd: \|

The map is:

nnoremap a :echo 1\|echo 2<Cr>

Probably related to #27 , the echo 2 parses as part of the parent script file rather than the map statement, then it looks like the error is thrown with the <Cr>.

The register '@@' breaks the syntax

When using the unnamed register @@ in scripts, it seems to error out and breaks highlighting for the rest of the file

Example:
Screen Shot 2022-02-02 at 17 06 39

Commenting out lines with @@, brings back the highlighting in the rest of the file.

No highlighting on string command arguments

Hello there,

Thanks for this project :) I'm a tree sitter noob here, so this may not be an issue at all.

I've noticed that string parameters to command arguments are not highlighted, where as they do get highlighted when passed as arguments to function calls.

To me, this is unexpected. Attached is the screenshot (with default neovim theme)

image

Is this a known issue?

Thanks again!

unsupported `command`

command Test call Test()
ERROR [185, 0] - [185, 12]
  identifier [185, 0] - [185, 7]
  identifier [185, 8] - [185, 12]

Nodes include EOL chars

let foo = "bar"
$ npm run parse -- test.vim

(script_file [0, 0] - [1, 0]
  (let_statement [0, 0] - [1, 0]
    (identifier [0, 4] - [0, 7])
    (string_literal [0, 10] - [0, 15])))

As you can see the script file and let_statement nodes put the end at the "next" line, aka EOL char, instead of having the end at [0, 15].

This is because of the _cmd_separator is included at the end of every line/sentence

tree-sitter-viml/grammar.js

Lines 135 to 141 in 5959544

seq(
$._embedded_script_start,
$._cmd_separator,
repeat(alias($.chunk, $.line)),
$._embedded_script_end,
$._cmd_separator,
),

that node should be always be advanced as advance(lexer, true), but there is more code to change for that works.

augroup name not parsed correctly

Describe the bug

the augroup name isn't parsed correctly

I have an augroup with a _in the name. The _and the part after it are seen as command and not as name. Perhhaps an error with the regex
Screen Shot 2021-08-20 at 16 03 03

fails to install

TSInstall vim results in below errors..

nvim-treesitter[vim]: Error during compilation                 
src/scanner.c: In function ‘check_prefix’:
src/scanner.c:221:3: error: ‘for’ loop initial declarations are only allowed in C99 mode                                                                                                                                                         
   for (unsigned int i = 0; i < preffix_len; i++) {
   ^
src/scanner.c:221:3: note: use option -std=c99 or -std=gnu99 to compile your code
src/scanner.c: In function ‘try_lex_script_start’:
src/scanner.c:243:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for(size_t j = 0; j < 2; j++) {
   ^
src/scanner.c: In function ‘try_lex_keyword’:
src/scanner.c:367:15: error: redeclaration of ‘i’ with no linkage
   for (size_t i = 0; keyword.opt[i] && possible[mandat_len + i]; i++) {
               ^
src/scanner.c:358:10: note: previous declaration of ‘i’ was here
   size_t i;
          ^
src/scanner.c:367:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (size_t i = 0; keyword.opt[i] && possible[mandat_len + i]; i++) {
   ^
src/scanner.c: In function ‘scope_correct’:
src/scanner.c:378:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (size_t i = 0; SCOPES[i]; i++) {
   ^
src/scanner.c: In function ‘lex_scope’:
src/scanner.c:395:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; sid[i] && lexer->lookahead; i++) {
     ^
src/scanner.c: In function ‘tree_sitter_vim_external_scanner_scan’:
src/scanner.c:518:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < s->marker_len; i++) {
     ^
src/scanner.c:575:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
     for (enum TokenType t = TRIE_START; t < TOKENTYPE_NR; t++) {
     ^

The literal-Dict feature isn't supported

Taking the example from help:

let mydict = #{zero: 0, one_key: 1, two-key: 2, 333: 3}

Possible output syntax tree

(let_statement
  (identifier)
  (literal_dictionary
    (literal_dictionary_entry
      key: (literal_key)
      value: (integer_literal))
    (literal_dictionary_entry
      key: (literal_key)
      value: (integer_literal))
    (literal_dictionary_entry
      key: (literal_key)
      value: (integer_literal))
    (literal_dictionary_entry
      key: (literal_key)
      value: (integer_literal))))

Or as an output of tree-sitter's playground:

let_statement [0, 0] - [0, 55]
  identifier [0, 4] - [0, 10]
  literal_dictionary [0, 13] - [0, 55]
    literal_dictionary_entry [0, 15] - [0, 22]
      key: literal_key [0, 15] - [0, 19]
      value: integer_literal [0, 21] - [0, 22]
    literal_dictionary_entry [0, 24] - [0, 34]
      key: literal_key [0, 24] - [0, 31]
      value: integer_literal [0, 33] - [0, 34]
    literal_dictionary_entry [0, 36] - [0, 46]
      key: literal_key [0, 36] - [0, 43]
      value: integer_literal [0, 45] - [0, 46]
    literal_dictionary_entry [0, 48] - [0, 54]
      key: literal_key [0, 48] - [0, 51]
      value: integer_literal [0, 53] - [0, 54]

Current output syntax tree

let_statement [0, 0] - [0, 3]
ERROR [0, 4] - [0, 55]
  identifier [0, 4] - [0, 10]
  keyword [0, 15] - [0, 19]
  keyword [0, 24] - [0, 31]
  keyword [0, 36] - [0, 39]
  keyword [0, 40] - [0, 43]

autocommand error on `term://*`

au BufWinEnter,WinEnter,FocusGained term://* startinsert
autocmd_statement [239, 2] - [240, 0]
  au_event_list [239, 5] - [239, 37]
    au_event [239, 5] - [239, 16]
    au_event [239, 17] - [239, 25]
    au_event [239, 26] - [239, 37]
  pattern [239, 38] - [239, 42]
  ERROR [239, 42] - [239, 46]
  command: command [239, 47] - [240, 0]
    command_name [239, 47] - [239, 58]

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.