diff options
| author | nsfisis <nsfisis@gmail.com> | 2021-12-04 23:54:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2021-12-04 23:54:00 +0900 |
| commit | 88b864aebf0ac2ac35f721f5425f35c37a1412c8 (patch) | |
| tree | e36744c8104e8efce14277bfcbd4cc1b1f20dd24 | |
| parent | c4f9a45ab32a45004210cf750ecbaffa2624c07f (diff) | |
| download | dotfiles-88b864aebf0ac2ac35f721f5425f35c37a1412c8.tar.gz dotfiles-88b864aebf0ac2ac35f721f5425f35c37a1412c8.tar.zst dotfiles-88b864aebf0ac2ac35f721f5425f35c37a1412c8.zip | |
neovim: port mopp/autodirmake.vim
| -rw-r--r-- | .config/nvim/init.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 1ed9117..7ac24e8 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -352,8 +352,6 @@ paq({ -- Python: autopep8 'tell-k/vim-autopep8', -- QoL {{{2 - -- If a directory is missing, make it automatically. - 'mopp/autodirmake.vim', -- Capture the output of a command. 'tyru/capture.vim', -- Write git commit message. @@ -410,6 +408,22 @@ vimrc.autocmd('BufRead', '*', function() end) +-- Port this to Lua: https://github.com/mopp/autodirmake.vim +-- License: NYSL +vimrc.autocmd('BufWritePre', '*', function() + local dir = F.expand('<afile>:p:h') + if F.isdirectory(dir) ~= 0 then + return + end + vimrc.echo(('"%s" does not exist. Create? [y/N] '):format(dir), 'Question') + local answer = vimrc.getchar() + if answer ~= 'y' and answer ~= 'Y' then + return + end + F.mkdir(dir, 'p') +end) + + vimrc.register_filetype_autocmds_for_indentation() @@ -1301,12 +1315,6 @@ xmap <expr> g# My_asterisk('<Plug>(asterisk-gz*)', 1) --- autodirmake {{{2 - -G['autodirmake#msg_highlight'] = 'Question' - - - -- autopep8 {{{2 G.autopep8_on_save = true |
