From 8bf446ec214b43d79e64055876b3bfbb41966317 Mon Sep 17 00:00:00 2001 From: bhagwan Date: Sat, 18 Jan 2025 21:12:07 -0800 Subject: [PATCH] feat(treesitter): enabled by default for all pickers 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}}) ``` --- README.md | 2 +- lua/fzf-lua/defaults.lua | 8 +++----- lua/fzf-lua/profiles/ivy.lua | 30 +++++++++++++++--------------- lua/fzf-lua/win.lua | 1 + 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index dea1550f..77cc85e7 100644 --- a/README.md +++ b/README.md @@ -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 = { diff --git a/lua/fzf-lua/defaults.lua b/lua/fzf-lua/defaults.lua index 315f3f7d..9914a3dd 100644 --- a/lua/fzf-lua/defaults.lua +++ b/lua/fzf-lua/defaults.lua @@ -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 = { @@ -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 @@ -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" }, } @@ -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" }, } @@ -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]", diff --git a/lua/fzf-lua/profiles/ivy.lua b/lua/fzf-lua/profiles/ivy.lua index cffb6203..cb4ce6d1 100644 --- a/lua/fzf-lua/profiles/ivy.lua +++ b/lua/fzf-lua/profiles/ivy.lua @@ -1,4 +1,4 @@ -local M = { +local M = { { "default-title" }, -- base profile desc = "UI at the bottom of the screen", winopts = { @@ -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 diff --git a/lua/fzf-lua/win.lua b/lua/fzf-lua/win.lua index 88927653..f2905aee 100644 --- a/lua/fzf-lua/win.lua +++ b/lua/fzf-lua/win.lua @@ -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()