The autocomplete in the editor often gives nonsensical suggestions for example
This paired with the fact that Enter selects the suggestion (I’d typically remap this action to Tab if possible) means that when you are at the end of the line you need to escape the suggestion to be able to write.
Even if the keybinding is more of a question of habit/opinion, I think these generic lua suggestions might need a bit of toning down.
That’s LuaLS doing its job here. Same should happen in e.g. vscode as well.
The tool editor’s LuaLS can be configure via the file .luarc in the “User Scripts” root directory. You’ll see a template file when opening the Renoise inbuilt scripting editor.
For phrase scripts there’s no user config path for a .luarc yet. Probably should add one.
It seems that in Renoise the autocomplete works a little differently, for the above example the prompt “lags behind” whereas in my editor (helix with lua-ls), I get the same suggestion but once I finish typing the float, the suggestion window disappears, it won’t try to replace the 5 with a do block like in Renoise.
I think there are more instances like this, where the autocomplete prompt would be expected to disappear at a point (and it does in other editors) but in Renoise it doesn’t, which is why I think maybe there is some difference here with “polling the lsp”, not familiar with how that works though. So in the above example the . triggers the hint but the 5 should make it disappear. I can gather more cases demonstrating this later if needed.
Having the select action remappable to Tab would solve the main annoyance for me but the prompt lagging behind the context could still be confusing for users new to coding.
Personally, I wouldn’t disable autocomplete completely as it is otherwise very handy, but having that as an option can’t hurt.
I have no preference over where the settings should be.
Just put this together with aid of Copilot to add a menu to the scripting ed, maybe needs to be checked for file writing safety?
Seems to work ok to toggle AC on and off though. It just toggles the true/false in .luarc.json
-- Menu
renoise.tool():add_menu_entry {
name = "Scripting Menu:View:Enable Autocomplete",
invoke = function()
main()
end
}
---------------
function main()
---------------
local file_path = renoise.tool().bundle_path
local result = file_path:match("^(.-Scripts\\)")
file_path = result..".luarc.json"
-- Read file
local file = io.open(file_path, "r")
local content = file:read("*a")
file:close()
local toggle_flag = false
-- Toggle "hover.enable"
if content:find('"hover.enable"%s*:%s*true') then
content = content:gsub('"hover.enable"%s*:%s*true', '"hover.enable": false')
elseif content:find('"hover.enable"%s*:%s*false') then
content = content:gsub('"hover.enable"%s*:%s*false', '"hover.enable": true')
toggle_flag = true
end
-- Write it back
file = io.open(file_path, "w")
file:write(content)
file:close()
renoise.app():show_status("Toggled hover.enable in settings.json: "..tostring(toggle_flag))
end
--[[
--debug
-------------------------------
local function print_contents()
-------------------------------
local file = io.open(file_path, "r")
if not file then
print("Failed to open file")
return
end
local content = file:read("*a")
file:close()
print("File contents:\n" .. content)
local file = io.open(file_path, "w")
file:write(content)
file:flush() -- ensure the buffer is flushed
file:close()
print("Wrote updated content to file.")
end
---
print_contents()
--]]