scnvim icon indicating copy to clipboard operation
scnvim copied to clipboard

[BUG] Windows 10: Code evaluation does not work

Open ckutzner opened this issue 8 months ago • 12 comments

Describe the bug When launching nvim inside alacritty or Powershell, code evaluation does nothing. Booting/quitting the server, starting/stopping sclang via configured keybindings work. Toggling the post window via "Enter" key also works.

This happens regardless if I configure custom keybindings or use the default configuration.

Expected behavior Code evaluation happens as configured via keybindings.

Steps to reproduce

Information

  • Operating system Windows 10 Pro Version 10.0.19045

  • SuperCollider version 3.13.0-rc3

  • nvim --version 0.11.0

  • Package manager packer.nvim

  • checkhealth scnvim output:

scnvim:                                       require("scnvim.health").check()

scnvim ~
- OK nvim version 0.11.0
- OK sclang executable: C:/Program Files/SuperCollider/sclang.exe
- OK scnvim classes are installed: C:/Users/User/AppData/Local/SuperCollider/Extensions/scide_scnvim
- OK keymaps are defined

scnvim documentation ~
- using HelpBrowser for documentation

scnvim extensions ~

ckutzner avatar Apr 01 '25 17:04 ckutzner

Thanks for the report. Unfortunately I don't have access to a computer running Windows at the moment, but I will try to reproduce this as soon as I do. Meanwhile, if you are up for it, you could perhaps have a look at the sclang.send function that is found in lua/scnvim/sclang.lua on line 179 in the most recent version of the plugin. You could replace it with this function and observe the result by typing :messages in nvim after trying to evalute some code.

function M.send(data, silent)
  silent = silent or false
  if M.is_running() then
    local res = M.stdin:write {
      data,
      not silent and cmd_char.interpret_print or cmd_char.interpret,
    }
    print('send:', res)
  end
end

davidgranstrom avatar Apr 02 '25 07:04 davidgranstrom

Thanks for your swift answer! :messages gives me the following output:

Image

ckutzner avatar Apr 02 '25 19:04 ckutzner

Thanks for the info! That looks good to me, the result value means that the write to sclang succeeded. Perhaps we can make sure that cmd_char.interpret_print is used instead of cmd_char.interpret by either logging the value of silent or simply change the function to this:

function M.send(data, silent)
  silent = silent or false
  if M.is_running() then
    local res = M.stdin:write {
      data,
      cmd_char.interpret_print,
    }
    print('send:', res, 'silent:', silent)
  end
end

davidgranstrom avatar Apr 03 '25 08:04 davidgranstrom

@ckutzner Do you have your scnvim config available online, or could you perhaps post it in this thread? It could help in further debugging this issue.

davidgranstrom avatar Apr 07 '25 07:04 davidgranstrom

Sorry that it took me so long. My scnvim config:

-- configuration for scnvim
local scnvim = require 'scnvim'
local map = scnvim.map
local map_expr = scnvim.map_expr
scnvim.setup {
	sclang = {
		cmd = 'C:/Program Files/SuperCollider/sclang.exe'
	},
	keymaps = {
		['<S-CR>'] = map('editor.send_line', {'i', 'n'}),
		['<C-CR>'] = {
		  map('editor.send_block', {'i', 'n'}),
		  map('editor.send_selection', 'x'),
		},
		['<CR>'] = map('postwin.toggle'),
		['<M-CR>'] = map('postwin.toggle', 'i'),
		['<M-l>'] = map('postwin.clear', {'n', 'i'}),
		['<C-k>'] = map('signature.show', {'n', 'i'}),
		['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
		['<leader>st'] = map('sclang.start'),
		['<leader>sk'] = map('sclang.recompile'),
		['<F1>'] = map_expr('s.boot'),
		['<F2>'] = map_expr('s.meter'),
		['<F3>'] = map_expr('s.plotTree'),
		['<F4>'] = map_expr('s.quit'),
		['<F5>'] = map('sclang.stop')
	},
	editor = {
		highlight = {
		  color = 'IncSearch',
		  type = 'fade', 
				duration = 600
		},
	},
	postwin = {
		float = {
		  enabled = true,
		},
	},
 --  extensions = {
	-- ['fzf-sc'] = {
	-- 		search_plugin = 'nvim-fzf',
	-- 	},
  --},
}

ckutzner avatar May 02 '25 16:05 ckutzner

Attempting the suggested code changes to sclang.lua: Image

ckutzner avatar May 02 '25 16:05 ckutzner

I finally managed to find a Windows laptop to test the plugin on and code evaluation worked for me as expected. (It was Windows 11 and not 10 though).

In the output you sent, it looks like all of the writes to sclang are happening with the "silent" option, that means that they should not output anything to the post window (but the code still evaluates). I've tested using your keymaps and I can't reproduce the log - the silent option is false for me when evaluating code. Are you using the latest version of the (scnvim) plugin?

I also noticed in your screenshot that you have a "system overwrite" from an Extension (but I couldn't see which one). It is a long shot, but it would be interesting to know in case that has anything to do with this issue that you are experiencing.

davidgranstrom avatar May 20 '25 08:05 davidgranstrom

I deleted the offending extension (ChordSymbol) - no change. I ran every update I could think of (updating neovim via Chocolatey, updating all my nvim plugins via Packer), and the silent option continues to return true.

I only learned very recently that Packer is currently unmaintained. I haven't gotten around to migrating to lazy.nvim, but I'm skeptical whether that will change anything.

ckutzner avatar May 23 '25 13:05 ckutzner

Thanks for the info. I did not use any package manager at all when doing the test I mentioned above, just native packages, i.e. a fresh clone of this repository in something like pack/myplugins/start/scnvim in the runtime path. But I doubt it will change anything (unless packer.nvim is reading some old version of the scnvim plugin?). Unfortunately I'm out of ideas at the moment, perhaps someone else using Windows can chime in on this issue.

davidgranstrom avatar May 24 '25 10:05 davidgranstrom

Hello, I'm having the exact same issue, though I'm on macOS. Perhaps it's not an OS issue, but an issue with the configuration? My config is here, if anyone see's something wrong with it.

I tried changing the sclang.send function as described above and got a similar result as ckutzner, though I didn't have silent: true.

I am using lazy.nvim for package management so I doubt that's the issue ckutzner was facing

amitmaish avatar Oct 10 '25 15:10 amitmaish

Hello again, I fixed the issue in my configuration. I was passing in a startup file as an argument, which doesn't work on macOS. Given that there weren't any command arguments in ckutzner's config, his issue in almost certainly different

amitmaish avatar Oct 13 '25 20:10 amitmaish

In the meantime, I have switched to Ubuntu and am using lazy.nvim as a plugin manager. Code execution works now. Should I close this issue?

ckutzner avatar Nov 13 '25 13:11 ckutzner