From 6fd69447679a99b463025e7f2f787e8b185dd740 Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Sat, 21 Dec 2024 10:37:06 +0100 Subject: [PATCH] Fix Lua regex to allow `require"foo"` & `require("foo")` (#34) Closes #33 ![image](https://github.com/user-attachments/assets/c110d017-d482-4973-bf36-349d187b280e) --- lua/import/regex.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/import/regex.lua b/lua/import/regex.lua index 2eade9f..30fdcf2 100644 --- a/lua/import/regex.lua +++ b/lua/import/regex.lua @@ -3,7 +3,7 @@ local regex = { go = [[^\t(\".*\")|^import (\".*\")]], java = [[^import\s+((static\s+)?[\w.]+\*?);\s*$]], javascript = [[^(?:import(?:[\"'\s]*([\w*{}\n, ]+)from\s*)?[\"'\s](.*?)[\"'\s].*)]], - lua = [[^local (\w+) = require\([\"'](.*?)[\"']\)]], + lua = [[^local (\w+) = require\(?[\"'](.*?)[\"']\)?]], php = [[^\s*use\s+([\w\\]+)(?:\s*;)?]], python = [[(?m)^(?:from[ ]+(\S+)[ ]+)?import[ ]+(\S+)[ ]*$]], shell = [[^(?:source\s+)]],