diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-01-02 12:19:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-01-06 21:18:25 +0900 |
| commit | d0ebe31c0128893644c7e8cc3faa407b301fefac (patch) | |
| tree | 11e49cad9791503f78e92f05ede74b08f4a1b8c1 /.config/nvim/lua/init/03-autocmds.lua | |
| parent | 223b61994f4d9aceba596aba813a36501f9b0c9c (diff) | |
| download | dotfiles-d0ebe31c0128893644c7e8cc3faa407b301fefac.tar.gz dotfiles-d0ebe31c0128893644c7e8cc3faa407b301fefac.tar.zst dotfiles-d0ebe31c0128893644c7e8cc3faa407b301fefac.zip | |
nvim: set up *scratch* buffer when re-opening a scratch file
Diffstat (limited to '.config/nvim/lua/init/03-autocmds.lua')
| -rw-r--r-- | .config/nvim/lua/init/03-autocmds.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/.config/nvim/lua/init/03-autocmds.lua b/.config/nvim/lua/init/03-autocmds.lua index 01c6e4f..6025c00 100644 --- a/.config/nvim/lua/init/03-autocmds.lua +++ b/.config/nvim/lua/init/03-autocmds.lua @@ -1,6 +1,7 @@ local F = vim.fn local O = vim.o local vimrc = require('vimrc') +local my_env = require('vimrc.my_env') local A = vimrc.autocmd @@ -52,6 +53,18 @@ A('BufWritePre', { }) +A('BufEnter', { + desc = 'Set up *scratch* buffer', + pattern = my_env.scratch_dir .. '/*/*.*', + callback = function() + vim.b._scratch_ = true + if F.exists(':AutosaveEnable') == 2 then + vim.cmd('AutosaveEnable') + end + end, +}) + + vimrc.register_filetype_autocmds_for_indentation() -- TODO: move it elsewhere |
