File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -378,6 +378,28 @@ nnoremap <silent> <F12> :FloatermToggle<CR>
378378tnoremap <silent> <F12> <C-\><C-n>:FloatermToggle<CR>
379379```
380380
381+ To toggle a term in the current buffer directory :
382+
383+ ``` vim
384+ function! s:get_dir(path) abort
385+ if isdirectory(a:path)
386+ let dir = fnamemodify(a:path, ':p')
387+ elseif filereadable(a:path)
388+ let dir = fnamemodify(a:path, ':p:h')
389+ else
390+ let dir = fnamemodify(getcwd(), ':p')
391+ endif
392+ let dir = fnamemodify(dir, ':~')
393+ let dir = escape(dir, ' %#|"')
394+ return dir
395+ endfunction
396+
397+ nnoremap <silent><expr> <F6> g:floaterm#buflist#curr() == -1 ?
398+ \ ':<c-u>FloatermNew --cwd=<C-R>=<sid>get_dir(expand("%"))<CR><CR>'
399+ \ : ':<c-u>FloatermToggle<CR>'
400+ tnoremap <silent> <F6> <C-\><C-n>:<c-u>FloatermToggle<cr>
401+ ```
402+
381403### Highlights
382404
383405There are two ` highlight-groups ` to specify the color of floaterm (also the
You can’t perform that action at this time.
0 commit comments