NvChad / ui

Lightweight & high performance UI plugin for nvchad
GNU General Public License v3.0
214 stars 123 forks source link

LSP rename failed for variable named "end" #206

Closed ValouBambou closed 10 months ago

ValouBambou commented 11 months ago

Describe the bug LSP rename failed when the initial variable name is "end". I tested with 2 lsp (pyright and rust analyzer) but the raised error seems lua related.

To Reproduce Steps to reproduce the behavior:

  1. Create a python file with a content like this end = 1; print(end). 2, Rename the end variable to another name.

Expected behavior Rename is effective without error.

Screenshots image

Desktop :

Also tested on WSL with an older neovim and the result is the same.

ValouBambou commented 11 months ago

The source cause seems to be line 43 in renamer.lua which use a string as lua input command. I'm not sure on how to change this since I'm not fluent in lua, maybe there is some escape function to apply before ?

ValouBambou commented 11 months ago

After trying a dummy fix of simply adding single quotes to the 2 lua strings, it worked. I will open a PR for submitting the quick fix on top of the current implementation.

Also creating lua code from string from user input is a clever trick to get the implementation working on most cases but I think this is a dirty hack since code injection is possible, and should be avoided.