Browse Source

vim: update plugins

master
Maxim Likhachev 3 years ago
parent
commit
f5514ac476
  1. 422
      etc/soft/nvim/+plugins/vim-floaterm/README.md
  2. 42
      etc/soft/nvim/+plugins/vim-floaterm/autoload/clap/provider/floaterm.vim
  3. 41
      etc/soft/nvim/+plugins/vim-floaterm/autoload/coc/source/floaterm.vim
  4. 110
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm.vim
  5. 39
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/buffer.vim
  6. 88
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/cmdline.vim
  7. 114
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/config.vim
  8. 31
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/client.vim
  9. 48
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/editor.vim
  10. 5
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/util.vim
  11. 5
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/setup.vim
  12. 53
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/vim/client.vim
  13. 50
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/vim/editor.vim
  14. 7
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/path.vim
  15. 121
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/terminal.vim
  16. 102
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/util.vim
  17. 173
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/window.vim
  18. 61
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/broot.vim
  19. 26
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/fff.vim
  20. 24
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/fzf.vim
  21. 14
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/lf.vim
  22. 14
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/nnn.vim
  23. 24
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/ranger.vim
  24. 54
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/rg.vim
  25. 20
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/vifm.vim
  26. 43
      etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/xplr.vim
  27. 59
      etc/soft/nvim/+plugins/vim-floaterm/autoload/health/floaterm.vim
  28. 144
      etc/soft/nvim/+plugins/vim-floaterm/doc/floaterm.txt
  29. 93
      etc/soft/nvim/+plugins/vim-floaterm/plugin/floaterm.vim
  30. 25
      etc/soft/nvim/+plugins/vim-floaterm/test/base_vader.vim
  31. 9
      etc/soft/nvim/+plugins/vim-floaterm/test/test.sh
  32. 9
      etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermKill.vader
  33. 26
      etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermNew.vader
  34. 16
      etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermSend.vader
  35. 31
      etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermShow-FloatermHide.vader
  36. 32
      etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermToggle.vader
  37. 13
      etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_AsyncRun-floaterm-runner.vader
  38. 15
      etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_Clap-floaterm.vader
  39. 14
      etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_Fzf-floaterm.vader
  40. 14
      etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_LeaderF-floaterm.vader
  41. 182
      etc/soft/nvim/+plugins/vim-floaterm/test/test_functions/test-floaterm_cmdline.vader
  42. 4
      etc/soft/nvim/+plugins/vim-floaterm/test/test_functions/test-floaterm_config_get_all.vader
  43. 139
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-autohide.vader
  44. 7
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-autoinsert.vader
  45. 21
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-cwd.vader
  46. 14
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-disposable.vader
  47. 24
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-gitcommit.vader
  48. 31
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-open_command.vader
  49. 33
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-opener.vader
  50. 1
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-silent.vader
  51. 19
      etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-wintype.vader
  52. 49
      etc/soft/nvim/+plugins/vim-floaterm/test/vimrc

422
etc/soft/nvim/+plugins/vim-floaterm/README.md

