summaryrefslogtreecommitdiff
path: root/lua/mo/fzf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/mo/fzf.lua')
-rw-r--r--lua/mo/fzf.lua77
1 files changed, 77 insertions, 0 deletions
diff --git a/lua/mo/fzf.lua b/lua/mo/fzf.lua
new file mode 100644
index 0000000..c5c4b3e
--- /dev/null
+++ b/lua/mo/fzf.lua
@@ -0,0 +1,77 @@
+--- @diagnostic disable: missing-fields
+local fzf = require("fzf-lua")
+
+local swiper = {
+ previewer = "swiper",
+ winopts = function()
+ local height = math.ceil(vim.o.lines / 3)
+ return { split = ("botright %snew +set\\ nobl"):format(height) }
+ end,
+}
+
+fzf.setup({
+ { "default-title", "hide" },
+ fzf_colors = true,
+ lsp = {
+ symbols = { symbol_style = 3 },
+ document_symbols = swiper,
+ code_actions = { previewer = "codeaction_native" },
+ },
+ manpages = { previewer = "man_native" },
+ helptags = { previewer = "help_native" },
+ defaults = { git_icons = false, file_icons = false },
+ tags = { previewer = "bat" },
+ btags = { previewer = "bat" },
+ files = { fzf_opts = { ["--ansi"] = false } },
+ grep = {
+ fzf_opts = { ["--ansi"] = false },
+ rg_glob = true,
+ rg_opts = " --color=never --column --line-number --no-heading --smart-case --max-columns=4096 -e",
+ },
+ builtin = { winopts = { width = 1, height = 1 } },
+ blines = swiper,
+ grep_curbuf = swiper,
+ treesitter = swiper,
+ git = { blame = swiper },
+
+ winopts = function()
+ local height = math.ceil(vim.o.lines / 2)
+ return {
+ backdrop = 80,
+ row = 1,
+ col = 0,
+ width = 1,
+ height = height > 3 and height or 1,
+ border = {"", " ", "", "", "", "", "", ""},
+ toggle_behavior = "extend",
+ --- @diagnostic disable-next-line: missing-fields
+ preview = {
+ default = { "bat" },
+ treesitter = false,
+ layout = "vertical",
+ vertical = "up:60%",
+ border = {"", " ", "", "", "", "", "", ""},
+ },
+ on_create = function()
+ vim.keymap.set(
+ "t",
+ "<C-r>",
+ [['<C-\><C-N>"'.nr2char(getchar()).'pi']],
+ {
+ expr = true,
+ buffer = true,
+ desc = "insert register value into the FZF prompt",
+ }
+ )
+ end,
+ }
+ end,
+ keymap = {
+ fzf = {
+ ["ctrl-q"] = "select-all+accept",
+ },
+ },
+})
+
+_G.old_vim_ui_select = vim.ui.select
+fzf.register_ui_select()