nvim: added clearing of preview files for markdown

master
tiyn 10 months ago
parent 2f74fa5c04
commit e8a7b8d896

@ -1,8 +1,13 @@
vim.api.nvim_create_autocmd({ 'BufEnter', 'FileType' },
vim.api.nvim_create_autocmd({ 'BufEnter' },
{
callback = function() vim.o.foldenable = false end
})
vim.api.nvim_create_autocmd({ 'VimLeave' },
{
callback = function() os.execute('mdclear ' .. vim.fn.expand('%')) end
})
vim.o.shiftwidth = 2
vim.o.softtabstop = 2
vim.o.textwidth = 100

@ -0,0 +1,13 @@
#!/usr/bin/env sh
# Clears the files created for previewing markdown files in nvim
# based on a program by lukesmithxyz
case "$1" in
*.md)
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(html|pdf)" -delete ;;
*) printf "Give .md file as argument.\\n" ;;
esac
Loading…
Cancel
Save