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 omnifunc icase override setting #2961

Merged
merged 2 commits into from
Jul 25, 2020
Merged

Add omnifunc icase override setting #2961

merged 2 commits into from
Jul 25, 2020

Conversation

peterstace
Copy link
Contributor

This change allows a plugin user to set the icase key in omnifunc results. By setting this to 1, the user is able to filter omnifunc results in a non-case sensitive manner.

For example:

  1. Enter insert mode.
  2. Type fmt.
  3. Trigger omnifunc completion using <C-X><C-O>
  4. Deselect the first item in the list (Formatter) by pressing <C-P>.
  5. If g:go_code_completion_icase is set to 0 (default), then anything you type next will filter the completion list but in a case sensitive manner. This is also the behaviour when icase is not present at all. But if g:go_code_completion_icase set to 1, then the filtering is case-insensitive.

My own personal workaround to get this behaviour has been to define my own omnifunc for Go files that calls go#complete#Complete and then modifies the result on the way back through.

function MyOmniFunc(findstart, base)
    let results = go#complete#Complete(a:findstart, a:base)
    if !a:findstart
        for result in results
            let result.icase = 1
        endfor
    endif
    return results
endfunction
autocmd FileType go set omnifunc=MyOmniFunc

(so if you don't want to accept this PR, there aren't any dramas on my part since I have an functional workaround).

@bhcleek bhcleek added this to the vim-go 1.24 milestone Jul 22, 2020
@bhcleek
Copy link
Collaborator

bhcleek commented Jul 22, 2020

Thanks for contributing.

LGTM

@Shane-XB-Qian
Copy link

very good, i like this !
lots langs' omni compl supported case insensitive, or lang itself did not care func name must be Upper case or not.
Unlucky, so far, golang & this plugin limited had to input 1st Upper case letter to filter omni compl items, in its most cases ...

@bhcleek bhcleek merged commit f3a082c into fatih:master Jul 25, 2020
bhcleek added a commit that referenced this pull request Jul 25, 2020
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.

None yet

3 participants