Phrase Script Editor aggressive autocomplete

The autocomplete in the editor often gives nonsensical suggestions for example

editor_autocomplete

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.

2 Likes

I find myself having to press escape a lot, to remove (often bad) suggestions. +1 for changing it to “accept-with-tab” only.

Is it possible to disable the feature completely? I can’t seem to find the proper .luarc.json

Edit: My issues are in the normal scripting & terminal editor, but it seems to be exactly the same.

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.

luals

I don’t have anything relevant in my .luarc.

The behaviour is the same in vscode as well

luals_vscode

I had noted the location of the luarc file for joule, as he could not find it. Autocomplete can be disabled there completely.

The number typing thing is an easy one to fix, but doesn’t really address the initial issue?

For that I guess we’d need two options in Renoise:

“Autocomplete Start” → “Off”, “Manual”, “While Typing”
“Autocomplete Apply” → “Tab”, “Tab + Return”,

I could try cramming them into the editor’s context menu. Or where else would you expect them?

1 Like

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.

in this case, clear will only work if i remember to press Esc, if i press space and enter, i get an error.

clear_auto

Simply hit Command + L there to clear. We should get rid of the magic clear keyword here.

1 Like

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

Enable autocomplete


-- 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()
--]]