feat: emit CanolaFileCreated autocmd on file creation (#75)
* feat: emit \`CanolaFileCreated\` autocmd on file creation Problem: no way to hook into individual file creation to populate initial contents, without a plugin-specific config callback. Solution: fire \`User CanolaFileCreated\` with \`data.path\` after each successful \`fs.touch\` in the files adapter. Users listen with \`nvim_create_autocmd\` and write to the path however they like. * build: gitignore `doc/upstream.html` * docs(upstream): mark #721 fixed, triage #735 * docs(upstream): simplify #735 note
This commit is contained in:
parent
c7a55fd787
commit
a74747e1f5
4 changed files with 41 additions and 13 deletions
|
|
@ -600,7 +600,19 @@ M.perform_action = function(action, cb)
|
|||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
uv.fs_symlink(target, path, flags, cb)
|
||||
else
|
||||
fs.touch(path, config.new_file_mode, cb)
|
||||
fs.touch(
|
||||
path,
|
||||
config.new_file_mode,
|
||||
vim.schedule_wrap(function(err)
|
||||
if not err then
|
||||
vim.api.nvim_exec_autocmds(
|
||||
'User',
|
||||
{ pattern = 'CanolaFileCreated', modeline = false, data = { path = path } }
|
||||
)
|
||||
end
|
||||
cb(err)
|
||||
end)
|
||||
)
|
||||
end
|
||||
elseif action.type == 'delete' then
|
||||
local _, path = util.parse_url(action.url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue