markdown.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. vim.b.slime_cell_delimiter = '```'
  2. -- wrap text, but by word no character
  3. -- indent the wrappped line
  4. vim.wo.wrap = true
  5. vim.wo.linebreak = true
  6. vim.wo.breakindent = true
  7. vim.wo.showbreak = '|'
  8. vim.api.nvim_create_autocmd('BufEnter', {
  9. desc = 'Automatically pull when entering a buffer in my ~/notes/ directory',
  10. pattern = vim.fn.expand '~' .. '/notes/*.md' .. ',' .. vim.fn.expand '~' .. '/notes/*.qmd',
  11. group = vim.api.nvim_create_augroup('git_pull', { clear = true }),
  12. callback = function(ev)
  13. local file = ev.file
  14. vim.fn.jobstart('git pull', {
  15. on_exit = function()
  16. vim.fn.jobstart('git add ' .. file, {
  17. on_exit = function()
  18. vim.fn.jobstart('git commit -m "sync"', {
  19. on_exit = function()
  20. print('git pulled')
  21. end,
  22. })
  23. end,
  24. })
  25. end,
  26. })
  27. end,
  28. })
  29. vim.api.nvim_create_autocmd('BufWritePost', {
  30. desc = 'Automatically push git when saving in my ~/notes/ directory',
  31. pattern = vim.fn.expand '~' .. '/notes/*.md' .. ',' .. vim.fn.expand '~' .. '/notes/*.qmd',
  32. group = vim.api.nvim_create_augroup('git_push', { clear = true }),
  33. callback = function(ev)
  34. local file = ev.file
  35. vim.fn.jobstart('git add ' .. file, {
  36. on_exit = function()
  37. vim.fn.jobstart('git commit -m "sync"', {
  38. on_exit = function()
  39. vim.fn.jobstart('git push', {
  40. on_exit = function()
  41. print('git pushed')
  42. end,
  43. })
  44. end,
  45. })
  46. end,
  47. })
  48. end,
  49. })