a95eaa6
Branches > main > a95eaa6 > files / nvim / lua / fuzzy.lua
Fuzzy finder (+ undo stuff :p)
Commit: a95eaa69ab0036ea5e98954a38a030e7d2eafb1d
Parent: a4b40fb
4 changed files:
nixos/machines/pc/home.nix view file
@@ -47,6 +47,7 @@ clojure-lsp cljfmt lua-language-server+ fzf librewolf ## TODO config! tor-browsernvim/init.lua view file
@@ -18,8 +18,6 @@ --- Still to do: --- REPL (Conjure) --- Parens (Parinfer)---- Undotree---- LSP --- Formatting (better formatting anyway :p) --- Surround? @@ -27,10 +25,8 @@ --- Also: --- Looking at java stuff (where does that come from and how could I improve it?)---- Fuzzy finder (full screen like oil):---- Fuzzy find file names---- Fuzzy find inside files --- Fuzzy find code actions+--- Fuzzy find file contents --- Paren Editing: --- Could use s for bindings!nvim/lua/fuzzy.lua view file
@@ -0,0 +1,48 @@+local api = vim.api+local fn = vim.fn+local o = vim.o++local function open_fullscreen_window()+ local buf = api.nvim_create_buf(false, true)+ return api.nvim_open_win(buf, true, {+ relative = "editor",+ row = 0,+ col = 0,+ width = o.columns,+ height = o.lines,+ style = "minimal",+ border = "none"+ })+end++local function fzf_window(win)+ local tmp = fn.tempname()+ local cmd = 'fzf --pointer=">" --gutter=" " --prompt="" --no-info --no-scrollbar' .. ">" .. fn.shellescape(tmp)++ fn.termopen({"sh", "-c", cmd}, {+ on_exit = function()+ pcall(api.nvim_win_close, win, true)+ if fn.filereadable(tmp) == 1 then+ local sel = fn.readfile(tmp)[1]+ os.remove(tmp)+ if sel and #sel > 0 then+ vim.cmd("edit " .. fn.fnameescape(sel))+ end+ end+ end})+ vim.cmd("startinsert")+end++local function fuzzy_find()+ if fn.executable("fzf") ~= 1 then+ print("You don't have fzf, can't fuzzy find!")+ else+ local win = open_fullscreen_window()+ local ok = pcall(fzf_window, win)+ if not ok then+ pcall(api.nvim_win_close, win, true)+ end+ end+end++return {fuzzy_find = fuzzy_find}nvim/lua/keybindings.lua view file
@@ -27,12 +27,17 @@ keymap({"n", "v"}, "j", "gj") keymap({"n", "v"}, "k", "gk") +keymap({"n", "v"}, "gj", "<cmd>later<cr>")+keymap({"n", "v"}, "gk", "<cmd>earlier<cr>")+ keymap({"n", "v"}, "<Space>j", "J") keymap("n", "<Esc>", "<CMD>noh<CR>") keymap("n", "<Space>u", require("plugins.oil").open) +keymap("n", "<Space>f", function() require("fuzzy").fuzzy_find() end)+ keymap("n", ";", function() require("jump").jump() end) --- Either nil, "f/t", or "space"