chore: reformat with stylua 0.14.0
This commit is contained in:
@@ -242,10 +242,9 @@ end
|
|||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_default = {
|
actions.select_default = {
|
||||||
pre = function(prompt_bufnr)
|
pre = function(prompt_bufnr)
|
||||||
action_state.get_current_history():append(
|
action_state
|
||||||
action_state.get_current_line(),
|
.get_current_history()
|
||||||
action_state.get_current_picker(prompt_bufnr)
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "default")
|
return action_set.select(prompt_bufnr, "default")
|
||||||
@@ -259,10 +258,9 @@ actions.select_default = {
|
|||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_horizontal = {
|
actions.select_horizontal = {
|
||||||
pre = function(prompt_bufnr)
|
pre = function(prompt_bufnr)
|
||||||
action_state.get_current_history():append(
|
action_state
|
||||||
action_state.get_current_line(),
|
.get_current_history()
|
||||||
action_state.get_current_picker(prompt_bufnr)
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "horizontal")
|
return action_set.select(prompt_bufnr, "horizontal")
|
||||||
@@ -276,10 +274,9 @@ actions.select_horizontal = {
|
|||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_vertical = {
|
actions.select_vertical = {
|
||||||
pre = function(prompt_bufnr)
|
pre = function(prompt_bufnr)
|
||||||
action_state.get_current_history():append(
|
action_state
|
||||||
action_state.get_current_line(),
|
.get_current_history()
|
||||||
action_state.get_current_picker(prompt_bufnr)
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "vertical")
|
return action_set.select(prompt_bufnr, "vertical")
|
||||||
@@ -293,10 +290,9 @@ actions.select_vertical = {
|
|||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.select_tab = {
|
actions.select_tab = {
|
||||||
pre = function(prompt_bufnr)
|
pre = function(prompt_bufnr)
|
||||||
action_state.get_current_history():append(
|
action_state
|
||||||
action_state.get_current_line(),
|
.get_current_history()
|
||||||
action_state.get_current_picker(prompt_bufnr)
|
:append(action_state.get_current_line(), action_state.get_current_picker(prompt_bufnr))
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
action = function(prompt_bufnr)
|
action = function(prompt_bufnr)
|
||||||
return action_set.select(prompt_bufnr, "tab")
|
return action_set.select(prompt_bufnr, "tab")
|
||||||
@@ -1175,10 +1171,8 @@ actions.which_key = function(prompt_bufnr, opts)
|
|||||||
+ opts.name_width
|
+ opts.name_width
|
||||||
+ (3 * #opts.separator)
|
+ (3 * #opts.separator)
|
||||||
local num_total_columns = math.floor((vim.o.columns - #column_indent) / entry_width)
|
local num_total_columns = math.floor((vim.o.columns - #column_indent) / entry_width)
|
||||||
opts.num_rows = math.min(
|
opts.num_rows =
|
||||||
math.ceil(#mappings / num_total_columns),
|
math.min(math.ceil(#mappings / num_total_columns), resolver.resolve_height(opts.max_height)(_, _, vim.o.lines))
|
||||||
resolver.resolve_height(opts.max_height)(_, _, vim.o.lines)
|
|
||||||
)
|
|
||||||
local total_available_entries = opts.num_rows * num_total_columns
|
local total_available_entries = opts.num_rows * num_total_columns
|
||||||
local winheight = opts.num_rows + 2 * opts.line_padding
|
local winheight = opts.num_rows + 2 * opts.line_padding
|
||||||
|
|
||||||
|
|||||||
@@ -122,18 +122,20 @@ diagnostics.get = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
|
opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = opts.bufnr == nil and "Workspace Diagnostics" or "Document Diagnostics",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = opts.bufnr == nil and "Workspace Diagnostics" or "Document Diagnostics",
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_diagnostics(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_diagnostics(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.prefilter_sorter {
|
previewer = conf.qflist_previewer(opts),
|
||||||
tag = "type",
|
sorter = conf.prefilter_sorter {
|
||||||
sorter = conf.generic_sorter(opts),
|
tag = "type",
|
||||||
},
|
sorter = conf.generic_sorter(opts),
|
||||||
}):find()
|
},
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function apply_checks(mod)
|
local function apply_checks(mod)
|
||||||
|
|||||||
@@ -110,18 +110,20 @@ files.live_grep = function(opts)
|
|||||||
return flatten { vimgrep_arguments, additional_args, "--", prompt, search_list }
|
return flatten { vimgrep_arguments, additional_args, "--", prompt, search_list }
|
||||||
end, opts.entry_maker or make_entry.gen_from_vimgrep(opts), opts.max_results, opts.cwd)
|
end, opts.entry_maker or make_entry.gen_from_vimgrep(opts), opts.max_results, opts.cwd)
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Live Grep",
|
.new(opts, {
|
||||||
finder = live_grepper,
|
prompt_title = "Live Grep",
|
||||||
previewer = conf.grep_previewer(opts),
|
finder = live_grepper,
|
||||||
-- TODO: It would be cool to use `--json` output for this
|
previewer = conf.grep_previewer(opts),
|
||||||
-- and then we could get the highlight positions directly.
|
-- TODO: It would be cool to use `--json` output for this
|
||||||
sorter = sorters.highlighter_only(opts),
|
-- and then we could get the highlight positions directly.
|
||||||
attach_mappings = function(_, map)
|
sorter = sorters.highlighter_only(opts),
|
||||||
map("i", "<c-space>", actions.to_fuzzy_refine)
|
attach_mappings = function(_, map)
|
||||||
return true
|
map("i", "<c-space>", actions.to_fuzzy_refine)
|
||||||
end,
|
return true
|
||||||
}):find()
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
files.grep_string = function(opts)
|
files.grep_string = function(opts)
|
||||||
@@ -161,12 +163,14 @@ files.grep_string = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_vimgrep(opts)
|
opts.entry_maker = opts.entry_maker or make_entry.gen_from_vimgrep(opts)
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Find Word (" .. word:gsub("\n", "\\n") .. ")",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(args, opts),
|
prompt_title = "Find Word (" .. word:gsub("\n", "\\n") .. ")",
|
||||||
previewer = conf.grep_previewer(opts),
|
finder = finders.new_oneshot_job(args, opts),
|
||||||
sorter = conf.generic_sorter(opts),
|
previewer = conf.grep_previewer(opts),
|
||||||
}):find()
|
sorter = conf.generic_sorter(opts),
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
files.find_files = function(opts)
|
files.find_files = function(opts)
|
||||||
@@ -291,12 +295,14 @@ files.find_files = function(opts)
|
|||||||
|
|
||||||
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
|
opts.entry_maker = opts.entry_maker or make_entry.gen_from_file(opts)
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Find Files",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(find_command, opts),
|
prompt_title = "Find Files",
|
||||||
previewer = conf.file_previewer(opts),
|
finder = finders.new_oneshot_job(find_command, opts),
|
||||||
sorter = conf.file_sorter(opts),
|
previewer = conf.file_previewer(opts),
|
||||||
}):find()
|
sorter = conf.file_sorter(opts),
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function prepare_match(entry, kind)
|
local function prepare_match(entry, kind)
|
||||||
@@ -349,18 +355,20 @@ files.treesitter = function(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Treesitter Symbols",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "Treesitter Symbols",
|
||||||
results = results,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_treesitter(opts),
|
results = results,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_treesitter(opts),
|
||||||
previewer = conf.grep_previewer(opts),
|
},
|
||||||
sorter = conf.prefilter_sorter {
|
previewer = conf.grep_previewer(opts),
|
||||||
tag = "kind",
|
sorter = conf.prefilter_sorter {
|
||||||
sorter = conf.generic_sorter(opts),
|
tag = "kind",
|
||||||
},
|
sorter = conf.generic_sorter(opts),
|
||||||
}):find()
|
},
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
files.current_buffer_fuzzy_find = function(opts)
|
files.current_buffer_fuzzy_find = function(opts)
|
||||||
@@ -432,25 +440,27 @@ files.current_buffer_fuzzy_find = function(opts)
|
|||||||
opts.line_highlights = line_highlights
|
opts.line_highlights = line_highlights
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Current Buffer Fuzzy",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "Current Buffer Fuzzy",
|
||||||
results = lines_with_numbers,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_buffer_lines(opts),
|
results = lines_with_numbers,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_buffer_lines(opts),
|
||||||
sorter = conf.generic_sorter(opts),
|
},
|
||||||
previewer = conf.grep_previewer(opts),
|
sorter = conf.generic_sorter(opts),
|
||||||
attach_mappings = function()
|
previewer = conf.grep_previewer(opts),
|
||||||
action_set.select:enhance {
|
attach_mappings = function()
|
||||||
post = function()
|
action_set.select:enhance {
|
||||||
local selection = action_state.get_selected_entry()
|
post = function()
|
||||||
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
local selection = action_state.get_selected_entry()
|
||||||
end,
|
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
||||||
}
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}):find()
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
files.tags = function(opts)
|
files.tags = function(opts)
|
||||||
@@ -467,38 +477,40 @@ files.tags = function(opts)
|
|||||||
end
|
end
|
||||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_ctags(opts))
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_ctags(opts))
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Tags",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts),
|
prompt_title = "Tags",
|
||||||
previewer = previewers.ctags.new(opts),
|
finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts),
|
||||||
sorter = conf.generic_sorter(opts),
|
previewer = previewers.ctags.new(opts),
|
||||||
attach_mappings = function()
|
sorter = conf.generic_sorter(opts),
|
||||||
action_set.select:enhance {
|
attach_mappings = function()
|
||||||
post = function()
|
action_set.select:enhance {
|
||||||
local selection = action_state.get_selected_entry()
|
post = function()
|
||||||
if not selection then
|
local selection = action_state.get_selected_entry()
|
||||||
return
|
if not selection then
|
||||||
end
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if selection.scode then
|
if selection.scode then
|
||||||
-- un-escape / then escape required
|
-- un-escape / then escape required
|
||||||
-- special chars for vim.fn.search()
|
-- special chars for vim.fn.search()
|
||||||
-- ] ~ *
|
-- ] ~ *
|
||||||
local scode = selection.scode:gsub([[\/]], "/"):gsub("[%]~*]", function(x)
|
local scode = selection.scode:gsub([[\/]], "/"):gsub("[%]~*]", function(x)
|
||||||
return "\\" .. x
|
return "\\" .. x
|
||||||
end)
|
end)
|
||||||
|
|
||||||
vim.cmd "norm! gg"
|
vim.cmd "norm! gg"
|
||||||
vim.fn.search(scode)
|
vim.fn.search(scode)
|
||||||
vim.cmd "norm! zz"
|
vim.cmd "norm! zz"
|
||||||
else
|
else
|
||||||
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}):find()
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
files.current_buffer_tags = function(opts)
|
files.current_buffer_tags = function(opts)
|
||||||
|
|||||||
@@ -37,70 +37,76 @@ git.files = function(opts)
|
|||||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_file(opts))
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_file(opts))
|
||||||
local git_command = vim.F.if_nil(opts.git_command, { "git", "ls-files", "--exclude-standard", "--cached" })
|
local git_command = vim.F.if_nil(opts.git_command, { "git", "ls-files", "--exclude-standard", "--cached" })
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git Files",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(
|
prompt_title = "Git Files",
|
||||||
vim.tbl_flatten {
|
finder = finders.new_oneshot_job(
|
||||||
git_command,
|
vim.tbl_flatten {
|
||||||
show_untracked and "--others" or nil,
|
git_command,
|
||||||
recurse_submodules and "--recurse-submodules" or nil,
|
show_untracked and "--others" or nil,
|
||||||
},
|
recurse_submodules and "--recurse-submodules" or nil,
|
||||||
opts
|
},
|
||||||
),
|
opts
|
||||||
previewer = conf.file_previewer(opts),
|
),
|
||||||
sorter = conf.file_sorter(opts),
|
previewer = conf.file_previewer(opts),
|
||||||
}):find()
|
sorter = conf.file_sorter(opts),
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
git.commits = function(opts)
|
git.commits = function(opts)
|
||||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
||||||
local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit", "--", "." })
|
local git_command = vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit", "--", "." })
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git Commits",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(git_command, opts),
|
prompt_title = "Git Commits",
|
||||||
previewer = {
|
finder = finders.new_oneshot_job(git_command, opts),
|
||||||
previewers.git_commit_diff_to_parent.new(opts),
|
previewer = {
|
||||||
previewers.git_commit_diff_to_head.new(opts),
|
previewers.git_commit_diff_to_parent.new(opts),
|
||||||
previewers.git_commit_diff_as_was.new(opts),
|
previewers.git_commit_diff_to_head.new(opts),
|
||||||
previewers.git_commit_message.new(opts),
|
previewers.git_commit_diff_as_was.new(opts),
|
||||||
},
|
previewers.git_commit_message.new(opts),
|
||||||
sorter = conf.file_sorter(opts),
|
},
|
||||||
attach_mappings = function(_, map)
|
sorter = conf.file_sorter(opts),
|
||||||
actions.select_default:replace(actions.git_checkout)
|
attach_mappings = function(_, map)
|
||||||
map("i", "<c-r>m", actions.git_reset_mixed)
|
actions.select_default:replace(actions.git_checkout)
|
||||||
map("n", "<c-r>m", actions.git_reset_mixed)
|
map("i", "<c-r>m", actions.git_reset_mixed)
|
||||||
map("i", "<c-r>s", actions.git_reset_soft)
|
map("n", "<c-r>m", actions.git_reset_mixed)
|
||||||
map("n", "<c-r>s", actions.git_reset_soft)
|
map("i", "<c-r>s", actions.git_reset_soft)
|
||||||
map("i", "<c-r>h", actions.git_reset_hard)
|
map("n", "<c-r>s", actions.git_reset_soft)
|
||||||
map("n", "<c-r>h", actions.git_reset_hard)
|
map("i", "<c-r>h", actions.git_reset_hard)
|
||||||
return true
|
map("n", "<c-r>h", actions.git_reset_hard)
|
||||||
end,
|
return true
|
||||||
}):find()
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
git.stash = function(opts)
|
git.stash = function(opts)
|
||||||
opts.show_branch = vim.F.if_nil(opts.show_branch, true)
|
opts.show_branch = vim.F.if_nil(opts.show_branch, true)
|
||||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash(opts))
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_stash(opts))
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git Stash",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(
|
prompt_title = "Git Stash",
|
||||||
vim.tbl_flatten {
|
finder = finders.new_oneshot_job(
|
||||||
"git",
|
vim.tbl_flatten {
|
||||||
"--no-pager",
|
"git",
|
||||||
"stash",
|
"--no-pager",
|
||||||
"list",
|
"stash",
|
||||||
},
|
"list",
|
||||||
opts
|
},
|
||||||
),
|
opts
|
||||||
previewer = previewers.git_stash_diff.new(opts),
|
),
|
||||||
sorter = conf.file_sorter(opts),
|
previewer = previewers.git_stash_diff.new(opts),
|
||||||
attach_mappings = function()
|
sorter = conf.file_sorter(opts),
|
||||||
actions.select_default:replace(actions.git_apply_stash)
|
attach_mappings = function()
|
||||||
return true
|
actions.select_default:replace(actions.git_apply_stash)
|
||||||
end,
|
return true
|
||||||
}):find()
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_current_buf_line = function(winnr)
|
local get_current_buf_line = function(winnr)
|
||||||
@@ -112,83 +118,83 @@ git.bcommits = function(opts)
|
|||||||
opts.current_line = (opts.current_file == nil) and get_current_buf_line(opts.winnr) or nil
|
opts.current_line = (opts.current_file == nil) and get_current_buf_line(opts.winnr) or nil
|
||||||
opts.current_file = vim.F.if_nil(opts.current_file, vim.api.nvim_buf_get_name(opts.bufnr))
|
opts.current_file = vim.F.if_nil(opts.current_file, vim.api.nvim_buf_get_name(opts.bufnr))
|
||||||
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_commits(opts))
|
||||||
local git_command = vim.F.if_nil(
|
local git_command =
|
||||||
opts.git_command,
|
vim.F.if_nil(opts.git_command, { "git", "log", "--pretty=oneline", "--abbrev-commit", "--follow" })
|
||||||
{ "git", "log", "--pretty=oneline", "--abbrev-commit", "--follow" }
|
|
||||||
)
|
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git BCommits",
|
.new(opts, {
|
||||||
finder = finders.new_oneshot_job(
|
prompt_title = "Git BCommits",
|
||||||
vim.tbl_flatten {
|
finder = finders.new_oneshot_job(
|
||||||
git_command,
|
vim.tbl_flatten {
|
||||||
opts.current_file,
|
git_command,
|
||||||
|
opts.current_file,
|
||||||
|
},
|
||||||
|
opts
|
||||||
|
),
|
||||||
|
previewer = {
|
||||||
|
previewers.git_commit_diff_to_parent.new(opts),
|
||||||
|
previewers.git_commit_diff_to_head.new(opts),
|
||||||
|
previewers.git_commit_diff_as_was.new(opts),
|
||||||
|
previewers.git_commit_message.new(opts),
|
||||||
},
|
},
|
||||||
opts
|
sorter = conf.file_sorter(opts),
|
||||||
),
|
attach_mappings = function()
|
||||||
previewer = {
|
actions.select_default:replace(actions.git_checkout_current_buffer)
|
||||||
previewers.git_commit_diff_to_parent.new(opts),
|
local transfrom_file = function()
|
||||||
previewers.git_commit_diff_to_head.new(opts),
|
return opts.current_file and Path:new(opts.current_file):make_relative(opts.cwd) or ""
|
||||||
previewers.git_commit_diff_as_was.new(opts),
|
end
|
||||||
previewers.git_commit_message.new(opts),
|
|
||||||
},
|
|
||||||
sorter = conf.file_sorter(opts),
|
|
||||||
attach_mappings = function()
|
|
||||||
actions.select_default:replace(actions.git_checkout_current_buffer)
|
|
||||||
local transfrom_file = function()
|
|
||||||
return opts.current_file and Path:new(opts.current_file):make_relative(opts.cwd) or ""
|
|
||||||
end
|
|
||||||
|
|
||||||
local get_buffer_of_orig = function(selection)
|
local get_buffer_of_orig = function(selection)
|
||||||
local value = selection.value .. ":" .. transfrom_file()
|
local value = selection.value .. ":" .. transfrom_file()
|
||||||
local content = utils.get_os_command_output({ "git", "--no-pager", "show", value }, opts.cwd)
|
local content = utils.get_os_command_output({ "git", "--no-pager", "show", value }, opts.cwd)
|
||||||
|
|
||||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, content)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, content)
|
||||||
vim.api.nvim_buf_set_name(bufnr, "Original")
|
vim.api.nvim_buf_set_name(bufnr, "Original")
|
||||||
return bufnr
|
return bufnr
|
||||||
end
|
end
|
||||||
|
|
||||||
local vimdiff = function(selection, command)
|
local vimdiff = function(selection, command)
|
||||||
local ft = vim.bo.filetype
|
local ft = vim.bo.filetype
|
||||||
vim.cmd "diffthis"
|
vim.cmd "diffthis"
|
||||||
|
|
||||||
local bufnr = get_buffer_of_orig(selection)
|
local bufnr = get_buffer_of_orig(selection)
|
||||||
vim.cmd(string.format("%s %s", command, bufnr))
|
vim.cmd(string.format("%s %s", command, bufnr))
|
||||||
vim.bo.filetype = ft
|
vim.bo.filetype = ft
|
||||||
vim.cmd "diffthis"
|
vim.cmd "diffthis"
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("WinClosed", {
|
vim.api.nvim_create_autocmd("WinClosed", {
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
nested = true,
|
nested = true,
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.api.nvim_buf_delete(bufnr, { force = true })
|
vim.api.nvim_buf_delete(bufnr, { force = true })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
actions.select_vertical:replace(function(prompt_bufnr)
|
actions.select_vertical:replace(function(prompt_bufnr)
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
vimdiff(selection, "leftabove vert sbuffer")
|
vimdiff(selection, "leftabove vert sbuffer")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
actions.select_horizontal:replace(function(prompt_bufnr)
|
actions.select_horizontal:replace(function(prompt_bufnr)
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
vimdiff(selection, "belowright sbuffer")
|
vimdiff(selection, "belowright sbuffer")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
actions.select_tab:replace(function(prompt_bufnr)
|
actions.select_tab:replace(function(prompt_bufnr)
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
local selection = action_state.get_selected_entry()
|
local selection = action_state.get_selected_entry()
|
||||||
vim.cmd("tabedit " .. transfrom_file())
|
vim.cmd("tabedit " .. transfrom_file())
|
||||||
vimdiff(selection, "leftabove vert sbuffer")
|
vimdiff(selection, "leftabove vert sbuffer")
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}):find()
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
git.branches = function(opts)
|
git.branches = function(opts)
|
||||||
@@ -197,10 +203,8 @@ git.branches = function(opts)
|
|||||||
.. "%(authorname)"
|
.. "%(authorname)"
|
||||||
.. "%(upstream:lstrip=2)"
|
.. "%(upstream:lstrip=2)"
|
||||||
.. "%(committerdate:format-local:%Y/%m/%d %H:%M:%S)"
|
.. "%(committerdate:format-local:%Y/%m/%d %H:%M:%S)"
|
||||||
local output = utils.get_os_command_output(
|
local output =
|
||||||
{ "git", "for-each-ref", "--perl", "--format", format, opts.pattern },
|
utils.get_os_command_output({ "git", "for-each-ref", "--perl", "--format", format, opts.pattern }, opts.cwd)
|
||||||
opts.cwd
|
|
||||||
)
|
|
||||||
|
|
||||||
local results = {}
|
local results = {}
|
||||||
local widths = {
|
local widths = {
|
||||||
@@ -273,41 +277,43 @@ git.branches = function(opts)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git Branches",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "Git Branches",
|
||||||
results = results,
|
finder = finders.new_table {
|
||||||
entry_maker = function(entry)
|
results = results,
|
||||||
entry.value = entry.name
|
entry_maker = function(entry)
|
||||||
entry.ordinal = entry.name
|
entry.value = entry.name
|
||||||
entry.display = make_display
|
entry.ordinal = entry.name
|
||||||
return make_entry.set_default_entry_mt(entry, opts)
|
entry.display = make_display
|
||||||
|
return make_entry.set_default_entry_mt(entry, opts)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
previewer = previewers.git_branch_log.new(opts),
|
||||||
|
sorter = conf.file_sorter(opts),
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
actions.select_default:replace(actions.git_checkout)
|
||||||
|
map("i", "<c-t>", actions.git_track_branch)
|
||||||
|
map("n", "<c-t>", actions.git_track_branch)
|
||||||
|
|
||||||
|
map("i", "<c-r>", actions.git_rebase_branch)
|
||||||
|
map("n", "<c-r>", actions.git_rebase_branch)
|
||||||
|
|
||||||
|
map("i", "<c-a>", actions.git_create_branch)
|
||||||
|
map("n", "<c-a>", actions.git_create_branch)
|
||||||
|
|
||||||
|
map("i", "<c-s>", actions.git_switch_branch)
|
||||||
|
map("n", "<c-s>", actions.git_switch_branch)
|
||||||
|
|
||||||
|
map("i", "<c-d>", actions.git_delete_branch)
|
||||||
|
map("n", "<c-d>", actions.git_delete_branch)
|
||||||
|
|
||||||
|
map("i", "<c-y>", actions.git_merge_branch)
|
||||||
|
map("n", "<c-y>", actions.git_merge_branch)
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
},
|
})
|
||||||
previewer = previewers.git_branch_log.new(opts),
|
:find()
|
||||||
sorter = conf.file_sorter(opts),
|
|
||||||
attach_mappings = function(_, map)
|
|
||||||
actions.select_default:replace(actions.git_checkout)
|
|
||||||
map("i", "<c-t>", actions.git_track_branch)
|
|
||||||
map("n", "<c-t>", actions.git_track_branch)
|
|
||||||
|
|
||||||
map("i", "<c-r>", actions.git_rebase_branch)
|
|
||||||
map("n", "<c-r>", actions.git_rebase_branch)
|
|
||||||
|
|
||||||
map("i", "<c-a>", actions.git_create_branch)
|
|
||||||
map("n", "<c-a>", actions.git_create_branch)
|
|
||||||
|
|
||||||
map("i", "<c-s>", actions.git_switch_branch)
|
|
||||||
map("n", "<c-s>", actions.git_switch_branch)
|
|
||||||
|
|
||||||
map("i", "<c-d>", actions.git_delete_branch)
|
|
||||||
map("n", "<c-d>", actions.git_delete_branch)
|
|
||||||
|
|
||||||
map("i", "<c-y>", actions.git_merge_branch)
|
|
||||||
map("n", "<c-y>", actions.git_merge_branch)
|
|
||||||
return true
|
|
||||||
end,
|
|
||||||
}):find()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
git.status = function(opts)
|
git.status = function(opts)
|
||||||
@@ -349,23 +355,25 @@ git.status = function(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "Git Status",
|
.new(opts, {
|
||||||
finder = initial_finder,
|
prompt_title = "Git Status",
|
||||||
previewer = previewers.git_file_diff.new(opts),
|
finder = initial_finder,
|
||||||
sorter = conf.file_sorter(opts),
|
previewer = previewers.git_file_diff.new(opts),
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
sorter = conf.file_sorter(opts),
|
||||||
actions.git_staging_toggle:enhance {
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
post = function()
|
actions.git_staging_toggle:enhance {
|
||||||
action_state.get_current_picker(prompt_bufnr):refresh(gen_new_finder(), { reset_prompt = true })
|
post = function()
|
||||||
end,
|
action_state.get_current_picker(prompt_bufnr):refresh(gen_new_finder(), { reset_prompt = true })
|
||||||
}
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
map("i", "<tab>", actions.git_staging_toggle)
|
map("i", "<tab>", actions.git_staging_toggle)
|
||||||
map("n", "<tab>", actions.git_staging_toggle)
|
map("n", "<tab>", actions.git_staging_toggle)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}):find()
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
local set_opts_cwd = function(opts)
|
local set_opts_cwd = function(opts)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -39,17 +39,19 @@ lsp.references = function(opts)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "LSP References",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "LSP References",
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.generic_sorter(opts),
|
previewer = conf.qflist_previewer(opts),
|
||||||
push_cursor_on_edit = true,
|
sorter = conf.generic_sorter(opts),
|
||||||
push_tagstack_on_edit = true,
|
push_cursor_on_edit = true,
|
||||||
}):find()
|
push_tagstack_on_edit = true,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -77,17 +79,19 @@ local function call_hierarchy(opts, method, title, direction, item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = title,
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = title,
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.generic_sorter(opts),
|
previewer = conf.qflist_previewer(opts),
|
||||||
push_cursor_on_edit = true,
|
sorter = conf.generic_sorter(opts),
|
||||||
push_tagstack_on_edit = true,
|
push_cursor_on_edit = true,
|
||||||
}):find()
|
push_tagstack_on_edit = true,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -171,17 +175,19 @@ local function list_or_jump(action, title, opts)
|
|||||||
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
|
vim.lsp.util.jump_to_location(flattened_results[1], offset_encoding)
|
||||||
else
|
else
|
||||||
local locations = vim.lsp.util.locations_to_items(flattened_results, offset_encoding)
|
local locations = vim.lsp.util.locations_to_items(flattened_results, offset_encoding)
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = title,
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = title,
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.generic_sorter(opts),
|
previewer = conf.qflist_previewer(opts),
|
||||||
push_cursor_on_edit = true,
|
sorter = conf.generic_sorter(opts),
|
||||||
push_tagstack_on_edit = true,
|
push_cursor_on_edit = true,
|
||||||
}):find()
|
push_tagstack_on_edit = true,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -230,20 +236,22 @@ lsp.document_symbols = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
opts.path_display = { "hidden" }
|
opts.path_display = { "hidden" }
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "LSP Document Symbols",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "LSP Document Symbols",
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.prefilter_sorter {
|
previewer = conf.qflist_previewer(opts),
|
||||||
tag = "symbol_type",
|
sorter = conf.prefilter_sorter {
|
||||||
sorter = conf.generic_sorter(opts),
|
tag = "symbol_type",
|
||||||
},
|
sorter = conf.generic_sorter(opts),
|
||||||
push_cursor_on_edit = true,
|
},
|
||||||
push_tagstack_on_edit = true,
|
push_cursor_on_edit = true,
|
||||||
}):find()
|
push_tagstack_on_edit = true,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -273,18 +281,20 @@ lsp.workspace_symbols = function(opts)
|
|||||||
|
|
||||||
opts.ignore_filename = vim.F.if_nil(opts.ignore_filename, false)
|
opts.ignore_filename = vim.F.if_nil(opts.ignore_filename, false)
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "LSP Workspace Symbols",
|
.new(opts, {
|
||||||
finder = finders.new_table {
|
prompt_title = "LSP Workspace Symbols",
|
||||||
results = locations,
|
finder = finders.new_table {
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
results = locations,
|
||||||
},
|
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = conf.prefilter_sorter {
|
previewer = conf.qflist_previewer(opts),
|
||||||
tag = "symbol_type",
|
sorter = conf.prefilter_sorter {
|
||||||
sorter = conf.generic_sorter(opts),
|
tag = "symbol_type",
|
||||||
},
|
sorter = conf.generic_sorter(opts),
|
||||||
}):find()
|
},
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -309,19 +319,21 @@ local function get_workspace_symbols_requester(bufnr, opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
lsp.dynamic_workspace_symbols = function(opts)
|
lsp.dynamic_workspace_symbols = function(opts)
|
||||||
pickers.new(opts, {
|
pickers
|
||||||
prompt_title = "LSP Dynamic Workspace Symbols",
|
.new(opts, {
|
||||||
finder = finders.new_dynamic {
|
prompt_title = "LSP Dynamic Workspace Symbols",
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
finder = finders.new_dynamic {
|
||||||
fn = get_workspace_symbols_requester(opts.bufnr, opts),
|
entry_maker = opts.entry_maker or make_entry.gen_from_lsp_symbols(opts),
|
||||||
},
|
fn = get_workspace_symbols_requester(opts.bufnr, opts),
|
||||||
previewer = conf.qflist_previewer(opts),
|
},
|
||||||
sorter = sorters.highlighter_only(opts),
|
previewer = conf.qflist_previewer(opts),
|
||||||
attach_mappings = function(_, map)
|
sorter = sorters.highlighter_only(opts),
|
||||||
map("i", "<c-space>", actions.to_fuzzy_refine)
|
attach_mappings = function(_, map)
|
||||||
return true
|
map("i", "<c-space>", actions.to_fuzzy_refine)
|
||||||
end,
|
return true
|
||||||
}):find()
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function check_capabilities(feature, bufnr)
|
local function check_capabilities(feature, bufnr)
|
||||||
|
|||||||
@@ -147,11 +147,8 @@ local telescope_map = function(prompt_bufnr, mode, key_bind, key_func, opts)
|
|||||||
|
|
||||||
local map_string
|
local map_string
|
||||||
if opts.expr then
|
if opts.expr then
|
||||||
map_string = string.format(
|
map_string =
|
||||||
[[luaeval("require('telescope.mappings').execute_keymap(%s, %s)")]],
|
string.format([[luaeval("require('telescope.mappings').execute_keymap(%s, %s)")]], prompt_bufnr, key_id)
|
||||||
prompt_bufnr,
|
|
||||||
key_id
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
if mode == "i" and not opts.expr then
|
if mode == "i" and not opts.expr then
|
||||||
prefix = "<cmd>"
|
prefix = "<cmd>"
|
||||||
@@ -161,12 +158,8 @@ local telescope_map = function(prompt_bufnr, mode, key_bind, key_func, opts)
|
|||||||
prefix = ":"
|
prefix = ":"
|
||||||
end
|
end
|
||||||
|
|
||||||
map_string = string.format(
|
map_string =
|
||||||
"%slua require('telescope.mappings').execute_keymap(%s, %s)<CR>",
|
string.format("%slua require('telescope.mappings').execute_keymap(%s, %s)<CR>", prefix, prompt_bufnr, key_id)
|
||||||
prefix,
|
|
||||||
prompt_bufnr,
|
|
||||||
key_id
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
a.nvim_buf_set_keymap(prompt_bufnr, mode, key_bind, map_string, opts)
|
a.nvim_buf_set_keymap(prompt_bufnr, mode, key_bind, map_string, opts)
|
||||||
|
|||||||
@@ -372,11 +372,8 @@ function Picker:find()
|
|||||||
popup_opts.preview.titlehighlight = "TelescopePreviewTitle"
|
popup_opts.preview.titlehighlight = "TelescopePreviewTitle"
|
||||||
end
|
end
|
||||||
|
|
||||||
local results_win, results_opts, results_border_win = self:_create_window(
|
local results_win, results_opts, results_border_win =
|
||||||
"",
|
self:_create_window("", popup_opts.results, not self.wrap_results)
|
||||||
popup_opts.results,
|
|
||||||
not self.wrap_results
|
|
||||||
)
|
|
||||||
|
|
||||||
local results_bufnr = a.nvim_win_get_buf(results_win)
|
local results_bufnr = a.nvim_win_get_buf(results_win)
|
||||||
pcall(a.nvim_buf_set_option, results_bufnr, "tabstop", 1) -- #1834
|
pcall(a.nvim_buf_set_option, results_bufnr, "tabstop", 1) -- #1834
|
||||||
|
|||||||
@@ -693,11 +693,8 @@ layout_strategies.vertical = make_documented_layout(
|
|||||||
-- Cap over/undersized height (with previewer)
|
-- Cap over/undersized height (with previewer)
|
||||||
height, h_space = calc_size_and_spacing(height, max_lines, bs, 3, 6, 2)
|
height, h_space = calc_size_and_spacing(height, max_lines, bs, 3, 6, 2)
|
||||||
|
|
||||||
preview.height = resolve.resolve_height(vim.F.if_nil(layout_config.preview_height, 0.5))(
|
preview.height =
|
||||||
self,
|
resolve.resolve_height(vim.F.if_nil(layout_config.preview_height, 0.5))(self, max_columns, height)
|
||||||
max_columns,
|
|
||||||
height
|
|
||||||
)
|
|
||||||
else
|
else
|
||||||
-- Cap over/undersized height (without previewer)
|
-- Cap over/undersized height (without previewer)
|
||||||
height, h_space = calc_size_and_spacing(height, max_lines, bs, 2, 4, 1)
|
height, h_space = calc_size_and_spacing(height, max_lines, bs, 2, 4, 1)
|
||||||
|
|||||||
@@ -45,28 +45,26 @@ utils.job_maker = function(cmd, bufnr, opts)
|
|||||||
end
|
end
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
Job
|
Job:new({
|
||||||
:new({
|
command = command,
|
||||||
command = command,
|
args = cmd,
|
||||||
args = cmd,
|
env = opts.env,
|
||||||
env = opts.env,
|
cwd = opts.cwd,
|
||||||
cwd = opts.cwd,
|
writer = writer,
|
||||||
writer = writer,
|
on_exit = vim.schedule_wrap(function(j)
|
||||||
on_exit = vim.schedule_wrap(function(j)
|
if not vim.api.nvim_buf_is_valid(bufnr) then
|
||||||
if not vim.api.nvim_buf_is_valid(bufnr) then
|
return
|
||||||
return
|
end
|
||||||
end
|
if opts.mode == "append" then
|
||||||
if opts.mode == "append" then
|
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, j:result())
|
||||||
vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, j:result())
|
elseif opts.mode == "insert" then
|
||||||
elseif opts.mode == "insert" then
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, j:result())
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, j:result())
|
end
|
||||||
end
|
if opts.callback then
|
||||||
if opts.callback then
|
opts.callback(bufnr, j:result())
|
||||||
opts.callback(bufnr, j:result())
|
end
|
||||||
end
|
end),
|
||||||
end),
|
}):start()
|
||||||
})
|
|
||||||
:start()
|
|
||||||
else
|
else
|
||||||
if opts.callback then
|
if opts.callback then
|
||||||
opts.callback(bufnr)
|
opts.callback(bufnr)
|
||||||
|
|||||||
@@ -291,17 +291,17 @@ sorters.get_fuzzy_file = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local denominator = (
|
local denominator = (
|
||||||
(10 * match_count / #prompt_lower_ngrams)
|
(10 * match_count / #prompt_lower_ngrams)
|
||||||
-- biases for shorter strings
|
-- biases for shorter strings
|
||||||
+ 3 * match_count * ngram_len / #line
|
+ 3 * match_count * ngram_len / #line
|
||||||
+ consecutive_matches
|
+ consecutive_matches
|
||||||
+ N / (contains_string or (2 * #line))
|
+ N / (contains_string or (2 * #line))
|
||||||
-- + 30/(c1 or 2*N)
|
-- + 30/(c1 or 2*N)
|
||||||
-- TODO: It might be possible that this too strongly correlates,
|
-- TODO: It might be possible that this too strongly correlates,
|
||||||
-- but it's unlikely for people to type capital letters without actually
|
-- but it's unlikely for people to type capital letters without actually
|
||||||
-- wanting to do something with a capital letter in it.
|
-- wanting to do something with a capital letter in it.
|
||||||
+ uppers_matching
|
+ uppers_matching
|
||||||
) * tail_modifier
|
) * tail_modifier
|
||||||
|
|
||||||
if denominator == 0 or denominator ~= denominator then
|
if denominator == 0 or denominator ~= denominator then
|
||||||
return -1
|
return -1
|
||||||
|
|||||||
@@ -417,16 +417,14 @@ function utils.get_os_command_output(cmd, cwd)
|
|||||||
end
|
end
|
||||||
local command = table.remove(cmd, 1)
|
local command = table.remove(cmd, 1)
|
||||||
local stderr = {}
|
local stderr = {}
|
||||||
local stdout, ret = Job
|
local stdout, ret = Job:new({
|
||||||
:new({
|
command = command,
|
||||||
command = command,
|
args = cmd,
|
||||||
args = cmd,
|
cwd = cwd,
|
||||||
cwd = cwd,
|
on_stderr = function(_, data)
|
||||||
on_stderr = function(_, data)
|
table.insert(stderr, data)
|
||||||
table.insert(stderr, data)
|
end,
|
||||||
end,
|
}):sync()
|
||||||
})
|
|
||||||
:sync()
|
|
||||||
return stdout, ret, stderr
|
return stdout, ret, stderr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user