From 7243918bdd0a83d000278199aec398f5d4176add Mon Sep 17 00:00:00 2001 From: bhagwan Date: Sat, 2 Oct 2021 14:09:53 -0700 Subject: [PATCH] Default border color set to 'Normal', minor 'git_diff' fix --- README.md | 2 +- doc/fzf-lua.txt | 2 +- lua/fzf-lua/config.lua | 3 ++- lua/fzf-lua/core.lua | 2 +- lua/fzf-lua/previewer/fzf.lua | 2 +- minimal_init.lua | 50 +++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 minimal_init.lua diff --git a/README.md b/README.md index 7384d3e..c98edb6 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ require'fzf-lua'.setup { -- win_border = false, -- window border? or borderchars? win_border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, hl_normal = 'Normal', -- window normal color - hl_border = 'FloatBorder', -- window border color + hl_border = 'Normal', -- change to 'FloatBorder' if exists }, -- fzf_bin = 'sk', -- use skim instead of fzf? fzf_opts = { diff --git a/doc/fzf-lua.txt b/doc/fzf-lua.txt index 21d69dd..1380c65 100644 --- a/doc/fzf-lua.txt +++ b/doc/fzf-lua.txt @@ -256,7 +256,7 @@ Consult the list below for available settings: -- win_border = false, -- window border? or borderchars? win_border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, hl_normal = 'Normal', -- window normal color - hl_border = 'FloatBorder', -- window border color + hl_border = 'Normal', -- change to 'FloatBorder' if exists }, -- fzf_bin = 'sk', -- use skim instead of fzf? fzf_opts = { diff --git a/lua/fzf-lua/config.lua b/lua/fzf-lua/config.lua index 59faa61..0393ef7 100644 --- a/lua/fzf-lua/config.lua +++ b/lua/fzf-lua/config.lua @@ -28,7 +28,7 @@ M.globals = { win_border = true, borderchars = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, hl_normal = 'Normal', - hl_border = 'FloatBorder', + hl_border = 'Normal', --[[ window_on_create = function() -- Set popup background same as normal windows vim.cmd("set winhl=Normal:Normal,FloatBorder:FloatBorder") @@ -199,6 +199,7 @@ M.globals.git = { ["D"] = { icon = "D", color = "red" }, ["A"] = { icon = "A", color = "green" }, ["R"] = { icon = "R", color = "yellow" }, + ["C"] = { icon = "C", color = "yellow" }, ["?"] = { icon = "?", color = "magenta" }, }, } diff --git a/lua/fzf-lua/core.lua b/lua/fzf-lua/core.lua index 7fbf3b7..b7cbd33 100644 --- a/lua/fzf-lua/core.lua +++ b/lua/fzf-lua/core.lua @@ -209,7 +209,7 @@ local get_diff_files = function(opts) local status, err = utils.io_systemlist(path.git_cwd(cmd, opts.cwd)) if err == 0 then for i = 1, #status do - local icon = status[i]:match("[MUDAR?]+") + local icon = status[i]:match("[MUDARC?]+") local file = status[i]:match("[^ ]*$") if icon and file then diff_files[file] = icon diff --git a/lua/fzf-lua/previewer/fzf.lua b/lua/fzf-lua/previewer/fzf.lua index 8592985..830ee20 100644 --- a/lua/fzf-lua/previewer/fzf.lua +++ b/lua/fzf-lua/previewer/fzf.lua @@ -173,7 +173,7 @@ function Previewer.git_diff:cmdline(o) o = o or {} local act = helpers.choices_to_shell_cmd_previewer(function(items) local is_deleted = items[1]:match("D"..utils.nbsp) ~= nil - local is_untracked = items[1]:match("[?RA]"..utils.nbsp) ~= nil + local is_untracked = items[1]:match("[?RAC]"..utils.nbsp) ~= nil local file = path.entry_to_file(items[1], not self.relative and self.opts.cwd) local cmd = self.cmd local args = self.args diff --git a/minimal_init.lua b/minimal_init.lua new file mode 100644 index 0000000..077c85f --- /dev/null +++ b/minimal_init.lua @@ -0,0 +1,50 @@ +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Fzf-lua requires neovim > v0.5 | echohl None"') + return +end + +local res, packer = pcall(require, "packer") +local install_suffix = "/site/pack/packer/%s/packer.nvim" +local install_path = vim.fn.stdpath("data") .. string.format(install_suffix, "opt") +local is_installed = vim.loop.fs_stat(install_path) ~= nil + +if not res and is_installed then + vim.cmd("packadd packer.nvim") + res, packer = pcall(require, "packer") +end + +if not res then + print("Downloading packer.nvim...\n") + vim.fn.system({ + "git", "clone", '--depth', '1', + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + vim.cmd("packadd packer.nvim") + res, packer = pcall(require, "packer") + if res then + vim.fn.delete(packer.config.compile_path, "rf") + print("Successfully installed packer.nvim.") + else + print(("Error installing packer.nvim\nPath: %s"):format(install_path)) + return + end +end + +packer.startup({function(use) + use { 'wbthomason/packer.nvim', opt = true } + use { 'ibhagwan/fzf-lua', + requires = { 'vijaymarupudi/nvim-fzf' }, + config = function() + vim.api.nvim_set_keymap('n', '', + ':lua require"fzf-lua".files()', {}) + require'fzf-lua'.setup({}) + end, + } +end}) + +if not vim.loop.fs_stat(packer.config.compile_path) then + packer.sync() +else + packer.compile() +end