|
|
@ -324,17 +324,17 @@ local function find_git_root()
|
|
|
|
local current_dir
|
|
|
|
local current_dir
|
|
|
|
local cwd = vim.fn.getcwd()
|
|
|
|
local cwd = vim.fn.getcwd()
|
|
|
|
-- If the buffer is not associated with a file, return nil
|
|
|
|
-- If the buffer is not associated with a file, return nil
|
|
|
|
if current_file == "" then
|
|
|
|
if current_file == '' then
|
|
|
|
current_dir = cwd
|
|
|
|
current_dir = cwd
|
|
|
|
else
|
|
|
|
else
|
|
|
|
-- Extract the directory from the current file's path
|
|
|
|
-- Extract the directory from the current file's path
|
|
|
|
current_dir = vim.fn.fnamemodify(current_file, ":h")
|
|
|
|
current_dir = vim.fn.fnamemodify(current_file, ':h')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Find the Git root directory from the current file's path
|
|
|
|
-- Find the Git root directory from the current file's path
|
|
|
|
local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1]
|
|
|
|
local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
|
|
|
|
if vim.v.shell_error ~= 0 then
|
|
|
|
if vim.v.shell_error ~= 0 then
|
|
|
|
print("Not a git repository. Searching on current working directory")
|
|
|
|
print 'Not a git repository. Searching on current working directory'
|
|
|
|
return cwd
|
|
|
|
return cwd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return git_root
|
|
|
|
return git_root
|
|
|
@ -344,9 +344,9 @@ end
|
|
|
|
local function live_grep_git_root()
|
|
|
|
local function live_grep_git_root()
|
|
|
|
local git_root = find_git_root()
|
|
|
|
local git_root = find_git_root()
|
|
|
|
if git_root then
|
|
|
|
if git_root then
|
|
|
|
require('telescope.builtin').live_grep({
|
|
|
|
require('telescope.builtin').live_grep {
|
|
|
|
search_dirs = {git_root},
|
|
|
|
search_dirs = { git_root },
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -567,7 +567,7 @@ cmp.setup {
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
completion = {
|
|
|
|
completion = {
|
|
|
|
completeopt = 'menu,menuone,noinsert'
|
|
|
|
completeopt = 'menu,menuone,noinsert',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert {
|
|
|
|
mapping = cmp.mapping.preset.insert {
|
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
|
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
|
|