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

Improve struct and pointer autocompletion in C #4231

Merged
merged 2 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions autoload/ale/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ scriptencoding utf-8
" only valid in Insert mode. This way, feedkeys() won't send these keys if you
" quit Insert mode quickly enough.
inoremap <silent> <Plug>(ale_show_completion_menu) <C-x><C-o><C-p>
inoremap <silent> <Plug>(ale_stop_completion_menu) <C-x><C-z>
" If we hit the key sequence in normal mode, then we won't show the menu, so
" we should restore the old settings right away.
nnoremap <silent> <Plug>(ale_show_completion_menu) :call ale#completion#RestoreCompletionOptions()<CR>
Expand Down Expand Up @@ -133,6 +134,7 @@ let s:should_complete_map = {
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
\ 'c': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|-\>$',
\}

" Regular expressions for finding the start column to replace with completion.
Expand All @@ -148,6 +150,7 @@ let s:trigger_character_map = {
\ 'typescript': ['.', '''', '"'],
\ 'rust': ['.', '::'],
\ 'cpp': ['.', '::', '->'],
\ 'c': ['.', '->'],
s-marios marked this conversation as resolved.
Show resolved Hide resolved
\}

function! s:GetFiletypeValue(map, filetype) abort
Expand Down Expand Up @@ -978,6 +981,14 @@ function! ale#completion#StopTimer() abort
let s:timer_id = -1
endfunction

" Close the previous completion menu (if any), so that the newer autocompletion
" candidates will show up
function! s:closePreviousCompletionMenu() abort
if exists('*complete_info') && !empty(complete_info(['mode']))
call ale#util#FeedKeys("\<Plug>(ale_stop_completion_menu)")
endif
endfunction

function! ale#completion#Queue() abort
if !get(b:, 'ale_completion_enabled', g:ale_completion_enabled)
return
Expand All @@ -999,6 +1010,8 @@ function! ale#completion#Queue() abort

call ale#completion#StopTimer()

call s:closePreviousCompletionMenu()

let s:timer_id = timer_start(g:ale_completion_delay, function('s:TimerHandler'))
endfunction

Expand Down
1 change: 1 addition & 0 deletions rplugin/python3/deoplete/sources/ale.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, vim):
'rust': r'(\.|::)\w*$',
'typescript': r'(\.|\'|")\w*$',
'cpp': r'(\.|::|->)\w*$',
'c': r'(\.|->)\w*$',
}

# Returns an integer for the start position, as with omnifunc.
Expand Down
1 change: 1 addition & 0 deletions test/python/test_deoplete_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_attributes(self):
'rust': r'(\.|::)\w*$',
'typescript': r'(\.|\'|")\w*$',
'cpp': r'(\.|::|->)\w*$',
'c': r'(\.|->)\w*$',
},
'is_bytepos': True,
'is_volatile': True,
Expand Down