Skip to content

Commit

Permalink
feat(treesitter): enabled by default for all pickers
Browse files Browse the repository at this point in the history
Only pickers that support treesitter (i.e. display code lines)
are enabled, disable globally by setting `winopts.treesitter`:
```lua
:lua require("fzf-lua").setup({winopts={treesitter=false}})
```
  • Loading branch information
ibhagwan committed Jan 19, 2025
1 parent ea859a9 commit 8bf446e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ winopts = {
-- due to highlight color collisions will also override `fzf_colors`
-- set `fzf_colors=false` or `fzf_colors.hl=...` to override
treesitter = {
enabled = false,
enabled = true,
fzf_colors = { ["hl"] = "-1:reverse", ["hl+"] = "-1:reverse" }
},
preview = {
Expand Down
8 changes: 3 additions & 5 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ M.defaults = {
fullscreen = false,
title_pos = "center",
treesitter = {
enabled = false,
enabled = true,
fzf_colors = { ["hl"] = "-1:reverse", ["hl+"] = "-1:reverse" }
},
preview = {
Expand Down Expand Up @@ -435,7 +435,6 @@ M.defaults.git = {
["ctrl-t"] = actions.git_buf_tabedit,
["ctrl-y"] = { fn = actions.git_yank_commit, exec_silent = true },
},
winopts = { treesitter = true },
fzf_opts = { ["--no-multi"] = true },
_multiline = false,
-- `winopts.treesitter==true` line match format
Expand Down Expand Up @@ -565,9 +564,9 @@ M.defaults.quickfix = {
file_icons = 1,
color_icons = true,
git_icons = false,
only_valid = false,
fzf_opts = { ["--multi"] = true },
_actions = function() return M.globals.actions.files end,
only_valid = false,
_treesitter = true,
_cached_hls = { "path_colnr", "path_linenr" },
}
Expand All @@ -587,9 +586,9 @@ M.defaults.loclist = {
file_icons = 1,
color_icons = true,
git_icons = false,
only_valid = false,
fzf_opts = { ["--multi"] = true },
_actions = function() return M.globals.actions.files end,
only_valid = false,
_treesitter = true,
_cached_hls = { "path_colnr", "path_linenr" },
}
Expand Down Expand Up @@ -654,7 +653,6 @@ M.defaults.lines = {
show_unlisted = false,
no_term_buffers = true,
sort_lastused = true,
winopts = { treesitter = true },
fzf_opts = {
["--multi"] = true,
["--delimiter"] = "[\t]",
Expand Down
30 changes: 15 additions & 15 deletions lua/fzf-lua/profiles/ivy.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local M = {
local M = {
{ "default-title" }, -- base profile
desc = "UI at the bottom of the screen",
winopts = {
Expand Down Expand Up @@ -40,22 +40,22 @@ local M = {
},
}

M.blines = {
winopts = {
row = 1,
col = 0,
width = 1,
height = 1,
preview = {
layout = "vertical",
vertical = "up:60%",
border = "none",
},
local up = {
row = 1,
col = 0,
width = 1,
height = 1,
preview = {
layout = "vertical",
vertical = "up:60%",
border = "none",
},
previewer = { toggle_behavior = "extend" },
}

M.lines = M.blines
M.grep = M.blines
M.blines = { winopts = up, previewer = { toggle_behavior = "extend" } }
M.lines = M.blines
M.grep = M.blines
M.grep_curbuf = M.blines
M.git = { blame = { winopts = up } }

return M
1 change: 1 addition & 0 deletions lua/fzf-lua/win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ function FzfWin:treesitter_attach()
local min, max, tr = 0, nil, 4
if not self.preview_hidden
and (not self.previewer_is_builtin or self.winopts.split)
and vim.api.nvim_win_is_valid(self.fzf_winid)
then
local win_width = vim.api.nvim_win_get_width(self.fzf_winid)
local layout = self:fzf_preview_layout_str()
Expand Down

0 comments on commit 8bf446e

Please sign in to comment.