Move netrw.lua to plugin directory
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
-- Disable banner
|
||||
vim.g.netrw_banner = 0
|
||||
|
||||
-- Fix gx when running inside WSL
|
||||
if vim.env.WSLENV then
|
||||
vim.g.netrw_browsex_viewer = 'cmd.exe /C start'
|
||||
end
|
||||
|
||||
-- Map - key to open netrw in current files parent directory
|
||||
vim.keymap.set('n', '-', function()
|
||||
-- Get the filename before invoking netrw
|
||||
local filename = vim.fn.expand('%:t')
|
||||
local directory = vim.fn.expand('%:hp')
|
||||
|
||||
if directory == '' then
|
||||
directory = vim.fn.getcwd()
|
||||
end
|
||||
|
||||
-- Invoke netrw on the directory containing the current file
|
||||
vim.fn.execute(string.format("edit %s", directory))
|
||||
if filename ~= '' then
|
||||
-- In the netrw buffer, move the cursor to the first character of filename
|
||||
vim.fn.search('\\<' .. filename .. '\\>')
|
||||
end
|
||||
end)
|
||||
|
||||
-- Unmap <C-l> in netrw buffers so it can be used for natigation
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'netrw',
|
||||
group = vim.api.nvim_create_augroup('netrw_unmap', {}),
|
||||
callback = function()
|
||||
local buffer = vim.api.nvim_get_current_buf()
|
||||
if vim.fn.hasmapto('<Plug>NetrwRefresh') == 1 then
|
||||
vim.keymap.del('n', '<C-l>', { buffer = buffer })
|
||||
end
|
||||
end
|
||||
})
|
||||
Reference in New Issue
Block a user