From cc7d2566fbcf08de6463dba3942b8ead70f8f119 Mon Sep 17 00:00:00 2001 From: Haelnorr Date: Thu, 23 Jan 2025 10:08:19 +1100 Subject: [PATCH] added oil.nvim --- README.md | 7 ++++++- lazy-lock.json | 1 + lua/haelnorr/lazy/oil.lua | 12 ++++++++++++ lua/haelnorr/remap.lua | 29 +++++++++++++++-------------- 4 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 lua/haelnorr/lazy/oil.lua diff --git a/README.md b/README.md index fe260bc..c3aa205 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Plugins are managed using [lazy.nvim](https://github.com/folke/lazy.nvim) - [Harpoon](#harpoon) - [Markdown Preview](#markdown-preview) - [NVIM Web Devicons](#nvim-web-devicons) + - [Oil](#oil) - [SUDA](#suda) - [Surround](#surround) - [Telescope](#telescope) @@ -116,6 +117,10 @@ Live preview of markdown files in browser, with synced scrolling #### [NVIM Web Devicons](https://github.com/nvim-tree/nvim-web-devicons) Provides Nerd font icons for other plugins to use +--- +#### [Oil](https://github.com/nvim-tree/nvim-web-devicons) +Edit/view your filesystem like a normal NeoVim buffer + --- #### [SUDA](https://github.com/lambdalisue/vim-suda) Write files using sudo inside NeoVim @@ -271,7 +276,7 @@ LSP has been setup with the following dependencies: | Keybind | Behaviour | Normal | Visual | Select | |---------|-----------|--------|--------|--------| -| `pv` | View directory of current file | ✓ | ✗ | ✗ | +| `-` | View parent directory (works in file and in Oil filetree viewer) | ✓ | ✗ | ✗ | | `J` | Move selection down and autoindent | ✗ | ✓ | ✓ | | `K` | Move selection up and autoindent | ✗ | ✓ | ✓ | | `J` | Moves line below current line into sameline | ✓ | ✗ | ✗ | diff --git a/lazy-lock.json b/lazy-lock.json index 30f8a7b..75a3554 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -26,6 +26,7 @@ "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, "nvim-treesitter": { "branch": "master", "commit": "0c94de7e9792cf89c14a865ab819ad5c6e6a7f77" }, "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, + "oil.nvim": { "branch": "master", "commit": "62c5683c2e4f968dce27048e11e72f662d6d90e5" }, "plenary": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, diff --git a/lua/haelnorr/lazy/oil.lua b/lua/haelnorr/lazy/oil.lua new file mode 100644 index 0000000..8743892 --- /dev/null +++ b/lua/haelnorr/lazy/oil.lua @@ -0,0 +1,12 @@ +return { + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + -- Optional dependencies + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("oil").setup() + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + end, +} diff --git a/lua/haelnorr/remap.lua b/lua/haelnorr/remap.lua index d7adfe9..9d8f9b6 100644 --- a/lua/haelnorr/remap.lua +++ b/lua/haelnorr/remap.lua @@ -1,6 +1,7 @@ vim.g.mapleader = " " -- directory viewer -vim.keymap.set("n", "pv", vim.cmd.Ex) +-- has been replaced with Oil.nvim, keybind "-" +-- vim.keymap.set("n", "pv", vim.cmd.Ex) -- move highlighted lines up and down vim.keymap.set("v", "J", ":m '>+1gv=gv") @@ -25,14 +26,14 @@ vim.keymap.set({ "n", "v" }, "d", [["_d]]) -- formats file using LSP -- vim.keymap.set("n", "f", vim.lsp.buf.format) vim.keymap.set("", "f", function() - require("conform").format({ async = true }, function(err) - if not err then - local mode = vim.api.nvim_get_mode().mode - if vim.startswith(string.lower(mode), "v") then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) - end - end - end) + require("conform").format({ async = true }, function(err) + if not err then + local mode = vim.api.nvim_get_mode().mode + if vim.startswith(string.lower(mode), "v") then + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end + end + end) end, { desc = "Format code" }) vim.keymap.set("n", "", "cnextzz") @@ -46,9 +47,9 @@ vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) vim.keymap.set("n", "o", "ok") vim.keymap.set("n", "", function() - if vim.inspect(vim.opt.colorcolumn:get()) == "{}" then - vim.opt.colorcolumn = "80" - else - vim.opt.colorcolumn = "" - end + if vim.inspect(vim.opt.colorcolumn:get()) == "{}" then + vim.opt.colorcolumn = "80" + else + vim.opt.colorcolumn = "" + end end)