Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rename function usages in shell script #52

Open
saccarosium opened this issue Oct 7, 2023 · 0 comments
Open

Don't rename function usages in shell script #52

saccarosium opened this issue Oct 7, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@saccarosium
Copy link

Describe the bug

Considering the following script:

For example, I have the following script:

greet() {
  echo "Hello"
}

greet

If I try to rename the function greet with new_name it will rename the function declaration, or the individual function call I have my cursor on, but not all the other references to than function.

The function will look something like this:

new_name() {
  echo "Hello"
}

greet

Expected behavior

After I rename one reference to a function I expect that all the renamed references were renamed too.

Output of :checkhealth nvim_treesitter

Installation - OK `tree-sitter` found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar) - OK `node` found v20.8.0 (only needed for :TSInstallFromGrammar) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: Apple clang version 15.0.0 (clang-1500.0.40.1) - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
machine = "x86_64",
release = "23.0.0",
sysname = "Darwin",
version = "Darwin Kernel Version 23.0.0: Fri Sep 15 14:42:42 PDT 2023; root:xnu-10002.1.13~1/RELEASE_X86_64"
} ~

Parser/Features H L F I J

  • bash ✓ ✓ ✓ . ✓
  • c ✓ ✓ ✓ ✓ ✓
  • cmake ✓ . ✓ ✓ .
  • cpp ✓ ✓ ✓ ✓ ✓
  • diff ✓ . . . .
  • git_rebase ✓ . . . ✓
  • gitcommit ✓ . . . ✓
  • gitignore ✓ . . . .
  • java ✓ ✓ ✓ ✓ ✓
  • javascript ✓ ✓ ✓ ✓ ✓
  • json ✓ ✓ ✓ ✓ .
  • lua ✓ ✓ ✓ ✓ ✓
  • make ✓ . ✓ . ✓
  • markdown ✓ . ✓ ✓ ✓
  • markdown_inline ✓ . . . ✓
  • python ✓ ✓ ✓ ✓ ✓
  • query ✓ ✓ ✓ ✓ ✓
  • requirements ✓ . . . ✓
  • teal ✓ ✓ ✓ ✓ ✓
  • toml ✓ ✓ ✓ ✓ ✓
  • vim ✓ ✓ ✓ . ✓
  • vimdoc ✓ . . . ✓
  • yaml ✓ ✓ ✓ ✓ ✓

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}

Output of nvim --version

Note
Appens also on stable release

NVIM v0.10.0-dev-1280+g3079fa1f9
Build type: RelWithDebInfo
LuaJIT 2.1.1695653777
Run "nvim -V1 -v" for more info

Additional context

I'm pretty sure is a problem with the bash parser, but wanna make sure that it is the case.

The parser will produce the following AST for the example script above:

(function_definition) ; [1:1 - 3:1]
 name: (word) ; [1:1 - 5]
 body: (compound_statement) ; [1:9 - 3:1]
  (command) ; [2:5 - 16]
   name: (command_name) ; [2:5 - 8]
    (word) ; [2:5 - 8]
   argument: (string) ; [2:10 - 16]
    (string_content) ; [2:11 - 15]
(command) ; [5:1 - 5]
 name: (command_name) ; [5:1 - 5]
  (word) ; [5:1 - 5]

When you call a function it doesn't distinguish if you are calling a function or an executable. I think this is the issue.

@saccarosium saccarosium added the bug Something isn't working label Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant