xaizek / vim-inccomplete (License: Vim) (since 2018-12-07)
Vim plugin for #include directive completion in C family of languages.
Commit d020e8f4811892afb0b03bf5aafead987e19f542

Don't list includes that are already present
This is a very crude implementation of the idea, which lacks:
- proper path comparation function
- handling of conditional includes (surrounded by #ifdef)

The first one is needed and can be implemented, while the second
one is too complex for this plugin. Though we can try to use
syntax groups defined by ifdef.vim plugin.
Author: xaizek
Author date (UTC): 2012-09-03 17:59
Committer name: xaizek
Committer date (UTC): 2012-09-14 20:19
Parent(s): 898ae13c0b841fb9f82b25037d86a6517800a953
Signing key:
Tree: 9df77877571fe48b264c4749b46da9d3351eaee3
File Lines added Lines deleted
plugin/inccomplete.vim 29 0
File plugin/inccomplete.vim changed (mode: 100644) (index de48aec..e053608)
... ... function! ICComplete(findstart, base)
129 129 let l:closebracket = '' let l:closebracket = ''
130 130 endif endif
131 131
132 let l:existend_list = s:ICListIncludes()[l:bracket == '"']
133
132 134 " form list of dictionaries " form list of dictionaries
133 135 let [l:pos, l:sl1, l:sl2] = s:ICParsePath(a:base) let [l:pos, l:sl1, l:sl2] = s:ICParsePath(a:base)
134 136 let l:comlst = [] let l:comlst = []
 
... ... function! ICComplete(findstart, base)
145 147
146 148 let l:strend = g:inccomplete_appendslash ? l:sl2 : '' let l:strend = g:inccomplete_appendslash ? l:sl2 : ''
147 149 let l:slash = l:sl2 let l:slash = l:sl2
150 elseif index(l:existend_list, l:increc[1]) >= 0
151 continue
148 152 else else
149 153 let l:strend = l:closebracket let l:strend = l:closebracket
150 154 let l:slash = '' let l:slash = ''
 
... ... function! ICComplete(findstart, base)
171 175 endif endif
172 176 endfunction endfunction
173 177
178 function! s:ICListIncludes()
179 let l:lines = getline(0, '$')
180 call filter(l:lines, 'v:val =~? &include')
181 call map(l:lines, 'matchstr(v:val, &include.''\s*\zs.*\ze$'')')
182
183 let l:sys = []
184 let l:usr = []
185 for l:include in l:lines
186 if l:include[0] == '<'
187 call add(l:sys, l:include[1:])
188 else
189 call add(l:usr, l:include[1:])
190 endif
191 endfor
192 unlet l:lines
193
194 call map(l:sys, 'matchstr(v:val, ''^[^>]\+'')')
195 call map(l:usr, 'matchstr(v:val, ''^[^"]\+'')')
196
197 " echo l:sys
198 " echo l:usr
199
200 return [l:sys, l:usr]
201 endfunction
202
174 203 " sorts completion list " sorts completion list
175 204 function s:SortList(lst) function s:SortList(lst)
176 205 if g:inccomplete_sort == 'ignorecase' if g:inccomplete_sort == 'ignorecase'
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vim-inccomplete

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vim-inccomplete

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master