changed directories and addet fzf to zsh
This commit is contained in:
parent
0acd581d40
commit
cb928bb0b4
428 changed files with 20659 additions and 15 deletions
|
@ -0,0 +1,30 @@
|
|||
describe 'a suggestion' do
|
||||
let(:term_opts) { { width: 200 } }
|
||||
let(:long_command) { "echo #{'a' * 100}" }
|
||||
|
||||
around do |example|
|
||||
with_history(long_command) { example.run }
|
||||
end
|
||||
|
||||
it 'is provided for any buffer length' do
|
||||
session.send_string(long_command[0...-1])
|
||||
wait_for { session.content }.to eq(long_command)
|
||||
end
|
||||
|
||||
context 'when ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE is specified' do
|
||||
let(:buffer_max_size) { 10 }
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=#{buffer_max_size}"] }
|
||||
|
||||
it 'is provided when the buffer is shorter than the specified length' do
|
||||
session.send_string(long_command[0...(buffer_max_size - 1)])
|
||||
wait_for { session.content }.to eq(long_command)
|
||||
end
|
||||
|
||||
it 'is provided when the buffer is equal to the specified length' do
|
||||
session.send_string(long_command[0...(buffer_max_size)])
|
||||
wait_for { session.content }.to eq(long_command)
|
||||
end
|
||||
|
||||
it 'is not provided when the buffer is longer than the specified length'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
describe 'a displayed suggestion' do
|
||||
it 'is shown in the default style'
|
||||
|
||||
describe 'when ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE is set to a zle_highlight string' do
|
||||
it 'is shown in the specified style'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
describe 'an original zle widget' do
|
||||
context 'is accessible with the default prefix'
|
||||
|
||||
context 'when ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX is set' do
|
||||
it 'is accessible with the specified prefix'
|
||||
end
|
||||
end
|
55
.zsh/plugins/autosuggestions/spec/options/strategy_spec.rb
Normal file
55
.zsh/plugins/autosuggestions/spec/options/strategy_spec.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
describe 'a suggestion for a given prefix' do
|
||||
let(:history_strategy) { '_zsh_autosuggest_strategy_history() { suggestion="history" }' }
|
||||
let(:foobar_strategy) { '_zsh_autosuggest_strategy_foobar() { [[ "foobar baz" = $1* ]] && suggestion="foobar baz" }' }
|
||||
let(:foobaz_strategy) { '_zsh_autosuggest_strategy_foobaz() { [[ "foobaz bar" = $1* ]] && suggestion="foobaz bar" }' }
|
||||
|
||||
let(:after_sourcing) do
|
||||
-> do
|
||||
session.run_command(history_strategy)
|
||||
end
|
||||
end
|
||||
|
||||
it 'by default is determined by calling the `history` strategy function' do
|
||||
session.send_string('h')
|
||||
wait_for { session.content }.to eq('history')
|
||||
end
|
||||
|
||||
context 'when ZSH_AUTOSUGGEST_STRATEGY is set to an array' do
|
||||
let(:after_sourcing) do
|
||||
-> do
|
||||
session.
|
||||
run_command(foobar_strategy).
|
||||
run_command(foobaz_strategy).
|
||||
run_command('ZSH_AUTOSUGGEST_STRATEGY=(foobar foobaz)')
|
||||
end
|
||||
end
|
||||
|
||||
it 'is determined by the first strategy function to return a suggestion' do
|
||||
session.send_string('foo')
|
||||
wait_for { session.content }.to eq('foobar baz')
|
||||
|
||||
session.send_string('baz')
|
||||
wait_for { session.content }.to eq('foobaz bar')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when ZSH_AUTOSUGGEST_STRATEGY is set to a string' do
|
||||
let(:after_sourcing) do
|
||||
-> do
|
||||
session.
|
||||
run_command(foobar_strategy).
|
||||
run_command(foobaz_strategy).
|
||||
run_command('ZSH_AUTOSUGGEST_STRATEGY="foobar foobaz"')
|
||||
end
|
||||
end
|
||||
|
||||
it 'is determined by the first strategy function to return a suggestion' do
|
||||
session.send_string('foo')
|
||||
wait_for { session.content }.to eq('foobar baz')
|
||||
|
||||
session.send_string('baz')
|
||||
wait_for { session.content }.to eq('foobaz bar')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
121
.zsh/plugins/autosuggestions/spec/options/widget_lists_spec.rb
Normal file
121
.zsh/plugins/autosuggestions/spec/options/widget_lists_spec.rb
Normal file
|
@ -0,0 +1,121 @@
|
|||
describe 'a zle widget' do
|
||||
let(:widget) { 'my-widget' }
|
||||
let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } }
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_ACCEPT_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'accepts the suggestion and moves the cursor to the end of the buffer when invoked' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
||||
wait_for { session.cursor }.to eq([10, 0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_CLEAR_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'clears the suggestion when invoked' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content }.to eq('e')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_EXECUTE_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_EXECUTE_WIDGETS+=(#{widget})"] }
|
||||
|
||||
it 'executes the suggestion when invoked' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content }.to end_with("\nhello")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_IGNORE_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(#{widget})"] }
|
||||
|
||||
it 'should not be wrapped with an autosuggest widget' do
|
||||
session.run_command("echo $widgets[#{widget}]")
|
||||
wait_for { session.content }.to end_with("\nuser:#{widget}")
|
||||
end
|
||||
end
|
||||
|
||||
context 'that moves the cursor forward' do
|
||||
before { session.run_command("#{widget}() { zle forward-char }") }
|
||||
|
||||
context 'when added to ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(#{widget})"] }
|
||||
|
||||
it 'accepts the suggestion as far as the cursor is moved when invoked' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to start_with('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content(esc_seqs: true) }.to match(/\Aec\e\[[0-9]+mho hello/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'that modifies the buffer' do
|
||||
before { session.run_command("#{widget}() { BUFFER=\"foo\" }") }
|
||||
|
||||
context 'when not added to any of the widget lists' do
|
||||
it 'modifies the buffer and fetches a new suggestion' do
|
||||
with_history('foobar') do
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content }.to eq('foobar')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'a modification to the widget lists' do
|
||||
let(:widget) { 'my-widget' }
|
||||
let(:before_sourcing) { -> { session.run_command("#{widget}() {}; zle -N #{widget}; bindkey ^B #{widget}") } }
|
||||
before { session.run_command("ZSH_AUTOSUGGEST_ACCEPT_WIDGETS+=(#{widget})") }
|
||||
|
||||
it 'takes effect on the next cmd line' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when manual rebind is enabled' do
|
||||
let(:options) { ["ZSH_AUTOSUGGEST_MANUAL_REBIND=true"] }
|
||||
|
||||
it 'does not take effect until bind command is re-run' do
|
||||
with_history('echo hello') do
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
sleep 1
|
||||
expect(session.content(esc_seqs: true)).not_to eq('echo hello')
|
||||
|
||||
session.send_keys('C-c')
|
||||
session.run_command('_zsh_autosuggest_bind_widgets').clear_screen
|
||||
wait_for { session.content }.to eq('')
|
||||
|
||||
session.send_string('e')
|
||||
wait_for { session.content }.to eq('echo hello')
|
||||
session.send_keys('C-b')
|
||||
wait_for { session.content(esc_seqs: true) }.to eq('echo hello')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue