Updated config
This commit is contained in:
@ -16,12 +16,24 @@ on({ "BufNewFile", "BufRead" }, {
|
||||
|
||||
on({ "VimEnter" }, {
|
||||
callback = function()
|
||||
-- Change file to its directory if needed
|
||||
local file = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
if vim.fn.isdirectory(file) == 0 then
|
||||
file = vim.fs.dirname(file)
|
||||
end
|
||||
|
||||
-- Switch to root directory of the project
|
||||
local root_patterns = { ".git", "go.mod", "init.lua" }
|
||||
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1])
|
||||
local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, {
|
||||
upward = true,
|
||||
path = file,
|
||||
})[1])
|
||||
|
||||
if root_dir then
|
||||
vim.api.nvim_set_current_dir(root_dir)
|
||||
else
|
||||
vim.api.nvim_set_current_dir(file)
|
||||
end
|
||||
|
||||
-- Open file explorer if we have enough space
|
||||
|
@ -10,7 +10,9 @@ local function on_attach(bufnr)
|
||||
|
||||
-- navigation
|
||||
vim.keymap.set("n", "<C-Up>", api.tree.change_root_to_parent, opts("Up"))
|
||||
vim.keymap.set("n", "<C-Enter>", api.tree.change_root_to_node, opts("Enter"))
|
||||
vim.keymap.set("n", "<C-Left>", api.tree.change_root_to_parent, opts("Up"))
|
||||
vim.keymap.set("n", "<C-Down>", api.tree.change_root_to_node, opts("Enter"))
|
||||
vim.keymap.set("n", "<C-Right>", api.tree.change_root_to_node, opts("Enter"))
|
||||
|
||||
-- open folders with a single click
|
||||
vim.keymap.set("n", "<LeftRelease>", function()
|
||||
|
Reference in New Issue
Block a user