Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow open_cmd to be a lua function #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ the default settings.
require('spectre').setup({

color_devicons = true,
open_cmd = 'vnew',
open_cmd = 'vnew', -- can also be a lua function
live_update = false, -- auto execute search again when you write to any file in vim
lnum_for_results = true, -- show line number for search/replace results
line_sep_start = '┌-----------------------------------------',
Expand Down
2 changes: 1 addition & 1 deletion doc/spectre.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ default settings.
require('spectre').setup({

color_devicons = true,
open_cmd = 'vnew',
open_cmd = 'vnew', -- can also be a lua function
live_update = false, -- auto execute search again when you write to any file in vim
lnum_for_results = true, -- show line number for search/replace results
line_sep_start = '┌-----------------------------------------',
Expand Down
6 changes: 5 additions & 1 deletion lua/spectre/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ M.open = function(opts)
end
end
if state.bufnr == nil or is_new then
vim.cmd(state.user_config.open_cmd)
if type(state.user_config.open_cmd) == 'function' then
state.user_config.open_cmd()
else
vim.cmd(state.user_config.open_cmd)
end
else
if state.query.path ~= nil and #state.query.path > 1 and opts.path == '' then
opts.path = state.query.path
Expand Down