@ -12,12 +12,13 @@ Use (neo)vim terminal in the floating/popup window. @@ -12,12 +12,13 @@ Use (neo)vim terminal in the floating/popup window.
- [Options](#options)
- [Keymaps](#keymaps)
- [Highlights](#highlights)
- [Autocmd](#autocmd)
- [Advanced Topics](#advanced-topics)
- [Use with command line tools](#use-with-command-line-tools)
- [Use with other plugins](#use-with-other-plugins)
- [How to define more wrappers](#how-to-define-more-wrappers)
- [How to write sources for fuzzy finder plugins](#how-to-write-sources-for-fuzzy-finder-plugins)
- [Wiki](#wiki)
- [Contributing](#contributing)
- [FAQ](#faq)
- [Breaking changes](#breaking-changes)
- [Related projects](#related-projects)
@ -31,10 +32,8 @@ Use (neo)vim terminal in the floating/popup window. @@ -31,10 +32,8 @@ Use (neo)vim terminal in the floating/popup window.
- Customizable terminal window style
- Switch/preview floating terminal buffers using fuzzy-finder plugins such as
[denite.nvim](https://github.com/Shougo/denite.nvim) or
[coc.nvim](https://github.com/neoclide/coc.nvim), etc.
- Use with other external command-line tools(ranger, lf, fzf, etc.)
- Autocompletion from within floaterms(require [coc.nvim](https://github.com/neoclide/coc.nvim)
or [deoplete.nvim](https://github.com/Shougo/deoplete.nvim))
[fzf](https://github.com/junegunn/fzf), etc.
- Use with other external command-line tools(ranger, fzf, ripgrep etc.)
- Use as a custom task runner for [asynctasks.vim](https://github.com/skywind3000/asynctasks.vim)
or [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim)
@ -42,10 +41,15 @@ Use (neo)vim terminal in the floating/popup window. @@ -42,10 +41,15 @@ Use (neo)vim terminal in the floating/popup window.
- Vim or neovim with `terminal` feature
Run `:checkhealth` for more info.
## Installation
- packer.nvim
```lua
use 'voldikss/vim-floaterm'
```
- vim-plug
```vim
@ -67,6 +71,10 @@ If you've opened multiple floaterm instances, they will be attached to a @@ -67,6 +71,10 @@ If you've opened multiple floaterm instances, they will be attached to a
double-circular-linkedlist. Then you can use `:FloatermNext` or
`: FloatermPrev` to switch between them.
**❗Note**: Long-running jobs (e.g. `yarn watch`) inside the builtin terminal
would probably slowdown your operation. It's recommended to put them into the
external terminals.
### Commands
#### `:FloatermNew[!] [options] [cmd]` Open a floaterm window.
@ -78,25 +86,32 @@ double-circular-linkedlist. Then you can use `:FloatermNext` or @@ -78,25 +86,32 @@ double-circular-linkedlist. Then you can use `:FloatermNext` or
attributes of a specific floaterm instance. Note that in order to input
space, you have to form it as `\` followed by space, and `\` must be typed
as `\\`
- `cwd` working directory that floaterm will be opened at, accept either a
path or literal `<root>` which represents the project root directory
- `cwd` working directory that floaterm will be opened at. Accepts a
path, the literal `<root>` which represents the project root directory, and
the literal `<buffer>` which specifies the directory of the active buffer
- `name` name of the floaterm
- `silent` If `--silent` is given, spawn a floaterm but not open the window,
you may toggle it afterwards
- `height` see `g:floaterm_height`
- `width` see `g:floaterm_width`
- `disposable` If `--disposable` is given, the floaterm will be destroyed
once it is hidden.
- `title` see `g:floaterm_title`
- `width` see `g:floaterm_width`
- `height` see `g:floaterm_height`
- `opener` see `g:floaterm_opener`
- `wintype` see `g:floaterm_wintype`
- `position` see `g:floaterm_position`
- `borderchars` see `g:floaterm_borderchars`
- `autoclose` see `g:floaterm_autoclose`
- Use `<TAB>` to get completion.
- This command basically shares the consistent behaviors with the builtin `:terminal` :
- `borderchars` see `g:floaterm_borderchars`
- This command basically shares the consistent behaviors with the builtin `:terminal`:
- The special characters(`:help cmdline-special`) such as `%` and `<cfile>`
will be auto-expanded, to get standalone characters, use `\` followed by
the corresponding character(e.g., `\%`).
- Note that `<bar>`(i.e., `|`) will be seen as an argument of the command,
therefore it can not be followed by another Vim command.
- If execute this command with a range, i.e., `'<,'>:FloatermNew ...`, the
selected lines will be sent to the created floaterm. For example, see
[python repl use case](#python) below.
- Use `<TAB>` to get completion.
For example, the command
@ -104,7 +119,8 @@ For example, the command @@ -104,7 +119,8 @@ For example, the command
:FloatermNew --height=0.6 --width=0.4 --wintype=float --name=floaterm1 --position=topleft --autoclose=2 ranger --cmd="cd ~"
```
will open a new floating/popup floaterm instance named `floaterm1` running `ranger --cmd="cd ~"` in the `topleft` corner of the main window.
will open a new floating/popup floaterm instance named `floaterm1` running
`ranger --cmd="cd ~"` in the `topleft` corner of the main window.
The following command allows you to compile and run your C code in the floaterm window:
@ -132,13 +148,14 @@ The following command allows you to compile and run your C code in the floaterm @@ -132,13 +148,14 @@ The following command allows you to compile and run your C code in the floaterm
attribute is `floaterm_name`. Otherwise create a new floaterm named
`floaterm_name`.
- Use `<TAB>` to get completion.
- If `!` is given, toggle all floaterms
- If `!` is given, toggle all floaterms (`:FloatermHide!` or `: FloatermShow!`)
#### `:[N]FloatermShow[!] [floaterm_name]` Show the current floaterm window.
- If `N` is given, show the floaterm whose buffer number is `N`
- If `floaterm_name` is given, show the floaterm named `floaterm_name`.
- If `!` is given, show all floaterms
- If `!` is given, show all floaterms (If multiple floaterms have the same
position attribute, only one of them will be show)
#### `:[N]FloatermHide[!] [floaterm_name]` Hide the current floaterms window.
@ -152,14 +169,16 @@ The following command allows you to compile and run your C code in the floaterm @@ -152,14 +169,16 @@ The following command allows you to compile and run your C code in the floaterm
- If `floaterm_name` is given, kill the floaterm instance named `floaterm_name`.
- If `!` is given, kill all floaterms
#### `:FloatermSend [--name=floaterm_name] [cmd]` Send command to a job in floaterm.
#### `:FloatermSend[!] [--name=floaterm_name] [cmd]` Send command to a job in floaterm.
- If `--name=floaterm_name` is given, send lines to the floaterm instance
whose `name` is `floaterm_name`. Otherwise use the current floaterm.
- If `cmd` is given, it will be sent to floaterm and selected lines will be ignored.
- This command can also be used with a range, i.e., `'<,'>:FloatermSend [--name=floaterm_name]` to send selected lines to a floaterm.
- This command can also be used with a range, i.e., `'<,'>:FloatermSend [--name=floaterm_name]`
to send selected lines to a floaterm.
- If `cmd` is given, the selected lines will be ignored.
- If use this command with a `!`, i.e., `'<,'>:FloatermSend! [--name=floaterm_name]` the common white spaces in the beginning of lines
- If use this command with a `!`, i.e., `'<,'>:FloatermSend! [--name=floaterm_name]`
the common white spaces in the beginning of lines
will be trimmed while the relative indent between lines will still be
kept.
- Use `<TAB>` to get completion.
@ -195,7 +214,7 @@ Example: `'floaterm($1|$2)'` @@ -195,7 +214,7 @@ Example: `'floaterm($1|$2)'`
#### **`g:floaterm_wintype`**
Type `String`. `'float'`(nvim's floating or vim's popup) by default. Set it to
`'normal'` if your vim/nvim doesn't support `floatwin` or `popupwin` feature.
`'split'` or `'vsplit'` if you don't want to use floating or popup window.
#### **`g:floaterm_width`**
@ -215,9 +234,14 @@ Default: `0.6` @@ -215,9 +234,14 @@ Default: `0.6`
Type `String`. The position of the floating window. Available values:
- If `wintype` is `normal`: `'top'`, `'right'`, `'bottom'`, `'left'`. Default: `'bottom'`
- If `wintype` is `float`: `'top'`, `'right'`, `'bottom'`, `'left'`,
`'center'`, `'topleft'`, `'topright'`, `'bottomleft'`, `'bottomright'`,
- If `wintype` is `split`/`vsplit`: `'leftabove'`, `'aboveleft'`,
`'rightbelow'`, `'belowright'`, `'topleft'`, `'botright'`. Default:
`'botright'`.
It's recommended to have a look at those options meanings, e.g. `:help :leftabove`.
- If `wintype` is `float`: `'top'`, `'bottom'`, `'left'`, `'right'`,
`'topleft'`, `'topright'`, `'bottomleft'`, `'bottomright'`, `'center'`,
`'auto'(at the cursor place)`. Default: `'center'`
In addition, there is another option `'random'` which allows to pick a random
@ -236,56 +260,43 @@ Type `List` of `String`. Markers used to detect the project root directory for ` @@ -236,56 +260,43 @@ Type `List` of `String`. Markers used to detect the project root directory for `
Default: `['.project', '.git', '.hg', '.svn', '.root']`
#### **`g:floaterm_open_command`**
#### **`g:floaterm_opener`**
Type `String`. Command used for opening a file in the outside nvim from within `:terminal`.
Available: `'edit'`, `'split'`, `'vsplit'`, `'tabe'`, `'drop'`. Default: `'edit'`
#### **`g:floaterm_gitcommit`**
Type `String`. Opening strategy for `COMMIT_EDITMSG` window by running `git commit` in the floaterm window. Only works in neovim.
Available: `'edit'`, `'split'`, `'vsplit'`, `'tabe'`, `'drop'` or
[user-defined commands](https://github.com/voldikss/vim-floaterm/issues/259)
Available: `'floaterm'`(open `gitcommit` in the floaterm window), `'split'`(recommended), `'vsplit'`, `'tabe'`.
Default: `''`, which means this is disabled by default(use your own `$GIT_EDITOR`).
Default: `'split'`
#### **`g:floaterm_autoclose`**
Type `Number`. Whether to close floaterm window once the job gets finished.
- `0`: Always do NOT close floaterm window
- `1`: Close window if the job exits normally, otherwise stay it with messages like `[Process exited 101]`
- `1`: Close window if the job exits normally, otherwise stay it with messages
like `[Process exited 101]`
- `2`: Always close floaterm window
Default: `0`.
#### **`g:floaterm_autoinsert`**
Type `Boolean`. Whether to enter Terminal-mode after opening a floaterm.
Default: `v:true`
Default: `1`.
#### **`g:floaterm_autohide`**
Type `Boolean`. Decide whether to hide previous floaterms before switching to or opening a new one.
Type `Number`. Whether to hide previous floaterms before switching to or
opening a another one.
Default: `v:true`.
- `0`: Always do NOT hide previous floaterm windows
- `1`: Only hide those whose position (`b:floaterm_position`) is identical to
that of the floaterm which will be opened
- `2`: Always hide them
#### **`g:floaterm_complete_options`**
Default: `1`.
Type `Dict`. Autocompletion options (The completion from floaterm is synchronous)
Available options:
#### **`g:floaterm_autoinsert`**
- `shortcut`: A string.
- `priority`: Number between 0-99.
- `filetypes`: Array of filetype names this source should be triggered by.
Available for all filetypes when ommited and for no filetypes when empty
- `filter_length`: Array of 2 numbers. Candidates whose length is not
in the range will be removed.
Type `Boolean`. Whether to enter Terminal-mode after opening a floaterm.
Default value: `{'shortcut': 'floaterm', 'priority': 5, 'filter_length': [5, 20]}`
Default: `v:true`
### Keymaps
@ -349,7 +360,10 @@ hi Floaterm guibg=black @@ -349,7 +360,10 @@ hi Floaterm guibg=black
hi FloatermBorder guibg=orange guifg=cyan
```
![](https://user-images.githubusercontent.com/20282795/91368959-fee00f00-e83c-11ea-9002-cab992d30794.png)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91368959-fee00f00-e83c-11ea-9002-cab992d30794.png"/>
</details>
Besides, there is a neovim only highlight group which can be used to configure
no-current-focused window(`:help NormalNC`).
@ -357,11 +371,20 @@ no-current-focused window(`:help NormalNC`). @@ -357,11 +371,20 @@ no-current-focused window(`:help NormalNC`).
```vim
" Configuration example
" Set floaterm window background to gray once the cursor moves out from it
hi FloatermNC guibg=gray
" Set floaterm window foreground to gray once the cursor moves out from it
hi FloatermNC guifg=gray
```
![](https://user-images.githubusercontent.com/20282795/91380259-28a62f80-e857-11ea-833f-11160d15647a.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380259-28a62f80-e857-11ea-833f-11160d15647a.gif"/>
</details>
### Autocmd
```vim
autocmd User FloatermOpen " triggered after opening a new/existed floaterm
```
## Advanced Topics
@ -376,32 +399,34 @@ Normally if you run `vim/nvim somefile.txt` within the builtin terminal, you @@ -376,32 +399,34 @@ Normally if you run `vim/nvim somefile.txt` within the builtin terminal, you
would get another nvim/vim instance running in the subprocess.
[Floaterm](https://github.com/voldikss/vim-floaterm/tree/master/bin), which is
a builtin script in this plugin, allows you to open files from within `: terminal` without starting a nested nvim. To archive that, just literally
replace `vim/nvim` with `floaterm`, i.e., `floaterm somefile.txt`
a builtin script in this plugin, allows you to open files from within `: terminal`
without starting a nested nvim. To achieve that, just literally replace
`vim/nvim` with `floaterm`, e.g. `floaterm somefile.txt`
**❗Note**: This should works both in neovim and vim, but if you are using
neovim, make sure [neovim-remote](https://github.com/mhinz/neovim-remote) has been installed. You can install it via
pip:
```sh
pip install neovim-remote
```
P.S.
P.S. [#208](https://github.com/voldikss/vim-floaterm/issues/208#issuecomment-747829311) describes how to use `gf` in the floating terminal window.
- [#208](https://github.com/voldikss/vim-floaterm/issues/208#issuecomment-747829311)
describes how to use `gf` in the floating terminal window.
- `floaterm` is too long to type? set alias in your `bashrc`, e.g. `alias f=floaterm`
- For configurable open action, refer to [g:floaterm_opener](#gfloaterm_opener)
![](https://user-images.githubusercontent.com/20282795/91380257-27750280-e857-11ea-8d49-d760c009fee0.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380257-27750280-e857-11ea-8d49-d760c009fee0.gif"/>
</details>
#### git
#### [git](https://git-scm.com/)
See `g:floaterm_gitcommit` option.
Execute `git commit` in the terminal window without starting a nested vim/nvim.
Execute `git commit` in the terminal window without starting a nested nvim.
Refer to [g:floaterm_opener](#gfloaterm_opener) for configurable open action
**❗Note**: neovim only feature. Moreover, it also requires [neovim-remote](https://github.com/mhinz/neovim-remote), please install it using `pip3 install neovim-remote`.
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380268-2cd24d00-e857-11ea-8dbd-d39a0bbb105e.gif"/>
</details>
![](https://user-images.githubusercontent.com/20282795/91380268-2cd24d00-e857-11ea-8dbd-d39a0bbb105e.gif)
#### fzf
#### [fzf](https://github.com/junegunn/fzf)
This plugin has implemented a [wrapper](./autoload/floaterm/wrapper/fzf.vim)
for `fzf` command. So it can be used as a tiny fzf plugin.
@ -412,9 +437,45 @@ Try `:FloatermNew fzf` or even wrap this to a new command like this: @@ -412,9 +437,45 @@ Try `:FloatermNew fzf` or even wrap this to a new command like this:
command! FZF FloatermNew fzf
```
![](https://user-images.githubusercontent.com/20282795/91380264-2b088980-e857-11ea-80ff-062b3d3bbf12.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/107140144-10d0ec80-695b-11eb-8c2f-8bd42ae26e6d.gif"/>
</details>
#### [ripgrep](https://github.com/BurntSushi/ripgrep)
This plugin has implemented a [wrapper](./autoload/floaterm/wrapper/rg.vim)
for `rg` command.
#### fff
Try `:FloatermNew rg` or create yourself a new command like this:
```vim
command! Rg FloatermNew --width=0.8 --height=0.8 rg
```
<details>
<summary>Demo</summary>
You can use <button>Alt-A</button> to select all files and <button>Alt-D</button> to deselect them.
Use <button>Ctrl-/</button> to toggle preview.
<img src="https://user-images.githubusercontent.com/20282795/107148083-4c37df00-698c-11eb-80fb-ccfd94fc4419.gif"/>
</details>
#### [broot](https://github.com/Canop/broot)
This plugin has implemented a [wrapper](./autoload/floaterm/wrapper/broot.vim) for `broot`.
Try `:FloatermNew broot` or create yourself a new command like this:
```vim
command! Broot FloatermNew --width=0.8 --height=0.8 broot
```
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/109648379-83696c80-7b95-11eb-8776-071b816cce2d.gif"/>
</details>
#### [fff](https://github.com/dylanaraps/fff)
There is also an [fff wrapper](./autoload/floaterm/wrapper/fff.vim)
@ -424,9 +485,12 @@ Try `:FloatermNew fff` or define a new command: @@ -424,9 +485,12 @@ Try `:FloatermNew fff` or define a new command:
command! FFF FloatermNew fff
```
![](https://user-images.githubusercontent.com/1472981/75105718-9f315d00-567b-11ea-82d1-6f9a6365391f.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/1472981/75105718-9f315d00-567b-11ea-82d1-6f9a6365391f.gif"/>
</details>
#### nnn
#### [nnn](https://github.com/jarun/nnn)
There is also an [nnn wrapper](./autoload/floaterm/wrapper/nnn.vim)
@ -436,11 +500,30 @@ Try `:FloatermNew nnn` or define a new command: @@ -436,11 +500,30 @@ Try `:FloatermNew nnn` or define a new command:
command! NNN FloatermNew nnn
```
![](https://user-images.githubusercontent.com/20282795/91380278-322f9780-e857-11ea-8b1c-d40fc91bb07d.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380278-322f9780-e857-11ea-8b1c-d40fc91bb07d.gif"/>
</details>
#### [xplr](https://github.com/sayanarijit/xplr)
There is also an [xplr wrapper](./autoload/floaterm/wrapper/xplr.vim)
Try `:FloatermNew xplr` or define a new command:
```vim
command! XPLR FloatermNew xplr
```
<details>
<summary>Demo</summary>
<img src="https://s4.gifyu.com/images/ft-xplr9173d6a849e3f6b9.gif"/>
</details>
#### lf
#### [lf](https://github.com/gokcehan/lf)
There is also an [lf wrapper](./autoload/floaterm/wrapper/lf.vim)
There is also an [lf wrapper](./autoload/floaterm/wrapper/lf.vim).
It is recommened to use [lf.vim](https://github.com/ptzz/lf.vim) which is an lf wrapper with more features (Overriding netrw, Lfcd, etc.).
Try `:FloatermNew lf` or define a new command:
@ -448,9 +531,12 @@ Try `:FloatermNew lf` or define a new command: @@ -448,9 +531,12 @@ Try `:FloatermNew lf` or define a new command:
command! LF FloatermNew lf
```
![](https://user-images.githubusercontent.com/20282795/91380274-3065d400-e857-11ea-86df-981adddc04c6.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380274-3065d400-e857-11ea-86df-981adddc04c6.gif"/>
</details>
#### ranger
#### [ranger](https://github.com/ranger/ranger)
This plugin can also be a handy ranger plugin since it also has a [ranger wrapper](./autoload/floaterm/wrapper/ranger.vim)
@ -460,9 +546,12 @@ Try `:FloatermNew ranger` or define a new command: @@ -460,9 +546,12 @@ Try `:FloatermNew ranger` or define a new command:
command! Ranger FloatermNew ranger
```
![](https://user-images.githubusercontent.com/20282795/91380284-3360c480-e857-11ea-9966-34856592d487.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380284-3360c480-e857-11ea-9966-34856592d487.gif"/>
</details>
#### vifm
#### [vifm](https://github.com/vifm/vifm)
There is also a [vifm wrapper](./autoload/floaterm/wrapper/vifm.vim)
@ -472,23 +561,37 @@ Try `:FloatermNew vifm` or define a new command: @@ -472,23 +561,37 @@ Try `:FloatermNew vifm` or define a new command:
command! Vifm FloatermNew vifm
```
![](https://user-images.githubusercontent.com/43941510/77137476-3c888100-6ac2-11ea-90f2-2345c881aa8f.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/43941510/77137476-3c888100-6ac2-11ea-90f2-2345c881aa8f.gif"/>
</details>
#### lazygit
#### [lazygit](https://github.com/jesseduffield/lazygit)
Furthermore, you can also use other command-line programs, such as lazygit, htop, ncdu, etc.
Use `lazygit` for instance:
![](https://user-images.githubusercontent.com/20282795/74755376-0f239a00-52ae-11ea-9261-44d94abe5924.png)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/74755376-0f239a00-52ae-11ea-9261-44d94abe5924.png"/>
</details>
#### python
#### [python](https://www.python.org/)
Use `:FloatermNew python` to open a python shell. After that you can use `: FloatermSend` to send lines to the Python interactive shell.
Use `:FloatermNew python` to open a python shell. After that you can use
`: FloatermSend` to send lines to the Python interactive shell.
Or you can just select lines and execute `:'<,'>FloatermNew --wintype=split python`, then the
selected lines will be sent and executed once a python repl floaterm window is
opened.
This can also work for other languages which have interactive shells, such as lua, node, etc.
![](https://user-images.githubusercontent.com/20282795/91380286-352a8800-e857-11ea-800c-ac54efa7dd72.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380286-352a8800-e857-11ea-800c-ac54efa7dd72.gif"/>
</details>
### Use with other plugins
@ -496,17 +599,23 @@ This can also work for other languages which have interactive shells, such as lu @@ -496,17 +599,23 @@ This can also work for other languages which have interactive shells, such as lu
Use vim-clap to switch/preview floating terminal buffers.
Try `:Clap floaterm`
Install [clap-floaterm](https://github.com/voldikss/clap-floaterm) and try `:Clap floaterm`
![](https://user-images.githubusercontent.com/20282795/91380243-217f2180-e857-11ea-9f64-46e8676adc11.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380243-217f2180-e857-11ea-9f64-46e8676adc11.gif"/>
</details>
#### [denite.nvim](https://github.com/Shougo/denite.nvim)
Use denite to switch/preview/open floating terminal buffers.
Try `:Denite floaterm`
Install [denite-floaterm](https://github.com/delphinus/denite-floaterm) and try `:Denial floaterm`
![](https://user-images.githubusercontent.com/1239245/73604753-17ef4d00-45d9-11ea-967f-ef75927e2beb.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/1239245/73604753-17ef4d00-45d9-11ea-967f-ef75927e2beb.gif"/>
</details>
#### [coc.nvim](https://github.com/neoclide/coc.nvim)
@ -514,7 +623,10 @@ Use CocList to switch/preview/open floating terminal buffers. @@ -514,7 +623,10 @@ Use CocList to switch/preview/open floating terminal buffers.
Install [coc-floaterm](https://github.com/voldikss/coc-floaterm) and try `:CocList floaterm`
![](https://user-images.githubusercontent.com/20282795/91380254-25ab3f00-e857-11ea-9733-d0ae5a954848.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/91380254-25ab3f00-e857-11ea-9733-d0ae5a954848.gif"/>
</details>
#### [fzf](https://github.com/junegunn/fzf)
@ -526,53 +638,14 @@ Install [LeaderF-floaterm](https://github.com/voldikss/LeaderF-floaterm) and try @@ -526,53 +638,14 @@ Install [LeaderF-floaterm](https://github.com/voldikss/LeaderF-floaterm) and try
#### [asynctasks.vim](https://github.com/skywind3000/asynctasks.vim) | [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim)
This plugin can be a runner for asynctasks.vim or asyncrun.vim.
To use it, try the following code in your `vimrc`.
```vim
function! s:run_in_floaterm(opts)
execute 'FloatermNew --position=bottomright' .
\ ' --wintype=float' .
\ ' --height=0.4' .
\ ' --width=0.4' .
\ ' --title=floaterm_runner' .
\ ' --autoclose=0' .
\ ' --silent=' . get(a:opts, 'silent', 0)
\ ' --cwd=' . a:opts.cwd
\ ' ' . a:opts.cmd
" Do not focus on floaterm window, and close it once cursor moves
" If you want to jump to the floaterm window, use <C-w>p
" You can choose whether to use the following code or not
stopinsert | noa wincmd p
augroup close-floaterm-runner
autocmd!
autocmd CursorMoved,InsertEnter * ++nested
\ call timer_start(100, { -> s:close_floaterm_runner() })
augroup END
endfunction
function! s:close_floaterm_runner() abort
if &ft == 'floaterm' | return | endif
for b in tabpagebuflist()
if getbufvar(b, '&ft') == 'floaterm' &&
\ getbufvar(b, 'floaterm_jobexists') == v:false
execute b 'bwipeout!'
break
endif
endfor
autocmd! close-floaterm-runner
endfunction
let g:asyncrun_runner = get(g:, 'asyncrun_runner', {})
let g:asyncrun_runner.floaterm = function('s:run_in_floaterm')
let g:asynctasks_term_pos = 'floaterm'
```
Then your task will be run in the floaterm instance. See asynctasks.vim
[Wiki](https://github.com/skywind3000/asynctasks.vim/wiki/Customize-Runner) for more information.
You can also modify the code in `s: run_in_floaterm` by yourself to meet your
tastes, which is the reason why this code is not made builtin.
This plugin can be a runner for asynctasks.vim or asyncrun.vim. See
[asyncrun.extra](https://github.com/skywind3000/asyncrun.extra) for the
installation and usage.
![](https://user-images.githubusercontent.com/20282795/104123344-b3f70c00-5385-11eb-9f61-0a5703ba78f5.gif)
<details>
<summary>Demo</summary>
<img src="https://user-images.githubusercontent.com/20282795/104123344-b3f70c00-5385-11eb-9f61-0a5703ba78f5.gif"/>
</details>
### How to define more wrappers
@ -585,23 +658,24 @@ There are two ways for a command to be spawned: @@ -585,23 +658,24 @@ There are two ways for a command to be spawned:
[fzf wrapper](./autoload/floaterm/wrapper/fzf.vim)
```vim
function! floaterm#wrapper#fzf#() abort
return ['floaterm $(fzf)', {}, v:true]
function! floaterm#wrapper#fzf#(cmd, jobopts, config) abort
return [v:true, 'floaterm $(fzf)']
endfunction
```
The code above returns a list. `floaterm $(fzf)` is the command to be
executed. `v:true` means the command will be executed after the `&shell`
startup. In this way, the second element of the list must be `{}`.
startup.
- To be executed through `termopen()`/`term_start()` function, in that case, a
callback option can be provided. See [fzf wrapper](./autoload/floaterm/wrapper/fzf.vim)
```vim
function! floaterm#wrapper#fzf#(cmd) abort
function! floaterm#wrapper#fzf#(cmd, jobopts, config) abort
let s:fzf_tmpfile = tempname()
let cmd = a:cmd . ' > ' . s:fzf_tmpfile
return [cmd, {'on_exit': funcref('s:fzf_callback')}, v:false]
let a:jobopts.on_exit = funcref('s:fzf_callback')
return [v:false, cmd]
endfunction
function! s:fzf_callback(...) abort
@ -611,22 +685,44 @@ There are two ways for a command to be spawned: @@ -611,22 +685,44 @@ There are two ways for a command to be spawned:
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations)
endif
endif
endfunction
```
In the example above, after executing `:FloatermNew fzf`, function
`floaterm#wrapper#fzf#` will return `['fzf > /tmp/atmpfilename', {'on_exit': funcref('s:fzf_callback')}, v:false]`.
`floaterm#wrapper#fzf#` will return
```vim
[v:false, 'fzf > /tmp/atmpfilename'].
```
Here `v:false` means `cmd`
```vim
fzf > /tmp/atmpfilename
```
will be passed through `termopen()`(neovim) or `term_start()`(vim). As the
result, an fzf interactive will be opened in a floaterm window.
When user picks a file using `ENTER`, fzf exits and the filepath will be
written in `/tmp/atmpfilename` and `s:fzf_callback()` will be invoked to
open the file. Note that the function `s: fzf_callback()` is registered by
```vim
let a:jobopts.on_exit = funcref('s:fzf_callback')
```
Here `v:false` means `cmd`(`fzf > /tmp/atmpfilename`) will be passed through
`termopen()`(neovim) or `term_start()`(vim). As a result, an fzf interactive
will be opened in a floaterm window. After choosing a file using `<CR>`, fzf
exits and the filepath will be written in `/tmp/atmpfilename`. Then the
function `s:fzf_callback()` will be invoked to open the file.
The variable `a:jobopts` in the above code will be eventually passed to
`termopen()`(neovim) or `term_start()`(vim). For more info, see
`:help jobstart-options`(neovim) or `:help job-options`(vim)
### How to write sources for fuzzy finder plugins
@ -634,11 +730,12 @@ Function `floaterm#buflist#gather()` returns a list contains all the floaterm bu @@ -634,11 +730,12 @@ Function `floaterm#buflist#gather()` returns a list contains all the floaterm bu
Function `floaterm#terminal#open_existing({bufnr})` opens the floaterm whose buffer number is `{bufnr}`.
For reference, see [floaterm source for vim-clap](./autoload/clap/provider/floaterm.vim).
For reference, see [floaterm source for LeaderF](https://github.com/voldikss/LeaderF-floaterm/blob/master/autoload/lf_floaterm.vim).
## Wiki
## Contributing
https://github.com/voldikss/vim-floaterm/wiki
- Improve the documentation
- Help resolve issues labeled as [help wanted](https://github.com/voldikss/vim-floaterm/issues?q=is%3Aissue+label%3A%22help+wanted%22)
## FAQ
@ -654,16 +751,15 @@ https://github.com/voldikss/vim-floaterm/issues?q=label%3A%22breaking+change%22 @@ -654,16 +751,15 @@ https://github.com/voldikss/vim-floaterm/issues?q=label%3A%22breaking+change%22
- [coc-floaterm](https://github.com/voldikss/coc-floaterm)
- [fzf-floaterm](https://github.com/voldikss/fzf-floaterm)
- [popc-floaterm](https://github.com/yehuohan/popc-floaterm)
- [Leaderf-floaterm](https://github.com/voldikss/LeaderF-floaterm)
- [LeaderF-floaterm](https://github.com/voldikss/LeaderF-floaterm)
## Credits
- [Vim](https://github.com/vim/vim/) and [Neovim](https://github.com/neovim/neovim/) the editor God
- [floaterm executable](https://github.com/voldikss/vim-floaterm/blob/master/bin/floaterm) is modified
from [vim-terminal-help](https://github.com/skywind3000/vim-terminal-help/blob/master/tools/utils/drop)
- [vim-terminal-help](https://github.com/skywind3000/vim-terminal-help/blob/master/tools/utils/drop)
- Some features require [neovim-remote](https://github.com/mhinz/neovim-remote)
- [edita.vim](https://github.com/lambdalisue/edita.vim)
## License

42
etc/soft/nvim/+plugins/vim-floaterm/autoload/clap/provider/floaterm.vim

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
" vim:sw=2:
" ============================================================================
" FileName: floaterm.vim
" Description:
" Author: voldikss <dyzplus@gmail.com>
" GitHub: https://github.com/voldikss
" ============================================================================
let s:floaterm = {}
let s:preview_height = 10
let s:bar = '[bufnr] [name]'
function! s:floaterm.source() abort
let candidates = [s:bar]
let bufs = floaterm#buflist#gather()
for bufnr in bufs
let bufinfo = getbufinfo(bufnr)[0]
let name = bufinfo['name']
let title = getbufvar(bufnr, 'term_title')
let line = printf(' %s %s %s', bufnr, name, title)
call add(candidates, line)
endfor
return candidates
endfunction
function! s:floaterm.on_move() abort
let curline = g:clap.display.getcurline()
if curline == s:bar
return
endif
let bufnr = str2nr(matchstr(curline, '\S'))
let lines = floaterm#util#getbuflines(bufnr, s:preview_height)
call g:clap.preview.show(lines)
endfunction
function! s:floaterm.sink(curline) abort
if a:curline == s:bar | return | endif
let bufnr = str2nr(matchstr(a:curline, '\S'))
call floaterm#terminal#open_existing(bufnr)
endfunction
let g:clap#provider#floaterm# = s:floaterm

41
etc/soft/nvim/+plugins/vim-floaterm/autoload/coc/source/floaterm.vim

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
" ============================================================================
" FileName: floaterm.vim
" Author: voldikss <dyzplus@gmail.com>
" GitHub: https://github.com/voldikss
" ============================================================================
function! coc#source#floaterm#init() abort
return g:floaterm_complete_options
endfunction
function! coc#source#floaterm#complete(opt, cb) abort
let lines = floaterm#util#getbuflines(-1, 100)
let completion = []
let [minlength, maxlength] = g:floaterm_complete_options['filter_length']
for line in lines
let item = map(
\ filter(
\ s:matchstrlist(line, '[a-zA-Z0-9]\+'),
\ { _,val -> len(val) >= minlength && len(val) <= maxlength}
\ ),
\ { _,val -> {'word': val, 'dup': 0} }
\ )
let completion += item
endfor
call a:cb(completion)
endfunction
function! s:matchstrlist(expr, pat) abort
let res = []
let start = 0
while 1
let m = matchstrpos(a:expr, a:pat, start)
if m[1] == -1
break
endif
call add(res, m[0])
let start = m[2]
endwhile
return res
endfunction

110
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm.vim

@ -5,44 +5,21 @@ @@ -5,44 +5,21 @@
" GitHub: https://github.com/voldikss
" ============================================================================
"-----------------------------------------------------------------------------
" script level variables and environment variables
"-----------------------------------------------------------------------------
let $VIM_SERVERNAME = v:servername
let $VIM_EXE = v:progpath
let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h')
let s:script = fnamemodify(s:home . '/../bin', ':p')
let s:windows = has('win32') || has('win64')
if stridx($PATH, s:script) < 0
if s:windows == 0
let $PATH .= ':' . s:script
else
let $PATH .= ';' . s:script
endif
endif
if !empty(g:floaterm_gitcommit)
autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete
if g:floaterm_gitcommit == 'floaterm'
let $GIT_EDITOR = 'nvr --remote-wait'
else
let $GIT_EDITOR = printf(
\ 'nvr -cc "call floaterm#hide(1, 0, \"\") | %s" --remote-wait',
\ g:floaterm_gitcommit
\ )
endif
endif
" ----------------------------------------------------------------------------
" wrapper function for `floaterm#new()` and `floaterm#update()` since they
" share the same argument: `config`
" ----------------------------------------------------------------------------
function! floaterm#run(action, bang, ...) abort
let [cmd, config] = floaterm#cmdline#parse(a:000)
function! floaterm#run(action, bang, rangeargs, cmdargs) abort
let [cmd, config] = floaterm#cmdline#parse(a:cmdargs)
if a:action == 'new'
call floaterm#new(a:bang, cmd, {}, config)
let [visualmode, range, line1, line2] = a:rangeargs
if range > 0
let lines = floaterm#util#get_selected_text(visualmode, range, line1, line2)
endif
let bufnr = floaterm#new(a:bang, cmd, {}, config)
if range > 0 && !empty(lines)
call floaterm#terminal#send(bufnr, lines)
endif
elseif a:action == 'update'
call floaterm#update(config)
endif
@ -51,20 +28,34 @@ endfunction @@ -51,20 +28,34 @@ endfunction
" create a floaterm. return bufnr of the terminal
" argument `jobopts` is passed by user in the case using this function as API
function! floaterm#new(bang, cmd, jobopts, config) abort
call floaterm#util#autohide()
if a:cmd != ''
let env = floaterm#util#setenv()
let vim_version = floaterm#util#vim_version()
if vim_version[0] == 'nvim' && vim_version[1] <= '0.4.4'
for [name, value] in items(env)
call setenv(name, value)
endfor
else
call floaterm#util#deep_extend(a:jobopts, {'env': env})
endif
if !empty(a:cmd)
let wrappers_path = globpath(&runtimepath, 'autoload/floaterm/wrapper/*vim', 0, 1)
let wrappers = map(wrappers_path, "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')")
let maybe_wrapper = split(a:cmd, '\s')[0]
if index(wrappers, maybe_wrapper) >= 0
let WrapFunc = function(printf('floaterm#wrapper#%s#', maybe_wrapper))
let [name, jobopts, send2shell] = WrapFunc(a:cmd)
if send2shell
let bufnr = floaterm#terminal#open(-1, g:floaterm_shell, {}, a:config)
call floaterm#terminal#send(bufnr, [name])
else
let bufnr = floaterm#terminal#open(-1, name, jobopts, a:config)
endif
try
let [shell, shellslash, shellcmdflag, shellxquote] = floaterm#util#use_sh_or_cmd()
let WrapFunc = function(printf('floaterm#wrapper#%s#', maybe_wrapper))
" NOTE: a:jobopts and a:config can be changed in WrapFunc
let [send2shell, newcmd] = WrapFunc(a:cmd, a:jobopts, a:config)
if send2shell
let bufnr = floaterm#terminal#open(-1, g:floaterm_shell, a:jobopts, a:config)
call floaterm#terminal#send(bufnr, [newcmd])
else
let bufnr = floaterm#terminal#open(-1, newcmd, a:jobopts, a:config)
endif
finally
let [&shell, &shellslash, &shellcmdflag, &shellxquote] = [shell, shellslash, shellcmdflag, shellxquote]
endtry
elseif a:bang
let bufnr = floaterm#terminal#open(-1, g:floaterm_shell, a:jobopts, a:config)
call floaterm#terminal#send(bufnr, [a:cmd])
@ -84,13 +75,14 @@ function! floaterm#toggle(bang, bufnr, name) abort @@ -84,13 +75,14 @@ function! floaterm#toggle(bang, bufnr, name) abort
if a:bang
let found_winnr = floaterm#window#find()
if found_winnr > 0
for bufnr in floaterm#buflist#gather()
call floaterm#window#hide(bufnr)
endfor
call floaterm#hide(1, 0, '')
else
for bufnr in floaterm#buflist#gather()
call floaterm#terminal#open_existing(bufnr)
endfor
let buffers = floaterm#buflist#gather()
if empty(buffers)
let curr_bufnr = floaterm#new(v:true, '', {}, {})
else
call floaterm#show(1, 0, '')
endif
endif
return
endif
@ -108,7 +100,7 @@ function! floaterm#toggle(bang, bufnr, name) abort @@ -108,7 +100,7 @@ function! floaterm#toggle(bang, bufnr, name) abort
else
let found_winnr = floaterm#window#find()
if found_winnr > 0
noautocmd execute found_winnr . 'wincmd w'
execute found_winnr . 'wincmd w'
else
call floaterm#curr()
endif
@ -117,7 +109,7 @@ function! floaterm#toggle(bang, bufnr, name) abort @@ -117,7 +109,7 @@ function! floaterm#toggle(bang, bufnr, name) abort
if bufnr == bufnr('%')
call floaterm#window#hide(bufnr)
elseif bufwinnr(bufnr) > -1
noautocmd execute bufwinnr(bufnr) . 'wincmd w'
execute bufwinnr(bufnr) . 'wincmd w'
else
call floaterm#terminal#open_existing(bufnr)
endif
@ -137,7 +129,7 @@ function! floaterm#update(config) abort @@ -137,7 +129,7 @@ function! floaterm#update(config) abort
let bufnr = bufnr('%')
call floaterm#window#hide(bufnr)
call floaterm#buffer#set_config_dict(bufnr, a:config)
call floaterm#config#set_all(bufnr, a:config)
call floaterm#terminal#open_existing(bufnr)
endfunction
@ -147,7 +139,6 @@ function! floaterm#next() abort @@ -147,7 +139,6 @@ function! floaterm#next() abort
let msg = 'No more floaterms'
call floaterm#util#show_msg(msg, 'warning')
else
call floaterm#util#autohide()
call floaterm#terminal#open_existing(next_bufnr)
endif
endfunction
@ -158,7 +149,6 @@ function! floaterm#prev() abort @@ -158,7 +149,6 @@ function! floaterm#prev() abort
let msg = 'No more floaterms'
call floaterm#util#show_msg(msg, 'warning')
else
call floaterm#util#autohide()
call floaterm#terminal#open_existing(prev_bufnr)
endif
endfunction
@ -178,7 +168,6 @@ function! floaterm#first() abort @@ -178,7 +168,6 @@ function! floaterm#first() abort
if first_bufnr == -1
call floaterm#util#show_msg('No more floaterms', 'warning')
else
call floaterm#util#autohide()
call floaterm#terminal#open_existing(first_bufnr)
endif
endfunction
@ -188,7 +177,6 @@ function! floaterm#last() abort @@ -188,7 +177,6 @@ function! floaterm#last() abort
if last_bufnr == -1
call floaterm#util#show_msg('No more floaterms', 'warning')
else
call floaterm#util#autohide()
call floaterm#terminal#open_existing(last_bufnr)
endif
endfunction
@ -218,6 +206,7 @@ endfunction @@ -218,6 +206,7 @@ endfunction
function! floaterm#show(bang, bufnr, name) abort
if a:bang
call floaterm#hide(1, 0, '')
for bufnr in floaterm#buflist#gather()
call floaterm#terminal#open_existing(bufnr)
endfor
@ -233,7 +222,6 @@ function! floaterm#show(bang, bufnr, name) abort @@ -233,7 +222,6 @@ function! floaterm#show(bang, bufnr, name) abort
endif
if bufnr > 0
call floaterm#util#autohide()
call floaterm#terminal#open_existing(bufnr)
else
call floaterm#util#show_msg('No floaterms with the bufnr or name', 'error')
@ -264,13 +252,7 @@ function! floaterm#hide(bang, bufnr, name) abort @@ -264,13 +252,7 @@ function! floaterm#hide(bang, bufnr, name) abort
endfunction
function! floaterm#send(bang, visualmode, range, line1, line2, argstr) abort
if &filetype ==# 'floaterm'
let msg = "FloatermSend can't be used in the floaterm window"
call floaterm#util#show_msg(msg, 'warning')
return
endif
let [cmd, config] = floaterm#cmdline#parse(split(a:argstr))
let [cmd, config] = floaterm#cmdline#parse(a:argstr)
let termname = get(config, 'termname', '')
if !empty(termname)
let bufnr = floaterm#terminal#get_bufnr(termname)

39
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/buffer.vim

@ -24,7 +24,6 @@ function! floaterm#buffer#create_border_buf(options) abort @@ -24,7 +24,6 @@ function! floaterm#buffer#create_border_buf(options) abort
let repeat_width = a:options.width - 2
let repeat_height = a:options.height - 2
let title = a:options.title
let title = empty(title) ? title : (' ' . title . ' ')
let title_width = strdisplaywidth(title)
let borderchars = a:options.borderchars
let [c_top, c_right, c_bottom, c_left, c_topleft, c_topright, c_botright, c_botleft] = borderchars
@ -34,32 +33,16 @@ function! floaterm#buffer#create_border_buf(options) abort @@ -34,32 +33,16 @@ function! floaterm#buffer#create_border_buf(options) abort
return floaterm#buffer#create_scratch_buf(content)
endfunction
function! floaterm#buffer#get_config(bufnr, key, ...) abort
let key = 'floaterm_' . a:key
let val = getbufvar(a:bufnr, key)
if val == '' && a:0 == 1
return a:1
function! floaterm#buffer#getlines(bufnr, length) abort
let lines = []
if a:bufnr == -1
for bufnr in floaterm#buflist#gather()
let lnum = getbufinfo(bufnr)[0]['lnum']
let lines += getbufline(bufnr, max([lnum - a:length, 0]), '$')
endfor
else
let lnum = getbufinfo(a:bufnr)[0]['lnum']
let lines += getbufline(a:bufnr, max([lnum - a:length, 0]), '$')
endif
return val
endfunction
function! floaterm#buffer#get_config_dict(bufnr) abort
let config = {}
for var in items(getbufvar(a:bufnr, ''))
if var[0] =~ '^floaterm_'
let config[var[0][9:]] = var[1]
endif
endfor
return config
endfunction
function! floaterm#buffer#set_config(bufnr, key, val) abort
let key = 'floaterm_' . a:key
call setbufvar(a:bufnr, key, a:val)
endfunction
function! floaterm#buffer#set_config_dict(bufnr, config) abort
for [key, val] in items(a:config)
call floaterm#buffer#set_config(a:bufnr, key, val)
endfor
return lines
endfunction

88
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/cmdline.vim

@ -9,16 +9,19 @@ @@ -9,16 +9,19 @@
" used for `:FloatermNew` and `:FloatermUpdate`
" parse argument list to `cmd`(string, default '') and `config`(dict)
" ----------------------------------------------------------------------------
function! floaterm#cmdline#parse(arglist) abort
function! floaterm#cmdline#parse(argstr) abort
let config = {}
let cmd = ''
if a:arglist != []
let arglist = split(a:argstr, '\\\@<!\s')
if arglist != []
let c = 0
for arg in a:arglist
for arg in arglist
let arg = substitute(arg, '\\\\', '\', 'g')
let arg = substitute(arg, '\\ ', ' ', 'g')
if arg =~ '^--\S.*=\?.*$'
let pair = split(arg, '=')
if len(pair) != 2
if index(['--silent'], pair[0]) >= 0
if index(['--silent', '--disposable'], pair[0]) >= 0
let [key, value] = [pair[0][2:], v:true]
else
call floaterm#util#show_msg('Argument Error: No value given to option: ' . pair[0], 'error')
@ -26,13 +29,22 @@ function! floaterm#cmdline#parse(arglist) abort @@ -26,13 +29,22 @@ function! floaterm#cmdline#parse(arglist) abort
endif
else
let [key, value] = [pair[0][2:], pair[1]]
if key == 'cwd'
if value == '<root>'
let value = floaterm#path#get_root()
elseif value == '<buffer>'
let value = expand('%:p:h')
else
let value = fnamemodify(value, ':p')
endif
endif
endif
if index(['height', 'width', 'autoclose'], key) > -1
let value = eval(value)
endif
let config[key] = value
else
let cmd = s:expand(join(a:arglist[c:]))
let cmd = s:expand(join(arglist[c:]))
break
endif
let c += 1
@ -56,14 +68,16 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort @@ -56,14 +68,16 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort
let options = [
\ '--cwd=',
\ '--name=',
\ '--title=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--opener=',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ '--silent',
\ '--disposable',
\ ]
let cmd_line_before_cursor = a:cmd_line[:a:cursor_pos - 1]
@ -77,22 +91,14 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort @@ -77,22 +91,14 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort
endfor
if match(a:arg_lead, '--wintype=') > -1
let vals = ['normal', 'float']
let vals = ['float', 'split', 'vsplit']
let candidates = map(vals, {idx -> '--wintype=' . vals[idx]})
elseif match(a:arg_lead, '--position=') > -1
let vals = [
\ 'top',
\ 'right',
\ 'bottom',
\ 'left',
\ 'center',
\ 'topleft',
\ 'topright',
\ 'bottomleft',
\ 'bottomright',
\ 'auto',
\ ]
let candidates = map(vals, {idx -> '--position=' . vals[idx]})
elseif match(a:arg_lead, '--opener=') > -1
let vals = ['edit', 'split', 'vsplit', 'tabe', 'drop']
if index(vals, g:floaterm_opener) == -1
call add(vals, g:floaterm_opener)
endif
let candidates = map(vals, {idx -> '--opener=' . vals[idx]})
elseif match(a:arg_lead, '--autoclose=') > -1
let vals = [0, 1, 2]
let candidates = map(vals, {idx -> '--autoclose=' . vals[idx]})
@ -100,7 +106,10 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort @@ -100,7 +106,10 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort
return []
elseif match(a:arg_lead, '--cwd=') > -1
let prestr = matchstr(a:arg_lead, '--cwd=\zs.*\ze')
let dirs = getcompletion(prestr, 'dir') + ['<root>']
let dirs = getcompletion(prestr, 'dir')
if a:arg_lead == '--cwd='
let dirs = ['<buffer>', '<root>'] + dirs
endif
return map(dirs, { k,v -> '--cwd=' . v })
elseif match(a:arg_lead, '--name=') > -1
return []
@ -112,6 +121,37 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort @@ -112,6 +121,37 @@ function! floaterm#cmdline#complete(arg_lead, cmd_line, cursor_pos) abort
return []
elseif match(a:arg_lead, '--borderchars=') > -1
return []
elseif match(a:arg_lead, '--position=') > -1
let wintype = matchstr(a:cmd_line, '--wintype=\zs\w\+\ze')
if empty(wintype)
let wintype = g:floaterm_wintype
endif
if wintype == 'float'
let vals = [
\ 'auto',
\ 'center',
\ 'random',
\ 'top',
\ 'topleft',
\ 'topright',
\ 'bottom',
\ 'bottomleft',
\ 'bottomright',
\ 'left',
\ 'right',
\ ]
else
let vals = [
\ 'random',
\ 'leftabove',
\ 'aboveleft',
\ 'rightbelow',
\ 'belowright',
\ 'topleft',
\ 'botright',
\ ]
endif
let candidates = map(vals, {idx -> '--position=' . vals[idx]})
" The dash absolutely belongs to the `options` instead of executable
" commands(e.g. `nvim-qt.exe`). So if `a:arg_lead` matches 1 or 2 dash, the
" user wants to complete options.
@ -143,7 +183,7 @@ function! floaterm#cmdline#complete_names1(...) abort @@ -143,7 +183,7 @@ function! floaterm#cmdline#complete_names1(...) abort
let buflist = floaterm#buflist#gather()
let ret = []
for bufnr in buflist
let termname = floaterm#buffer#get_config(bufnr, 'name', '')
let termname = floaterm#config#get(bufnr, 'name', '')
if !empty(termname)
call add(ret, termname)
endif

114
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/config.vim

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
" ============================================================================
" FileName: config.vim
" Author: voldikss <dyzplus@gmail.com>
" GitHub: https://github.com/voldikss
" ============================================================================
function! floaterm#config#get(bufnr, key, ...) abort
let key = 'floaterm_' . a:key
let val = getbufvar(a:bufnr, key)
if val == '' && a:0 == 1
return a:1
endif
return val
endfunction
function! floaterm#config#get_all(bufnr) abort
let config = {}
for var in items(getbufvar(a:bufnr, ''))
if var[0] =~ '^floaterm_'
let config[var[0][9:]] = var[1]
endif
endfor
return config
endfunction
function! floaterm#config#set(bufnr, key, val) abort
let key = 'floaterm_' . a:key
call setbufvar(a:bufnr, key, a:val)
endfunction
function! floaterm#config#set_all(bufnr, config) abort
for [key, val] in items(a:config)
call floaterm#config#set(a:bufnr, key, val)
endfor
endfunction
" TODO: give this function a better name
" @argument: config, a floaterm local variable, will be stored as a `b:` variable
" @return: config, generated from `a:config`, has more additional info, used to
" config the floaterm style
function! floaterm#config#parse(bufnr, config) abort
let a:config.title = get(a:config, 'title', g:floaterm_title)
let a:config.width = get(a:config, 'width', g:floaterm_width)
let a:config.height = get(a:config, 'height', g:floaterm_height)
let a:config.opener = get(a:config, 'opener', g:floaterm_opener)
let a:config.wintype = get(a:config, 'wintype', floaterm#window#win_gettype())
let a:config.position = get(a:config, 'position', g:floaterm_position)
let a:config.autoclose = get(a:config, 'autoclose', g:floaterm_autoclose)
let a:config.borderchars = get(a:config, 'borderchars', g:floaterm_borderchars)
" Edge cases
if type(a:config.height) == v:t_number && a:config.height < 3
call floaterm#util#show_msg('Floaterm height should be at least 3', 'warning')
let a:config.height = 3
endif
if type(a:config.width) == v:t_number && a:config.width < 3
call floaterm#util#show_msg('Floaterm width should be at least 3', 'warning')
let a:config.width = 3
endif
" backward compatiblity
if a:config.wintype == 'normal'
let a:config.wintype = 'split'
endif
if a:config.wintype =~ 'split'
if a:config.position == 'center'
let a:config.position = 'botright'
elseif a:config.position == 'top' || a:config.position == 'left'
let a:config.position = 'aboveleft'
elseif a:config.position == 'bottom' || a:config.position == 'right'
let a:config.position = 'belowright'
endif
endif
" Dump these configs into buffer, they can be reused for reopening
call floaterm#config#set_all(a:bufnr, a:config)
" The following configs (width, height, borderchars, position) should be
" parsed and become static. After opening windows, the configs are discard
let config = deepcopy(a:config)
let config.title = floaterm#window#make_title(a:bufnr, a:config.title)
let width = config.width
if type(width) == v:t_float | let width = width * &columns | endif
let config.width = float2nr(width)
let height = config.height
if type(height) == v:t_float | let height = height * (&lines - &cmdheight - 1) | endif
let config.height = float2nr(height)
let borderchars = config.borderchars
" g:floaterm_borderchars is type v:t_list in old version vim-floaterm
" strcharpart is useful for multiple-byte characters
if type(borderchars) == v:t_string
let borderchars = map(range(8), { idx -> strcharpart(borderchars, idx, 1) })
endif
let config.borderchars = borderchars
if config.position == 'random'
let randnum = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:])
if config.wintype =~ 'split'
let config.position = ['leftabove', 'aboveleft', 'rightbelow', 'belowright', 'topleft', 'botright'][randnum % 4]
else
let config.position = ['top', 'right', 'bottom', 'left', 'center', 'topleft', 'topright', 'bottomleft', 'bottomright', 'auto'][randnum % 10]
endif
endif
let [row, col, anchor] = floaterm#window#win_getpos(config.width, config.height, config.position)
let config['anchor'] = anchor
let config['row'] = row
let config['col'] = col
return config
endfunction

31
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/client.vim

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
let s:repo = fnamemodify(expand('<sfile>'), ':p:h:h:h:h:h')
function! floaterm#edita#neovim#client#open() abort
let server = ($NVIM != '') ? $NVIM : $NVIM_LISTEN_ADDRESS
let mode = floaterm#edita#neovim#util#mode(server)
let ch = sockconnect(mode, server, { 'rpc': 1 })
let target = escape(fnamemodify(argv()[-1], ':p'), ' \')
let client = escape(serverstart(), ' \')
call rpcrequest(ch, 'nvim_command', printf(
\ 'call floaterm#edita#neovim#editor#open("%s", "%s")',
\ target,
\ client,
\))
endfunction
function! floaterm#edita#neovim#client#EDITOR() abort
let args = [
\ shellescape(v:progpath),
\ '--headless',
\ '--clean',
\ '--noplugin',
\ '-n',
\ '-R',
\]
let cmds = [
\ printf('set runtimepath^=%s', fnameescape(s:repo)),
\ 'call floaterm#edita#neovim#client#open()'
\]
call map(cmds, { -> printf('-c %s', shellescape(v:val)) })
return join(args + cmds)
endfunction

48
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/editor.vim

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
function! floaterm#edita#neovim#editor#open(target, client)
let bufnr = floaterm#buflist#curr()
call floaterm#window#hide(bufnr)
let opener = floaterm#config#get(bufnr, 'opener', g:floaterm_opener)
call floaterm#util#open([{'filename': fnameescape(a:target)}], opener)
let mode = floaterm#edita#neovim#util#mode(a:client)
let b:edita = sockconnect(mode, a:client, { 'rpc': 1 })
if index([
\ 'COMMIT_EDITMSG',
\ 'git-rebase-todo',
\ 'addp-hunk-edit.diff'
\ ], expand('%:t')) > -1
setlocal bufhidden=wipe
augroup edita_buffer
autocmd! * <buffer>
autocmd BufDelete <buffer> call s:BufDelete()
autocmd BufDelete <buffer> call timer_start(100, {->floaterm#curr()})
augroup END
else
call timer_start(100, {->s:BufDelete()})
endif
endfunction
function! s:BufDelete() abort
let ch = getbufvar(expand('<afile>'), 'edita', v:null)
if ch is# v:null
return
endif
silent! call rpcrequest(ch, 'nvim_command', 'qall')
call setbufvar(expand('<afile>'), 'edita', v:null)
endfunction
function! s:VimLeave() abort
let expr = v:dying || v:exiting > 0 ? 'cquit' : 'qall'
let editas = range(0, bufnr('$'))
call map(editas, { -> getbufvar(v:val, 'edita', v:null) })
call filter(editas, { -> !empty(v:val) })
silent! call map(editas, { -> rpcrequest(v:val, 'nvim_command', expr) })
" If COMMIT_EDITMSG buffer exists, suspend for the git commiting
if len(editas) > 0
sleep 10m
endif
endfunction
augroup edita_internal
autocmd! *
autocmd VimLeave * call s:VimLeave()
augroup END

5
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/neovim/util.vim

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
function! floaterm#edita#neovim#util#mode(address) abort
return a:address =~# '^\%(\%(\d\{1,3}\.\)\{3}\d\{1,3}\|localhost\)\?:\d\+'
\ ? 'tcp'
\ : 'pipe'
endfunction

5
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/setup.vim

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
function! floaterm#edita#setup#EDITOR() abort
return has('nvim')
\ ? floaterm#edita#neovim#client#EDITOR()
\ : floaterm#edita#vim#client#EDITOR()
endfunction

53
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/vim/client.vim

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
let s:repo = fnamemodify(expand('<sfile>'), ':p:h:h:h:h:h')
function! floaterm#edita#vim#client#open() abort
bwipeout!
let target = fnamemodify(argv()[-1], ':p')
call s:send(['call', 'Tapi_edita_open', [target]])
enew | redraw
" Disable mappings to prevent accidental edit
for nr in range(256)
silent! execute printf("cnoremap \<buffer>\<silent> \<Char-%d> \<Nop>", nr)
endfor
" Accept 'Editaquit' to quit
silent! cnoremap <buffer> Editaquit <C-u>OK<Return>
silent! cnoremap <buffer> <C-c> <Esc>
let r = input(printf('Waiting %s. Hit Ctrl-C to cancel', target))
if !empty(r)
quitall!
else
cquit!
endif
endfunction
function! floaterm#edita#vim#client#EDITOR() abort
let args = [
\ shellescape(v:progpath),
\ '--not-a-term',
\ '--clean',
\ '--noplugin',
\ '-n',
\ '-R',
\]
let cmds = [
\ printf('set runtimepath^=%s', fnameescape(s:repo)),
\ 'call floaterm#edita#vim#client#open()'
\]
call map(cmds, { -> printf('-c %s', shellescape(v:val)) })
return join(args + cmds)
endfunction
function! s:send(data) abort
execute "set t_ts=\<Esc>]51; t_fs=\x07"
let &titlestring = json_encode(a:data)
set title
redraw!
let &titlestring = ''
set t_ts& t_fs&
endfunction
function! Tapi_edita_open(bufnr, arglist) abort
let target = a:arglist[0]
call floaterm#edita#vim#editor#open(target, a:bufnr)
return ''
endfunction

50
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/edita/vim/editor.vim

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
let s:quit_expr = "\<C-\>\<C-n>iEditaquit"
function! floaterm#edita#vim#editor#open(target, bufnr)
call floaterm#window#hide(a:bufnr)
let opener = floaterm#config#get(a:bufnr, 'opener', g:floaterm_opener)
call floaterm#util#open([{'filename': fnameescape(a:target)}], opener)
let b:edita = a:bufnr
if index([
\ 'COMMIT_EDITMSG',
\ 'git-rebase-todo',
\ 'addp-hunk-edit.diff'
\ ], expand('%:t')) > -1
setlocal bufhidden=wipe
augroup edita_buffer
autocmd! * <buffer>
autocmd BufDelete <buffer> call s:BufDelete()
autocmd BufDelete <buffer> call timer_start(100, {->floaterm#curr()})
augroup END
else
if !has('win32')
call timer_start(100, {->s:BufDelete()})
endif
endif
endfunction
function! s:BufDelete() abort
let bufnr = getbufvar(expand('<afile>'), 'edita', v:null)
if bufnr is# v:null
return
endif
silent! call term_sendkeys(bufnr, s:quit_expr)
call setbufvar(expand('<afile>'), 'edita', v:null)
endfunction
function! s:VimLeave() abort
let expr = v:dying || v:exiting > 0 ? 'cquit' : 'qall'
let editas = range(0, bufnr('$'))
call map(editas, { -> getbufvar(v:val, 'edita', v:null) })
call filter(editas, { -> !empty(v:val) })
silent! call map(editas, { -> term_sendkeys(v:val, s:quit_expr) })
" If COMMIT_EDITMSG buffer exists, suspend for the git commiting
if len(editas) > 0
sleep 10m
endif
endfunction
augroup edita_internal
autocmd! *
autocmd VimLeave * call s:VimLeave()
augroup END

7
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/path.vim

@ -136,10 +136,5 @@ function! floaterm#path#get_root() abort @@ -136,10 +136,5 @@ function! floaterm#path#get_root() abort
endfunction
function! floaterm#path#chdir(path) abort
if has('nvim')
let cmd = haslocaldir()? 'lcd' : (haslocaldir(-1, 0)? 'tcd' : 'cd')
else
let cmd = haslocaldir()? ((haslocaldir() == 1)? 'lcd' : 'tcd') : 'cd'
endif
silent execute cmd . ' '. fnameescape(a:path)
silent execute 'tcd '. fnameescape(a:path)
endfunction

121
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/terminal.vim

@ -5,22 +5,34 @@ @@ -5,22 +5,34 @@
" GitHub: https://github.com/voldikss
" ============================================================================
let s:timer_map = {}
let s:channel_map = {}
let s:is_win = has('win32') || has('win64')
function! s:on_floaterm_open(bufnr) abort
function! s:on_floaterm_create(bufnr) abort
call setbufvar(a:bufnr, '&buflisted', 0)
call setbufvar(a:bufnr, '&filetype', 'floaterm')
if has('nvim')
" TODO: need to be reworked
augroup floaterm_enter_insertmode
autocmd! * <buffer>
autocmd! User FloatermOpen
autocmd User FloatermOpen call floaterm#util#startinsert()
autocmd BufEnter <buffer> call floaterm#util#startinsert()
execute printf(
\ 'autocmd BufHidden,BufWipeout <buffer=%s> ++once call floaterm#window#hide(%s)',
\ 'autocmd BufHidden,BufWipeout <buffer=%s> call floaterm#window#hide(%s)',
\ a:bufnr,
\ a:bufnr
\ )
endif
if floaterm#config#get(a:bufnr, 'disposable')
execute printf(
\ 'autocmd BufHidden <buffer=%s> call floaterm#terminal#kill(%s)',
\ a:bufnr,
\ a:bufnr
\ )
endif
augroup END
endfunction
" for vim8: a:000 is empty
" for nvim: a:000 is ['exit'](event)
function! s:on_floaterm_close(bufnr, callback, job, data, ...) abort
if a:bufnr == -1
" In vim, buffnr is not known before starting a job, therefore, it's
@ -36,18 +48,19 @@ function! s:on_floaterm_close(bufnr, callback, job, data, ...) abort @@ -36,18 +48,19 @@ function! s:on_floaterm_close(bufnr, callback, job, data, ...) abort
else
let bufnr = a:bufnr
endif
let opener = floaterm#config#get(bufnr, 'opener')
call setbufvar(bufnr, '&bufhidden', 'wipe')
call floaterm#buffer#set_config(bufnr, 'jobexists', v:false)
let autoclose = floaterm#buffer#get_config(bufnr, 'autoclose', 0)
call floaterm#config#set(bufnr, 'jobexists', v:false)
let autoclose = floaterm#config#get(bufnr, 'autoclose')
if (autoclose == 1 && a:data == 0) || (autoclose == 2) || (a:callback isnot v:null)
call floaterm#window#hide(bufnr)
" if the floaterm is created with --silent, delete the buffer explicitly
silent! execute bufnr . 'bdelete!'
" update lightline
doautocmd BufDelete
silent doautocmd BufDelete
endif
if a:callback isnot v:null
call a:callback(a:job, a:data, 'exit')
call a:callback(a:job, a:data, 'exit', opener)
endif
endfunction
@ -59,34 +72,29 @@ function! floaterm#terminal#open(bufnr, cmd, jobopts, config) abort @@ -59,34 +72,29 @@ function! floaterm#terminal#open(bufnr, cmd, jobopts, config) abort
call floaterm#window#hide(bufnr('%'))
endif
" just open if floaterm exists
if a:bufnr > 0
call floaterm#window#open(a:bufnr, a:config)
call s:on_floaterm_open(a:bufnr)
return a:bufnr
endif
if !bufexists(a:bufnr)
" change cwd
let savedcwd = getcwd()
if has_key(a:config, 'cwd')
call floaterm#path#chdir(a:config.cwd)
endif
" change cwd
let savedcwd = getcwd()
let dest = get(a:config, 'cwd', '')
if dest == '<root>'
let dest = floaterm#path#get_root()
endif
if !empty(dest)
call floaterm#path#chdir(dest)
endif
" spawn terminal
let bufnr = s:spawn_terminal(a:cmd, a:jobopts, a:config)
" spawn terminal
let bufnr = s:spawn_terminal(a:cmd, a:jobopts, a:config)
" hide floaterm immediately if silent
if floaterm#config#get(bufnr, 'silent', 0)
call floaterm#window#hide(bufnr)
endif
" hide floaterm immediately if silent
if floaterm#buffer#get_config(bufnr, 'silent', 0)
call floaterm#window#hide(bufnr)
stopinsert
" restore cwd
call floaterm#path#chdir(savedcwd)
else
let config = floaterm#config#parse(a:bufnr, a:config)
call floaterm#window#open(a:bufnr, config)
let bufnr = a:bufnr
endif
" restore cwd
call floaterm#path#chdir(savedcwd)
doautocmd User FloatermOpen
return bufnr
endfunction
@ -96,11 +104,7 @@ function! floaterm#terminal#open_existing(bufnr) abort @@ -96,11 +104,7 @@ function! floaterm#terminal#open_existing(bufnr) abort
call floaterm#util#show_msg(printf("Buffer %s doesn't exists", a:bufnr), 'error')
return
endif
let winnr = bufwinnr(a:bufnr)
if winnr > -1
execute winnr . 'hide'
endif
let config = floaterm#buffer#get_config_dict(a:bufnr)
let config = floaterm#config#get_all(a:bufnr)
call floaterm#terminal#open(a:bufnr, '', {}, config)
endfunction
@ -112,7 +116,8 @@ function! s:spawn_terminal(cmd, jobopts, config) abort @@ -112,7 +116,8 @@ function! s:spawn_terminal(cmd, jobopts, config) abort
\ 's:on_floaterm_close',
\ [bufnr, get(a:jobopts, 'on_exit', v:null)]
\ )
call floaterm#window#open(bufnr, a:config)
let config = floaterm#config#parse(bufnr, a:config)
call floaterm#window#open(bufnr, config)
let ch = termopen(a:cmd, a:jobopts)
let s:channel_map[bufnr] = ch
else
@ -123,11 +128,12 @@ function! s:spawn_terminal(cmd, jobopts, config) abort @@ -123,11 +128,12 @@ function! s:spawn_terminal(cmd, jobopts, config) abort
if has_key(a:jobopts, 'on_exit')
unlet a:jobopts.on_exit
endif
if has('patch-8.1.2080')
let a:jobopts.term_api = 'floaterm#util#edit'
endif
let a:jobopts.hidden = 1
try
" TODO: need refactor
let config = floaterm#config#parse(-1, a:config)
let a:jobopts['term_cols'] = config.width - 2
let a:jobopts['term_rows'] = config.height - 2
let bufnr = term_start(a:cmd, a:jobopts)
catch
call floaterm#util#show_msg('Failed to execute: ' . a:cmd, 'error')
@ -136,10 +142,12 @@ function! s:spawn_terminal(cmd, jobopts, config) abort @@ -136,10 +142,12 @@ function! s:spawn_terminal(cmd, jobopts, config) abort
call floaterm#buflist#add(bufnr)
let job = term_getjob(bufnr)
let s:channel_map[bufnr] = job_getchannel(job)
call floaterm#window#open(bufnr, a:config)
let config = floaterm#config#parse(bufnr, a:config)
call floaterm#window#open(bufnr, config)
endif
call floaterm#buffer#set_config(bufnr, 'jobexists', v:true)
call s:on_floaterm_open(bufnr)
call floaterm#config#set(bufnr, 'jobexists', v:true)
call floaterm#config#set(bufnr, 'cmd', a:cmd)
call s:on_floaterm_create(bufnr)
return bufnr
endfunction
@ -159,7 +167,10 @@ function! floaterm#terminal#send(bufnr, cmds) abort @@ -159,7 +167,10 @@ function! floaterm#terminal#send(bufnr, cmds) abort
endif
noautocmd execute curr_winnr . 'wincmd w'
else
let newline = s:is_win ? "\r\n" : "\n"
let newline = "\n"
if has('win32') && bufname(a:bufnr) !~ 'ipython'
let newline = "\r\n"
endif
call ch_sendraw(ch, join(a:cmds, newline) . newline)
endif
endfunction
@ -167,7 +178,7 @@ endfunction @@ -167,7 +178,7 @@ endfunction
function! floaterm#terminal#get_bufnr(termname) abort
let buflist = floaterm#buflist#gather()
for bufnr in buflist
let name = floaterm#buffer#get_config(bufnr, 'name')
let name = floaterm#config#get(bufnr, 'name')
if name ==# a:termname
return bufnr
endif
@ -188,12 +199,24 @@ function! floaterm#terminal#kill(bufnr) abort @@ -188,12 +199,24 @@ function! floaterm#terminal#kill(bufnr) abort
call job_stop(job, 'kill')
endif
endif
call s:ensure_terminal_kill(a:bufnr)
let s:timer_map[a:bufnr] = timer_start(
\ 5,
\ { -> s:ensure_terminal_kill(a:bufnr) },
\ {'repeat': 3}
\ )
endfunction
function! s:ensure_terminal_kill(bufnr) abort
try
if bufexists(a:bufnr)
execute a:bufnr . 'bwipeout!'
else
call timer_stop(s:timer_map[a:bufnr])
call remove(s:timer_map, a:bufnr)
endif
catch
call popup_close(win_getid())
silent! call popup_close(win_getid())
endtry
endfunction

102
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/util.vim

@ -33,13 +33,30 @@ function! floaterm#util#show_msg(message, ...) abort @@ -33,13 +33,30 @@ function! floaterm#util#show_msg(message, ...) abort
endif
endfunction
function! floaterm#util#edit(_bufnr, filename) abort
call floaterm#hide(1, 0, '')
silent execute g:floaterm_open_command . ' ' . a:filename
" - locations: List of location, which is a Dictionary:
" - filename: String
" - lnum[optional]: Number, used to locate
" - text[optional]: String, search `/` content, used to locate
" - a:0: String, opening action, default `g:floaterm_opener`
function! floaterm#util#open(locations, ...) abort
let opener = get(a:000, 0, g:floaterm_opener)
execute opener a:locations[0].filename
for loc in a:locations[1:]
execute 'edit ' loc.filename
if has_key(loc, 'lnum')
execute loc.lnum
elseif has_key(loc, 'text')
execute '/' . loc.text
endif
normal! zz
endfor
endfunction
function! floaterm#util#startinsert() abort
if !g:floaterm_autoinsert
if &ft != 'floaterm'
return
endif
if !g:floaterm_autoinsert
call feedkeys("\<C-\>\<C-n>", 'n')
elseif mode() != 'i'
if has('nvim')
@ -50,27 +67,6 @@ function! floaterm#util#startinsert() abort @@ -50,27 +67,6 @@ function! floaterm#util#startinsert() abort
endif
endfunction
function! floaterm#util#autohide() abort
" hide all floaterms before opening a new floaterm
if g:floaterm_autohide
call floaterm#hide(1, 0, '')
endif
endfunction
function! floaterm#util#getbuflines(bufnr, length) abort
let lines = []
if a:bufnr == -1
for bufnr in floaterm#buflist#gather()
let lnum = getbufinfo(bufnr)[0]['lnum']
let lines += getbufline(bufnr, max([lnum - a:length, 0]), '$')
endfor
else
let lnum = getbufinfo(a:bufnr)[0]['lnum']
let lines += getbufline(a:bufnr, max([lnum - a:length, 0]), '$')
endif
return lines
endfunction
function! floaterm#util#get_selected_text(visualmode, range, line1, line2) abort
if a:range == 0
let lines = [getline('.')]
@ -114,3 +110,59 @@ function! floaterm#util#leftalign_lines(lines) abort @@ -114,3 +110,59 @@ function! floaterm#util#leftalign_lines(lines) abort
endfor
return linelist
endfunction
function! floaterm#util#use_sh_or_cmd() abort
let [shell, shellslash, shellcmdflag, shellxquote] = [&shell, &shellslash, &shellcmdflag, &shellxquote]
if has('win32')
set shell=cmd.exe
set noshellslash
let &shellcmdflag = has('nvim') ? '/s /c' : '/c'
let &shellxquote = has('nvim') ? '"' : '('
else
set shell=sh
endif
return [shell, shellslash, shellcmdflag, shellxquote]
endfunction
function! floaterm#util#deep_extend(dict1, dict2) abort
for key in keys(a:dict2)
if has_key(a:dict1, key)
if type(a:dict1[key]) == v:t_dict
call floaterm#util#deep_extend(a:dict1[key], a:dict2[key])
else
let a:dict1[key] = a:dict2[key]
endif
else
let a:dict1[key] = a:dict2[key]
endif
endfor
endfunction
let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
let s:binpath = fnamemodify(s:home . '/../bin', ':p')
function! floaterm#util#setenv() abort
let env = {}
" bin/floaterm.cmd
if has('win32') && !has('nvim')
let env.VIM_SERVERNAME = v:servername
let env.VIM_EXE = v:progpath
endif
if has('win32') == 0
let env.PATH = $PATH . ':' . s:binpath
else
let env.PATH = $PATH . ';' . s:binpath
endif
let editor = floaterm#edita#setup#EDITOR()
let env.FLOATERM = editor
let env.GIT_EDITOR = editor
return env
endfunction
function! floaterm#util#vim_version() abort
if !has('nvim')
return ['vim', string(v:version)]
endif
let c = execute('silent version')
let lines = split(matchstr(c, 'NVIM v\zs[^\n-]*'))
return ['nvim', lines[0]]
endfunction

173
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/window.vim

@ -8,36 +8,26 @@ @@ -8,36 +8,26 @@
let s:has_popup = has('textprop') && has('patch-8.2.0286')
let s:has_float = has('nvim') && exists('*nvim_win_set_config')
function! s:get_wintype() abort
function! floaterm#window#win_gettype() abort
if empty(g:floaterm_wintype)
if s:has_float || s:has_popup
return 'float'
else
return 'normal'
return 'split'
endif
elseif g:floaterm_wintype == 'normal'
return 'normal'
elseif g:floaterm_wintype =~ 'split'
return g:floaterm_wintype
else " backward compatiblity: float|floating|popup -> float
if s:has_float || s:has_popup
return 'float'
else
call floaterm#util#show_msg("floating or popup feature is not found, fall back to normal window", 'warning')
return 'normal'
return 'split'
endif
endif
endfunction
function! s:make_title(bufnr, text) abort
if empty(a:text) | return '' | endif
let buffers = floaterm#buflist#gather()
let cnt = len(buffers)
let idx = index(buffers, a:bufnr) + 1
let title = substitute(a:text, '$1', idx, 'gm')
let title = substitute(title, '$2', cnt, 'gm')
return title
endfunction
function! s:get_floatwin_pos(width, height, pos) abort
function! floaterm#window#win_getpos(width, height, pos) abort
if a:pos == 'topright'
let row = 1
let col = &columns
@ -106,69 +96,18 @@ function! s:get_floatwin_pos(width, height, pos) abort @@ -106,69 +96,18 @@ function! s:get_floatwin_pos(width, height, pos) abort
return [row, col, anchor]
endfunction
function! s:winexists(winid) abort
return !empty(getwininfo(a:winid))
function! floaterm#window#make_title(bufnr, tmpl) abort
if empty(a:tmpl) | return '' | endif
let buffers = floaterm#buflist#gather()
let cnt = len(buffers)
let idx = index(buffers, a:bufnr) + 1
let title = substitute(a:tmpl, '$1', idx, 'gm')
let title = substitute(title, '$2', cnt, 'gm')
return title
endfunction
" TODO: give this function a better name
" @argument: config, a floaterm local variable, will be stored as a `b:` variable
" @return: config, generated from `a:config`, has more additional info, used to
" config the floaterm style
function! s:parse_config(bufnr, config) abort
let a:config.title = get(a:config, 'title', g:floaterm_title)
let a:config.width = get(a:config, 'width', g:floaterm_width)
let a:config.height = get(a:config, 'height', g:floaterm_height)
let a:config.wintype = get(a:config, 'wintype', s:get_wintype())
let a:config.position = get(a:config, 'position', g:floaterm_position)
let a:config.autoclose = get(a:config, 'autoclose', g:floaterm_autoclose)
let a:config.borderchars = get(a:config, 'borderchars', g:floaterm_borderchars)
if type(a:config.height) == v:t_number && a:config.height < 3
call floaterm#util#show_msg('Floaterm height should be at least 3', 'warning')
let a:config.height = 3
endif
if type(a:config.width) == v:t_number && a:config.width < 3
call floaterm#util#show_msg('Floaterm width should be at least 3', 'warning')
let a:config.width = 3
endif
" Dump these configs into buffer, they can be reused for reopening
call floaterm#buffer#set_config_dict(a:bufnr, a:config)
" The following configs (width, height, borderchars, position) should be
" parsed and become static. After opening windows, the configs are discard
let config = deepcopy(a:config)
let width = config.width
if type(width) == v:t_float | let width = width * &columns | endif
let config.width = float2nr(width)
let height = config.height
if type(height) == v:t_float | let height = height * (&lines - &cmdheight - 1) | endif
let config.height = float2nr(height)
let borderchars = config.borderchars
" g:floaterm_borderchars is type v:t_list in old version vim-floaterm
" strcharpart is useful for multiple-byte characters
if type(borderchars) == v:t_string
let borderchars = map(range(8), { idx -> strcharpart(borderchars, idx, 1) })
endif
let config.borderchars = borderchars
if config.position == 'random'
let randnum = str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:])
if s:get_wintype() == 'normal'
let config.position = ['top', 'right', 'bottom', 'left'][randnum % 4]
else
let config.position = ['top', 'right', 'bottom', 'left', 'center', 'topleft', 'topright', 'bottomleft', 'bottomright', 'auto'][randnum % 10]
endif
endif
let [row, col, anchor] = s:get_floatwin_pos(config.width, config.height, config.position)
let config['anchor'] = anchor
let config['row'] = row
let config['col'] = col
return config
function! s:winexists(winid) abort
return !empty(getwininfo(a:winid))
endfunction
function! s:open_float(bufnr, config) abort
@ -183,7 +122,7 @@ function! s:open_float(bufnr, config) abort @@ -183,7 +122,7 @@ function! s:open_float(bufnr, config) abort
\ }
let winid = nvim_open_win(a:bufnr, v:true, options)
call s:init_win(winid, v:false)
call floaterm#buffer#set_config(a:bufnr, 'winid', winid)
call floaterm#config#set(a:bufnr, 'winid', winid)
let bd_options = {
\ 'relative': 'editor',
@ -195,11 +134,10 @@ function! s:open_float(bufnr, config) abort @@ -195,11 +134,10 @@ function! s:open_float(bufnr, config) abort
\ 'focusable': v:false,
\ 'style':'minimal',
\ }
let a:config.title = s:make_title(a:bufnr, a:config.title)
let bd_bufnr = floaterm#buffer#create_border_buf(a:config)
let bd_winid = nvim_open_win(bd_bufnr, v:false, bd_options)
call s:init_win(bd_winid, v:true)
call floaterm#buffer#set_config(a:bufnr, 'borderwinid', bd_winid)
call floaterm#config#set(a:bufnr, 'borderwinid', bd_winid)
return winid
endfunction
@ -212,6 +150,7 @@ function! s:open_popup(bufnr, config) abort @@ -212,6 +150,7 @@ function! s:open_popup(bufnr, config) abort
\ 'minwidth': a:config.width - 2,
\ 'maxheight': a:config.height - 2,
\ 'minheight': a:config.height - 2,
\ 'title': a:config.title,
\ 'border': [1, 1, 1, 1],
\ 'borderchars': a:config.borderchars,
\ 'borderhighlight': ['FloatermBorder'],
@ -219,31 +158,22 @@ function! s:open_popup(bufnr, config) abort @@ -219,31 +158,22 @@ function! s:open_popup(bufnr, config) abort
\ 'highlight': 'Floaterm',
\ 'zindex': len(floaterm#buflist#gather()) + 1
\ }
" vim will pad the end of title but not begin part
" so we build the title as ' floaterm (idx/cnt)'
let title =s:make_title(a:bufnr, a:config.title)
let options.title = empty(title) ? '' : ' ' . title
let winid = popup_create(a:bufnr, options)
call s:init_win(winid, v:false)
call floaterm#buffer#set_config(a:bufnr, 'winid', winid)
call floaterm#config#set(a:bufnr, 'winid', winid)
return winid
endfunction
function! s:open_split(bufnr, config) abort
if a:config.position == 'top'
execute 'topleft' . a:config.height . 'split'
elseif a:config.position == 'left'
execute 'topleft' . a:config.width . 'vsplit'
elseif a:config.position == 'right'
execute 'botright' . a:config.width . 'vsplit'
else " default position: bottom
execute 'botright' . a:config.height . 'split'
if a:config.wintype == 'split'
execute a:config.position . a:config.height . 'split'
elseif a:config.wintype == 'vsplit'
execute a:config.position . a:config.width . 'vsplit'
endif
execute 'buffer ' . a:bufnr
let winid = win_getid()
call s:init_win(winid, v:false)
call floaterm#buffer#set_config(a:bufnr, 'winid', winid)
call floaterm#config#set(a:bufnr, 'winid', winid)
return winid
endfunction
@ -258,39 +188,62 @@ function! s:init_win(winid, is_border) abort @@ -258,39 +188,62 @@ function! s:init_win(winid, is_border) abort
endif
call setwinvar(a:winid, '&sidescrolloff', 0)
call setwinvar(a:winid, '&colorcolumn', '')
call setwinvar(a:winid, '&winfixheight', 1)
call setwinvar(a:winid, '&winfixwidth', 1)
endfunction
" :currpos: the position of the floaterm which will be opened soon
function! s:autohide(currpos) abort
if g:floaterm_autohide == 2
" hide all other floaterms
call floaterm#hide(1, 0, '')
elseif g:floaterm_autohide == 1
" hide all other floaterms that will be overlaied by this one
for bufnr in floaterm#buflist#gather()
if getbufvar(bufnr, 'floaterm_position') == a:currpos
call floaterm#hide(0, bufnr, '')
endif
endfor
elseif g:floaterm_autohide == 0
" nop
endif
endfunction
function! floaterm#window#open(bufnr, config) abort
let config = s:parse_config(a:bufnr, a:config)
if config.wintype == 'normal'
call s:open_split(a:bufnr, config)
let winnr = bufwinnr(a:bufnr)
if winnr > -1
execute winnr . 'wincmd w'
return
endif
call s:autohide(a:config.position)
if a:config.wintype =~ 'split'
call s:open_split(a:bufnr, a:config)
else " backward compatiblity: float|floating|popup -> float
if s:has_float
call s:open_float(a:bufnr, config)
call s:open_float(a:bufnr, a:config)
else
call s:open_popup(a:bufnr, config)
call s:open_popup(a:bufnr, a:config)
endif
endif
endfunction
function! floaterm#window#hide(bufnr) abort
let winid = floaterm#buffer#get_config(a:bufnr, 'winid', -1)
let bd_winid = floaterm#buffer#get_config(a:bufnr, 'borderwinid', -1)
if getbufvar(a:bufnr, '&filetype') != 'floaterm'
return
endif
let winid = floaterm#config#get(a:bufnr, 'winid', -1)
let bd_winid = floaterm#config#get(a:bufnr, 'borderwinid', -1)
if has('nvim')
if s:winexists(winid)
if s:winexists(winid)
call nvim_win_close(winid, v:true)
endif
if s:winexists(bd_winid)
call nvim_win_close(bd_winid, v:true)
endif
else
if exists('*win_gettype')
if win_gettype() == 'popup'
call popup_close(winid)
elseif bufwinnr(a:bufnr) > 0
silent! execute bufwinnr(a:bufnr) . 'hide'
endif
else
if s:winexists(winid)
try
call popup_close(winid)
catch

61
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/broot.vim

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
" vim:sw=2:
" ============================================================================
" FileName: broot.vim
" Author: voldikss <dyzplus@gmail.com>
" GitHub: https://github.com/voldikss
" ============================================================================
let s:broot_default_confpath = fnamemodify('~/.config/broot/conf.hjson', ':p')
let s:broot_wrapper_confpath = fnamemodify(expand('<sfile>'), ':h') . '/broot.hjson'
let s:broot_confpath = s:broot_wrapper_confpath . ';' . s:broot_default_confpath
let s:broot_wrapper_config = [
\ '{',
\ ' verbs: [',
\ ' {',
\ ' invocation: terminal',
\ ' key: enter',
\ ' execution: ":print_path"',
\ ' apply_to: file',
\ ' }',
\ ' ]',
\ '}',
\ ]
call writefile(s:broot_wrapper_config, s:broot_wrapper_confpath)
function! floaterm#wrapper#broot#(cmd, jobopts, config) abort
let s:broot_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
let cmdlist = split(a:cmd)
let cmd = printf(
\ '%s --conf "%s" --out "%s"',
\ a:cmd,
\ s:broot_confpath,
\ s:broot_tmpfile
\ )
exe "lcd " . original_dir
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:broot_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:broot_callback(job, data, event, opener) abort
if filereadable(s:broot_tmpfile)
let filenames = readfile(s:broot_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

26
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/fff.vim

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
" GitHub: https://github.com/benwoodward
" ============================================================================
function! floaterm#wrapper#fff#(cmd) abort
function! floaterm#wrapper#fff#(cmd, jobopts, config) abort
let original_dir = getcwd()
lcd %:p:h
@ -18,10 +18,13 @@ function! floaterm#wrapper#fff#(cmd) abort @@ -18,10 +18,13 @@ function! floaterm#wrapper#fff#(cmd) abort
endif
exe "lcd " . original_dir
return [cmd, {'on_exit': funcref('s:fff_callback')}, v:false]
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:fff_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:fff_callback(...) abort
function! s:fff_callback(job, data, event, opener) abort
let s:fff_tmpfile = $XDG_CACHE_HOME
if !isdirectory(s:fff_tmpfile)
@ -32,16 +35,17 @@ function! s:fff_callback(...) abort @@ -32,16 +35,17 @@ function! s:fff_callback(...) abort
let s:fff_tmpfile = fnameescape(s:fff_tmpfile)
if filereadable(s:fff_tmpfile)
let file_data = readfile(s:fff_tmpfile)
execute delete(s:fff_tmpfile)
else
return
endif
if filereadable(file_data[0])
let filenames = readfile(s:fff_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
execute g:floaterm_open_command . ' ' . file_data[0]
let locations = []
for filename in filenames
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

24
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/fzf.vim

@ -5,22 +5,36 @@ @@ -5,22 +5,36 @@
" GitHub: https://github.com/voldikss
" ============================================================================
function! floaterm#wrapper#fzf#(cmd) abort
function! floaterm#wrapper#fzf#(cmd, jobopts, config) abort
let s:fzf_tmpfile = tempname()
let cmd = a:cmd . ' > ' . s:fzf_tmpfile
return [cmd, {'on_exit': funcref('s:fzf_callback')}, v:false]
let cmd = a:cmd
if cmd !~ '--preview'
if executable('bat')
let cmd .= ' --preview ' . shellescape('bat --style=numbers --color=always {}')
else
let cmd .= ' --preview ' . shellescape('cat -n {}')
endif
endif
let cmd .= ' > ' . s:fzf_tmpfile
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:fzf_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:fzf_callback(...) abort
function! s:fzf_callback(job, data, event, opener) abort
if filereadable(s:fzf_tmpfile)
let filenames = readfile(s:fzf_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

14
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/lf.vim

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
" GitHub: https://github.com/benwoodward
" ============================================================================
function! floaterm#wrapper#lf#(cmd) abort
function! floaterm#wrapper#lf#(cmd, jobopts, config) abort
let s:lf_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
@ -19,19 +19,25 @@ function! floaterm#wrapper#lf#(cmd) abort @@ -19,19 +19,25 @@ function! floaterm#wrapper#lf#(cmd) abort
endif
exe "lcd " . original_dir
return [cmd, {'on_exit': funcref('s:lf_callback')}, v:false]
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:lf_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:lf_callback(...) abort
function! s:lf_callback(job, data, event, opener) abort
if filereadable(s:lf_tmpfile)
let filenames = readfile(s:lf_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

14
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/nnn.vim

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
" GitHub: https://github.com/voldikss
" ============================================================================
function! floaterm#wrapper#nnn#(cmd) abort
function! floaterm#wrapper#nnn#(cmd, jobopts, config) abort
let s:nnn_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
@ -19,19 +19,25 @@ function! floaterm#wrapper#nnn#(cmd) abort @@ -19,19 +19,25 @@ function! floaterm#wrapper#nnn#(cmd) abort
endif
exe "lcd " . original_dir
return [cmd, {'on_exit': funcref('s:nnn_callback')}, v:false]
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:nnn_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:nnn_callback(...) abort
function! s:nnn_callback(job, data, event, opener) abort
if filereadable(s:nnn_tmpfile)
let filenames = readfile(s:nnn_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

24
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/ranger.vim

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
" GitHub: https://github.com/voldikss
" ============================================================================
function! floaterm#wrapper#ranger#(cmd) abort
function! floaterm#wrapper#ranger#(cmd, jobopts, config) abort
let s:ranger_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
@ -15,27 +15,35 @@ function! floaterm#wrapper#ranger#(cmd) abort @@ -15,27 +15,35 @@ function! floaterm#wrapper#ranger#(cmd) abort
if len(cmdlist) > 1
let cmd .= ' ' . join(cmdlist[1:], ' ')
else
if expand('%:p') != ''
let cmd .= ' --selectfile="' . expand('%:p') . '"'
else
let cmd .= ' "' . getcwd() . '"'
if !has_key(a:config, 'cwd')
if expand('%:p') != ''
let cmd .= ' --selectfile="' . expand('%:p') . '"'
else
let cmd .= ' "' . getcwd() . '"'
endif
endif
endif
exe "lcd " . original_dir
return [cmd, {'on_exit': funcref('s:ranger_callback')}, v:false]
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:ranger_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:ranger_callback(...) abort
function! s:ranger_callback(job, data, event, opener) abort
if filereadable(s:ranger_tmpfile)
let filenames = readfile(s:ranger_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

54
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/rg.vim

@ -5,23 +5,65 @@ @@ -5,23 +5,65 @@
" GitHub: https://github.com/voldikss
" ============================================================================
function! floaterm#wrapper#rg#(cmd) abort
if executable('bat')
let s:viewer = 'bat --style=numbers --color=always --highlight-line {2}'
elseif executable('batcat')
let s:viewer = 'batcat --style=numbers --color=always --highlight-line {2}'
else
let s:viewer = 'cat -n'
endif
function! floaterm#wrapper#rg#(cmd, jobopts, config) abort
let FZF_DEFAULT_COMMAND = join([
\ "rg",
\ "--column",
\ "--line-number",
\ "--no-heading",
\ "--color=always",
\ "--smart-case",
\ join(split(a:cmd)[1:])
\ ])
let s:rg_tmpfile = tempname()
let cmd = a:cmd . '| fzf > ' . s:rg_tmpfile
return [cmd, {'on_exit': funcref('s:rg_callback')}, v:false]
let prog = 'fzf'
let arglist = [
\ '--ansi',
\ '--multi',
\ '--no-height',
\ '--delimiter :',
\ '--bind ctrl-/:toggle-preview' ,
\ '--bind alt-a:select-all,alt-d:deselect-all',
\ '--preview-window +{2}-/2 --preview-window right',
\ printf('--preview "%s {1}"', s:viewer)
\ ]
let cmd = printf('%s %s > %s', prog, join(arglist), s:rg_tmpfile)
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {
\ 'on_exit': funcref('s:rg_callback'),
\ 'env': {'FZF_DEFAULT_COMMAND': FZF_DEFAULT_COMMAND}
\ }
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:rg_callback(...) abort
function! s:rg_callback(job, data, event, opener) abort
if filereadable(s:rg_tmpfile)
let filenames = readfile(s:rg_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
let realfilename = matchlist(filename, '\(.\{-}\):.*$')[1]
execute g:floaterm_open_command . ' ' . fnameescape(realfilename)
let parts = matchlist(filename, '\(.\{-}\)\s*:\s*\(\d\+\)\%(\s*:\s*\(\d\+\)\)\?\%(\s*:\(.*\)\)\?')
let dict = {
\ 'filename': fnamemodify(parts[1], ':p'),
\ 'lnum': parts[2],
\ 'text': parts[4]
\ }
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

20
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/vifm.vim

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
" GitHub: https://github.com/kazhala
" ============================================================================
function! floaterm#wrapper#vifm#(cmd) abort
function! floaterm#wrapper#vifm#(cmd, jobopts, config) abort
let s:vifm_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
@ -19,19 +19,31 @@ function! floaterm#wrapper#vifm#(cmd) abort @@ -19,19 +19,31 @@ function! floaterm#wrapper#vifm#(cmd) abort
endif
exe "lcd " . original_dir
return [cmd, {'on_exit': funcref('s:vifm_callback')}, v:false]
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:vifm_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:vifm_callback(...) abort
function! s:vifm_callback(job, data, event, opener) abort
if filereadable(s:vifm_tmpfile)
let filenames = readfile(s:vifm_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
execute g:floaterm_open_command . ' ' . fnameescape(filename)
if isdirectory(filename)
exe "cd " . filename
else
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endif
endfor
if len(locations) != 0
call floaterm#util#open(locations, a:opener)
endif
endif
endif
endfunction

43
etc/soft/nvim/+plugins/vim-floaterm/autoload/floaterm/wrapper/xplr.vim

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
" vim:sw=2:
" ============================================================================
" FileName: xplr.vim
" Author: Arijit Basu <sayanarijit@gmail.com>
" GitHub: https://github.com/sayanarijit
" ============================================================================
function! floaterm#wrapper#xplr#(cmd, jobopts, config) abort
let s:xplr_tmpfile = tempname()
let original_dir = getcwd()
lcd %:p:h
let cmdlist = split(a:cmd)
let cmd = 'xplr > "' . s:xplr_tmpfile . '"'
if len(cmdlist) > 1
let cmd .= ' ' . join(cmdlist[1:], ' ')
else
let cmd .= ' "' . getcwd() . '"'
endif
exe "lcd " . original_dir
let cmd = [&shell, &shellcmdflag, cmd]
let jobopts = {'on_exit': funcref('s:xplr_callback')}
call floaterm#util#deep_extend(a:jobopts, jobopts)
return [v:false, cmd]
endfunction
function! s:xplr_callback(job, data, event, opener) abort
if filereadable(s:xplr_tmpfile)
let filenames = readfile(s:xplr_tmpfile)
if !empty(filenames)
if has('nvim')
call floaterm#window#hide(bufnr('%'))
endif
let locations = []
for filename in filenames
let dict = {'filename': fnamemodify(filename, ':p')}
call add(locations, dict)
endfor
call floaterm#util#open(locations, a:opener)
endif
endif
endfunction

59
etc/soft/nvim/+plugins/vim-floaterm/autoload/health/floaterm.vim

@ -5,32 +5,63 @@ @@ -5,32 +5,63 @@
" GitHub: https://github.com/voldikss
" ============================================================================
let s:home = fnamemodify(resolve(expand('<sfile>:p')), ':h:h:h')
function! s:check_common() abort
call health#report_start('common')
call health#report_info('Platform: ' . s:get_platform_info())
call health#report_info('Nvim: ' . s:get_nvim_info())
call health#report_info('Plugin: ' . s:get_plugin_info())
endfunction
function! s:check_terminal() abort
call health#report_start('terminal')
if exists(':terminal') > 0
call health#report_ok('Terminal feature is OK')
call health#report_ok('Terminal emulator is available')
else
call health#report_error('Terminal feature is required but not found')
call health#report_error(
\ 'Terminal emulator is missing',
\ ['Install the latest version neovim']
\ )
endif
endfunction
function! s:check_floating() abort
if has('nvim') && exists('*nvim_win_set_config')
call health#report_ok('Floating window feature is OK')
else
call health#report_error('Floating window feature is required but not found, will use normal window')
endif
endfunction
function! s:check_nvr() abort
if executable('nvr')
call health#report_ok('nvr is OK')
call health#report_start('floating')
if exists('*nvim_win_set_config')
call health#report_ok('Floating window is available')
else
call health#report_error('nvr executable is not found, run `pip3 install neovim-remote` to install')
call health#report_warn(
\ 'Floating window is missing, will fallback to use normal window',
\ ['Install the latest version neovim']
\ )
endif
endfunction
function! health#floaterm#check() abort
call s:check_common()
call s:check_terminal()
call s:check_floating()
call s:check_nvr()
endfunction
function! s:get_nvim_info() abort
return split(execute('version'), "\n")[0]
endfunction
function! s:get_platform_info() abort
if has('win32') || has('win64')
return 'win'
elseif has('mac') || has('macvim')
return 'macos'
endif
return 'linux'
endfunction
function! s:get_plugin_info() abort
let save_cwd = getcwd()
silent! execute 'cd ' . s:home
let result = system('git rev-parse --short HEAD')
silent! execute 'cd ' . save_cwd
return result
endfunction

144
etc/soft/nvim/+plugins/vim-floaterm/doc/floaterm.txt

@ -5,7 +5,7 @@ License: MIT license @@ -5,7 +5,7 @@ License: MIT license
NOTE: This doc may be outdated, please refer to the README file instead,
https://github.com/voldikss/vim-floaterm/blob/master/README.md
or
../README.md
../README.md(put the cursor on this and type `gf`)
==============================================================================
CONTENTS *floaterm-contents*
@ -18,6 +18,7 @@ Extensions |floaterm-extensions| @@ -18,6 +18,7 @@ Extensions |floaterm-extensions|
Integrations |floaterm-integrations|
FAQ |floaterm-faq|
Repository |floaterm-repository|
==============================================================================
INTRODUCTION *floaterm-introduction*
@ -32,6 +33,7 @@ Use (neo)vim terminal in the floating/popup window. @@ -32,6 +33,7 @@ Use (neo)vim terminal in the floating/popup window.
- Integrate with other external command-line tools(ranger, lf, fzf, etc.)
- Autocompletion from within floaterms(require |coc.nvim|)
- Use as a custom task runner for |asynctasks.vim|
==============================================================================
OPTIONS *floaterm-options*
@ -48,8 +50,8 @@ g:floaterm_title *g:floaterm_title* @@ -48,8 +50,8 @@ g:floaterm_title *g:floaterm_title*
g:floaterm_wintype *g:floaterm_wintype*
Type |String|.
'float'(nvim's floatwin or vim's popupwin) by default. Set it to 'normal'
if your vim/nvim doesn't support |api-floatwin| or |popup-window|.
'float'(nvim's floatwin or vim's popupwin) by default. Set it to
'split' or 'vsplit'if you don't want to use floating or popup window.
g:floaterm_width *g:floaterm_width*
Type: |Number| (number of columns) or |Float| (between 0 and 1).
@ -64,11 +66,17 @@ g:floaterm_height *g:floaterm_height* @@ -64,11 +66,17 @@ g:floaterm_height *g:floaterm_height*
g:floaterm_position *g:floaterm_position*
Type |String|.
The position of the floaterm window.
If |g:floaterm_wintype| is 'normal', the value can be 'top', 'right',
'bottom', 'left'. Default value is 'bottom'.
If |g:floaterm_wintype| is 'popup', the value can be 'top', 'right', 'bottom',
'left', 'center', 'topleft', 'topright', 'bottomleft', 'bottomright',
'auto'(at the cursor place). Default value is 'center'.
If |g:floaterm_wintype| is 'split' or 'vsplit': 'leftabove', 'aboveleft',
'rightbelow', 'belowright', 'topleft', 'botright'.
Default: 'botright'.
It's recommended to have a look at those options meanings, e.g.
>
`:help :leftabove`.
<
If |g:floaterm_wintype| is 'float': 'top', 'bottom', 'left', 'right',
'topleft', 'topright', 'bottomleft', 'bottomright', 'center', 'auto'(at the
cursor place).
Default: 'center'
g:floaterm_borderchars *g:floaterm_borderchars*
Type |String|.
@ -78,60 +86,41 @@ g:floaterm_borderchars *g:floaterm_borderchars* @@ -78,60 +86,41 @@ g:floaterm_borderchars *g:floaterm_borderchars*
g:floaterm_rootmarkers *g:floaterm_rootmarkers*
Type |List| of |String|.
Markers used to detect the project root directory when running
Markers used to detect the project root directory when running
>
:FloatermNew --cwd=<root>
<
Default: `['.project', '.git', '.hg', '.svn', '.root']`
g:floaterm_open_command *g:floaterm_open_command*
Type |String|.
Command used for opening a file in the outside nvim from within
|terminal|. The value can be 'edit', 'split', 'vsplit', 'tabe', 'drop'.
Default value is 'edit'.
g:floaterm_gitcommit *g:floaterm_gitcommit*
Type |String|.
Opening strategy for `COMMIT_EDITMSG` window by running `git commit` in
the floaterm window. Only works in neovim. The value can be
'floaterm'(open gitcommit in the floaterm window), 'split'(recommended),
'vsplit', 'tabe'.
Default value is '', which means this feature is disabled by default(use
your own `$GIT_EDITOR`).
g:floaterm_opener
Type |String|.
Command used for opening a file in the outside nvim from within `:terminal`.
Available: 'edit', 'split', 'vsplit', 'tabe', 'drop' or user-defined commands
Default: 'split'
g:floaterm_autoclose *g:floaterm_autoclose*
Type |Number|.
Whether to close floaterm window once a job gets finished.
0 - Always do NOT close floaterm window.
1 - Close window only if the job exits normally
2 - Always close floaterm window.
Default value is 0.
0 - Always do NOT close floaterm window.
1 - Close window only if the job exits normally
2 - Always close floaterm window.
Default value is 1.
g:floaterm_autohide *g:floaterm_autohide*
Type |Number|.
Whether to hide previous floaterms before switching to or opening a another
one.
0 - Always do NOT hide previous floaterm windows
1 - Only hide those whose position (`b:floaterm_position`) is identical to
that of the floaterm which will be opened
2 - Always hide them
Default value is 1.
g:floaterm_autoinsert *g:floaterm_autoinsert*
Type |Boolean|.
Whether to enter |Terminal-mode| after opening a floaterm.
Default value is |v:true|.
g:floaterm_autohide *g:floaterm_autohide*
Type |Boolean|.
Decide whether to hide previous floaterms before switching to or opening
another one.
Default value is |v:true|.
g:floaterm_complete_options *g:floaterm_complete_options*
Type |Dict|.
Autocompletion options used for coc.nvim.
Available options:
- `shortcut`: a string
- `priority`: number between 0-99
- `filetypes`: array of filetype names this source should be triggered
by. Available for all filetypes when ommited and for no filetypes
when empty
- `firstMatch`: if not falsy, only the completion item that has the
first letter matching the user input will be shown
- `triggerCharacters`: trigger characters for this source.
Default value: `{'shortcut': 'floaterm', 'priority': 5}`
==============================================================================
MAPPINGS *floaterm-mappings*
@ -207,7 +196,7 @@ COMMANDS *floaterm-commands* @@ -207,7 +196,7 @@ COMMANDS *floaterm-commands*
:[N]FloatermKill[!] [floaterm_name] *FloatermKill*
Kill the current floaterm instance
:FloatermSend [--name=floaterm_name] [cmd] *FloatermSend*
:FloatermSend[!] [--name=floaterm_name] [cmd] *FloatermSend*
Send command to a job in floaterm.
For the detailed information about the arguments, please refer to
@ -233,7 +222,9 @@ no-current-focused window(:help |hl-NormalNC|). @@ -233,7 +222,9 @@ no-current-focused window(:help |hl-NormalNC|).
EXTENSIONS *floaterm-extensions*
------------------------------------------------------------------------------
VIM-CLAP *clap-floaterm*
CLAP-FLOATERM *clap-floaterm*
Install voldikss/clap-floaterm.
Start |vim-clap| to manage floaterms.
>
@ -242,6 +233,8 @@ Start |vim-clap| to manage floaterms. @@ -242,6 +233,8 @@ Start |vim-clap| to manage floaterms.
------------------------------------------------------------------------------
DENITE-FLOATERM *denite-floaterm*
Install delphinus/denite-floaterm.
*denite-source-floaterm*
SOURCES~
@ -280,7 +273,7 @@ Start with all features and preview automatically with moving the cursor. @@ -280,7 +273,7 @@ Start with all features and preview automatically with moving the cursor.
------------------------------------------------------------------------------
COC-FLOATERM *coc-floaterm*
Install coc-floaterm firstly.
Install coc-floaterm using `:CocInstall coc-floaterm`
COMMANDS~
>
@ -296,7 +289,7 @@ COMMANDS~ @@ -296,7 +289,7 @@ COMMANDS~
<
COCLIST~
>
CocList floaterm
:CocList floaterm
<
------------------------------------------------------------------------------
FZF-FLOATERM *fzf-floaterm*
@ -308,61 +301,22 @@ Install voldikss/fzf-floaterm and run: @@ -308,61 +301,22 @@ Install voldikss/fzf-floaterm and run:
------------------------------------------------------------------------------
LEADERF-FLOATERM *leaderf-floaterm*
Install voldikss/leaderf-floaterm and run:
Install voldikss/LeaderF-floaterm and run:
>
:Leaderf floaterm
<
------------------------------------------------------------------------------
ASYNCTASKS.VIM *asynctasks.vim*
This plugin can be a runner for |asynctasks.vim|. To use it, copy the
following code to your `vimrc` set |g:asynctasks_term_pos| to `'floaterm'` or
add a `pos=floaterm` filed in your asynctasks configuration files.
>
function! s:run_in_floaterm(opts)
execute 'FloatermNew --position=bottomright' .
\ ' --wintype=float' .
\ ' --height=0.4' .
\ ' --width=0.4' .
\ ' --title=floaterm_runner' .
\ ' --autoclose=0' .
\ ' --silent=' . get(a:opts, 'silent', 0)
\ ' --cwd=' . a:opts.cwd
\ ' ' . a:opts.cmd
" Do not focus on floaterm window, and close it once cursor moves
" If you want to jump to the floaterm window, use <C-w>p
" You can choose whether to use the following code or not
stopinsert | noa wincmd p
augroup close-floaterm-runner
autocmd!
autocmd CursorMoved,InsertEnter * ++nested
\ call timer_start(100, { -> s:close_floaterm_runner() })
augroup END
endfunction
function! s:close_floaterm_runner() abort
if &ft == 'floaterm' | return | endif
for b in tabpagebuflist()
if getbufvar(b, '&ft') == 'floaterm' &&
\ getbufvar(b, 'floaterm_jobexists') == v:false
execute b 'bwipeout!'
break
endif
endfor
autocmd! close-floaterm-runner
endfunction
let g:asyncrun_runner = get(g:, 'asyncrun_runner', {})
let g:asyncrun_runner.floaterm = function('s:run_in_floaterm')
let g:asynctasks_term_pos = 'floaterm'
<
Then your task will be ran in the floaterm instance. See
https://github.com/skywind3000/asynctasks.vim/wiki/Customize-Runner for more
information.
This plugin can be a runner for |asynctasks.vim| or |asyncrun.vim|. See
[|asyncrun.extra|](https://github.com/skywind3000/asyncrun.extra) for the
installation and usage.
==============================================================================
INTEGRATIONS *floaterm-integrations*
Please refer to
https://github.com/voldikss/vim-floaterm#integrate-with-command-line-tools
https://github.com/voldikss/vim-floaterm#use-with-command-line-tools
==============================================================================
FAQ *floaterm-faq*

93
etc/soft/nvim/+plugins/vim-floaterm/plugin/floaterm.vim

@ -7,6 +7,9 @@ @@ -7,6 +7,9 @@
if exists('g:loaded_floaterm')
finish
elseif !has('nvim') && !has('terminal')
call floaterm#util#show_msg("floaterm requires vim to be compiled with 'terminal'", "error")
finish
endif
let g:loaded_floaterm = 1
@ -15,30 +18,18 @@ let g:floaterm_title = get(g:, 'floaterm_title', 'floaterm($1/$2)') @@ -15,30 +18,18 @@ let g:floaterm_title = get(g:, 'floaterm_title', 'floaterm($1/$2)')
let g:floaterm_width = get(g:, 'floaterm_width', 0.6)
let g:floaterm_height = get(g:, 'floaterm_height', 0.6)
let g:floaterm_wintype = get(g:, 'floaterm_wintype', 'float')
let g:floaterm_autoclose = get(g:, 'floaterm_autoclose', 0)
let g:floaterm_autoclose = get(g:, 'floaterm_autoclose', 1)
let g:floaterm_autoinsert = get(g:, 'floaterm_autoinsert', v:true)
let g:floaterm_autohide = get(g:, 'floaterm_autohide', v:true)
let g:floaterm_autohide = get(g:, 'floaterm_autohide', 1)
let g:floaterm_position = get(g:, 'floaterm_position', 'center')
let g:floaterm_borderchars = get(g:, 'floaterm_borderchars', '─│─│┌┐┘└')
let g:floaterm_rootmarkers = get(g:, 'floaterm_rootmarkers', ['.project', '.git', '.hg', '.svn', '.root'])
let g:floaterm_open_command = get(g:, 'floaterm_open_command', 'edit')
let g:floaterm_gitcommit = get(g:, 'floaterm_gitcommit', '')
let g:floaterm_complete_options = get(g:, 'floaterm_complete_options', {'shortcut': 'floaterm', 'priority': 5, 'filter_length': [5, 20]})
let g:floaterm_keymap_new = get(g:, 'floaterm_keymap_new', '')
let g:floaterm_keymap_prev = get(g:, 'floaterm_keymap_prev', '')
let g:floaterm_keymap_next = get(g:, 'floaterm_keymap_next', '')
let g:floaterm_keymap_first = get(g:, 'floaterm_keymap_first', '')
let g:floaterm_keymap_last = get(g:, 'floaterm_keymap_last', '')
let g:floaterm_keymap_hide = get(g:, 'floaterm_keymap_hide', '')
let g:floaterm_keymap_show = get(g:, 'floaterm_keymap_show', '')
let g:floaterm_keymap_kill = get(g:, 'floaterm_keymap_kill', '')
let g:floaterm_keymap_toggle = get(g:, 'floaterm_keymap_toggle', '')
let g:floaterm_opener = get(g:, 'floaterm_opener', 'split')
command! -nargs=* -bang -complete=customlist,floaterm#cmdline#complete
\ FloatermNew call floaterm#run('new', <bang>0, <f-args>)
command! -nargs=* -complete=customlist,floaterm#cmdline#complete
\ FloatermUpdate call floaterm#run('update', 0, <f-args>)
command! -nargs=* -complete=customlist,floaterm#cmdline#complete -bang -range
\ FloatermNew call floaterm#run('new', <bang>0, [visualmode(), <range>, <line1>, <line2>], <q-args>)
command! -nargs=* -complete=customlist,floaterm#cmdline#complete
\ FloatermUpdate call floaterm#run('update', 0, [], <q-args>)
command! -nargs=? -count=0 -bang -complete=customlist,floaterm#cmdline#complete_names1
\ FloatermShow call floaterm#show(<bang>0, <count>, <q-args>)
command! -nargs=? -count=0 -bang -complete=customlist,floaterm#cmdline#complete_names1
@ -58,48 +49,28 @@ hi def link Floaterm Normal @@ -58,48 +49,28 @@ hi def link Floaterm Normal
hi def link FloatermNC NormalNC
hi def link FloatermBorder NormalFloat
augroup floaterm_enter_insertmode
autocmd!
autocmd BufEnter * if &ft == 'floaterm' | call floaterm#util#startinsert() | endif
autocmd FileType floaterm call floaterm#util#startinsert()
augroup END
let g:floaterm_keymap_new = get(g:, 'floaterm_keymap_new', '')
let g:floaterm_keymap_prev = get(g:, 'floaterm_keymap_prev', '')
let g:floaterm_keymap_next = get(g:, 'floaterm_keymap_next', '')
let g:floaterm_keymap_first = get(g:, 'floaterm_keymap_first', '')
let g:floaterm_keymap_last = get(g:, 'floaterm_keymap_last', '')
let g:floaterm_keymap_hide = get(g:, 'floaterm_keymap_hide', '')
let g:floaterm_keymap_show = get(g:, 'floaterm_keymap_show', '')
let g:floaterm_keymap_kill = get(g:, 'floaterm_keymap_kill', '')
let g:floaterm_keymap_toggle = get(g:, 'floaterm_keymap_toggle', '')
function! s:install_keymap()
if !empty(g:floaterm_keymap_new)
exe printf('nnoremap <silent> %s :FloatermNew<CR>', g:floaterm_keymap_new)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermNew<CR>', g:floaterm_keymap_new)
endif
if !empty(g:floaterm_keymap_prev)
exe printf('nnoremap <silent> %s :FloatermPrev<CR>', g:floaterm_keymap_prev)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermPrev<CR>', g:floaterm_keymap_prev)
endif
if !empty(g:floaterm_keymap_next)
exe printf('nnoremap <silent> %s :FloatermNext<CR>', g:floaterm_keymap_next)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermNext<CR>', g:floaterm_keymap_next)
endif
if !empty(g:floaterm_keymap_first)
exe printf('nnoremap <silent> %s :FloatermFirst<CR>', g:floaterm_keymap_first)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermFirst<CR>', g:floaterm_keymap_first)
endif
if !empty(g:floaterm_keymap_last)
exe printf('nnoremap <silent> %s :FloatermLast<CR>', g:floaterm_keymap_last)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermLast<CR>', g:floaterm_keymap_last)
endif
if !empty(g:floaterm_keymap_hide)
exe printf('nnoremap <silent> %s :FloatermHide<CR>', g:floaterm_keymap_hide)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermHide<CR>', g:floaterm_keymap_hide)
endif
if !empty(g:floaterm_keymap_show)
exe printf('nnoremap <silent> %s :FloatermShow<CR>', g:floaterm_keymap_show)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermShow<CR>', g:floaterm_keymap_show)
endif
if !empty(g:floaterm_keymap_kill)
exe printf('nnoremap <silent> %s :FloatermKill<CR>', g:floaterm_keymap_kill)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermKill<CR>', g:floaterm_keymap_kill)
endif
if !empty(g:floaterm_keymap_toggle)
exe printf('nnoremap <silent> %s :FloatermToggle<CR>', g:floaterm_keymap_toggle)
exe printf('tnoremap <silent> %s <C-\><C-n>:FloatermToggle<CR>', g:floaterm_keymap_toggle)
function! s:bind_keymap(mapvar, command) abort
if !empty(a:mapvar)
execute printf('nnoremap <silent> %s :%s<CR>', a:mapvar, a:command)
execute printf('tnoremap <silent> %s <C-\><C-n>:%s<CR>', a:mapvar, a:command)
endif
endfunction
call s:install_keymap()
call s:bind_keymap(g:floaterm_keymap_new, 'FloatermNew')
call s:bind_keymap(g:floaterm_keymap_prev, 'FloatermPrev')
call s:bind_keymap(g:floaterm_keymap_next, 'FloatermNext')
call s:bind_keymap(g:floaterm_keymap_first, 'FloatermFirst')
call s:bind_keymap(g:floaterm_keymap_last, 'FloatermLast')
call s:bind_keymap(g:floaterm_keymap_hide, 'FloatermHide')
call s:bind_keymap(g:floaterm_keymap_show, 'FloatermShow')
call s:bind_keymap(g:floaterm_keymap_kill, 'FloatermKill')
call s:bind_keymap(g:floaterm_keymap_toggle, 'FloatermToggle')

25
etc/soft/nvim/+plugins/vim-floaterm/test/base_vader.vim

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
" vim:ft=vim
" Seems vader.vim doesn't support relative path in `Include:`
" So I can not use `Include: ../base.vader`
" The solution is to use vim's `:source` command
function! BufWinExists(bufnr) abort
return bufwinnr(a:bufnr) != -1
endfunction
function! IsFloatOrPopup(winid) abort
if has('nvim')
return has_key(nvim_win_get_config(a:winid), 'anchor')
else
return win_gettype(a:winid) == 'popup'
endif
endfunction
function! IsBufValid(bufnr) abort
return bufexists(a:bufnr) && floaterm#terminal#jobexists(a:bufnr)
endfunction
function! IsInFloatermBuffer() abort
return &ft == 'floaterm'
endfunction

9
etc/soft/nvim/+plugins/vim-floaterm/test/test.sh

@ -5,11 +5,12 @@ CGREEN='\033[0;32m' @@ -5,11 +5,12 @@ CGREEN='\033[0;32m'
CCYAN='\033[0;36m'
CEND='\033[0m' # No Color
# USAGE: ./test/test.sh [vim]
VIM_EXEC=nvim
if [[ $1 = vim ]]
# USAGE: ./test/test.sh [vim-bin]
if [[ $1 = '' ]]
then
VIM_EXEC=/usr/bin/vim
VIM_EXEC=nvim
else
VIM_EXEC=$1
fi
passnum=0

9
etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermKill.vader

@ -1,13 +1,12 @@ @@ -1,13 +1,12 @@
" vim:ft=vim
Execute(test-FloatermKill):
function! IsBufValid(bufnr) abort
return bufexists(a:bufnr) && floaterm#terminal#jobexists(a:bufnr)
endfunction
Execute(Include base):
source test/base_vader.vim
Execute(test-FloatermKill):
Log '# FloatermKill'
FloatermNew
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
FloatermKill
AssertEqual '', &filetype

26
etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermNew.vader

@ -1,17 +1,37 @@ @@ -1,17 +1,37 @@
" vim:ft=vim
Execute(Include base):
source test/base_vader.vim
Given(One line text):
# text to be send
Execute(test-FloatermNew):
Log '# FloatermNew with range'
normal! G
AssertEqual getline('.'), '# text to be send'
execute "normal! V\<Esc>"
:'<,'>FloatermNew
sleep 500m
let bufnr = bufnr()
let lines = getbufline(bufnr, 0, '$')
for l in lines
Log ' ' . l
endfor
Assert IsInFloatermBuffer()
Assert join(lines) =~ '# text to be send'
Log '# FloatermNew'
FloatermNew
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
Log '# FloatermNew!'
FloatermNew!
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
Log '# FloatermNew with arguments'
FloatermNew --height=0.6 --width=0.4 --wintype=float --name=test --position=topleft --autoclose=0 ls
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
FloatermKill!
stopinsert

16
etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermSend.vader

@ -4,17 +4,19 @@ Given(One line text): @@ -4,17 +4,19 @@ Given(One line text):
# text to be send
Execute(test-FloatermSend):
Log '# FloatermNew'
FloatermNew
let bufnr1 = bufnr('%')
FloatermHide
FloatermNew
let bufnr1 = bufnr('%')
FloatermHide
Log '# FloatermSend'
FloatermSend
sleep 500m
let lines = join(getbufline(bufnr1, 0, '$'))
Log lines
Assert lines =~ '# text to be send'
Log getline('.')
let lines = getbufline(bufnr1, 0, '$')
for l in lines
Log ' ' . l
endfor
Assert join(lines) =~ '# text to be send'
Log '# FloatermSend with argument'
FloatermNew

31
etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermShow-FloatermHide.vader

@ -1,39 +1,50 @@ @@ -1,39 +1,50 @@
" vim:ft=vim
Execute(Include base):
source test/base_vader.vim
Execute(FloatermShow/Hide):
Log '# Basic'
Log '# FloatermHide'
FloatermNew
FloatermHide
AssertEqual '', &filetype
Log '# FloatermShow'
FloatermNew
FloatermShow
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
Log '# Show or hide between multiple floaterms'
Log '# FloatermHide!'
FloatermNew
let bufnr1 = bufnr('%')
FloatermNew
let bufnr2 = bufnr('%')
FloatermHide!
AssertEqual -1,bufwinnr(bufnr1)
AssertEqual -1,bufwinnr(bufnr2)
Assert !BufWinExists(bufnr1)
Assert !BufWinExists(bufnr2)
Log '# FloatermShow!'
if has('nvim')
" NOTE: the 2 floaterms must have different positions can `:FloatermShow!
" ` take effect
FloatermNew --position=left
let bufnr1 = bufnr('%')
FloatermNew --position=right
let bufnr2 = bufnr('%')
FloatermShow!
AssertNotEqual -1,bufwinnr(bufnr1)
AssertNotEqual -1,bufwinnr(bufnr2)
Assert BufWinExists(bufnr1)
Assert BufWinExists(bufnr2)
endif
Log '# [N]FloatermHide'
FloatermNew
let bufnr1 = bufnr('%')
execute bufnr1 . 'FloatermHide'
AssertEqual -1,bufwinnr(bufnr1)
Assert !BufWinExists(bufnr1)
FloatermNew
let bufnr2 = bufnr('%')
execute bufnr2 . 'FloatermHide'
AssertEqual -1,bufwinnr(bufnr2)
Assert !BufWinExists(bufnr2)
Log '# [N]FloatermShow'
if has('nvim')

32
etc/soft/nvim/+plugins/vim-floaterm/test/test_commands/test-FloatermToggle.vader

@ -1,29 +1,37 @@ @@ -1,29 +1,37 @@
" vim:ft=vim
Execute(Include base):
source test/base_vader.vim
Execute(FloatermToggle):
Log '# Basic'
Log '# FloatermToggle'
FloatermToggle
AssertEqual 'floaterm', &filetype
Assert IsInFloatermBuffer()
FloatermToggle
AssertEqual '', &filetype
Log '# Toggle between multiple floaterms'
FloatermNew
Log '# FloatermToggle!'
FloatermKill!
Assert empty(floaterm#buflist#gather())
FloatermToggle! " FloatermToggle! should open floaterm if there are no floaterms opened yet.
Assert IsInFloatermBuffer()
" NOTE: the 2 floaterms must have different positions can `:FloatermShow!
" ` take effect
FloatermNew --position=left
let bufnr1 = bufnr('%')
FloatermToggle
FloatermNew
FloatermNew --position=right
let bufnr2 = bufnr('%')
FloatermToggle
if has('nvim')
Log '# FloatermToggle! to show and hide'
Log ' * FloatermToggle! to hide'
FloatermToggle!
AssertNotEqual -1,bufwinnr(bufnr1)
AssertNotEqual -1,bufwinnr(bufnr2)
Assert !BufWinExists(bufnr1)
Assert !BufWinExists(bufnr2)
Log ' * FloatermToggle! to show'
FloatermToggle!
AssertEqual -1,bufwinnr(bufnr1)
AssertEqual -1,bufwinnr(bufnr2)
Assert BufWinExists(bufnr1)
Assert BufWinExists(bufnr2)
endif
Log '# [N]FloatermToggle'

13
etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_AsyncRun-floaterm-runner.vader

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
" vim:ft=vim
Execute(test_AsyncRun-floaterm-runner):
if !g:run_in_ci | finish | endif
AsyncRun -mode=term -pos=floaterm -position=bottomright -width=0.4 ls -la
AssertEqual &ft, 'floaterm'
FloatermHide
FloatermKill!
stopinsert

15
etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_Clap-floaterm.vader

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
" vim:ft=vim
Execute(test_Clap-floaterm):
if !g:run_in_ci | finish | endif
FloatermNew
FloatermHide
let candidates = g:clap#provider#floaterm#.source()
Log candidates
Assert !empty(candidates)
FloatermKill!
stopinsert

14
etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_Fzf-floaterm.vader

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
" vim:ft=vim
Execute(test_Fzf-floaterm):
if !g:run_in_ci | finish | endif
FloatermNew
FloatermHide
let candidates = fzf_floaterm#feed()
Log candidates
Assert !empty(candidates)
FloatermKill!
stopinsert

14
etc/soft/nvim/+plugins/vim-floaterm/test/test_extensions/test_LeaderF-floaterm.vader

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
" vim:ft=vim
Execute(test_LeaderF-floaterm):
if !g:run_in_ci | finish | endif
FloatermNew
FloatermHide
let candidates = lf_floaterm#source()
Log candidates
Assert !empty(candidates)
FloatermKill!
stopinsert

182
etc/soft/nvim/+plugins/vim-floaterm/test/test_functions/test-floaterm_cmdline.vader

@ -17,7 +17,7 @@ Before(Define universal function used to test command completion): @@ -17,7 +17,7 @@ Before(Define universal function used to test command completion):
Execute(Test floaterm#cmdline#parse):
let argstr ='--height=0.6 --width=0.4 --wintype=float --name=floaterm1 --position=topleft --autoclose=2 ranger --cmd="cd ~"'
let [cmd, config] = floaterm#cmdline#parse(split(argstr))
let [cmd, config] = floaterm#cmdline#parse(argstr)
AssertEqual 'ranger --cmd="cd ~"', cmd
AssertEqual {
\ 'wintype': 'float',
@ -34,48 +34,48 @@ Execute(Test floaterm#cmdline#parse expand feature): @@ -34,48 +34,48 @@ Execute(Test floaterm#cmdline#parse expand feature):
normal! gg0
" %<
AssertEqual expand('%<'), floaterm#cmdline#parse(split('%<'))[0]
AssertEqual expand('%<'), floaterm#cmdline#parse('%<')[0]
" %\(:[phtreS8\~\.]\)
AssertEqual expand('%'), floaterm#cmdline#parse(split('%'))[0]
AssertEqual expand('%:p'), floaterm#cmdline#parse(split('%:p'))[0]
AssertEqual expand('%:h'), floaterm#cmdline#parse(split('%:h'))[0]
AssertEqual expand('%:t'), floaterm#cmdline#parse(split('%:t'))[0]
AssertEqual expand('%:r'), floaterm#cmdline#parse(split('%:r'))[0]
AssertEqual expand('%:e'), floaterm#cmdline#parse(split('%:e'))[0]
AssertEqual expand('%:S'), floaterm#cmdline#parse(split('%:S'))[0]
AssertEqual expand('%:8'), floaterm#cmdline#parse(split('%:8'))[0]
AssertEqual expand('%:~'), floaterm#cmdline#parse(split('%:~'))[0]
AssertEqual expand('%:.'), floaterm#cmdline#parse(split('%:.'))[0]
AssertEqual expand('%'), floaterm#cmdline#parse('%')[0]
AssertEqual expand('%:p'), floaterm#cmdline#parse('%:p')[0]
AssertEqual expand('%:h'), floaterm#cmdline#parse('%:h')[0]
AssertEqual expand('%:t'), floaterm#cmdline#parse('%:t')[0]
AssertEqual expand('%:r'), floaterm#cmdline#parse('%:r')[0]
AssertEqual expand('%:e'), floaterm#cmdline#parse('%:e')[0]
AssertEqual expand('%:S'), floaterm#cmdline#parse('%:S')[0]
AssertEqual expand('%:8'), floaterm#cmdline#parse('%:8')[0]
AssertEqual expand('%:~'), floaterm#cmdline#parse('%:~')[0]
AssertEqual expand('%:.'), floaterm#cmdline#parse('%:.')[0]
" %\(:g\=s?.*?.*?\)
AssertEqual expand('%:s?test?main?'), floaterm#cmdline#parse(split('%:s?test?main?'))[0]
AssertEqual expand('%:gs?test?main?'), floaterm#cmdline#parse(split('%:gs?test?main?'))[0]
AssertEqual '%', floaterm#cmdline#parse(split('\%'))[0]
AssertEqual '%:p', floaterm#cmdline#parse(split('\%:p'))[0]
AssertEqual expand('%:s?test?main?'), floaterm#cmdline#parse('%:s?test?main?')[0]
AssertEqual expand('%:gs?test?main?'), floaterm#cmdline#parse('%:gs?test?main?')[0]
AssertEqual '%', floaterm#cmdline#parse('\%')[0]
AssertEqual '%:p', floaterm#cmdline#parse('\%:p')[0]
" %\(\(:g\=s?.*?.*?\)\|\(:[phtreS8\~\.]\)\)*
AssertEqual expand('%:p:h'), floaterm#cmdline#parse(split('%:p:h'))[0]
AssertEqual expand('%:p:s?test?main?'), floaterm#cmdline#parse(split('%:p:s?test?main?'))[0]
AssertEqual expand('%:p:h'), floaterm#cmdline#parse('%:p:h')[0]
AssertEqual expand('%:p:s?test?main?'), floaterm#cmdline#parse('%:p:s?test?main?')[0]
" <cfile><
AssertEqual expand('<cfile><'), floaterm#cmdline#parse(split('<cfile><'))[0]
AssertEqual expand('<cfile><'), floaterm#cmdline#parse('<cfile><')[0]
" <cfile>\(:[phtreS8\~\.]\)
AssertEqual expand('<cfile>'), floaterm#cmdline#parse(split('<cfile>'))[0]
AssertEqual expand('<cfile>:p'), floaterm#cmdline#parse(split('<cfile>:p'))[0]
AssertEqual expand('<cfile>:h'), floaterm#cmdline#parse(split('<cfile>:h'))[0]
AssertEqual expand('<cfile>:t'), floaterm#cmdline#parse(split('<cfile>:t'))[0]
AssertEqual expand('<cfile>:r'), floaterm#cmdline#parse(split('<cfile>:r'))[0]
AssertEqual expand('<cfile>:e'), floaterm#cmdline#parse(split('<cfile>:e'))[0]
AssertEqual expand('<cfile>:S'), floaterm#cmdline#parse(split('<cfile>:S'))[0]
AssertEqual expand('<cfile>:8'), floaterm#cmdline#parse(split('<cfile>:8'))[0]
AssertEqual expand('<cfile>:~'), floaterm#cmdline#parse(split('<cfile>:~'))[0]
AssertEqual expand('<cfile>:.'), floaterm#cmdline#parse(split('<cfile>:.'))[0]
AssertEqual expand('<cfile>'), floaterm#cmdline#parse('<cfile>')[0]
AssertEqual expand('<cfile>:p'), floaterm#cmdline#parse('<cfile>:p')[0]
AssertEqual expand('<cfile>:h'), floaterm#cmdline#parse('<cfile>:h')[0]
AssertEqual expand('<cfile>:t'), floaterm#cmdline#parse('<cfile>:t')[0]
AssertEqual expand('<cfile>:r'), floaterm#cmdline#parse('<cfile>:r')[0]
AssertEqual expand('<cfile>:e'), floaterm#cmdline#parse('<cfile>:e')[0]
AssertEqual expand('<cfile>:S'), floaterm#cmdline#parse('<cfile>:S')[0]
AssertEqual expand('<cfile>:8'), floaterm#cmdline#parse('<cfile>:8')[0]
AssertEqual expand('<cfile>:~'), floaterm#cmdline#parse('<cfile>:~')[0]
AssertEqual expand('<cfile>:.'), floaterm#cmdline#parse('<cfile>:.')[0]
" <cfile>\(:g\=s?.*?.*?\)
AssertEqual expand('<cfile>:s?test?main?'), floaterm#cmdline#parse(split('<cfile>:s?test?main?'))[0]
AssertEqual expand('<cfile>:gs?test?main?'), floaterm#cmdline#parse(split('<cfile>:gs?test?main?'))[0]
AssertEqual '<cfile>', floaterm#cmdline#parse(split('\<cfile>'))[0]
AssertEqual '<cfile>:p', floaterm#cmdline#parse(split('\<cfile>:p'))[0]
AssertEqual expand('<cfile>:s?test?main?'), floaterm#cmdline#parse('<cfile>:s?test?main?')[0]
AssertEqual expand('<cfile>:gs?test?main?'), floaterm#cmdline#parse('<cfile>:gs?test?main?')[0]
AssertEqual '<cfile>', floaterm#cmdline#parse('\<cfile>')[0]
AssertEqual '<cfile>:p', floaterm#cmdline#parse('\<cfile>:p')[0]
" <cfile>\(\(:g\=s?.*?.*?\)\|\(:[phtreS8\~\.]\)\)*
AssertEqual expand('<cfile>:p:h'), floaterm#cmdline#parse(split('<cfile>:p:h'))[0]
AssertEqual expand('<cfile>:p:s?test?main?'), floaterm#cmdline#parse(split('<cfile>:p:s?test?main?'))[0]
AssertEqual expand('<cfile>:p:h'), floaterm#cmdline#parse('<cfile>:p:h')[0]
AssertEqual expand('<cfile>:p:s?test?main?'), floaterm#cmdline#parse('<cfile>:p:s?test?main?')[0]
silent !rm test.txt
@ -83,117 +83,99 @@ Execute(Test floaterm#cmdline#complete): @@ -83,117 +83,99 @@ Execute(Test floaterm#cmdline#complete):
function! Test__floaterm_cmdline_complete(command, expected)
call CmdlineCompleteTestWrapperFunc(a:command, a:expected, function('floaterm#cmdline#complete'))
endfunction
call Test__floaterm_cmdline_complete('FloatermNew ', [
let all_candidates = [
\ '--cwd=',
\ '--name=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ ])
call Test__floaterm_cmdline_complete('FloatermNew nv', sort(getcompletion('nv', 'shellcmd')))
call Test__floaterm_cmdline_complete('FloatermNew -', [
\ '--cwd=',
\ '--name=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--opener=',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --', [
\ '--cwd=',
\ '--name=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ ])
\ '--disposable',
\ ]
call Test__floaterm_cmdline_complete('FloatermNew ', all_candidates)
call Test__floaterm_cmdline_complete('FloatermNew -', all_candidates)
call Test__floaterm_cmdline_complete('FloatermNew --', all_candidates)
call Test__floaterm_cmdline_complete('FloatermNew nv', sort(getcompletion('nv', 'shellcmd')))
call Test__floaterm_cmdline_complete('FloatermNew --n', ['--name='])
call Test__floaterm_cmdline_complete('FloatermNew --w', ['--width=', '--wintype='])
call Test__floaterm_cmdline_complete('FloatermNew --name=', [])
call Test__floaterm_cmdline_complete('FloatermNew --title=', [])
call Test__floaterm_cmdline_complete('FloatermNew --width=', [])
call Test__floaterm_cmdline_complete('FloatermNew --height=', [])
call Test__floaterm_cmdline_complete('FloatermNew --title=', [])
call Test__floaterm_cmdline_complete('FloatermNew --silent', [])
call Test__floaterm_cmdline_complete('FloatermNew --wintype=', [
\ '--wintype=normal',
\ '--wintype=float'
\ '--wintype=float',
\ '--wintype=split',
\ '--wintype=vsplit',
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --wintype=n', [
\ '--wintype=normal'
call Test__floaterm_cmdline_complete('FloatermNew --wintype=f', [
\ '--wintype=float'
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --position=', [
\ '--position=top',
\ '--position=right',
\ '--position=bottom',
\ '--position=left',
\ '--position=auto',
\ '--position=center',
\ '--position=random',
\ '--position=top',
\ '--position=topleft',
\ '--position=topright',
\ '--position=bottom',
\ '--position=bottomleft',
\ '--position=bottomright',
\ '--position=auto'
\ '--position=left',
\ '--position=right',
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --wintype=split --position=', [
\ '--position=random',
\ '--position=leftabove',
\ '--position=aboveleft',
\ '--position=rightbelow',
\ '--position=belowright',
\ '--position=topleft',
\ '--position=botright',
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --position=t', [
\ '--position=top',
\ '--position=topleft',
\ '--position=topright'
\ ])
call Test__floaterm_cmdline_complete('FloatermNew --opener=', [
\ '--opener=edit',
\ '--opener=split',
\ '--opener=vsplit',
\ '--opener=tabe',
\ '--opener=drop'
\ ])
call Test__floaterm_cmdline_complete('FloatermNew '.
\ '--title=1 '.
\ '--name=1 '.
\ '--cwd=1 '.
\ '--name=1 '.
\ '--title=1 '.
\ '--width=1 '.
\ '--height=1 '.
\ '--opener=edit '.
\ '--silent '.
\ '--disposable '.
\ '--wintype=1 '.
\ '--position=1 '.
\ '--autoclose=1 '.
\ '--borderchars=1 ', sort(getcompletion('', 'shellcmd')))
call Test__floaterm_cmdline_complete('FloatermUpdate ', [
\ '--cwd=',
\ '--name=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ ])
call Test__floaterm_cmdline_complete('FloatermUpdate -', [
\ '--cwd=',
\ '--name=',
\ '--width=',
\ '--height=',
\ '--title=',
\ '--silent',
\ '--wintype=',
\ '--position=',
\ '--autoclose=',
\ '--borderchars=',
\ ])
call Test__floaterm_cmdline_complete('FloatermUpdate ', all_candidates)
call Test__floaterm_cmdline_complete('FloatermUpdate -', all_candidates)
call Test__floaterm_cmdline_complete('FloatermUpdate --', all_candidates)
call Test__floaterm_cmdline_complete('FloatermUpdate nv', [' '])
call Test__floaterm_cmdline_complete('FloatermUpdate '.
\ '--title=1 '.
\ '--name=1 '.
\ '--cwd=1 '.
\ '--name=1 '.
\ '--title=1 '.
\ '--width=1 '.
\ '--height=1 '.
\ '--opener=edit '.
\ '--silent '.
\ '--disposable '.
\ '--wintype=1 '.
\ '--position=1 '.
\ '--autoclose=1 '.

4
etc/soft/nvim/+plugins/vim-floaterm/test/test_functions/test-floaterm_buffer_get_config_dict.vader → etc/soft/nvim/+plugins/vim-floaterm/test/test_functions/test-floaterm_config_get_all.vader

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
" vim:ft=vim
Execute(test-floaterm#buffer#get_config_dict):
Execute(test-floaterm#config#get_all):
function! MyFunc() abort
" code
endfunction
@ -9,7 +9,7 @@ Execute(test-floaterm#buffer#get_config_dict): @@ -9,7 +9,7 @@ Execute(test-floaterm#buffer#get_config_dict):
let bufnr = bufnr('%')
call setbufvar(bufnr, 'Fn', function("MyFunc"))
" https://github.com/voldikss/vim-floaterm/issues/233
call floaterm#buffer#get_config_dict(bufnr)
call floaterm#config#get_all(bufnr)
FloatermKill!
stopinsert

139
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-autohide.vader

@ -1,94 +1,97 @@ @@ -1,94 +1,97 @@
" vim:ft=vim
"=============================================================================
" let g:floaterm_autohide = v:true
"=============================================================================
Execute(Enable autohide):
let g:floaterm_autohide = v:true
Log '# FloatermNew: the first should be closed, the second should be opened'
Execute(Include base):
source test/base_vader.vim
Execute(let g:floaterm_autohide = 0):
" NOTE: Vim does not support multiple popup terminals
if !has('nvim') | finish | endif
let g:floaterm_autohide = 0
Log '# FloatermNew'
FloatermNew
let buffer1 = bufnr('%')
FloatermNew
let buffer2 = bufnr('%')
AssertEqual -1,bufwinnr(buffer1)
if has('nvim')
AssertNotEqual -1,bufwinnr(buffer2)
endif
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log '# FloatermPrev: the first should be opened, the second should be closed'
Log '# FloatermPrev'
FloatermPrev
if has('nvim')
AssertNotEqual -1,bufwinnr(buffer1)
endif
AssertEqual -1,bufwinnr(buffer2)
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log '# FloatermNext: the first should be closed, the second should be opened'
Log '# FloatermNext'
FloatermNext
AssertEqual -1,bufwinnr(buffer1)
if has('nvim')
AssertNotEqual -1,bufwinnr(buffer2)
endif
" FloatermShow/FloatermHide/FloatermToggle should works normally regardless of this option
Log '# FloatermShow!: both floaterms should be opened'
if has('nvim')
FloatermShow!
AssertNotEqual -1,bufwinnr(buffer1)
AssertNotEqual -1,bufwinnr(buffer2)
endif
Log '# FloatermHide!: both floaterms should be closed'
FloatermHide!
AssertEqual -1,bufwinnr(buffer1)
AssertEqual -1,bufwinnr(buffer2)
Log '# FloatermToggle!: both floaterms should be opened'
if has('nvim')
FloatermToggle!
AssertNotEqual -1,bufwinnr(buffer1)
AssertNotEqual -1,bufwinnr(buffer2)
endif
Log '# FloatermToggle!: both floaterms should be closed'
if has('nvim')
FloatermToggle!
AssertEqual -1,bufwinnr(buffer1)
AssertEqual -1,bufwinnr(buffer2)
endif
Log '# FloatermKill!: kill all floaterms'
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
FloatermKill!
"=============================================================================
" let g:floaterm_autohide = v:false
"=============================================================================
Execute(Disable autohide):
let g:floaterm_autohide = v:false
Log '# FloatermNew && FloatermPrev && FloatermNext: both floaterms should always be opened'
if has('nvim')
Execute(let g:floaterm_autohide = 1):
if !has('nvim') | finish | endif
let g:floaterm_autohide = 1
Log '# Overlaied: true'
Log ' * FloatermNew'
FloatermNew
let buffer1 = bufnr('%')
FloatermNew
let buffer2 = bufnr('%')
AssertNotEqual -1,bufwinnr(buffer1)
AssertNotEqual -1,bufwinnr(buffer2)
Assert !BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log ' * FloatermPrev'
FloatermPrev
Assert BufWinExists(buffer1)
Assert !BufWinExists(buffer2)
Log ' * FloatermNext'
FloatermNext
Assert !BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log '# Overlaied: false'
Log ' * FloatermNew'
FloatermNew --position=left
let buffer1 = bufnr('%')
FloatermNew --position=right
let buffer2 = bufnr('%')
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log ' * FloatermPrev'
FloatermPrev
AssertNotEqual -1,bufwinnr(buffer1)
AssertNotEqual -1,bufwinnr(buffer2)
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log ' * FloatermNext'
FloatermNext
AssertNotEqual -1,bufwinnr(buffer1)
AssertNotEqual -1,bufwinnr(buffer2)
Assert BufWinExists(buffer1)
Assert BufWinExists(buffer2)
FloatermKill!
endif
FloatermKill!
Execute(let g:floaterm_autohide = 2):
if !has('nvim') | finish | endif
let g:floaterm_autohide = 2
Log '# FloatermNew'
FloatermNew --position=left
let buffer1 = bufnr('%')
FloatermNew --position=right
let buffer2 = bufnr('%')
Assert !BufWinExists(buffer1)
Assert BufWinExists(buffer2)
Log '# FloatermPrev'
FloatermPrev
Assert BufWinExists(buffer1)
Assert !BufWinExists(buffer2)
Log '# FloatermNext'
FloatermNext
Assert !BufWinExists(buffer1)
Assert BufWinExists(buffer2)
FloatermKill!
stopinsert

7
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-autoinsert.vader

@ -1,9 +1,12 @@ @@ -1,9 +1,12 @@
" vim:ft=vim
Execute(Include base):
source test/base_vader.vim
Execute(test-autoinsert):
Log '# Set autoinsert to 0'
FloatermNew --autoinsert=0 ls
AssertEqual 'floaterm',&filetype
Assert IsInFloatermBuffer()
if has('nvim')
let g:floaterm_autoinsert = 0
@ -13,7 +16,7 @@ Execute(test-autoinsert): @@ -13,7 +16,7 @@ Execute(test-autoinsert):
Log '# Set autoinsert to 1'
FloatermNew --autoinsert=1 ls
AssertEqual 'floaterm',&filetype
Assert IsInFloatermBuffer()
let g:floaterm_autoinsert = 1
FloatermNew! ls

21
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-cwd.vader

@ -1,7 +1,20 @@ @@ -1,7 +1,20 @@
" vim:ft=vim
Execute(Set cwd and open a floaterm):
" TODO
Execute(test-cwd):
Log '# --cwd=/'
let cwd = getcwd()
FloatermNew --cwd=/
" cwd should be restored after opening floaterm
AssertEqual cwd, getcwd()
Execute(Close floaterm and check cwd):
" TODO
Log '# --cwd=~'
FloatermNew --cwd=<root>
Log '# --cwd=..'
FloatermNew --cwd=<root>
Log '# --cwd=<root>'
FloatermNew --cwd=<root>
FloatermKill!
stopinsert

14
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-disposable.vader

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
" vim:ft=vim
Execute(test-disposable):
Log '# FloatermNew --disposable'
FloatermNew --disposable
FloatermNew --disposable
FloatermNew --disposable
FloatermHide!
sleep 100m
Log floaterm#buflist#gather()
Assert empty(floaterm#buflist#gather())
FloatermKill!
stopinsert

24
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-gitcommit.vader

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
" vim:ft=vim
Execute(FloatermNew git commit --amend):
if has('nvim')
let g:floaterm_gitcommit = 'split'
let pwd = $PWD
silent execute printf('!touch %s/afile && git add afile', pwd)
FloatermNew git commit
sleep 1000m
" Log $GIT_EDITOR
" Log nvim_win_get_config(win_getid())
" for l in range(1, line('$'))
" Log getline(l)
" endfor
"
" Log expand('%')
" Log &ft
AssertNotEqual 'floaterm',&filetype
silent execute printf('!cd %s && rm afile && git add afile', pwd)
endif
FloatermKill!
stopinsert

31
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-open_command.vader

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
" vim:ft=vim
Execute(test-open_command):
Log '# floaterm test.txt'
let original_winid = win_getid()
silent !touch test.txt
FloatermNew
FloatermHide
FloatermSend floaterm test.txt
sleep 1000m
" Log expand('%')
" Log &ft
AssertEqual 'test.txt',expand('%:t')
AssertNotEqual 'floaterm',&ft
Assert win_getid() == original_winid
silent !rm test.txt
Log '# cat test.txt | floaterm'
if has('nvim')
silent !touch test.txt
FloatermNew
FloatermHide
FloatermSend cat test.txt | floaterm
sleep 1000m
AssertNotEqual 'floaterm',&ft
Assert win_getid() == original_winid
silent !rm test.txt
endif
FloatermKill!
stopinsert

33
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-opener.vader

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
" vim:ft=vim
Execute(Include base):
source test/base_vader.vim
Execute(test-opener):
Log '# floaterm test.txt'
let original_winid = win_getid()
silent !touch test.txt
FloatermNew
FloatermHide
FloatermSend floaterm test.txt
sleep 500m
Log expand('%')
AssertEqual 'test.txt',expand('%:t')
Assert !IsInFloatermBuffer()
silent !rm test.txt
Log '# git commit'
let g:floaterm_opener = 'split'
let pwd = $PWD
silent execute printf('!touch %s/afile && git add afile', pwd)
FloatermNew git commit
sleep 500m
AssertEqual &ft, 'gitcommit'
silent execute printf('!cd %s && rm afile && git add afile', pwd)
Log '# set g:floaterm_opener to empty'
let g:floaterm_opener = ''
FloatermNew
FloatermKill!
stopinsert

1
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-silent.vader

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
" vim:ft=vim
Execute(test-silent):
if g:run_in_ci | finish | endif
Log '# FloatermNew --silent --autoclose=0 ls'
FloatermNew --silent --autoclose=0 ls
AssertEqual 1, len(floaterm#buflist#gather())

19
etc/soft/nvim/+plugins/vim-floaterm/test/test_options/test-wintype.vader

@ -1,16 +1,11 @@ @@ -1,16 +1,11 @@
" vim:ft=vim
Execute(test-wintype):
function! IsFloatOrPopup(winid) abort
if has('nvim')
return has_key(nvim_win_get_config(a:winid), 'anchor')
else
return win_gettype(a:winid) == 'popup'
endif
endfunction
Execute(Include base):
source test/base_vader.vim
Log '# Set wintype to normal'
let g:floaterm_wintype = 'normal'
Execute(test-wintype):
Log '# Set wintype to split/vsplit'
let g:floaterm_wintype = 'split'
FloatermNew
AssertEqual 0,IsFloatOrPopup(win_getid())
FloatermNew --wintype=float
@ -20,11 +15,11 @@ Execute(test-wintype): @@ -20,11 +15,11 @@ Execute(test-wintype):
let g:floaterm_wintype = 'float'
FloatermNew
AssertEqual 1,IsFloatOrPopup(win_getid())
FloatermNew --wintype=normal
FloatermNew --wintype=split
AssertEqual 0,IsFloatOrPopup(win_getid())
Log '# Independent wintype value for each floaterm'
FloatermNew --wintype=normal
FloatermNew --wintype=split
FloatermNew --wintype=float
FloatermPrev
AssertEqual 0,IsFloatOrPopup(win_getid())

49
etc/soft/nvim/+plugins/vim-floaterm/test/vimrc

@ -1,14 +1,24 @@ @@ -1,14 +1,24 @@
" Load plugin
"=============================================================================
set nocompatible
filetype off
let &runtimepath .= ',' . expand('<sfile>:p:h:h')
if $USER == 'runner'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/vader.vim'
let g:run_in_ci = v:true
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/vader.vim'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/LeaderF-floaterm'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/clap-floaterm'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/fzf-floaterm'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/asyncrun.vim'
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/asyncrun.extra'
else
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../vader.vim'
let g:run_in_ci = v:false
let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../vader.vim'
" let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../LeaderF-floaterm'
" let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../clap-floaterm'
" let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../fzf-floaterm'
" let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../asyncrun.vim'
" let &runtimepath .= ',' . expand('<sfile>:p:h:h') . '/../asyncrun.extra'
endif
" NOTE: echom will frozen vim8 in GitHub Action
@ -17,4 +27,35 @@ endif @@ -17,4 +27,35 @@ endif
filetype plugin indent on
syntax enable
" vim-floaterm configs
"=============================================================================
let g:floaterm_keymap_new = '<F7>'
let g:floaterm_keymap_prev = '<F8>'
let g:floaterm_keymap_next = '<F9>'
let g:floaterm_keymap_toggle = '<F12>'
" common configs
"=============================================================================
let g:mapleader = ';'
nnoremap <silent> Q :qa!<CR>
nnoremap <silent> <Leader>m :messages<CR>
" misc
"=============================================================================
if $USER == 'runner'
let g:run_in_ci = v:true
else
let g:run_in_ci = v:false
endif
if has('nvim')
if split(matchstr(execute('silent version'), 'NVIM v\zs[^\n-]*'))[0] == '0.4.4'
let g:vim_version_info = ['nvim', 'stable']
else
let g:vim_version_info = ['nvim', 'nightly']
endif
else
let g:vim_version_info = ['vim', 'nightly']
endif

Loading…
Cancel
Save