Safe and efficient code refactoring tools with scope analysis and conflict detection
Safe and efficient code refactoring tools to help you optimize code structure without breaking code logic. EmmyLua’s refactoring system provides intelligent analysis and conflict detection to ensure your changes are safe.
Position cursor on a variable, function, class, or field
Press F2
Type the new name
Press Enter to apply or Esc to cancel
local function processData(userData) -- ^^^^^^^^^^^ Press F2 here local result = userData.name return resultend-- After renaming to 'processUserData':local function processUserData(userData) local result = userData.name return resultend
Right-click → Rename Symbol
Right-click on the symbol you want to rename
Select “Rename Symbol” from the context menu
Enter the new name in the input box
Press Enter to confirm
Available for:
Variables (local and global)
Functions and methods
Class names
Table fields
Parameters
The language server validates if a symbol can be renamed before showing the input box.Renameable symbols:
The rename system understands Lua’s scoping rules and only renames symbols within their valid scope.
Local Scope
Global Scope
Module Scope
local function outer() local value = 10 -- Scope: outer function local function inner() local value = 20 -- Different scope, won't be renamed print(value) end print(value) -- Renaming this 'value' won't affect inner's 'value' inner()end
The system proactively detects potential naming conflicts and prevents problematic renames.
Name Collision
Keyword Conflicts
Type System Conflicts
local function process() local value = 10 local result = 20 -- Trying to rename 'result' to 'value' will be rejected -- because 'value' already exists in this scope return value + resultend
Conflict types detected:
Variable name collision in same scope
Parameter name conflicts
Field name conflicts in same class
Global name shadowing
local function example() local count = 10 -- Renaming 'count' to 'end', 'function', 'local', etc. -- will be rejected as these are Lua keywords return count * 2end
Protected names:
Lua keywords (if, then, end, function, etc.)
Built-in functions (print, require, etc.)
Standard library names (if configured)
---@class Userlocal User = {}---@class Admin : Userlocal Admin = {}-- Renaming 'User' to 'Admin' will be rejected-- because 'Admin' already exists and inherits from 'User'
EmmyLua supports renaming different types of symbols with specialized handling.
Variables
Functions
Classes & Types
Fields & Members
local originalName = "value"print(originalName)-- Rename 'originalName' to 'newName'local function process() return originalName .. " processed"end
Handles:
Local variables
Global variables
Upvalues
Closure variables
local function oldFunctionName(param) return param * 2endlocal result = oldFunctionName(5)-- Rename to 'newFunctionName'-- Updates definition and all call sites
Handles:
Function declarations
Function expressions
Method definitions
Lambda functions
---@class OldClassName---@field value numberlocal OldClassName = {}---@param obj OldClassNamelocal function process(obj) return obj.valueend---@type OldClassNamelocal instance = { value = 42 }-- Rename 'OldClassName' to 'NewClassName'-- Updates class definition and all type references
Handles:
Class definitions
Type aliases
Generic types
Union types
---@class Config---@field oldFieldName stringlocal Config = {}function Config:new() return { oldFieldName = "default" }endfunction Config:getField() return self.oldFieldNameend-- Rename 'oldFieldName' to 'newFieldName'-- Updates field annotation, assignments, and access