Skip to content

Commit

Permalink
feat(scope): disable treesitter blocks by default
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 15, 2024
1 parent e63fa7b commit 8ec6e6a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lua/snacks/scope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ local defaults = {
-- detect scope based on treesitter.
-- falls back to indent based detection if not available
enabled = true,
---@type string[]|false
---@type string[]|{enabled?:boolean}
blocks = {
enabled = false, -- enable to use the following blocks
"function_declaration",
"function_definition",
"method_declaration",
Expand Down Expand Up @@ -72,13 +73,13 @@ local defaults = {
min_size = 2, -- minimum size of the scope
edge = false, -- inner scope
cursor = false,
treesitter = { blocks = false },
treesitter = { blocks = { enabled = false } },
desc = "inner scope",
},
ai = {
cursor = false,
min_size = 2, -- minimum size of the scope
treesitter = { blocks = false },
treesitter = { blocks = { enabled = false } },
desc = "full scope",
},
},
Expand All @@ -89,15 +90,15 @@ local defaults = {
bottom = false,
cursor = false,
edge = true,
treesitter = { enabled = false },
treesitter = { blocks = { enabled = false } },
desc = "jump to top edge of scope",
},
["]i"] = {
min_size = 1, -- allow single line scopes
bottom = true,
cursor = false,
edge = true,
treesitter = { enabled = false },
treesitter = { blocks = { enabled = false } },
desc = "jump to bottom edge of scope",
},
},
Expand Down Expand Up @@ -360,7 +361,7 @@ function TSScope:with_edge()
end

function TSScope:root()
if self.opts.treesitter.blocks == false then
if type(self.opts.treesitter.blocks) ~= "table" or not self.opts.treesitter.blocks.enabled then
return self:fix()
end
local root = self.node --[[@as TSNode?]]
Expand Down

0 comments on commit 8ec6e6a

Please sign in to comment.