Mercurial > vim
comparison runtime/doc/quickfix.txt @ 20631:d6827bd31d1d v8.2.0869
patch 8.2.0869: it is not possible to customize the quickfix window contents
Commit: https://github.com/vim/vim/commit/858ba06d5f577b187da0367b231f7fa9461cb32d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 31 23:11:59 2020 +0200
patch 8.2.0869: it is not possible to customize the quickfix window contents
Problem: It is not possible to customize the quickfix window contents.
Solution: Add 'quickfixtextfunc'. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5465)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 31 May 2020 23:15:03 +0200 |
parents | 63beef1ca62c |
children | ada6f26e6eb1 |
comparison
equal
deleted
inserted
replaced
20630:b7bfe0a2b961 | 20631:d6827bd31d1d |
---|---|
13 5. Using :grep |grep| | 13 5. Using :grep |grep| |
14 6. Selecting a compiler |compiler-select| | 14 6. Selecting a compiler |compiler-select| |
15 7. The error format |error-file-format| | 15 7. The error format |error-file-format| |
16 8. The directory stack |quickfix-directory-stack| | 16 8. The directory stack |quickfix-directory-stack| |
17 9. Specific error file formats |errorformats| | 17 9. Specific error file formats |errorformats| |
18 10. Customizing the quickfix window |quickfix-window-function| | |
18 | 19 |
19 The quickfix commands are not available when the |+quickfix| feature was | 20 The quickfix commands are not available when the |+quickfix| feature was |
20 disabled at compile time. | 21 disabled at compile time. |
21 | 22 |
22 ============================================================================= | 23 ============================================================================= |
1919 In $VIMRUNTIME/tools you can find the efm_perl.pl script, which filters Perl | 1920 In $VIMRUNTIME/tools you can find the efm_perl.pl script, which filters Perl |
1920 error messages into a format that quickfix mode will understand. See the | 1921 error messages into a format that quickfix mode will understand. See the |
1921 start of the file about how to use it. (This script is deprecated, see | 1922 start of the file about how to use it. (This script is deprecated, see |
1922 |compiler-perl|.) | 1923 |compiler-perl|.) |
1923 | 1924 |
1924 | 1925 ============================================================================= |
1926 10. Customizing the quickfix window *quickfix-window-function* | |
1927 | |
1928 The default format for the lines displayed in the quickfix window and location | |
1929 list window is: | |
1930 | |
1931 <filename>|<lnum> col <col>|<text> | |
1932 | |
1933 The values displayed in each line correspond to the "bufnr", "lnum", "col" and | |
1934 "text" fields returned by the |getqflist()| function. | |
1935 | |
1936 For some quickfix/location lists, the displayed text need to be customized. | |
1937 For example, if only the filename is present for a quickfix entry, then the | |
1938 two "|" field separator characters after the filename are not needed. Another | |
1939 use case is to customize the path displayed for a filename. By default, the | |
1940 complete path (which may be too long) is displayed for files which are not | |
1941 under the current directory tree. The file path may need to be simplified to a | |
1942 common parent directory. | |
1943 | |
1944 The displayed text can be customized by setting the 'quickfixtextfunc' option | |
1945 to a Vim function. This function will be called with a dict argument for | |
1946 every entry in a quickfix or a location list. The dict argument will have the | |
1947 following fields: | |
1948 | |
1949 quickfix set to 1 when called for a quickfix list and 0 when called for | |
1950 a location list. | |
1951 id quickfix or location list identifier | |
1952 idx index of the entry in the quickfix or location list | |
1953 | |
1954 The function should return a single line of text to display in the quickfix | |
1955 window for the entry identified by idx. The function can obtain information | |
1956 about the current entry using the |getqflist()| function and specifying the | |
1957 quickfix list identifier "id" and the entry index "idx". | |
1958 | |
1959 If a quickfix or location list specific customization is needed, then the | |
1960 'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or | |
1961 |setloclist()| function. This overrides the global 'quickfixtextfunc' option. | |
1962 | |
1963 The example below displays the list of old files (|v:oldfiles|) in a quickfix | |
1964 window. As there is no line, column number and error text information | |
1965 associated with each entry, the 'quickfixtextfunc' function returns only the | |
1966 filename. | |
1967 Example: > | |
1968 " create a quickfix list from v:oldfiles | |
1969 call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f', | |
1970 \ 'quickfixtextfunc' : 'QfOldFiles'}) | |
1971 func QfOldFiles(info) | |
1972 " get information about the specific quickfix entry | |
1973 let e = getqflist({'id' : a:info.id, 'idx' : a:info.idx, | |
1974 \ 'items' : 1}).items[0] | |
1975 " return the simplified file name | |
1976 return fnamemodify(bufname(e.bufnr), ':p:.') | |
1977 endfunc | |
1978 < | |
1925 | 1979 |
1926 vim:tw=78:ts=8:noet:ft=help:norl: | 1980 vim:tw=78:ts=8:noet:ft=help:norl: |