GoSublime icon indicating copy to clipboard operation
GoSublime copied to clipboard

Prevent autocompletion of functions

Open anacrolix opened this issue 10 years ago • 2 comments

How do I prevent the function signature from being autocompleted and pre-filled? For example if I type strconv.ParseInt, and then press tab, it turns into this:

strconv.ParseInt(s, base, bitSize)

I'd rather it just completed the function name, and showed me the function signature in the status bar.

anacrolix avatar Jul 31 '15 01:07 anacrolix

Any update on this?

anacrolix avatar Jan 09 '19 22:01 anacrolix

I don't really want to add any more configuration because it makes maintenance a burden so hopefully the following reducer will suffice:

	mg.NewReducer(func(mx *mg.Ctx) *mg.State {
		if !mx.LangIs(mg.Go) || !mx.ActionIs(mg.QueryCompletions{}) {
			return mx.State
		}
		mx.Defer(func(mx *mg.Ctx) *mg.State {
			if len(mx.Completions) == 0 {
				return mx.State
			}
			cl := make([]mg.Completion, len(mx.State.Completions))
			for i, c := range mx.State.Completions {
				if pos := strings.IndexByte(c.Src, '('); pos > 0 && c.Tag == mg.FunctionTag {
					c.Src = c.Src[:pos]
				}
				cl[i] = c
			}
			return mx.State.Copy(func(st *mg.State) { st.Completions = cl })
		})
		return mx.State
	}),

DisposaBoy avatar Jan 10 '19 20:01 DisposaBoy