From 98587f4144af07d95dff055d62dd5592b1f2818d Mon Sep 17 00:00:00 2001 From: surdeus Date: Mon, 28 Aug 2023 13:47:12 +0300 Subject: [PATCH] Use carbon instead of nvim-tree. --- nvim/init.lua | 45 ++-------------------- nvim/lazy-lock.json | 5 --- nvim/lua/bootstrap.lua | 9 +++++ nvim/lua/maps.lua | 5 +-- nvim/lua/plugin/carbon.lua | 3 ++ nvim/lua/plugin/lf.lua | 76 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 94 insertions(+), 49 deletions(-) delete mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/bootstrap.lua create mode 100644 nvim/lua/plugin/carbon.lua create mode 100644 nvim/lua/plugin/lf.lua diff --git a/nvim/init.lua b/nvim/init.lua index e2c2dd8..178be7f 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -13,47 +13,10 @@ vim.api.nvim_cmd({ require("indent") require("maps") --- Do not put basic things after it, --- because the manager does not like it. - --- Plugin manager "Lazy" -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) - --- Plugins -plugins = { - require("plugin.tree") +require("bootstrap") +require("dep") { + require("plugin.carbon") } -require("lazy").setup(plugins, opts) - --- File tree plugin configuration -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 -vim.opt.termguicolors = true -require("nvim-tree").setup({ - sort_by = "case_sensitive", - view = { - width = 30, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = false, - }, - git = { - enable=false, - }, -}) +require("carbon").setup() diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json deleted file mode 100644 index d98558d..0000000 --- a/nvim/lazy-lock.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "lazy.nvim": { "branch": "main", "commit": "dac844ed617dda4f9ec85eb88e9629ad2add5e05" }, - "nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" }, - "nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" } -} \ No newline at end of file diff --git a/nvim/lua/bootstrap.lua b/nvim/lua/bootstrap.lua new file mode 100644 index 0000000..5dffe5d --- /dev/null +++ b/nvim/lua/bootstrap.lua @@ -0,0 +1,9 @@ +-- Installing the dep package manager +local path = vim.fn.stdpath("data") .. "/site/pack/deps/opt/dep" + +if vim.fn.empty(vim.fn.glob(path)) > 0 then + vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/chiyadev/dep", path }) +end + +vim.cmd("packadd dep") + diff --git a/nvim/lua/maps.lua b/nvim/lua/maps.lua index a7cf589..532c33c 100644 --- a/nvim/lua/maps.lua +++ b/nvim/lua/maps.lua @@ -13,9 +13,8 @@ local opts = {noremap = true, silent = true} map('n', '\\ecolor', ':e $HOME/lib/nvim/colors/jien.vim\n', opts) -- File tree.s - map('n', '\\home', ":cd $HOME | NvimTreeClose | NvimTreeOpen .;\n", opts) - map('n', '\\ft', ':NvimTreeFocus\n', opts) - map('n', '\\fT', ':NvimTreeToggle .\n', opts) + map('n', '\\home', ":cd $HOME\n", opts) + map('n', '\\ft', ':ToggleSidebarCarbon\n', opts) -- Tabs. map('n', '\\tn', ':tabnew\n', opts) diff --git a/nvim/lua/plugin/carbon.lua b/nvim/lua/plugin/carbon.lua new file mode 100644 index 0000000..d39822b --- /dev/null +++ b/nvim/lua/plugin/carbon.lua @@ -0,0 +1,3 @@ +return { + 'surdeus/carbon.nvim' +} diff --git a/nvim/lua/plugin/lf.lua b/nvim/lua/plugin/lf.lua new file mode 100644 index 0000000..668ac9a --- /dev/null +++ b/nvim/lua/plugin/lf.lua @@ -0,0 +1,76 @@ + +local setup = function() +local fn = vim.fn + +-- Defaults +require("lf").setup({ + default_action = "drop", -- default action when `Lf` opens a file + default_actions = { -- default action keybindings + [""] = "tabedit", + [""] = "split", + [""] = "vsplit", + [""] = "tab drop", + }, + + winblend = 10, -- psuedotransparency level + dir = "", -- directory where `lf` starts ('gwd' is git-working-directory, ""/nil is CWD) + direction = "float", -- window type: float horizontal vertical + border = "rounded", -- border kind: single double shadow curved + height = fn.float2nr(fn.round(0.75 * o.lines)), -- height of the *floating* window + width = fn.float2nr(fn.round(0.75 * o.columns)), -- width of the *floating* window + escape_quit = true, -- map escape to the quit command (so it doesn't go into a meta normal mode) + focus_on_open = true, -- focus the current file when opening Lf (experimental) + mappings = true, -- whether terminal buffer mapping is enabled + tmux = false, -- tmux statusline can be disabled on opening of Lf + default_file_manager = false, -- make lf default file manager + disable_netrw_warning = true, -- don't display a message when opening a directory with `default_file_manager` as true + highlights = { -- highlights passed to toggleterm + Normal = {link = "Normal"}, + NormalFloat = {link = 'Normal'}, + FloatBorder = {guifg = "", guibg = ""}, + }, + + -- Layout configurations + layout_mapping = "", -- resize window with this key + views = { -- window dimensions to rotate through + {width = 0.800, height = 0.800}, + {width = 0.600, height = 0.600}, + {width = 0.950, height = 0.950}, + {width = 0.500, height = 0.500, col = 0, row = 0}, + {width = 0.500, height = 0.500, col = 0, row = 0.5}, + {width = 0.500, height = 0.500, col = 0.5, row = 0}, + {width = 0.500, height = 0.500, col = 0.5, row = 0.5}, +} +}) + +-- Equivalent +vim.keymap.set("n", "", "lua require('lf').start()", {noremap = true}) +vim.keymap.set("n", "", "Lf", {noremap = true}) +end + +local ret = { + "lmburns/lf.nvim", + config = function() + -- This feature will not work if the plugin is lazy-loaded + vim.g.lf_netrw = 1 + + require("lf").setup({ + escape_quit = false, + border = "rounded", + }) + + vim.keymap.set("n", "", "Lf") + + vim.api.nvim_create_autocmd({ + event = "User", + pattern = "LfTermEnter", + callback = function(a) + vim.api.nvim_buf_set_keymap(a.buf, "t", "q", "q", {nowait = true}) + end, + }) + end, + requires = {"akinsho/toggleterm.nvim"}, +} + +return ret +