Skip to content

Instantly share code, notes, and snippets.

@vebbis321
Last active June 13, 2025 12:06
Show Gist options
  • Save vebbis321/41b91b56787ea3ad8f75853a7e9cb408 to your computer and use it in GitHub Desktop.
Save vebbis321/41b91b56787ea3ad8f75853a7e9cb408 to your computer and use it in GitHub Desktop.
Enable harper for only certain paths
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
local path = vim.loop.fs_realpath(fname)
if not path then
return nil
end
local allowed_dirs = {
vim.loop.fs_realpath(vim.fn.expand("~/wiki/math")),
vim.loop.fs_realpath(vim.fn.expand("~/wiki/physics")),
vim.loop.fs_realpath(vim.fn.expand("~/wiki/programming")),
}
for _, dir in ipairs(allowed_dirs) do
if dir and path:sub(1, #dir) == dir then
on_dir(dir)
end
end
end,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment