Auto merge of #3316 - micbou:command-line-window, r=micbou
[READY] Allow completion in the command-line window This implements @puremourning's suggestion from https://github.com/Valloric/YouCompleteMe/pull/1415#issuecomment-460197058 and adds an entry in the FAQ on how to override the `TAB` mapping in the command-line window. Since the `CmdwinEnter` event is triggered instead of `BufEnter` in that window, the `s:OnBufferEnter` function is called for that event too. Also, the contents of that window are empty when the filetype is set the first time so we ignore the `FileType` event in that window. Finally, the `qf` filetype is removed from the `g:ycm_filetype_blacklist` option since the quickfix window is always ignored. This needs testing as these changes may not work well with plugins that create special buffers. We may have to blacklist the filetype of these buffers. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/3316) <!-- Reviewable:end -->
This commit is contained in:
commit
66cd93e96f
14
README.md
14
README.md
@ -2215,9 +2215,9 @@ Default: `[see next line]`
|
||||
```viml
|
||||
let g:ycm_filetype_blacklist = {
|
||||
\ 'tagbar': 1,
|
||||
\ 'qf': 1,
|
||||
\ 'notes': 1,
|
||||
\ 'markdown': 1,
|
||||
\ 'netrw': 1,
|
||||
\ 'unite': 1,
|
||||
\ 'text': 1,
|
||||
\ 'vimwiki': 1,
|
||||
@ -3542,6 +3542,18 @@ more details.
|
||||
This is a Vim bug fixed in version 8.1.0256. Update your Vim to this version or
|
||||
later.
|
||||
|
||||
### `TAB` is already mapped to trigger completion in the command-line window
|
||||
|
||||
Vim automatically maps the key set by the `wildchar` option, which is `TAB` by
|
||||
default, to complete commands in the command-line window. If you would prefer
|
||||
using this key to cycle through YCM's suggestions without changing the value of
|
||||
`wildchar`, add the following to your vimrc:
|
||||
|
||||
```viml
|
||||
autocmd CmdwinEnter * inoremap <expr><buffer> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" : "\<TAB>"
|
||||
```
|
||||
|
||||
Contributor Code of Conduct
|
||||
---------------------------
|
||||
|
||||
|
@ -45,6 +45,11 @@ let s:pollers = {
|
||||
\ 'wait_milliseconds': 100
|
||||
\ }
|
||||
\ }
|
||||
let s:buftype_blacklist = {
|
||||
\ 'help': 1,
|
||||
\ 'terminal': 1,
|
||||
\ 'quickfix': 1
|
||||
\ }
|
||||
|
||||
|
||||
" When both versions are available, we prefer Python 3 over Python 2:
|
||||
@ -132,7 +137,7 @@ function! youcompleteme#Enable()
|
||||
" filetype) and if so, the FileType event has triggered before and thus the
|
||||
" buffer is already parsed.
|
||||
autocmd FileType * call s:OnFileTypeSet()
|
||||
autocmd BufEnter * call s:OnBufferEnter()
|
||||
autocmd BufEnter,CmdwinEnter * call s:OnBufferEnter()
|
||||
autocmd BufUnload * call s:OnBufferUnload()
|
||||
autocmd InsertLeave * call s:OnInsertLeave()
|
||||
autocmd VimLeave * call s:OnVimLeave()
|
||||
@ -428,23 +433,23 @@ endfunction
|
||||
|
||||
|
||||
function! s:AllowedToCompleteInBuffer( buffer )
|
||||
let buffer_filetype = getbufvar( a:buffer, '&filetype' )
|
||||
let buftype = getbufvar( a:buffer, '&buftype' )
|
||||
|
||||
if empty( buffer_filetype ) ||
|
||||
\ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' ||
|
||||
\ buffer_filetype ==# 'qf'
|
||||
if has_key( s:buftype_blacklist, buftype )
|
||||
return 0
|
||||
endif
|
||||
|
||||
if s:DisableOnLargeFile( a:buffer )
|
||||
let filetype = getbufvar( a:buffer, '&filetype' )
|
||||
|
||||
if empty( filetype ) || s:DisableOnLargeFile( a:buffer )
|
||||
return 0
|
||||
endif
|
||||
|
||||
let whitelist_allows = type( g:ycm_filetype_whitelist ) != type( {} ) ||
|
||||
\ has_key( g:ycm_filetype_whitelist, '*' ) ||
|
||||
\ has_key( g:ycm_filetype_whitelist, buffer_filetype )
|
||||
\ has_key( g:ycm_filetype_whitelist, filetype )
|
||||
let blacklist_allows = type( g:ycm_filetype_blacklist ) != type( {} ) ||
|
||||
\ !has_key( g:ycm_filetype_blacklist, buffer_filetype )
|
||||
\ !has_key( g:ycm_filetype_blacklist, filetype )
|
||||
|
||||
let allowed = whitelist_allows && blacklist_allows
|
||||
if allowed
|
||||
@ -528,6 +533,13 @@ endfunction
|
||||
|
||||
|
||||
function! s:OnFileTypeSet()
|
||||
" The contents of the command-line window are empty when the filetype is set
|
||||
" for the first time. Users should never change its filetype so we only rely
|
||||
" on the CmdwinEnter event for that window.
|
||||
if !empty( getcmdwintype() )
|
||||
return
|
||||
endif
|
||||
|
||||
if !s:AllowedToCompleteInCurrentBuffer()
|
||||
return
|
||||
endif
|
||||
|
@ -181,6 +181,7 @@ module could not be loaded" |youcompleteme-on-windows-i-get-e887-sorry-this-comm
|
||||
35. YCM does not shut down when I quit Vim |youcompleteme-ycm-does-not-shut-down-when-i-quit-vim|
|
||||
36. YCM does not work with my Anaconda Python setup |youcompleteme-ycm-does-not-work-with-my-anaconda-python-setup|
|
||||
37. Automatic import insertion after selecting a completion breaks undo |youcompleteme-automatic-import-insertion-after-selecting-completion-breaks-undo|
|
||||
38. 'TAB' is already mapped to trigger completion in the command-line window |youcompleteme-tab-is-already-mapped-to-trigger-completion-in-command-line-window|
|
||||
14. Contributor Code of Conduct |youcompleteme-contributor-code-of-conduct|
|
||||
15. Contact |youcompleteme-contact|
|
||||
16. License |youcompleteme-license|
|
||||
@ -2331,9 +2332,9 @@ Default: '[see next line]'
|
||||
>
|
||||
let g:ycm_filetype_blacklist = {
|
||||
\ 'tagbar': 1,
|
||||
\ 'qf': 1,
|
||||
\ 'notes': 1,
|
||||
\ 'markdown': 1,
|
||||
\ 'netrw': 1,
|
||||
\ 'unite': 1,
|
||||
\ 'text': 1,
|
||||
\ 'vimwiki': 1,
|
||||
@ -3601,6 +3602,18 @@ Automatic import insertion after selecting a completion breaks undo ~
|
||||
This is a Vim bug fixed in version 8.1.0256. Update your Vim to this version or
|
||||
later.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*youcompleteme-tab-is-already-mapped-to-trigger-completion-in-command-line-window*
|
||||
'TAB' is already mapped to trigger completion in the command-line window ~
|
||||
|
||||
Vim automatically maps the key set by the 'wildchar' option, which is 'TAB' by
|
||||
default, to complete commands in the command-line window. If you would prefer
|
||||
using this key to cycle through YCM's suggestions without changing the value of
|
||||
'wildchar', add the following to your vimrc:
|
||||
>
|
||||
autocmd CmdwinEnter * inoremap <expr><buffer> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" : "\<TAB>"
|
||||
<
|
||||
===============================================================================
|
||||
*youcompleteme-contributor-code-of-conduct*
|
||||
Contributor Code of Conduct ~
|
||||
|
@ -91,7 +91,6 @@ let g:ycm_filetype_whitelist =
|
||||
let g:ycm_filetype_blacklist =
|
||||
\ get( g:, 'ycm_filetype_blacklist', {
|
||||
\ 'tagbar': 1,
|
||||
\ 'qf': 1,
|
||||
\ 'notes': 1,
|
||||
\ 'markdown': 1,
|
||||
\ 'netrw': 1,
|
||||
|
Loading…
Reference in New Issue
Block a user