From 9aeb79262848b217f6386bb1ff22a6a5bc5ce94c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 12:44:42 +0100 Subject: [PATCH] Convert fzf.vim to fzf.lua --- home/.config/nvim/lua/plugins.d/fzf.lua | 39 +++++++++++++++++++++++++ home/.config/nvim/lua/plugins.d/fzf.vim | 22 -------------- home/.config/nvim/lua/plugins.lua | 2 +- 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 home/.config/nvim/lua/plugins.d/fzf.lua delete mode 100644 home/.config/nvim/lua/plugins.d/fzf.vim diff --git a/home/.config/nvim/lua/plugins.d/fzf.lua b/home/.config/nvim/lua/plugins.d/fzf.lua new file mode 100644 index 0000000..9fb1452 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/fzf.lua @@ -0,0 +1,39 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +cmd[[Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }]] +cmd[[Plug 'junegunn/fzf.vim']] +cmd[[Plug 'stsewd/fzf-checkout.vim']] + +g.fzf_layout = { + up = '~90%', + window = { + width = 0.8, + height = 0.8, + yoffset = 0.5, + offset = 0.5 + } +} + +cmd[[let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline']] + +-- Customize the Files command to use ripgrep which respects .gitignore files +cmd[[ +command! -bang -nargs=? -complete=dir Files + \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) +]] + +-- Add an AllFiles variation that shows ignored files too +cmd[[ +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) +]] + +Keymap("n", "f", ":Files") +Keymap("n", "F", ":AllFiles") +Keymap("n", "b", ":Buffers") +Keymap("n", "h", ":History") +Keymap("n", "r", ":Rg") +Keymap("n", "R", ":Rg", { silent = false }) +Keymap("n", "gb", ":GBranches") diff --git a/home/.config/nvim/lua/plugins.d/fzf.vim b/home/.config/nvim/lua/plugins.d/fzf.vim deleted file mode 100644 index 575e211..0000000 --- a/home/.config/nvim/lua/plugins.d/fzf.vim +++ /dev/null @@ -1,22 +0,0 @@ -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' -Plug 'stsewd/fzf-checkout.vim' - -let g:fzf_layout = { 'up': '~90%', 'window': { 'width': 0.8, 'height': 0.8, 'yoffset':0.5, 'xoffset': 0.5 } } -let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' - -" Customise the Files command to use ripgrep which respects .gitignore files -command! -bang -nargs=? -complete=dir Files - \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) - -" Add an AllFiles variation that shows ignored files too -command! -bang -nargs=? -complete=dir AllFiles - \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) - -nmap f :Files -nmap F :AllFiles -nmap b :Buffers -nmap h :History -nmap r :Rg -nmap R :Rg -nmap gb :GBranches diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index ed43964..3380b4a 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -47,7 +47,7 @@ load_plugin_file("coc.vim") load_plugin_file("vimwiki.lua") load_plugin_file("nerdtree.lua") load_plugin_file("airline.lua") -load_plugin_file("fzf.vim") +load_plugin_file("fzf.lua") -- End Plug.vim loading process cmd[[call plug#end()]]