nvim-various-textobjs icon indicating copy to clipboard operation
nvim-various-textobjs copied to clipboard

[Bug]: incorrect key for c++

Open daniilrozanov opened this issue 10 months ago • 3 comments

Bug Description

In line

std::string c = "afaf";

vik command selects only string c, ignoring std::.

I am using defaut configuration of plugin from README.

neovim version

0.9.5

daniilrozanov avatar Apr 04 '24 22:04 daniilrozanov

This is expected. The key object matches one word in front of : or =. See https://github.com/chrisgrieser/nvim-various-textobjs/blob/3ab25fe20f8f9c2035425d0cf5c9634a063cb98e/lua/various-textobjs/charwise-textobjs.lua#L302-L306

b0ae989c avatar Jun 04 '24 23:06 b0ae989c

Indeed, the behavior is expected. I don't know any C, so I am not familiar with how the pattern has to be adapted to make it work correctly there - any PRs welcome.

chrisgrieser avatar Jun 05 '24 04:06 chrisgrieser

C and C++ don't have the key/value syntax. The :: in that snippet is a scope resolution operator, and std::string s = "abc"; is a copy initialization of the variable s. This is not a key/value pair. Should close.

b0ae989c avatar Jun 09 '24 18:06 b0ae989c