Use neotree instead of nvimtree

This commit is contained in:
Zoe Roux
2022-05-31 00:19:08 +02:00
parent 25bff6599e
commit 9e8a3a0faf
5 changed files with 101 additions and 75 deletions

View File

@@ -77,7 +77,15 @@ return packer.startup(function(use)
use "folke/which-key.nvim"
use "akinsho/toggleterm.nvim"
use "metakirby5/codi.vim"
use "kyazdani42/nvim-tree.lua"
use {
"nvim-neo-tree/neo-tree.nvim",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
}
use "nvim-lualine/lualine.nvim"
use { "RRethy/vim-hexokinase", run = "make hexokinase", config = function()

View File

@@ -10,7 +10,7 @@ end
vim.cmd [[
augroup virtcolumn
autocmd!
autocmd FileType * if index(["netrw", "NvimTree", "UltestAttach", "dap-float", "Trouble", "lspinfo", "qf", "harpoon", "toggleterm", "packer"], &ft) == -1 | lua require("windows.colorcolumn").setup()
autocmd FileType * if index(["netrw", "NvimTree", "neo-tree", "UltestAttach", "dap-float", "Trouble", "lspinfo", "qf", "harpoon", "toggleterm", "packer"], &ft) == -1 | lua require("windows.colorcolumn").setup()
augroup end
]]

View File

@@ -1,76 +1,106 @@
vim.g.nvim_tree_icons = {
default = "",
symlink = "",
git = {
unstaged = "",
staged = "",
unmerged = "",
renamed = "",
deleted = "",
untracked = "U",
ignored = "",
},
folder = {
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
},
}
local status_ok, nvim_tree = pcall(require, "nvim-tree")
if not status_ok then
local ok, neotree = pcall(require, "neo-tree")
if not ok then
return
end
nvim_tree.setup {
hijack_netrw = true,
update_cwd = true,
view = {
mappings = {
list = {
{ key = "<CR>", action = "edit_in_place" },
{ key = "h", action = "close_node" },
{ key = "<Left>", action = "close_node" },
{ key = "t", action = "tabnew" },
{ key = "<C-t>", action = "" },
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
neotree.setup {
close_if_last_window = true,
close_floats_on_escape_key = true,
default_source = "filesystem",
popup_border_style = "rounded",
sort_case_insensitive = true,
use_popups_for_input = false,
use_default_mappings = true,
default_component_configs = {
git_status = {
symbols = {
-- Change type
added = "",
deleted = "",
modified = "",
renamed = "",
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
align = "left",
},
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = true,
update_cwd = false,
ignore_list = {},
},
diagnostics = {
enable = true,
icons = {
hint = "",
info = "",
warning = "",
error = "",
window = {
position = "current",
mappings = {
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["S"] = "open_split",
["s"] = "open_vsplit",
["t"] = "open_tabnew",
["w"] = "open_with_window_picker",
["C"] = "close_node",
["z"] = "close_all_nodes",
["R"] = "refresh",
["a"] = { "add", config = { show_path = "none" } },
["A"] = "add_directory", -- also accepts the config.show_path option.
["d"] = "delete",
["r"] = "rename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination
["m"] = "move", -- takes text input for destination
["q"] = "close_window",
["?"] = "show_help",
["h"] = function(state)
local node = state.tree:get_node()
if node.type == 'directory' and node:is_expanded() then
require 'neo-tree.sources.filesystem'.toggle_directory(state, node)
else
require 'neo-tree.ui.renderer'.focus_node(state, node:get_parent_id())
end
end,
["l"] = function(state)
local node = state.tree:get_node()
if node.type == 'directory' then
if not node:is_expanded() then
require 'neo-tree.sources.filesystem'.toggle_directory(state, node)
elseif node:has_children() then
require 'neo-tree.ui.renderer'.focus_node(state, node:get_child_ids()[1])
end
end
end,
['<tab>'] = function(state)
local node = state.tree:get_node()
if require("neo-tree.utils").is_expandable(node) then
state.commands["toggle_node"](state)
else
state.commands['open'](state)
vim.cmd('Neotree reveal')
end
end,
},
},
git = {
enable = true,
ignore = true,
},
actions = {
change_dir = {
enable = false,
},
open_file = {
quit_on_open = true,
filesystem = {
bind_to_cwd = false,
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = false,
hide_gitignored = true,
},
follow_current_file = true,
hijack_netrw_behavior = "open_current",
use_libuv_file_watcher = false,
},
nesting_rules = {
["js"] = { "js.map" },
}
}
local wk = require "which-key"
wk.register({
["-"] = { "<cmd>lua require'nvim-tree'.open_replacing_current_buffer()<CR>", "Toggle explorer" }
["-"] = { "<cmd>Neotree current dir=%:h reveal_force_cwd toggle<CR>", "Toggle explorer" },
["<leader>e"] = { "<cmd>Neotree left toggle<CR>", "Toggle left explorer" },
})

View File

@@ -1,9 +0,0 @@
print(2)
x = 306
y = 3
x += 1
x + y * 56816
"Teest"
x
print("testebjkgbsgfeifheifeofheifheofh")

View File

@@ -1,3 +0,0 @@
12
println(12 * 1)