UserNobody14 / tree-sitter-dart

Attempt to make a tree-sitter grammar for dart
MIT License
62 stars 40 forks source link

Don't detect Dollar Sign ($) as Part of String on Brace-less Interpolation #22

Closed ybbond closed 2 years ago

ybbond commented 3 years ago

Summary

Pressing neovim's asterisk * or pound # to search word will exclude variable interpolated in String.

Example

const String baseURL = 'https://github.com/UserNobody14/tree-sitter-dart';
//             ^------ press * when cursor here
const String pullRequestsURL = '$baseURL/pulls';
const String issuesURL = '${baseURL}/issues';

given that example, the highlighted will only be the one in issuesURL.

Expected Result

Dollar sign with brace-less String interpolation don't detected as part of the String.

akinsho commented 3 years ago

@ybbond I believe this is probably not the correct place for this issue. The commands you are referring to are neovim commands and I don't believe that they are currently actually connected to treesitter i.e. they work using some much older vim mechanism that pre-dates treesitter unless you installed a plugin for this. This repository is a general repository for the tree sitter dart grammar and isn't specific to any particular editor's functionality.

ybbond commented 3 years ago

hi @akinsho thank you for your reply.

my reason to assume that this is something to do with treesitter parser is that if I test the same in a string of a *.lua file, the behavior is different.

Demo on Dart String

https://user-images.githubusercontent.com/25895873/132248632-926ee162-7420-4a8e-8a86-4f7affb42661.mov

Demo on Lua string

https://user-images.githubusercontent.com/25895873/132248627-4557ca41-a55c-4f5d-ae33-eee943758de9.mov

akinsho commented 3 years ago

@ybbond it's more likely that this is because of how vim is determining what is a part of a string using iskeyword in either case as long as * and # aren't mapped to some treesittter based plugin I don't believe this issue belongs here and tbh even if it was treesitter based it would be better to put this issue in nvim-treesitter as the issue would very likely relate to nvim treesitter not this editor agnostic library.

ybbond commented 3 years ago

@akinsho hey, thank you for explaining twice.

I missed the point from your first reply that this repository is not NeoVim specific (that may be used for treesitter implementation in other editor such as Sublime Text).

I will take some time to compose wording for nvim-treesitter issue, mentioning insights I got from you too (probable iskeyword implementation)

good day :D

ybbond commented 3 years ago

as per suggested, I reported this issue in https://github.com/nvim-treesitter/nvim-treesitter/issues/1850