Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ubaldot/vim-poptools

Exploit popups as much as you can!
https://github.com/ubaldot/vim-poptools

vim9 vim9-plugin

Last synced: 11 days ago
JSON representation

Exploit popups as much as you can!

Awesome Lists containing this project

README

        

# vim-poptools

Exploit popups as much as you can!




* Vim-poptools *

This plugin aims to scale your productivity by conveniently using popups for a
multitude of tasks, from finding files and directories, to setting your
favorite colorscheme.

It is more essential compared to similar plugins such as [fzf][0], [fuzzyy][1]
or [scope][2]. Under some circumstances it may be slower, but I don't mind
waiting a bit when the search process takes a while; it helps me pause and
reflect on what I am doing, giving my brain some breathing room.

Nevertheless, I personally like the interface and how it displays all the
results at once. Additionally, I find the opportunity of saving the last
search very handy. The configuration is also fairly straightforward.

### Commands

At the moment the following is what you can search and show in popups. I guess
the commands are self-explanatory:

```
:PoptoolsFindFile
:PoptoolsFindFileInPath # Takes into account the setting of :h 'path'.
:PoptoolsFindDir
:PoptoolsBuffers
:PoptoolsRecentFiles
:PoptoolsCmdHistory
:PoptoolsColorscheme # The displayed colors depends on the value of :h 'background'
:PoptoolsGrepInBuffer # Find pattern in the current buffer
:PoptoolsGrep # External grep. Grep command is displayed.
:PoptoolsVimgrep # Vimgrep, show results in the quickfix-list instead of a popup.
:PoptoolsLastSearch # Show the last search results
```

... and if you are curious, the following is how I mapped them in my `.vimrc`:

```
nnoremap PoptoolsFindFile
nnoremap f PoptoolsFindFile
nnoremap l PoptoolsLastSearch
nnoremap PoptoolsBuffers
nnoremap h PoptoolsCmdHistory
xnoremap h PoptoolsCmdHistory
nnoremap d PoptoolsFindDir
nnoremap o PoptoolsRecentFiles
nnoremap g PoptoolsGrep
```

## File search

`PoptoolsFindFile` and `PoptoolsFindInPath`

These commands take into account the setting of `:h 'wildignore'`,
`:h 'wildoptions'` and `:h 'path'` options, so if you want to include/exclude
some search path, you must adjust such options.

By default, hidden files are excluded. If you want to find them, then you must
add `.` at the beginning of the search pattern, e.g. use `.git*` to get e.g.
`.gitignore`.

Hidden files are searched in non-hidden folders. To find files in a hidden
folder, you must first `cd` into such a folder. For example, `cd ~/.vim`
followed by `PopupFindFiles` will search files inside the `.vim` folder.

`PoptoolsGrep`

This command uses an external "grep" program and therefore it is not affected
by the Vim options settings. The default "grep" commands are the following:

```
cmd_win_default = $'powershell -NoProfile -ExecutionPolicy Bypass -Command "for /R \"{search_dir}\" %f in ({files}) do @findstr /C:\"{what}\" /N \"%f\""' # Not working yet
cmd_nix_default = $'grep -nrH --include="{files}" "{what}" {search_dir}'
```

where the values of `{what}`,`{files}` and `{search_dir}` are replaced by user input.

### Folder search

To find hidden folders with `PopupFindDir` command, just add a `.` in front of
the search pattern, e.g. `.git*`. That will return e.g. `.git/, .github/`,
etc.

## Configuration

If you don't like the default behavior, there is room for some customization.
You can do it through Vim the options `:h 'wildignore'`, `:h 'wildoptions'`
and `:h 'path'` and/or through the `g:poptools_config` dictionary that you can
set as it follows.

To do that, be sure to create an empty dictionary in your `.vimrc` file, i.e.
`g:poptools_config = {}`.

### Preview window

You may not want the preview window in every case. For example, you want it
when you _grep_ but not when you open recent files. You can specify when you
want the following keys:

```
'preview_file',
'preview_file_in_path',
'preview_recent_files',
'preview_buffer',
'preview_grep'.
```

You can for example specify
`g:poptools_config['preview_grep'] = true, g:poptools_config['preview_recent_files'] = false,`
to have a preview window in your grep result list, but not in the recent files
list.

Syntax highlight in the preview can be handy, but it may slow down the user
experience. You can avoid using syntax highlight in the preview window by
setting `g:poptools_config['preview_syntax'] = false`. This is useful in case
you are encountering troubles when using the preview window. The match are
still highlighted.

All the boolean values in the `g:poptools_config` are set to `true` as
default.

It follows an example of configuration:

```
g:poptools_config = {}`
g:poptools_config['preview_syntax'] = false
g:poptools_config['preview_recent_files'] = false
```

[0]: https://github.com/junegunn/fzf.vim
[1]: https://github.com/Donaldttt/fuzzyy
[2]: https://github.com/girishji/scope.vim