fix: live_grep path appending with cwd when already absolute (#768)
This commit is contained in:
committed by
GitHub
parent
d27907b0da
commit
f92b9b1fae
@@ -376,10 +376,10 @@ Built-in functions. Ready to be bound to any key you like. :smile:
|
|||||||
|
|
||||||
#### Options for builtin.live_grep
|
#### Options for builtin.live_grep
|
||||||
|
|
||||||
| Keys | Description | Options |
|
| Keys | Description | Options |
|
||||||
|------------------------|-------------------------------------------------------|--------------|
|
|------------------------|------------------------------------------------------------------------------------|--------------|
|
||||||
| `grep_open_files` | Restrict live_grep to currently open files. | boolean |
|
| `grep_open_files` | Restrict live_grep to currently open files, mutually exclusive with `search_dirs` | boolean |
|
||||||
| `search_dirs` | List of directories to search in. | list |
|
| `search_dirs` | List of directories to search in, mutually exclusive with `grep_open_files` | list |
|
||||||
|
|
||||||
|
|
||||||
### Vim Pickers
|
### Vim Pickers
|
||||||
|
|||||||
@@ -51,9 +51,7 @@ files.live_grep = function(opts)
|
|||||||
local file = vim.api.nvim_buf_get_name(bufnr)
|
local file = vim.api.nvim_buf_get_name(bufnr)
|
||||||
table.insert(filelist, tele_path.make_relative(file, opts.cwd))
|
table.insert(filelist, tele_path.make_relative(file, opts.cwd))
|
||||||
end
|
end
|
||||||
end
|
elseif search_dirs then
|
||||||
|
|
||||||
if search_dirs then
|
|
||||||
for i, path in ipairs(search_dirs) do
|
for i, path in ipairs(search_dirs) do
|
||||||
search_dirs[i] = vim.fn.expand(path)
|
search_dirs[i] = vim.fn.expand(path)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ local entry_display = require('telescope.pickers.entry_display')
|
|||||||
local path = require('telescope.path')
|
local path = require('telescope.path')
|
||||||
local utils = require('telescope.utils')
|
local utils = require('telescope.utils')
|
||||||
|
|
||||||
|
local Path = require('plenary.path')
|
||||||
|
|
||||||
local get_default = utils.get_default
|
local get_default = utils.get_default
|
||||||
|
|
||||||
local treesitter_type_highlight = {
|
local treesitter_type_highlight = {
|
||||||
@@ -155,7 +157,11 @@ do
|
|||||||
|
|
||||||
local execute_keys = {
|
local execute_keys = {
|
||||||
path = function(t)
|
path = function(t)
|
||||||
return t.cwd .. path.separator .. t.filename, false
|
if Path:new(t.filename):is_absolute() then
|
||||||
|
return t.filename, false
|
||||||
|
else
|
||||||
|
return t.cwd .. path.separator .. t.filename, false
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
filename = function(t)
|
filename = function(t)
|
||||||
|
|||||||
Reference in New Issue
Block a user