mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-23 17:28:50 +02:00
add: auto cmd for create folder and file
This commit is contained in:
parent
73fb95878b
commit
f99a244c36
3 changed files with 29 additions and 2 deletions
|
@ -16,3 +16,18 @@ local term_program = vim.fn.getenv("TERM_PROGRAM")
|
|||
if term_program == "WezTerm" then
|
||||
vim.cmd('silent !wezterm cli set-tab-title "' .. _get_folder_name() .. '"')
|
||||
end
|
||||
|
||||
-- vim.cmd([[
|
||||
-- function s:MkNonExDir(file, buf)
|
||||
-- if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
|
||||
-- let dir=fnamemodify(a:file, ':h')
|
||||
-- if !isdirectory(dir)
|
||||
-- call mkdir(dir, 'p')
|
||||
-- endif
|
||||
-- endif
|
||||
-- endfunction
|
||||
-- augroup BWCCreateDir
|
||||
-- autocmd!
|
||||
-- autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
|
||||
-- augroup END
|
||||
-- ]])
|
||||
|
|
|
@ -43,6 +43,19 @@ vim.cmd([[
|
|||
" allows you to use Ctrl-c on terminal window
|
||||
autocmd TermOpen * nnoremap <buffer> <C-c> i<C-c>
|
||||
augroup END
|
||||
|
||||
function s:MkNonExDir(file, buf)
|
||||
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
|
||||
let dir=fnamemodify(a:file, ':h')
|
||||
if !isdirectory(dir)
|
||||
call mkdir(dir, 'p')
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
augroup BWCCreateDir
|
||||
autocmd!
|
||||
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
|
||||
augroup END
|
||||
]])
|
||||
|
||||
-- for fix error last close buffer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue