All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 Save g:ale_completion_autoimport
3 Save g:ale_completion_max_suggestions
5 let g:ale_completion_max_suggestions = 50
10 unlet! b:ale_completion_info
12 Execute(Should handle Rust completion results correctly):
13 let g:ale_completion_autoimport = 0
17 \ {'word': 'new', 'dup': 0, 'menu': 'pub fn new() -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
18 \ {'word': 'with_capacity', 'dup': 0, 'menu': 'pub fn with_capacity(capacity: usize) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
19 \ {'word': 'from_utf8', 'dup': 0, 'menu': 'pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error>', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
20 \ {'word': 'from_utf8_lossy', 'dup': 0, 'menu': 'pub fn from_utf8_lossy<''a>(v: &''a [u8]) -> Cow<''a, str>', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
21 \ {'word': 'from_utf16', 'dup': 0, 'menu': 'pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error>', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
22 \ {'word': 'from_utf16_lossy', 'dup': 0, 'menu': 'pub fn from_utf16_lossy(v: &[u16]) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
23 \ {'word': 'from_raw_parts', 'dup': 0, 'menu': 'pub unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
24 \ {'word': 'from_utf8_unchecked', 'dup': 0, 'menu': 'pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
25 \ {'word': 'from_iter', 'dup': 0, 'menu': 'fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
26 \ {'word': 'from_iter', 'dup': 0, 'menu': 'fn from_iter<I: IntoIterator<Item = &''a char>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
27 \ {'word': 'from_iter', 'dup': 0, 'menu': 'fn from_iter<I: IntoIterator<Item = &''a str>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
28 \ {'word': 'from_iter', 'dup': 0, 'menu': 'fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
29 \ {'word': 'from_iter', 'dup': 0, 'menu': 'fn from_iter<I: IntoIterator<Item = Cow<''a, str>>>(iter: I) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
30 \ {'word': 'Searcher', 'dup': 0, 'menu': 'type Searcher = <&''b str as Pattern<''a>>::Searcher;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
31 \ {'word': 'default', 'dup': 0, 'menu': 'fn default() -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
32 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = String;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
33 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
34 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
35 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
36 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
37 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
38 \ {'word': 'Output', 'dup': 0, 'menu': 'type Output = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
39 \ {'word': 'Target', 'dup': 0, 'menu': 'type Target = str;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
40 \ {'word': 'Err', 'dup': 0, 'menu': 'type Err = ParseError;', 'info': '', 'kind': 't', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
41 \ {'word': 'from_str', 'dup': 0, 'menu': 'fn from_str(s: &str) -> Result<String, ParseError>', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
42 \ {'word': 'from', 'dup': 0, 'menu': 'fn from(s: &''a str) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
43 \ {'word': 'from', 'dup': 0, 'menu': 'fn from(s: Box<str>) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
44 \ {'word': 'from', 'dup': 0, 'menu': 'fn from(s: Cow<''a, str>) -> String', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
45 \ {'word': 'to_vec', 'dup': 0, 'menu': 'pub fn to_vec(&self) -> Vec<T> where T: Clone,', 'info': '', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
47 \ ale#completion#ParseLSPCompletions({
54 \ "detail":"pub fn new() -> String"
57 \ "label":"with_capacity",
59 \ "detail":"pub fn with_capacity(capacity: usize) -> String"
62 \ "label":"from_utf8",
64 \ "detail":"pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error>"
67 \ "label":"from_utf8_lossy",
69 \ "detail":"pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> Cow<'a, str>"
72 \ "label":"from_utf16",
74 \ "detail":"pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error>"
77 \ "label":"from_utf16_lossy",
79 \ "detail":"pub fn from_utf16_lossy(v: &[u16]) -> String"
82 \ "label":"from_raw_parts",
84 \ "detail":"pub unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> String"
87 \ "label":"from_utf8_unchecked",
89 \ "detail":"pub unsafe fn from_utf8_unchecked(bytes: Vec<u8>) -> String"
92 \ "label":"from_iter",
94 \ "detail":"fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> String"
97 \ "label":"from_iter",
99 \ "detail":"fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> String"
102 \ "label":"from_iter",
104 \ "detail":"fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> String"
107 \ "label":"from_iter",
109 \ "detail":"fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> String"
112 \ "label":"from_iter",
114 \ "detail":"fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> String"
117 \ "label":"Searcher",
119 \ "detail":"type Searcher = <&'b str as Pattern<'a>>::Searcher;"
124 \ "detail":"fn default() -> String"
129 \ "detail":"type Output = String;"
134 \ "detail":"type Output = str;"
139 \ "detail":"type Output = str;"
144 \ "detail":"type Output = str;"
149 \ "detail":"type Output = str;"
154 \ "detail":"type Output = str;"
159 \ "detail":"type Output = str;"
164 \ "detail":"type Target = str;"
169 \ "detail":"type Err = ParseError;"
172 \ "label":"from_str",
174 \ "detail":"fn from_str(s: &str) -> Result<String, ParseError>"
179 \ "detail":"fn from(s: &'a str) -> String"
184 \ "detail":"fn from(s: Box<str>) -> String"
189 \ "detail":"fn from(s: Cow<'a, str>) -> String"
194 \ "detail":"pub fn to_vec(&self) -> Vec<T>\nwhere\n T: Clone,"
199 Execute(Should handle Python completion results correctly):
200 let g:ale_completion_autoimport = 0
201 let b:ale_completion_info = {
202 \ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
207 \ {'word': 'what', 'dup': 0, 'menu': 'example-python-project.bar.Bar', 'info': "what()\n\n", 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
209 \ ale#completion#ParseLSPCompletions({
213 \ "isIncomplete":v:false,
218 \ "detail":"example-python-project.bar.Bar",
219 \ "documentation":"what()\n\n",
220 \ "sortText":"awhat",
221 \ "insertText":"what"
224 \ "label":"__class__",
227 \ "documentation":"type(object_or_name, bases, dict)\ntype(object) -> the object's type\ntype(name, bases, dict) -> a new type",
228 \ "sortText":"z__class__",
229 \ "insertText":"__class__"
232 \ "label":"__delattr__(name)",
235 \ "documentation":"Implement delattr(self, name).",
236 \ "sortText":"z__delattr__",
237 \ "insertText":"__delattr__"
240 \ "label":"__dir__()",
243 \ "documentation":"__dir__() -> list\ndefault dir() implementation",
244 \ "sortText":"z__dir__",
245 \ "insertText":"__dir__"
251 \ "documentation":"str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",
252 \ "sortText":"z__doc__",
253 \ "insertText":"__doc__"
256 \ "label":"__eq__(value)",
259 \ "documentation":"Return self==value.",
260 \ "sortText":"z__eq__",
261 \ "insertText":"__eq__"
264 \ "label":"__format__()",
267 \ "documentation":"default object formatter",
268 \ "sortText":"z__format__",
269 \ "insertText":"__format__"
272 \ "label":"__ge__(value)",
275 \ "documentation":"Return self>=value.",
276 \ "sortText":"z__ge__",
277 \ "insertText":"__ge__"
280 \ "label":"__getattribute__(name)",
283 \ "documentation":"Return getattr(self, name).",
284 \ "sortText":"z__getattribute__",
285 \ "insertText":"__getattribute__"
288 \ "label":"__gt__(value)",
291 \ "documentation":"Return self>value.",
292 \ "sortText":"z__gt__",
293 \ "insertText":"__gt__"
296 \ "label":"__hash__()",
299 \ "documentation":"Return hash(self).",
300 \ "sortText":"z__hash__",
301 \ "insertText":"__hash__"
304 \ "label":"__init__(args, kwargs)",
307 \ "documentation":"Initialize self.\u00a0\u00a0See help(type(self)) for accurate signature.",
308 \ "sortText":"z__init__",
309 \ "insertText":"__init__"
312 \ "label":"__init_subclass__()",
315 \ "documentation":"This method is called when a class is subclassed.\n\nThe default implementation does nothing. It may be\noverridden to extend subclasses.",
316 \ "sortText":"z__init_subclass__",
317 \ "insertText":"__init_subclass__"
320 \ "label":"__le__(value)",
323 \ "documentation":"Return self<=value.",
324 \ "sortText":"z__le__",
325 \ "insertText":"__le__"
328 \ "label":"__lt__(value)",
331 \ "documentation":"Return self<value.",
332 \ "sortText":"z__lt__",
333 \ "insertText":"__lt__"
336 \ "label":"__ne__(value)",
339 \ "documentation":"Return self!=value.",
340 \ "sortText":"z__ne__",
341 \ "insertText":"__ne__"
344 \ "label":"__new__(kwargs)",
347 \ "documentation":"Create and return a new object.\u00a0\u00a0See help(type) for accurate signature.",
348 \ "sortText":"z__new__",
349 \ "insertText":"__new__"
352 \ "label":"__reduce__()",
355 \ "documentation":"helper for pickle",
356 \ "sortText":"z__reduce__",
357 \ "insertText":"__reduce__"
360 \ "label":"__reduce_ex__()",
363 \ "documentation":"helper for pickle",
364 \ "sortText":"z__reduce_ex__",
365 \ "insertText":"__reduce_ex__"
368 \ "label":"__repr__()",
371 \ "documentation":"Return repr(self).",
372 \ "sortText":"z__repr__",
373 \ "insertText":"__repr__"
376 \ "label":"__setattr__(name, value)",
379 \ "documentation":"Implement setattr(self, name, value).",
380 \ "sortText":"z__setattr__",
381 \ "insertText":"__setattr__"
384 \ "label":"__sizeof__()",
387 \ "documentation":"__sizeof__() -> int\nsize of object in memory, in bytes",
388 \ "sortText":"z__sizeof__",
389 \ "insertText":"__sizeof__"
392 \ "label":"__str__()",
395 \ "documentation":"Return str(self).",
396 \ "sortText":"z__str__",
397 \ "insertText":"__str__"
400 \ "label":"__subclasshook__()",
403 \ "documentation":"Abstract classes can override this to customize issubclass().\n\nThis is invoked early on by abc.ABCMeta.__subclasscheck__().\nIt should return True, False or NotImplemented.\u00a0\u00a0If it returns\nNotImplemented, the normal algorithm is used.\u00a0\u00a0Otherwise, it\noverrides the normal algorithm (and the outcome is cached).",
404 \ "sortText":"z__subclasshook__",
405 \ "insertText":"__subclasshook__"
411 Execute(Should handle extra Python completion results correctly):
412 let g:ale_completion_autoimport = 0
414 let b:ale_completion_info = {
415 \ 'completion_filter': 'ale#completion#python#CompletionItemFilter',
421 \ {'word': 'migrations', 'dup': 0, 'menu': 'xxx', 'info': 'migrations', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
422 \ {'word': 'MigEngine', 'dup': 0, 'menu': 'xxx', 'info': 'mig engine', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
424 \ ale#completion#ParseLSPCompletions({
428 \ 'isIncomplete': v:false,
431 \ 'label': 'migrations',
434 \ 'documentation': 'migrations',
437 \ 'label': 'MigEngine',
440 \ 'documentation': 'mig engine',
443 \ 'label': 'ignore me',
446 \ 'documentation': 'nope',
452 Execute(Should handle missing keys):
453 let g:ale_completion_autoimport = 0
457 \ {'word': 'x', 'dup': 0, 'menu': '', 'info': '', 'kind': 'v', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
459 \ ale#completion#ParseLSPCompletions({
463 \ 'isIncomplete': v:false,
472 Execute(Should handle documentation in the markdown format):
473 let g:ale_completion_autoimport = 0
477 \ {'word': 'migrations', 'dup': 0, 'menu': 'xxx', 'info': 'Markdown documentation', 'kind': 'f', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
479 \ ale#completion#ParseLSPCompletions({
483 \ 'isIncomplete': v:false,
486 \ 'label': 'migrations',
490 \ 'kind': 'markdown',
491 \ 'value': 'Markdown documentation',
498 Execute(Should handle completion messages with textEdit objects):
499 let g:ale_completion_autoimport = 0
503 \ {'word': 'next_callback', 'dup': 0, 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
505 \ ale#completion#ParseLSPCompletions({
509 \ 'isIncomplete': v:false,
512 \ 'detail': 'PlayTimeCallback',
513 \ 'filterText': 'next_callback',
514 \ 'insertText': 'ignoreme',
515 \ 'insertTextFormat': 1,
517 \ 'label': ' next_callback',
518 \ 'sortText': '3ee19999next_callback',
520 \ 'newText': 'next_callback',
522 \ 'end': {'character': 13, 'line': 12},
523 \ 'start': {'character': 4, 'line': 12},
531 Execute(Should handle completion messages with textEdit objects and no insertTextFormat key):
532 let g:ale_completion_autoimport = 0
536 \ {'word': 'next_callback', 'dup': 0, 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
538 \ ale#completion#ParseLSPCompletions({
542 \ 'isIncomplete': v:false,
545 \ 'detail': 'PlayTimeCallback',
546 \ 'filterText': 'next_callback',
547 \ 'insertText': 'ignoreme',
549 \ 'label': ' next_callback',
550 \ 'sortText': '3ee19999next_callback',
552 \ 'newText': 'next_callback',
554 \ 'end': {'character': 13, 'line': 12},
555 \ 'start': {'character': 4, 'line': 12},
563 Execute(Should handle completion messages with the deprecated insertText attribute):
564 let g:ale_completion_autoimport = 0
568 \ {'word': 'next_callback', 'dup': 0, 'menu': 'PlayTimeCallback', 'info': '', 'kind': 'v', 'icase': 1, 'user_data': json_encode({'_ale_completion_item': 1})},
570 \ ale#completion#ParseLSPCompletions({
574 \ 'isIncomplete': v:false,
577 \ 'detail': 'PlayTimeCallback',
578 \ 'filterText': 'next_callback',
579 \ 'insertText': 'next_callback',
580 \ 'insertTextFormat': 1,
582 \ 'label': ' next_callback',
583 \ 'sortText': '3ee19999next_callback',
589 Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
590 let g:ale_completion_autoimport = 1
595 \ 'word': 'next_callback',
597 \ 'menu': 'PlayTimeCallback',
601 \ 'user_data': json_encode({
602 \ '_ale_completion_item': 1,
605 \ 'description': 'completion',
608 \ 'fileName': expand('#' . bufnr('') . ':p'),
619 \ 'newText': 'from "module" import next_callback',
629 \ ale#completion#ParseLSPCompletions({
633 \ 'isIncomplete': v:false,
636 \ 'detail': 'PlayTimeCallback',
637 \ 'filterText': 'next_callback',
638 \ 'insertText': 'next_callback',
639 \ 'insertTextFormat': 1,
641 \ 'label': ' next_callback',
642 \ 'sortText': '3ee19999next_callback',
643 \ 'additionalTextEdits': [
655 \ 'newText': 'from "module" import next_callback',
663 Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
664 let g:ale_completion_autoimport = 0
665 let b:ale_completion_info = {'line': 30}
669 \ ale#completion#ParseLSPCompletions({
673 \ 'isIncomplete': v:false,
676 \ 'detail': 'PlayTimeCallback',
677 \ 'filterText': 'next_callback',
678 \ 'insertText': 'next_callback',
679 \ 'insertTextFormat': 1,
681 \ 'label': ' next_callback',
682 \ 'sortText': '3ee19999next_callback',
683 \ 'additionalTextEdits': [
695 \ 'newText': 'from "module" import next_callback',
703 Execute(Should still handle completion messages with empty additionalTextEdits with ale_completion_autoimport turned off):
704 let g:ale_completion_autoimport = 0
709 \ 'word': 'next_callback',
711 \ 'menu': 'PlayTimeCallback',
715 \ 'user_data': json_encode({'_ale_completion_item': 1}),
718 \ ale#completion#ParseLSPCompletions({
722 \ 'isIncomplete': v:false,
725 \ 'detail': 'PlayTimeCallback',
726 \ 'filterText': 'next_callback',
727 \ 'insertText': 'next_callback',
728 \ 'insertTextFormat': 1,
730 \ 'label': ' next_callback',
731 \ 'sortText': '3ee19999next_callback',
732 \ 'additionalTextEdits': [],