Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mizlan/termbufm
Lightweight Terminal Buffer Manager for Neovim.
https://github.com/mizlan/termbufm
Last synced: 9 days ago
JSON representation
Lightweight Terminal Buffer Manager for Neovim.
- Host: GitHub
- URL: https://github.com/mizlan/termbufm
- Owner: mizlan
- Created: 2020-10-31T18:29:06.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-31T23:29:14.000Z (over 3 years ago)
- Last Synced: 2024-10-10T23:29:21.053Z (about 1 month ago)
- Language: Vim script
- Homepage:
- Size: 7.81 KB
- Stars: 18
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
📋 termbufm
A lightweight terminal buffer manager for Neovim.
A wrapper around the Neovim terminal window, with functionality for toggling and auto-compiling and running code.
A simple install using a plugin manager, in this case [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Plug 'mizlan/termbufm', {'branch': 'main'}
```## Follow these steps to configure:
### Set preferred direction:
```vim
" if you prefer it opening in a left-right split:
let g:termbufm_direction_cmd = 'vnew'" if you prefer it opening in a top-down split:
let g:termbufm_direction_cmd = 'new'
```### Load default keymaps:
```vim
" init.vim" DEFAULTS:
" tb to build
" tr to run
" t to toggle window
call termbufm#load_keymaps()
```### Define Vim commands for terminal commands:
```vim
command! TBuild call TermBufMExecCodeScript(&filetype, 'build')
command! TRun call TermBufMExecCodeScript(&filetype, 'run')
```### Create keybinds:
```vim
nnoremap b :TBuild
nnoremap r :TRun" toggle the window (show/hide)
nnoremap :call TermBufMToggle()
```### Load auxiliary keymap:
```vim
" will enable using in terminal
call termbufm#load_terminal_keymaps()
```### Edit language configurations:
Add languages to the dictionary, determined by `filetype` and provide a `build`
and `run` command. The first element of the list (if any) is a `printf` style
string. Read `:h printf()` for information on how to format this. Any other
elements will be expanded through `expand()` (read `:h expand()`) and passed in
as arguments, along with the format string, to `printf()`.For your convenience, some common options for the `expand()` command are here:
| Type | Value | Meaning |
| :--- | :--- | :--- |
| `%` | `test.cpp` | filename |
| `%:r` | `test` | basename |
| `%:e` | `cpp` | extension |
| `%:p:h` | `/home/ml/code` | directory |
| `%:p` | `/home/ml/code/test.cpp` | full path |For example, for `cpp` filetypes, `'g++ -std=c++11 %s'` is the format string, and `'%'` means the filename.
```vim
" the default configuration
let g:termbufm_code_scripts = {
\ 'python': { 'build': [''], 'run': ['python %s', '%'] },
\ 'cpp': { 'build': ['g++ %s', '%'], 'run': ['./a.out'] },
\ 'java': { 'build': ['javac %s', '%'], 'run': ['java %s', '%:r'] },
\ 'c': { 'build': ['gcc %s', '%'], 'run': ['./a.out'] },
\ }
```#### Note for Windows users:
Set the shell to PowerShell in windows along with some additional necessary options:
```vim
" inside init.vimset shell=powershell
set shellcmdflag=-c
set shellquote=\"
set shellxquote=
```