nvim-pack/nvim-spectre

Error when changing replace_engine

yofriadi opened this issue · 4 comments

when changing replace_engine to other than sed

require('spectre').setup({
  default = {
    replace = { cmd = "sd" },
  },
})

after filling out the search input and hit escape, it throws

18:07:17 msg_show.lua_error Error detected while processing InsertLeave Autocommands for "<buffer=2>":
18:07:17 msg_show E5108: Error executing lua ...im/default/lazy/nvim-spectre/lua/spectre/state_utils.lua:17: attempt to index field 'options' (a nil value)
stack traceback:
	...im/default/lazy/nvim-spectre/lua/spectre/state_utils.lua:17: in function 'get_options'
	...im/default/lazy/nvim-spectre/lua/spectre/state_utils.lua:27: in function 'get_replace_engine_config'
	...hare/nvim/default/lazy/nvim-spectre/lua/spectre/init.lua:650: in function 'init_regex'
	...hare/nvim/default/lazy/nvim-spectre/lua/spectre/init.lua:646: in function 'search'
	...hare/nvim/default/lazy/nvim-spectre/lua/spectre/init.lua:326: in function 'on_search_change'
	[string ":lua"]:1: in main chunk
   Error  18:07:17 msg_show.lua_error Error executing vim.schedule lua callback: ...are/nvim/default/lazy/nvim-spectre/lua/spectre/utils.lua:170: attempt to index local 'regex' (a nil value)
stack traceback:
	...are/nvim/default/lazy/nvim-spectre/lua/spectre/utils.lua:170: in function 'get_hl_line_text'
	.../share/nvim/default/lazy/nvim-spectre/lua/spectre/ui.lua:18: in function 'render_line'
	...hare/nvim/default/lazy/nvim-spectre/lua/spectre/init.lua:551: in function 'on_result'
	...im/default/lazy/nvim-spectre/lua/spectre/search/base.lua:66: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>
   Error  18:07:17 msg_show.lua_error Error executing vim.schedule lua callback: ...are/nvim/default/lazy/nvim-spectre/lua/spectre/utils.lua:170: attempt to index local 'regex' (a nil value)
stack traceback:
	...are/nvim/default/lazy/nvim-spectre/lua/spectre/utils.lua:170: in function 'get_hl_line_text'
	.../share/nvim/default/lazy/nvim-spectre/lua/spectre/ui.lua:18: in function 'render_line'
	...hare/nvim/default/lazy/nvim-spectre/lua/spectre/init.lua:551: in function 'on_result'
	...im/default/lazy/nvim-spectre/lua/spectre/search/base.lua:66: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

hope it gets addressed, thank you for the plugin

Spectre supports oxi and sed replace utility. Before adding sd as default replace you need to add sd to replace_engine.

thank you for your response, I believe I already try all possible things, including adding replace_engine. sure perhaps I could look at the code to try fix it.

I have also tried to this before in #56. But sd was missing line numbers option. Also highlighting engine does not support thr fixed string option directly so that was also a bit messed up.

I hope you have better chance then I had and open a pull request for it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.