Skip to content

Commit

Permalink
feat: allow disabling treesitter
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Aug 6, 2021
1 parent 0ac66e8 commit 8ab43c0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Twilight comes with the following defaults:
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10, -- amount of lines we will try to show around the current line
treesitter = true, -- use treesitter when available for the filetype
-- treesitter is used to automatically expand the visible text,
-- but you can further control the types of nodes that should always be fully expanded
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
Expand Down
1 change: 1 addition & 0 deletions lua/twilight/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local defaults = {
inactive = false, -- when true, other windows will be fully dimmed (unless they contain the same buffer)
},
context = 10, -- amount of lines we will try to show arounc the current line
treesitter = true, -- use treesitter when available for the filetype
-- treesitter is used to automatically expand the visible text,
-- but you can further control the types of nodes that should always be fully expanded
expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types
Expand Down
2 changes: 1 addition & 1 deletion lua/twilight/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function M.get_expand_root(node, opts)
end

function M.get_context(buf, line)
if pcall(vim.treesitter.get_parser, buf) then
if config.options.treesitter and pcall(vim.treesitter.get_parser, buf) then
local node = M.get_node(buf, line)
local root = M.get_expand_root(node)
if root then
Expand Down

0 comments on commit 8ab43c0

Please sign in to comment.