Commit graph

16 commits

Author SHA1 Message Date
Eric Freese
7afb7364f1 Allow skipping completion suggestions when buffer matches a pattern
Set ZSH_AUTOSUGGEST_COMPLETION_IGNORE to a glob pattern to have the
completion suggestion strategy never make suggestions when the buffer
matches the pattern.

This can be helpful when some completion routines you have are
particularly expensive and you want to prevent them from running
automatically on every keystroke.

See GitHub issue #463.
2019-12-15 08:13:54 -07:00
Eric Freese
b87a4972c8 Allow configuring to ignore history entries matching a pattern
Set ZSH_AUTOSUGGEST_HISTORY_IGNORE to a glob pattern to have the history
and match_prev_cmd suggestion strategies never make suggestions matching
that pattern.

For example, set to "cd *" to never suggest any `cd` commands from
history (see issues #340 and #425). Or set to "?(#c50,)" to never
suggest anything 50 characters or longer (see issue #429).
2019-07-02 21:46:17 -06:00
Eric Freese
adb02c44a2 Prefix custom _complete implementation with "function" keyword
For some reason, when `_complete` is aliased before sourcing the plugin,
zsh was blowing up with a parse error. Adding "function" keyword makes
it parse successfully.

See similar issue: https://github.com/robbyrussell/oh-my-zsh/issues/6723#issuecomment-381220834

Fixes GitHub #442
2019-06-17 22:04:31 -06:00
Eric Freese
f543ba08c3 Fix cr/lf handling in completion strategy 2019-06-15 21:17:58 -06:00
Eric Freese
e263845bed Add an extra completion to better exercise choosing first 2019-06-15 21:17:58 -06:00
Eric Freese
c1910348c7 Implement completion suggestion strategy (#111)
Based on https://github.com/Valodim/zsh-capture-completion

`zpty -r` with a pattern seems to have some funky behavior on older
versions, giving unpredictable results

Don't use `-s` option to `zmodload`. It is not available in zsh versions
older than 5.3

If running in sync mode and a completion takes a long time, the user can
^C out of it. We need to use `always` in the strategy function or the
pty will not be destroyed in this case and the next time we go to create
it, it will fail, making the shell unusable.

User can have many different completion styles set that will modify what
they've already typed. These styles will result in suggestions that
don't match what the user has already typed. We try our best to unset
some of the more problematic ones, but add some code to fetch to
invalidate suggestions that don't match what the user's already typed.
2019-04-11 09:53:55 -06:00
Eric Freese
41657e3565 Revert async process substitution & completion strategy
They're not quite ready. Keep them on a feature branch for now.
2018-12-16 20:49:06 -07:00
Eric Freese
d7171232c3 Merge branch 'develop' into features/completion-suggestions 2018-06-11 02:34:24 -06:00
Eric Freese
973205005c Add spec for completion strategy 2018-05-26 15:42:50 -06:00
Eric Freese
7d19f8f9b2 Rename default spec to history spec 2018-05-26 15:35:29 -06:00
Eric Freese
9e110406fa Add test for special characters with match_prev_cmd strategy
Github #247 and #258
2017-08-18 11:18:07 -06:00
Eric Freese
ed8056c5e8 Lots of async changes 2017-02-16 19:19:30 -07:00
Eric Freese
c3425870f1 Wait for the terminal.clear to go through before continuing
Prevents some flakiness in tests
2017-01-27 14:07:06 -07:00
Eric Freese
0305908adf Revert fc usage in calculating suggestion
As far as I know, `fc` makes it impossible to tell whether history items
used an actual newline character or the string "\n". Pulling from the
`$history` array gives a more accurate representation of the actual
command that was run.
2017-01-24 23:04:07 -07:00
Eric Freese
8e06a54b1c Add test for string with "\n" in it 2017-01-24 22:49:21 -07:00
Eric Freese
c22ab0e399 Implement suggestion integration tests in RSpec + tmux 2017-01-19 22:38:19 -07:00