bugfix: [No Name] buffer, minor live_grep modifications

main
bhagwan 3 years ago
parent 78895876c2
commit 7a144f81da

@ -519,7 +519,8 @@ function M.normalize_opts(opts, defaults)
not executable(opts.fzf_bin, utils.warn, "fallback to 'fzf'.") then
-- default|fallback to fzf
opts.fzf_bin = "fzf"
if not executable(opts.fzf_bin, utils.err, "aborting.") then
if not executable(opts.fzf_bin, utils.err,
"aborting. Please make sure 'fzf' is in installed.") then
return nil
end
end

@ -49,7 +49,7 @@ function M.extension(path)
-- 1. match anything before the first ':'
-- 2. greedy match anything after the last dot
-- 3. remove coloring escape sequence
return utils.strip_ansi_coloring(path:match("[^:]+"):match("[^.]*$"))
return utils.strip_ansi_coloring(path:match("[^:]*"):match("[^.]*$"))
end
---Get the path to the parent directory of the given path. Returns `nil` if the

@ -118,7 +118,7 @@ M.live_grep = function(opts)
local placeholder
local reload_command
local initial_command = "true"
local initial_command = nil
if opts._is_skim then
placeholder = '"{}"'
reload_command = get_grep_cmd(opts , placeholder, true)
@ -139,14 +139,15 @@ M.live_grep = function(opts)
-- around the place holder
placeholder = '{q}'
reload_command = get_grep_cmd(opts, placeholder, true) .. " || true"
opts.fzf_fn = {}
if opts.exec_empty_query or (opts.search and #opts.search > 0) then
initial_command = get_grep_cmd(opts, opts.search)
end
opts.fzf_fn = fzf_helpers.cmd_line_transformer(
opts.fzf_fn = fzf_helpers.cmd_line_transformer(
initial_command,
function(x)
return core.make_entry_file(opts, x)
return core.make_entry_file(opts, x)
end)
end
opts._fzf_cli_args = string.format('--phony --query="%s" --bind=%s', query,
vim.fn.shellescape(string.format("change:reload:%s", reload_command)))
end
@ -202,6 +203,9 @@ M.grep_curbuf = function(opts)
if not opts then opts = {} end
opts.rg_opts = config.globals.grep.rg_opts .. " --with-filename"
opts.grep_opts = config.globals.grep.grep_opts .. " --with-filename"
if opts.exec_empty_query == nil then
opts.exec_empty_query = true
end
opts.filename = vim.api.nvim_buf_get_name(0)
if #opts.filename > 0 then
opts.filename = path.relative(opts.filename, vim.loop.cwd())

@ -233,6 +233,7 @@ end
local function fzf_lsp_locations(opts)
opts = normalize_lsp_opts(opts, config.globals.lsp)
if not opts then return end
opts = core.set_fzf_line_args(opts)
opts = set_lsp_fzf_fn(opts)
if not opts.fzf_fn then return end
@ -270,6 +271,7 @@ end
M.workspace_symbols = function(opts)
opts = normalize_lsp_opts(opts, config.globals.lsp)
if not opts then return end
opts.lsp_params = {query = opts.query or ''}
opts = core.set_fzf_line_args(opts)
opts = set_lsp_fzf_fn(opts)
@ -279,6 +281,7 @@ end
M.code_actions = function(opts)
opts = normalize_lsp_opts(opts, config.globals.lsp)
if not opts then return end
-- irrelevant for code actions and can cause
-- single results to be skipped with 'async = false'
opts.jump_to_single_result = false
@ -355,6 +358,7 @@ end
M.diagnostics = function(opts)
opts = normalize_lsp_opts(opts, config.globals.lsp)
if not opts then return end
local lsp_clients = vim.lsp.buf_get_clients(0)
if #lsp_clients == 0 then
@ -491,6 +495,7 @@ end
M.live_workspace_symbols = function(opts)
opts = normalize_lsp_opts(opts, config.globals.lsp)
if not opts then return end
opts.lsp_params = {query = ''}
-- must get those here, otherwise we get the

Loading…
Cancel
Save