1

Refresh generated nvim config

This commit is contained in:
2024-06-03 21:11:20 +02:00
parent fd506d4921
commit 50723ef645
2114 changed files with 84528 additions and 44473 deletions

View File

@ -53,6 +53,9 @@ telescope.actions.history.History:new() telescope.txt /*telescope.actions.histor
telescope.actions.history.History:reset() telescope.txt /*telescope.actions.history.History:reset()*
telescope.actions.history.get_simple_history() telescope.txt /*telescope.actions.history.get_simple_history()*
telescope.actions.history.new() telescope.txt /*telescope.actions.history.new()*
telescope.actions.insert_original_cWORD() telescope.txt /*telescope.actions.insert_original_cWORD()*
telescope.actions.insert_original_cfile() telescope.txt /*telescope.actions.insert_original_cfile()*
telescope.actions.insert_original_cline() telescope.txt /*telescope.actions.insert_original_cline()*
telescope.actions.insert_original_cword() telescope.txt /*telescope.actions.insert_original_cword()*
telescope.actions.insert_symbol() telescope.txt /*telescope.actions.insert_symbol()*
telescope.actions.insert_symbol_i() telescope.txt /*telescope.actions.insert_symbol_i()*

View File

@ -3393,6 +3393,30 @@ actions.insert_original_cword({prompt_bufnr}) *telescope.actions.insert_original
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cWORD({prompt_bufnr}) *telescope.actions.insert_original_cWORD()*
Insert the WORD under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cfile({prompt_bufnr}) *telescope.actions.insert_original_cfile()*
Insert the file under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cline({prompt_bufnr}) *telescope.actions.insert_original_cline()*
Insert the line under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
================================================================================
ACTIONS_STATE *telescope.actions.state*

View File

@ -1496,6 +1496,27 @@ actions.insert_original_cword = function(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cword, false)
end
--- Insert the WORD under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cWORD = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cWORD, false)
end
--- Insert the file under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cfile = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cfile, false)
end
--- Insert the line under the cursor of the original (pre-Telescope) window
---@param prompt_bufnr number: The prompt bufnr
actions.insert_original_cline = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker:set_prompt(current_picker.original_cline, false)
end
actions.nop = function(_) end
actions.mouse_click = function(prompt_bufnr)

View File

@ -132,12 +132,12 @@ diagnostics.get = function(opts)
if opts.bufnr ~= 0 then
opts.bufnr = nil
end
if opts.bufnr == nil then
opts.path_display = vim.F.if_nil(opts.path_display, {})
end
if type(opts.bufnr) == "string" then
opts.bufnr = tonumber(opts.bufnr)
end
if opts.bufnr ~= nil then
opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
end
local locations = diagnostics_to_tbl(opts)
@ -157,7 +157,6 @@ diagnostics.get = function(opts)
return
end
opts.path_display = vim.F.if_nil(opts.path_display, "hidden")
pickers
.new(opts, {
prompt_title = opts.bufnr == nil and "Workspace Diagnostics" or "Document Diagnostics",

View File

@ -531,7 +531,7 @@ internal.oldfiles = function(opts)
local results = {}
if opts.include_current_session then
for _, buffer in ipairs(vim.split(vim.fn.execute ":buffers! t", "\n")) do
for _, buffer in ipairs(utils.split_lines(vim.fn.execute ":buffers! t")) do
local match = tonumber(string.match(buffer, "%s*(%d+)"))
local open_by_lsp = string.match(buffer, "line 0$")
if match and not open_by_lsp then
@ -574,7 +574,7 @@ end
internal.command_history = function(opts)
local history_string = vim.fn.execute "history cmd"
local history_list = vim.split(history_string, "\n")
local history_list = utils.split_lines(history_string)
local results = {}
local filter_fn = opts.filter_fn
@ -614,7 +614,7 @@ end
internal.search_history = function(opts)
local search_string = vim.fn.execute "history search"
local search_list = vim.split(search_string, "\n")
local search_list = utils.split_lines(search_string)
local results = {}
for i = #search_list, 3, -1 do
@ -690,7 +690,7 @@ internal.help_tags = function(opts)
opts.fallback = vim.F.if_nil(opts.fallback, true)
opts.file_ignore_patterns = {}
local langs = vim.split(opts.lang, ",", true)
local langs = vim.split(opts.lang, ",", { trimempty = true })
if opts.fallback and not vim.tbl_contains(langs, "en") then
table.insert(langs, "en")
end
@ -729,11 +729,11 @@ internal.help_tags = function(opts)
local delimiter = string.char(9)
for _, lang in ipairs(langs) do
for _, file in ipairs(tag_files[lang] or {}) do
local lines = vim.split(Path:new(file):read(), "\n", true)
local lines = utils.split_lines(Path:new(file):read(), { trimempty = true })
for _, line in ipairs(lines) do
-- TODO: also ignore tagComment starting with ';'
if not line:match "^!_TAG_" then
local fields = vim.split(line, delimiter, true)
local fields = vim.split(line, delimiter, { trimempty = true })
if #fields == 3 and not tags_map[fields[1]] then
if fields[1] ~= "help-tags" or fields[2] ~= "tags" then
table.insert(tags, {

View File

@ -184,7 +184,7 @@ do
if k == "path" then
local retpath = Path:new({ t.cwd, t.value }):absolute()
if not vim.loop.fs_access(retpath, "R", nil) then
if not vim.loop.fs_access(retpath, "R") then
retpath = t.value
end
return retpath
@ -540,8 +540,14 @@ function make_entry.gen_from_lsp_symbols(opts)
msg,
}
else
local display_path, path_style = utils.transform_path(opts, entry.filename)
return displayer {
utils.transform_path(opts, entry.filename),
{
display_path,
function()
return path_style
end,
},
entry.symbol_name,
{ entry.symbol_type:lower(), type_highlight[entry.symbol_type] },
msg,
@ -1043,7 +1049,7 @@ function make_entry.gen_from_ctags(opts)
}
local make_display = function(entry)
local filename = utils.transform_path(opts, entry.filename)
local display_path, path_style = utils.transform_path(opts, entry.filename)
local scode
if opts.show_line then
@ -1057,7 +1063,12 @@ function make_entry.gen_from_ctags(opts)
}
else
return displayer {
filename,
{
display_path,
function()
return path_style
end,
},
entry.tag,
scode,
}
@ -1073,7 +1084,7 @@ function make_entry.gen_from_ctags(opts)
if k == "path" then
local retpath = Path:new({ t.filename }):absolute()
if not vim.loop.fs_access(retpath, "R", nil) then
if not vim.loop.fs_access(retpath, "R") then
retpath = t.filename
end
return retpath
@ -1174,7 +1185,7 @@ function make_entry.gen_from_diagnostics(opts)
}
local make_display = function(entry)
local filename = utils.transform_path(opts, entry.filename)
local display_path, path_style = utils.transform_path(opts, entry.filename)
-- add styling of entries
local pos = string.format("%4d:%2d", entry.lnum, entry.col)
@ -1187,7 +1198,12 @@ function make_entry.gen_from_diagnostics(opts)
return displayer {
line_info,
entry.text,
filename,
{
display_path,
function()
return path_style
end,
},
}
end
@ -1345,11 +1361,18 @@ function make_entry.gen_from_git_status(opts)
local status_x = git_abbrev[x] or {}
local status_y = git_abbrev[y] or {}
local display_path, path_style = utils.transform_path(opts, entry.path)
local empty_space = " "
return displayer {
{ status_x.icon or empty_space, status_x.hl },
{ status_y.icon or empty_space, status_y.hl },
utils.transform_path(opts, entry.path),
{
display_path,
function()
return path_style
end,
},
}
end

View File

@ -176,6 +176,9 @@ mappings.default_mappings = config.values.default_mappings
["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
["<C-w>"] = { "<c-s-w>", type = "command" },
["<C-r><C-w>"] = actions.insert_original_cword,
["<C-r><C-a>"] = actions.insert_original_cWORD,
["<C-r><C-f>"] = actions.insert_original_cfile,
["<C-r><C-l>"] = actions.insert_original_cline,
-- disable c-j because we dont want to allow new lines #2123
["<C-j>"] = actions.nop,

View File

@ -537,6 +537,10 @@ function Picker:find()
self.original_win_id = a.nvim_get_current_win()
_, self.original_cword = pcall(vim.fn.expand, "<cword>")
_, self.original_cWORD = pcall(vim.fn.expand, "<cWORD>")
_, self.original_cfile = pcall(vim.fn.expand, "<cfile>")
_, self.original_cline = pcall(vim.api.nvim_get_current_line)
_, self.original_cline = pcall(vim.trim, self.original_cline)
-- User autocmd run it before create Telescope window
vim.api.nvim_exec_autocmds("User", { pattern = "TelescopeFindPre" })

View File

@ -1090,7 +1090,7 @@ previewers.highlights = defaulter(function(_)
define_preview = function(self, entry)
if not self.state.bufname then
local output = vim.split(vim.fn.execute "highlight", "\n")
local output = utils.split_lines(vim.fn.execute "highlight")
local hl_groups = {}
for _, v in ipairs(output) do
if v ~= "" then

View File

@ -5,12 +5,14 @@ local conf = require("telescope.config").values
local Job = require "plenary.job"
local Path = require "plenary.path"
local telescope_utils = require "telescope.utils"
local utils = {}
local detect_from_shebang = function(p)
local s = p:readbyterange(0, 256)
if s then
local lines = vim.split(s, "\n")
local lines = telescope_utils.split_lines(s)
return vim.filetype.match { contents = lines }
end
end
@ -24,7 +26,7 @@ end
local detect_from_modeline = function(p)
local s = p:readbyterange(-256, 256)
if s then
local lines = vim.split(s, "\n")
local lines = telescope_utils.split_lines(s)
local idx = lines[#lines] ~= "" and #lines or #lines - 1
if idx >= 1 then
return parse_modeline(lines[idx])

View File

@ -216,13 +216,25 @@ end)()
utils.path_tail = (function()
local os_sep = utils.get_separator()
return function(path)
for i = #path, 1, -1 do
if path:sub(i, i) == os_sep then
return path:sub(i + 1, -1)
if os_sep == "/" then
return function(path)
for i = #path, 1, -1 do
if path:sub(i, i) == os_sep then
return path:sub(i + 1, -1)
end
end
return path
end
else
return function(path)
for i = #path, 1, -1 do
local c = path:sub(i, i)
if c == os_sep or c == "/" then
return path:sub(i + 1, -1)
end
end
return path
end
return path
end
end)()
@ -727,4 +739,16 @@ utils.reverse_table = function(input_table)
return temp_table
end
utils.split_lines = (function()
if utils.iswin then
return function(s, opts)
return vim.split(s, "\r?\n", opts)
end
else
return function(s, opts)
return vim.split(s, "\n", opts)
end
end
end)()
return utils

View File

@ -307,3 +307,87 @@ describe("transform_path", function()
end, new_relpath "doc/mydoc.md", new_relpath "d/mydoc.md")
end)
end)
describe("path_tail", function()
local function assert_tails(paths)
for _, path in ipairs(paths) do
it("gets the tail of " .. path, function()
local tail = vim.fn.fnamemodify(path, ":p:t")
eq(tail, utils.path_tail(path))
end)
end
end
if jit and jit.os:lower() == "windows" then
describe("handles windows paths", function()
local paths = {
[[C:\Users\username\AppData\Local\nvim-data\log]],
[[D:\Projects\project_folder\source_code.py]],
[[E:\Music\song.mp3]],
[[/home/usuario/documents/archivo.txt]],
[[/var/www/html/index.html]],
[[/mnt/backup/backup_file.tar.gz]],
}
assert_tails(paths)
end)
elseif jit and jit.os:lower() == "linux" then
describe("handles linux paths", function()
local paths = {
[[/home/usuario/documents/archivo.txt]],
[[/var/www/html/index.html]],
[[/mnt/backup/backup_file.tar.gz]],
}
assert_tails(paths)
end)
elseif jit and jit.os:lower() == "osx" then
describe("handles macos paths", function()
local paths = {
[[/Users/Usuario/Documents/archivo.txt]],
[[/Applications/App.app/Contents/MacOS/app_executable]],
[[/Volumes/ExternalDrive/Data/file.xlsx]],
}
assert_tails(paths)
end)
end
end)
describe("split_lines", function()
local expect = {
"",
"",
"line3 of the file",
"",
"line5 of the file",
"",
"",
"line8 of the file, last line of file",
"",
}
local function get_fake_file(line_ending)
return table.concat(expect, line_ending)
end
local newline_file = get_fake_file "\n"
local carriage_newline_file = get_fake_file "\r\n"
if utils.iswin then
describe("handles files on Windows", function()
it("reads file with newline only", function()
assert.are.same(expect, utils.split_lines(newline_file))
end)
it("reads file with carriage return and newline", function()
assert.are.same(expect, utils.split_lines(carriage_newline_file))
end)
end)
else
describe("handles files on non Windows environment", function()
it("reads file with newline only", function()
assert.are.same(expect, utils.split_lines(newline_file))
end)
end)
end
end)

View File

@ -22,7 +22,7 @@ rock_manifest = {
},
doc = {
["secret.txt"] = "59f2d5cd8b01a044b4e7f598244869ec",
["telescope.txt"] = "190706f7b21d86c8809b8b0d946d8aec",
["telescope.txt"] = "7216a8bf6e20d1fffcd8a31b127219c7",
["telescope_changelog.txt"] = "5c807cb49d45799276be85c33693c08f"
},
ftplugin = {
@ -38,7 +38,7 @@ rock_manifest = {
actions = {
["generate.lua"] = "b627dbab3b7d2a572779707529331a5f",
["history.lua"] = "6b34c6a357dfad0762f099c1ba3b426f",
["init.lua"] = "0d6ea5eaeb361e6298663fbf0ea52206",
["init.lua"] = "40eb8512d6b1f07e26043e3489dcf94d",
["layout.lua"] = "91470edb5dd37a3025e141d5cc6691bd",
["mt.lua"] = "9c22e387921dbfbd56afdf3fed7b84af",
["set.lua"] = "e0b8491c7e789e09c032e650d8c858ef",
@ -51,10 +51,10 @@ rock_manifest = {
["string_distance.lua"] = "1d63486c008b414586ec505b36c361a2"
},
builtin = {
["__diagnostics.lua"] = "f2edc0b78359facb94a2269bf28fb0a7",
["__diagnostics.lua"] = "debd53606d5dee06bb2031026c7c3145",
["__files.lua"] = "d2c0373381ef70771adae4b6e9bb03ce",
["__git.lua"] = "a40e030790285c1e8706d181f0b4a831",
["__internal.lua"] = "04bf667684de70d6c6d600ba7c40ee99",
["__internal.lua"] = "89209cb8f9d22b8b6712243182f06c66",
["__lsp.lua"] = "03e5d78027aa37c04280151029744063",
["init.lua"] = "0e0188ef0f37c07387270ea8594c0f2e"
},
@ -76,8 +76,8 @@ rock_manifest = {
["health.lua"] = "885a0947d640b003eba0b9aac67f5a21",
["init.lua"] = "defe6eaf81f3596ccfafb9647afdac9f",
["log.lua"] = "5c57992c1ac7c17c2e5879d38921f819",
["make_entry.lua"] = "ece9c42534f9296fb9873147fe53291c",
["mappings.lua"] = "5cfd5f1aff126928f745439d5c61b12b",
["make_entry.lua"] = "4fe6b147629c109e23c3962ba9cf2ba6",
["mappings.lua"] = "aa736d661e2200619a98629ebb07f505",
["operators.lua"] = "e7244d086698dfaa71be2133820e57ee",
pickers = {
["entry_display.lua"] = "27c74c2c4812244722444ebafbccd1ae",
@ -88,13 +88,13 @@ rock_manifest = {
["scroller.lua"] = "54fc7267917bf9f9076a632293a73cd5",
["window.lua"] = "fc74d7849a1381643289a65678e14aa3"
},
["pickers.lua"] = "b72754962d52ff38ec5af1ba74d51d34",
["pickers.lua"] = "2dd384f602a65ad2df4ac75ffc77bcfa",
previewers = {
["buffer_previewer.lua"] = "415436f46b3df7c247fbee9a466a4467",
["buffer_previewer.lua"] = "544d3e3417a9c496277f3a8118141007",
["init.lua"] = "fa1745a8bef70d35f713d3c4b3c70257",
["previewer.lua"] = "3b02d1b4a9aeb5c6a79771709ca799cc",
["term_previewer.lua"] = "6d38b050b6bc564215113e7cb42bb42a",
["utils.lua"] = "9d4808a9af4dca92c1fb6f5993185213"
["utils.lua"] = "6aad15a9e8ec96ddb7576e0f3bd9bc48"
},
["sorters.lua"] = "bb1c9e687331d5cf0952582b2dadab7f",
["state.lua"] = "450c0b38c2497ae8c505a882257e0bed",
@ -104,7 +104,7 @@ rock_manifest = {
["runner.lua"] = "1201b1158848fc7e6a581f258776a977"
},
["themes.lua"] = "02e18c91826ee7834ffedc9378cbc9b9",
["utils.lua"] = "a0d3abb98a237ada18f8a57421270af7"
["utils.lua"] = "fe4d526b4086bc9e2f28b7c716eea000"
},
tests = {
automated = {
@ -121,7 +121,7 @@ rock_manifest = {
["scroller_spec.lua"] = "3595abe16efe6753888274f11f1818ad",
["sorters_spec.lua"] = "6a5c265752ac0ea6a07ef39d66518b8e",
["telescope_spec.lua"] = "573cee7dce62d9f8cd0d3592f784aade",
["utils_spec.lua"] = "e246ecc4ce2e9676a16c0269cf770bcc"
["utils_spec.lua"] = "48b3bda11ba9261ddc0b1c122adfbb44"
},
fixtures = {
find_files = {

View File

@ -3393,6 +3393,30 @@ actions.insert_original_cword({prompt_bufnr}) *telescope.actions.insert_original
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cWORD({prompt_bufnr}) *telescope.actions.insert_original_cWORD()*
Insert the WORD under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cfile({prompt_bufnr}) *telescope.actions.insert_original_cfile()*
Insert the file under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
actions.insert_original_cline({prompt_bufnr}) *telescope.actions.insert_original_cline()*
Insert the line under the cursor of the original (pre-Telescope) window
Parameters: ~
{prompt_bufnr} (number) The prompt bufnr
================================================================================
ACTIONS_STATE *telescope.actions.state*

View File

@ -22,7 +22,7 @@ rock_manifest = {
},
doc = {
["secret.txt"] = "59f2d5cd8b01a044b4e7f598244869ec",
["telescope.txt"] = "190706f7b21d86c8809b8b0d946d8aec",
["telescope.txt"] = "7216a8bf6e20d1fffcd8a31b127219c7",
["telescope_changelog.txt"] = "5c807cb49d45799276be85c33693c08f"
},
ftplugin = {
@ -38,7 +38,7 @@ rock_manifest = {
actions = {
["generate.lua"] = "b627dbab3b7d2a572779707529331a5f",
["history.lua"] = "6b34c6a357dfad0762f099c1ba3b426f",
["init.lua"] = "0d6ea5eaeb361e6298663fbf0ea52206",
["init.lua"] = "40eb8512d6b1f07e26043e3489dcf94d",
["layout.lua"] = "91470edb5dd37a3025e141d5cc6691bd",
["mt.lua"] = "9c22e387921dbfbd56afdf3fed7b84af",
["set.lua"] = "e0b8491c7e789e09c032e650d8c858ef",
@ -51,10 +51,10 @@ rock_manifest = {
["string_distance.lua"] = "1d63486c008b414586ec505b36c361a2"
},
builtin = {
["__diagnostics.lua"] = "f2edc0b78359facb94a2269bf28fb0a7",
["__diagnostics.lua"] = "debd53606d5dee06bb2031026c7c3145",
["__files.lua"] = "d2c0373381ef70771adae4b6e9bb03ce",
["__git.lua"] = "a40e030790285c1e8706d181f0b4a831",
["__internal.lua"] = "04bf667684de70d6c6d600ba7c40ee99",
["__internal.lua"] = "89209cb8f9d22b8b6712243182f06c66",
["__lsp.lua"] = "03e5d78027aa37c04280151029744063",
["init.lua"] = "0e0188ef0f37c07387270ea8594c0f2e"
},
@ -76,8 +76,8 @@ rock_manifest = {
["health.lua"] = "885a0947d640b003eba0b9aac67f5a21",
["init.lua"] = "defe6eaf81f3596ccfafb9647afdac9f",
["log.lua"] = "5c57992c1ac7c17c2e5879d38921f819",
["make_entry.lua"] = "ece9c42534f9296fb9873147fe53291c",
["mappings.lua"] = "5cfd5f1aff126928f745439d5c61b12b",
["make_entry.lua"] = "4fe6b147629c109e23c3962ba9cf2ba6",
["mappings.lua"] = "aa736d661e2200619a98629ebb07f505",
["operators.lua"] = "e7244d086698dfaa71be2133820e57ee",
pickers = {
["entry_display.lua"] = "27c74c2c4812244722444ebafbccd1ae",
@ -88,13 +88,13 @@ rock_manifest = {
["scroller.lua"] = "54fc7267917bf9f9076a632293a73cd5",
["window.lua"] = "fc74d7849a1381643289a65678e14aa3"
},
["pickers.lua"] = "b72754962d52ff38ec5af1ba74d51d34",
["pickers.lua"] = "2dd384f602a65ad2df4ac75ffc77bcfa",
previewers = {
["buffer_previewer.lua"] = "415436f46b3df7c247fbee9a466a4467",
["buffer_previewer.lua"] = "544d3e3417a9c496277f3a8118141007",
["init.lua"] = "fa1745a8bef70d35f713d3c4b3c70257",
["previewer.lua"] = "3b02d1b4a9aeb5c6a79771709ca799cc",
["term_previewer.lua"] = "6d38b050b6bc564215113e7cb42bb42a",
["utils.lua"] = "9d4808a9af4dca92c1fb6f5993185213"
["utils.lua"] = "6aad15a9e8ec96ddb7576e0f3bd9bc48"
},
["sorters.lua"] = "bb1c9e687331d5cf0952582b2dadab7f",
["state.lua"] = "450c0b38c2497ae8c505a882257e0bed",
@ -104,7 +104,7 @@ rock_manifest = {
["runner.lua"] = "1201b1158848fc7e6a581f258776a977"
},
["themes.lua"] = "02e18c91826ee7834ffedc9378cbc9b9",
["utils.lua"] = "a0d3abb98a237ada18f8a57421270af7"
["utils.lua"] = "fe4d526b4086bc9e2f28b7c716eea000"
},
tests = {
automated = {
@ -121,7 +121,7 @@ rock_manifest = {
["scroller_spec.lua"] = "3595abe16efe6753888274f11f1818ad",
["sorters_spec.lua"] = "6a5c265752ac0ea6a07ef39d66518b8e",
["telescope_spec.lua"] = "573cee7dce62d9f8cd0d3592f784aade",
["utils_spec.lua"] = "e246ecc4ce2e9676a16c0269cf770bcc"
["utils_spec.lua"] = "48b3bda11ba9261ddc0b1c122adfbb44"
},
fixtures = {
find_files = {