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.

2 Likes

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

Just to note setting the .luarc to false gets rid of the hover box but not this, so we can’t fully disable autocomplete? .

autocomplete

{
  // see https://luals.github.io/wiki/settings/
  "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
  "hover.enable": false,
}

////////////////////

NM, I learnt to read:

//see Lua Language Server | Wiki

{
  //see https://luals.github.io/wiki/settings/
  "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
  "hover.enable": false,
  "completion.enable" : false,
}

getting this error now but I’ll keep at it:

*** .luarc.json:1: unexpected symbol near '{'

Another weird example of the autocomplete removing an already typed out line if you aren’t vigilant about escaping the suggestion box.

autocomplete_remove

1 Like

I’m trying to disable the annoying autocomplete in the scripting editor, but adding a .luarc.json file in the ~/Preferences/Renoise/V3.5.3/Scripts directory is having no effect. I can see from the log file in ~/Library/Logs/LuaLS that LuaLS is picking it up, but is then reloading the default ‘fallback’ config afterwards.

My .luarc.json looks like this:

{
  "completion.enable": false,
  "hint.enable": false,
  "hover.enable": false,
}

What am I doing wrong?

The autocomplete rarely gets it right and is really distracting. I really just want it off entirely, especially since I can see that it has an option “telemetry.enable” in it, which is an absolute no-no from my point of view. Please can we have a global option to stop it from running at all. It’s not a helpful addition and adds a lot of faff and overhead, such as having its own log folder completely separate from the Renoise logs.

Disabling hover tips via "hover.enable": false, should work. Just have tested that here.

"completion.enable": false indeed isn’t picked up by Renoise. Maybe we should add our own preferences for that in Renoise, avoiding the use of .luarc.json completely here.

Telemetry always gets disabled by Renoise when starting up the language server, so there there’s no need to disable it there.

Thanks for confirming it’s not just my error. I can see that I am getting no hover pop-ups with those settings, but my main aim was turning completion off entirely. I added the hover/hint options as a way to cover all areas, but was really expecting that completion.enable: false would do the job for everything.

If there could be an option to totally disable LuaLS, ie. stop it from being run at all, that would be ideal, even if it was a deeper options file setting rather than a menu item/GUI entry.