RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.14k stars 47 forks source link

Invalid expression: .pat..'$' #67

Closed apemost closed 3 years ago

apemost commented 3 years ago

environment

actual behavior

Error detected while processing function illuminate#on_cursor_moved[1]..<SNR>223_should_illuminate_file[4]..<SNR>223_list_contains_pat:
line    2:
E15: Invalid expression: .pat..'$'
Error detected while processing function illuminate#on_cursor_moved[1]..<SNR>223_should_illuminate_file[4]..<SNR>223_list_contains_pat:
line    2:
E15: Invalid expression: a:val =~# '^'..pat..'$'

expected behavior

No errors.

screen shot (if possible)

image

apemost commented 3 years ago

Lua offers a string concatenation operator, denoted by "..", but strings can be concatenated with "." in vimscript:

:echo "foo" . "bar"
foobar 
RRethy commented 3 years ago

String concatenation can be done in vimscript with ...

https://vimhelp.org/eval.txt.html#expr6:

For String concatenation ".." is preferred, since "." is ambiguous, it is also
used for |Dict| member access and floating point numbers.

The vim help you linked is for version 7.3.

It seems you are using an early 8.0 version which doesn't have this upgrade in the expression parsing, I'll merge the change, but you need to upgrade your Vim version since many plugins devs (and myself) won't go out of our way to support old version of Vim (5 years old in this case).

apemost commented 3 years ago

Can we add a compatibility check?

Patch 8.1.1114 Problem: Confusing overloaded operator "." for string concatenation. Solution: Add ".." for string concatenation. Also "let a ..= b". Files: src/eval.c, src/testdir/test_eval_stuff.vim, runtime/doc/eval.txt

RRethy commented 3 years ago

Compatibility check wouldn't be beneficial since it's adding a lot of logic (check for patch for Neovim and Vim) while the reward is just syntactical.