Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bfrg/vim-qf-history
Navigate Vim's quickfix and location-list history using a popup menu
https://github.com/bfrg/vim-qf-history
vim vim-plugin vim-qf vim9script
Last synced: 8 days ago
JSON representation
Navigate Vim's quickfix and location-list history using a popup menu
- Host: GitHub
- URL: https://github.com/bfrg/vim-qf-history
- Owner: bfrg
- Created: 2020-02-20T18:52:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-02T22:07:11.000Z (9 months ago)
- Last Synced: 2024-08-07T18:45:48.843Z (3 months ago)
- Topics: vim, vim-plugin, vim-qf, vim9script
- Language: Vim Script
- Homepage:
- Size: 46.9 KB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-vim9 - vim-qf-history - list history using a popup menu | ✅ | (UI / Quickfix)
README
# vim-qf-history
Quickly navigate Vim's `quickfix` and `location-list` history using a popup
menu.
**Background**
Vim remembers the ten last used quickfix lists, and the ten last used
location-lists for each window. The entire quickfix and location-list stack can
be displayed with `:chistory` and `:lhistory`, respectively. Older quickfix
lists are accessed through `:colder` and `:cnewer`, or directly with
`:[count]chistory` (and similar for location-lists). See `:help
quickfix-error-lists` for more details.
This plugin will display the quickfix and location-list stack in a popup menu
allowing the user to easily switch to an earlier error list. If one of the lists
contains different error types, the total number of each error type (E, W, I, N)
is shown along with the total number of entries. Unknown error types are
displayed in column "?", and empty lists are greyed out.
## Usage
### Commands
- **`:Chistory`** - Display the quickfix history in a popup window and make the
selected list the current list, similar to `:[count]chistory`.
- **`:Lhistory`** - Same as above, but display the location-list history of the
current window, similar to `:[count]lhistory`.
When switching the quickfix or location list through the popup menu, the plugin
will execute the `QuickFixCmdPost` event with the pattern `chistory` and
`lhistory`, respectively.
### Popup mappings
| Key | Description |
| --------------------------------------------- | ------------------------------------------------------------------- |
| j, Down, Tab | Move cursorline down one line. |
| k, up, S-Tab | Move cursorline up one line. |
| g | Move cursorline to top. |
| G | Move cursorline to bottom. |
| q | Close the popup menu. |
| 0 - 9 | Make the respective error list the current list. |
| Enter | Accept current selection. Makes the selected list the current list. |
**Note:** Pressing 0 to 9 will select and automatically
close the popup window. 0 will select the 10th error list, or the
last one in the stack (most recent one) if there are less than ten lists.
### Examples
1. Open quickfix and location-list history with
Leader+c+h and
Leader+l+h, respectively:
```vim
nnoremap ch Chistory
nnoremap lh Lhistory
```
2. Alternatively, if you're not using the default `Select-mode` mappings
(mnemonic: go history):
```vim
nnoremap gh Chistory
nnoremap gH Lhistory
```
3. Print a short info of the selected list in the command-line after switching
lists:
```vim
augroup qf-history
autocmd!
autocmd QuickFixCmdPost chistory echo printf('Quickfix %d of %d (%d items): %s',
\ getqflist({nr: 0}).nr,
\ getqflist({nr: '$'}).nr,
\ getqflist({size: 0}).size,
\ getqflist({title: 0}).title
\ )
autocmd QuickFixCmdPost lhistory echo printf('Location-list %d of %d (%d items): %s',
\ getloclist(0, {nr: 0}).nr,
\ getloclist(0, {nr: '$'}).nr,
\ getloclist(0, {size: 0}).size,
\ getloclist(0, {title: 0}).title
\ )
augroup END
```
4. Automatically open the quickfix or location-list window after selecting a
list in the popup menu:
```vim
augroup qf-history
autocmd!
autocmd QuickFixCmdPost chistory cwindow
autocmd QuickFixCmdPost lhistory lwindow
augroup END
```
## Configuration
### `g:qfhistory`
The appearance of the popup window can be configured through the dictionary
`g:qfhistory`. The following entries are supported:
| Entry | Description | Default |
| ----------------- | ------------------------------------------------------------------- | ------------------------------------------ |
| `title` | Whether to show a popup window title (`0` or `1`). | `true` |
| `padding` | List with numbers defining the padding inside the popup window. | `[1, 1, 1, 1]` |
| `border` | List with numbers (`0` or `1`) specifying whether to draw a border. | `[1, 1, 1, 1]` |
| `borderchars` | List with characters used for drawing the window border. | `['─', '│', '─', '│', '┌', '┐', '┘', '└']` |
| `borderhighlight` | List with highlight group names used for drawing the border. | `['QfHistory']` |
**Note:** when only one `borderchars` or `borderhighlight` item is specified, it
is used on all sides.
### Highlighting
The highlighting of the popup window can be changed through the following
highlight groups:
| Highlight group | Description | Default |
| ------------------- | ----------------------------------------- | --------- |
| `QfHistory` | Popup window background and normal text. | `Pmenu` |
| `QfHistoryHeader` | Top line of the quickfix-history list. | `Title` |
| `QfHistoryCurrent` | Character marking the current error list. | `Title` |
| `QfHistoryEmpty` | Empty error list. | `Comment` |
### Examples
![img][image-examples]
**Left:** no window border and no window title:
```vim
g:qfhistory = {border: [0, 0, 0, 0], title: false}
```
**Center:** border with round corners, padding on left and right side:
```vim
g:qfhistory = {
padding: [0, 1, 0, 1],
borderchars: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'],
borderhighlight: ['MyBoldPopupBorder']
}
```
**Right:** same as middle image but without a window title
```vim
g:qfhistory = {
title: false,
padding: [0, 1, 0, 1],
borderchars: ['─', '│', '─', '│', '╭', '╮', '╯', '╰'],
borderhighlight: ['MyBoldPopupBorder']
}
```
## Installation
Run the following commands in your terminal:
```bash
$ cd ~/.vim/pack/git-plugins/start
$ git clone https://github.com/bfrg/vim-qf-history
$ vim -u NONE -c 'helptags vim-qf-history/doc | quit'
```
**Note:** The directory name `git-plugins` is arbitrary, you can pick any other
name. For more details see `:help packages`. Alternatively, use your favorite
plugin manager.
## Credits
This plugin was inspired by the Vimways article [Colder quickfix lists][vimways]
written by [Nick Jensen][nickspoons].
## License
Distributed under the same terms as Vim itself. See `:help license`.
[vimways]: https://vimways.org/2018/colder-quickfix-lists
[nickspoons]: https://github.com/nickspoons
[image-examples]: https://user-images.githubusercontent.com/6266600/74968239-cb01d800-541a-11ea-87f6-cb6ba9829395.png