Changed tree viewer to oil.nvim
This commit is contained in:
parent
6e6e7e050d
commit
1fae90350f
|
|
@ -25,10 +25,10 @@
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "1ddc1a2e692b120cda6d33c890461e49cb85d6bf" },
|
"nvim-lspconfig": { "branch": "master", "commit": "1ddc1a2e692b120cda6d33c890461e49cb85d6bf" },
|
||||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||||
"nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" },
|
"nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" },
|
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||||
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
|
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
|
||||||
"nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" },
|
"nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" },
|
||||||
|
"oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
|
||||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
|
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
|
||||||
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
return {
|
||||||
|
'stevearc/oil.nvim',
|
||||||
|
lazy = false,
|
||||||
|
---@module 'oil'
|
||||||
|
---@type oil.SetupOpts
|
||||||
|
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||||
|
config = function()
|
||||||
|
local oil = require 'oil'
|
||||||
|
|
||||||
|
oil.setup {
|
||||||
|
columns = { 'icon' },
|
||||||
|
keymaps = {
|
||||||
|
['g?'] = { 'actions.show_help', mode = 'n' },
|
||||||
|
['gs'] = { 'actions.change_sort', mode = 'n' },
|
||||||
|
['<C-Space>'] = { 'actions.select' },
|
||||||
|
['<C-l>'] = { 'actions.select' },
|
||||||
|
['<C-h>'] = { 'actions.parent' },
|
||||||
|
['<M-h>'] = { 'actions.select_split' },
|
||||||
|
['<C-c>'] = { 'actions.close', mode = 'n' },
|
||||||
|
['<Esc>'] = { 'actions.close', mode = 'n' },
|
||||||
|
},
|
||||||
|
view_options = {
|
||||||
|
show_hidden = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set('n', '-', oil.toggle_float, { desc = 'Open parent directory' })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -1,89 +0,0 @@
|
||||||
return {
|
|
||||||
'nvim-tree/nvim-tree.lua',
|
|
||||||
version = '*',
|
|
||||||
lazy = false,
|
|
||||||
dependencies = {
|
|
||||||
'nvim-tree/nvim-web-devicons',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local function custom_attach(bufnr)
|
|
||||||
local api = require 'nvim-tree.api'
|
|
||||||
|
|
||||||
local function opts(desc)
|
|
||||||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
|
||||||
end
|
|
||||||
local function edit_or_open()
|
|
||||||
local node = api.tree.get_node_under_cursor()
|
|
||||||
|
|
||||||
if node.nodes ~= nil then
|
|
||||||
-- expand or collapse folder
|
|
||||||
api.node.open.edit()
|
|
||||||
else
|
|
||||||
-- open file
|
|
||||||
api.node.open.edit()
|
|
||||||
-- Close the tree if file was opened
|
|
||||||
api.tree.close()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- open as vsplit on current node
|
|
||||||
local function vsplit_preview()
|
|
||||||
local node = api.tree.get_node_under_cursor()
|
|
||||||
|
|
||||||
if node.nodes ~= nil then
|
|
||||||
-- expand or collapse folder
|
|
||||||
api.node.open.edit()
|
|
||||||
else
|
|
||||||
-- open file as vsplit
|
|
||||||
api.node.open.vertical()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Finally refocus on tree if it was lost
|
|
||||||
api.tree.focus()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- default mappings
|
|
||||||
api.config.mappings.default_on_attach(bufnr)
|
|
||||||
|
|
||||||
-- custom mappings
|
|
||||||
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts 'Up')
|
|
||||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts 'Help')
|
|
||||||
--
|
|
||||||
-- global
|
|
||||||
vim.api.nvim_set_keymap('n', '<C-h>', ':NvimTreeToggle<cr>', { silent = true, noremap = true })
|
|
||||||
|
|
||||||
-- on_attach
|
|
||||||
vim.keymap.set('n', 'l', edit_or_open, opts 'Edit Or Open')
|
|
||||||
vim.keymap.set('n', 'L', vsplit_preview, opts 'Vsplit Preview')
|
|
||||||
vim.keymap.set('n', 'h', api.tree.close, opts 'Close')
|
|
||||||
vim.keymap.set('n', 'H', api.tree.collapse_all, opts 'Collapse All')
|
|
||||||
end
|
|
||||||
|
|
||||||
require('nvim-tree').setup {
|
|
||||||
on_attach = custom_attach,
|
|
||||||
sort = {
|
|
||||||
sorter = 'case_sensitive',
|
|
||||||
},
|
|
||||||
view = {
|
|
||||||
width = 30,
|
|
||||||
},
|
|
||||||
renderer = {
|
|
||||||
group_empty = true,
|
|
||||||
},
|
|
||||||
filters = {
|
|
||||||
dotfiles = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
-- return {
|
|
||||||
-- 'nvim-tree/nvim-tree.lua',
|
|
||||||
-- version = '*',
|
|
||||||
-- lazy = false,
|
|
||||||
-- dependencies = {
|
|
||||||
-- 'nvim-tree/nvim-web-devicons',
|
|
||||||
-- },
|
|
||||||
-- config = function()
|
|
||||||
-- require('nvim-tree').setup {}
|
|
||||||
-- end,
|
|
||||||
-- }
|
|
||||||
Loading…
Reference in New Issue