Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Source A File Every Time It's Saved In Neovim

This is what I'm using when I'm working on Lua script for Neovim. It sources/reloads the file every time I save it.

NOTE: THIS ISN"T CURRNET WORKING

Code

function start_source_buffer_on_save()
  print("Activated start_source_buffer_on_save")
  vim.api.nvim_create_autocmd("BufWritePost", {
    group = vim.api.nvim_create_augroup("AutoRunCurrentFile", { clear = true }),
    pattern = vim.api.nvim_buf_get_name(0),
    callback = function()
      vim.cmd("so %")
      -- print("got save")
    end,
  })
end

start_source_buffer_on_save()

Super handy little chunk of code