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

Add option to customize insertion points for completions #79

Merged
merged 3 commits into from
Jun 23, 2018

Conversation

c-bata
Copy link
Owner

@c-bata c-bata commented Jun 22, 2018

Summary

This PR fixed #53

By using this feature, we can complete items which is not only separated by space. For example, we can complete files on your local machine like:

file_completer

What should we define as default word separators

In #66, Chyroc suggest that "," should have the same effect with . I checked bash-shell's word separator by running Ctrl + W (Cut the word before the cursor) after input following text which includes space, comma, period, colon, semi-colon and em space.

$ abc def,hij.klm;opq rsu:vwx
                            . <- cursor is here

then Ctrl + W removes until space. The result is below:

$ abc
    .

From this behavior, I think we should only set space as a default word separator. This is the same as ever.

Interface design (still not implemented)

There is the scene to customize word separator.

Add prompt.OptionCompletionWordSeparator(x string) for #53 and #61.

These methods are used when we want to change the insertion points for completer.

func main() {
	p := prompt.New(
		executor,
		completer,
		prompt.OptionPrefix(">>> "),
		prompt.OptionCompletionWordSeparator(" /"),
	)
	p.Run()
}

Provide text query functions by arbitrary word separator for #66

These methods are available from KeyBind functions like:

var emacsKeyBindings = []KeyBind{
	// Cut the Word before the cursor.
	{
		Key: ControlW,
		Fn: func(buf *Buffer) {
			buf.DeleteBeforeCursor(
				len([]rune(buf.Document().GetWordBeforeCursorUntilSeparatorIgnoreNextToCursor(" ,")))
			)
		},
	},
        ...
}

@c-bata c-bata changed the title Custom word separator Customize insertion points for completions and add option to word separator Jun 23, 2018
@c-bata c-bata changed the title Customize insertion points for completions and add option to word separator Add OptionCompletionWordSeparator(x string) to customize insertion points for completions Jun 23, 2018
@c-bata c-bata changed the title Add OptionCompletionWordSeparator(x string) to customize insertion points for completions Add option to customize insertion points for completions Jun 23, 2018
@c-bata c-bata merged commit df74123 into master Jun 23, 2018
@c-bata c-bata deleted the custom-word-separator branch June 23, 2018 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customize insertion point for completion suggestions
1 participant