caio.co/de/querycommandcomplete.vim


Read settings from buffer variables first, if available 💬 by Caio 11 years ago (log)
Enable changing settings on a buffer-basis. QueryCommandComplete new
tries to read every configuration setting from the buffer-level
variables (b:qcc_*) before reading the global score ones (g:qcc_*).

This means that now you can have different buffers calling completely
different completion functions (and options).

This patch builds on top of the idea bootstrapped by @equalsraf
on his branch[1].

[1]: https://github.com/equalsraf/querycommandcomplete.vim/commit/7e9a7a602f4ae9c0355ca27cada4ba7173c6ec59

Blob README

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Query Command Complete
======================

Vim plugin to suggest completions with the results of an external
query command.

The original intention is to use it as a mutt query_command wrapper
to complete addresses in the mail headers, but it can be adapted
to any other kind of functionality by modifying the exposed setting
parameters.

Last Change: 2013 Jun 16
Author: Caio Romão (http://caioromao.com)
License: This file is placed in the public domain
Contributors:
  Brian Henderson https://github.com/bhenderson
  Mark Stillwell  https://github.com/marklee77
  Rui Abreu Ferreira http://ruiabreu.org

Setup:
  This plugin exports the completion function QueryCommandComplete,
  which can be set as the complete function (or omni function) for
  any filetype. If you have a working mutt setup with query_command
  configured, the plugin works out of the box.

  Example:
      let g:qcc_query_command='abook'
      au BufRead /tmp/mutt* setlocal omnifunc=QueryCommandComplete

Settings:
  Note: Overriding settings on a buffer-basis is supported. So
        b:qcc_query_command takes precedence over g:qcc_query_command

  g:qcc_query_command
      External command that queries for contacts
      If empty, QueryCommandComplete tries to guess what command to
      run by executing `mutt -Q query_command`.

  g:qcc_line_separator
      Separator for each entry in the result from the query
      default: '\n'

  g:qcc_field_separator
      Separator for the fields of an entry from the result
      default: '\t'

  g:qcc_pattern
      Pattern used to match against the current line to decide
      whether to call the query command
      default: '^\(To\|Cc\|Bcc\|From\|Reply-To\):'

  g:qcc_multiline
      Whether to try matching g:qcc_pattern against the current
      and any previous line
      default: 0

  g:qcc_multiline_pattern
      Pattern to match against the current line when deciding
      wether to keep looking for a line that matches g:qcc_pattern
      This provides finer control over the recursion, which
      is useful if calling the completion on really big files.
      default: '.*'

  g:qcc_format_word
      Format string to be used when building the word field
      of the completion (i.e.: the final result, what gets fed into
      the current line when you select an option)
      default: '${1} <${0}>' (as in: FirstName <email@domain.com>)

  g:qcc_format_abbr
      Format string to be used when building the abbreviation
      for the completion menu (i.e.: the first row in the completion
      menu).
      default: '${1}'

  g:qcc_format_menu
      Format string for the optional second column of the completion
      menu.
      default: '${2}'