Skip to content

Project Scopes

Calvin Bochulak edited this page Dec 7, 2022 · 1 revision

Examples

Cache resolved scope indefinitely

Pass cache = true (default) to never reset the project scope once it has been resolved.

require("grapple.scope").resolver(function()
    return vim.fn.getcwd()
end, { cache = true })

Never cache resolved scope

Pass cache = false to never cache the project scope.

require("grapple.scope").resolver(function()
    return vim.fn.getcwd()
end, { cache = false })

Invalidate resolved scope cache

Pass in key = {key} to allow for manually invalidating a cached scope.

local resolver = require("grapple.scope").resolver(function()
    return vim.fn.getcwd()
end, { key = "my_resolver" })

-- Invalidate using the resolver's key name
require("grapple.scope").invalidate("my_resolver")

-- Invalidate using the resolver's key
require("grapple.scope").invalidate(resolver.key)

Invalidate resolved scope cache using autocommand

Pass cache = {event} or cache = { {event}, ... } to invalidate the cached scope when one or more autocommand events are triggered.

require("grapple.scope").resolver(function()
    return vim.fn.getcwd()
end, { cache = "DirChanged" })
require("grapple.scope").resolver(function()
    return vim.fn.getcwd()
end, { cache = { "DirChanged", "FileType" } })

Clone this wiki locally