summaryrefslogtreecommitdiff
path: root/lua/ben/core/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/ben/core/init.lua')
-rw-r--r--lua/ben/core/init.lua41
1 files changed, 35 insertions, 6 deletions
diff --git a/lua/ben/core/init.lua b/lua/ben/core/init.lua
index e5bb0a2..5d8b7b0 100644
--- a/lua/ben/core/init.lua
+++ b/lua/ben/core/init.lua
@@ -6,12 +6,6 @@ vim.g.mapleader = ";"
-- Space is quicker than Shift+Semicolon
vim.keymap.set("n", "<space>", ":")
--- fm -> File Manager
-vim.keymap.set("n", "<leader>fm", "<cmd>Exp<cr>")
-
--- Tree View for the netrw File Manager
-vim.g.netrw_liststyle = 3
-
-- Set encoding to UTF-8
vim.opt.encoding = "utf-8"
@@ -74,3 +68,38 @@ vim.api.nvim_set_keymap("n", "<leader>w", ":update<CR>", { silent = true })
-- Remove trailing white spaces on BufWritePre
vim.cmd([[autocmd BufWritePre * %s/\s\+$//e]])
+
+-- Tree View for the netrw File Manager
+vim.g.netrw_liststyle = 3
+vim.g.netrw_banner = 0
+-- If nvim is opened with no arguments, open the netrw file manager
+local mygroup = vim.api.nvim_create_augroup("loading_netrwPlugin", { clear = true })
+vim.api.nvim_create_autocmd({ "VimEnter" }, {
+ pattern = { "*" },
+ callback = function()
+ -- Getting the file name that you pass when you launch nvim,
+ local current_file = vim.fn.expand("%")
+ -- if we have already file_name, then, we edit it
+ if current_file ~= "" then
+ vim.cmd(":silent! edit " .. current_file)
+ else
+ -- We will check if the window (buffer) is the lazy nvim, as it conflict if the buffer (popup menu) is lazy
+ local lazy_popup_buf_exists = false
+ -- We will get list of all current opened buffers
+ local buf_list = vim.api.nvim_list_bufs()
+ for _, buf in ipairs(buf_list) do
+ -- We will obtain from the table only the filetype
+ local buf_ft = vim.api.nvim_buf_get_option(buf, "filetype")
+ if buf_ft == "lazy" then
+ lazy_popup_buf_exists = true
+ end
+ end -- Check if vim-floaterm is loaded
+ local has_floaterm, _ = pcall(require, "floaterm")
+ if not lazy_popup_buf_exists and not has_floaterm then
+ -- Then we can safely loading netrwPlugin at startup
+ vim.cmd(":silent! Explore")
+ end
+ end
+ end,
+ group = mygroup,
+})