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.

Send A Neovim Buffer Filepath To An External Process

Example from a neovim plugin

Code

local function export_to_file()
  local Job = require 'plenary.job'
  print("Exporting from: " .. vim.uri_from_bufnr(0))
  Job:new({
    command = 'grimoire_caster',
    args = { '--action', 'export_file', '--path', vim.uri_from_bufnr(0) },
    on_exit = function(job, return_val)
      print(vim.inspect(job:result()))
    end,
  }):sync()
  print("Exported from: " .. vim.uri_from_bufnr(0))
end

return {
  export_to_file = export_to_file
}

In rust, that path has to be decoded with:

https://docs.rs/urlencoding/latest/urlencoding/index.html

References