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

Extending completions in ftplugin #146

Closed
mg979 opened this issue Mar 31, 2019 · 2 comments
Closed

Extending completions in ftplugin #146

mg979 opened this issue Mar 31, 2019 · 2 comments

Comments

@mg979
Copy link
Contributor

mg979 commented Mar 31, 2019

Since g:mucomplete#user_mappings is only read once, I was thinking of a buffer variable that is read to extend completions, if these are defined in a ftplugin.

In this example I'm using BufEnter because I think it runs after FileType event, and it wouldn't trigger too often. In the extend function I'm not using error or you'd get an error every time, keep could be used but I think it's not so important.

augroup MUcompleteUpdateCompletions
  au!
  au BufEnter * if exists('b:mucomplete_user_mappings')
        \     |   call extend(s:compl_mappings, b:mucomplete_user_mappings)
        \     | endif
augroup END
lifepillar added a commit that referenced this issue Apr 22, 2019
Addresses #146.

I prefer to use a function rather than a buffer variable because changes
to buffer variables should take effect immediately, which would not be
the case for a hypothetical `b:mucomplete_user_mappings` variable.

Note that existing keys cannot be overridden.

See also: #145.
@lifepillar
Copy link
Owner

lifepillar commented Apr 22, 2019

I don't think that a buffer variable is ideal for the situation you describe. I have added a new function to the current master, which can be used as follows (e.g., in your after/ftplugin/python.vim):

call mucomplete#add_user_mapping("python_exception", "\<c-r>=python#exceptions()\<cr>")

Note that you cannot override existing methods this way.

Edit: fix typo.

@mg979
Copy link
Contributor Author

mg979 commented Apr 23, 2019

Thanks it's working

Imgur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants