From 273008dd501b53c5433396e17ea9d8deafe02a03 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Mon, 22 Jan 2024 22:23:59 +0100 Subject: [PATCH] add oil.nvim --- CHEATSHEET.md | 3 ++- lazy-lock.json | 1 + lua/weeheavy/plugins/oil.lua | 25 +++++++++++++++++++++++++ lua/weeheavy/remap.lua | 22 ++++++++++++++-------- 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 lua/weeheavy/plugins/oil.lua diff --git a/CHEATSHEET.md b/CHEATSHEET.md index 6737ad8..57b9f71 100644 --- a/CHEATSHEET.md +++ b/CHEATSHEET.md @@ -27,6 +27,7 @@ Some of these are plain Vim commands, others are specific to Neovim. ### LSP - `:LspInfo` show currently attached LSP client details +- `:ConformInfo` useful to debug why a formatter times out ## NAVIGATION @@ -104,5 +105,5 @@ Use buffers in situations where - `leader`+`fg` search text in files (also searches for text under cursor) - `leader`+`ff` search files (respects `.gitignore`) -- `leader`+`e` file browser (disregards `.gitignore`) +- `leader`+`e` toggles Oil file explorer - `leader`+`fo` recently opened files diff --git a/lazy-lock.json b/lazy-lock.json index 9bb8cb6..7bf4d60 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -16,6 +16,7 @@ "nvim-treesitter-context": { "branch": "master", "commit": "85cf977181fb8e816e47ac05df7f756e9cb72caf" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" }, "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, + "oil.nvim": { "branch": "master", "commit": "bf753c3e3f8736939ad5597f92329dfe7b1df4f5" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "6f735a63dc24b9aed527cd505a31864223c8a6d8" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, diff --git a/lua/weeheavy/plugins/oil.lua b/lua/weeheavy/plugins/oil.lua new file mode 100644 index 0000000..a1a0286 --- /dev/null +++ b/lua/weeheavy/plugins/oil.lua @@ -0,0 +1,25 @@ +-- File system operations for nerds +-- https://github.com/stevearc/oil.nvim +return { + "stevearc/oil.nvim", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + local oil = require("oil") + oil.setup({ + default_file_explorer = true, + columns = { + --"size", + "icon", + }, + view_options = { + show_hidden = true, + }, + keymaps = { + -- This should be matched to the open action in remap.lua + ["e"] = "actions.close", + }, + }) + end, +} diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua index f81efd9..4ca7f51 100644 --- a/lua/weeheavy/remap.lua +++ b/lua/weeheavy/remap.lua @@ -5,12 +5,17 @@ vim.g.mapleader = " " vim.keymap.set("n", "r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer -vim.keymap.set( - "n", - "e", - ":Telescope file_browser hidden=true no_ignore=true previewer=false display_stat=false", - { noremap = true, desc = "Directory browser" } -) +--vim.keymap.set("n", "e", "lua require('oil').toggle_float('.')", { noremap = true, silent = true }) +vim.keymap.set("n", "e", ":Oil", { desc = "File navigation" }) + +--vim.keymap.set( +-- "n", +-- "e", +-- ":Telescope file_browser hidden=true no_ignore=true previewer=false display_stat=false", +-- { noremap = true, desc = "Directory browser" } +--) + +-- List recently opened files vim.keymap.set("n", "fo", ":Telescope oldfiles", { noremap = true, desc = "File history" }) vim.keymap.set( "n", @@ -18,7 +23,8 @@ vim.keymap.set( ":Telescope find_files hidden=true no_ignore=false ", { noremap = true, desc = "File search" } ) ---vim.keymap.set("n", "fg", ":Telescope live_grep", { noremap = true, desc = "Live grep through all files" }) + +-- Live grep, if cursor is on text, grep for this vim.keymap.set( "n", "fg", @@ -41,7 +47,7 @@ vim.keymap.set("n", "w", "W") -- skip punctuation when moving to start of next w vim.keymap.set("n", "e", "E") -- skip punctuation when moving to end of next word vim.keymap.set("n", "b", "B") -- skip punctuation when moving to end of previous word -vim.keymap.set("n", "i", "gg=G``", { noremap = true, desc = "Re-indent whole file" }) -- '``' makes it stay at current line+column position +--vim.keymap.set("n", "i", "gg=G``", { noremap = true, desc = "Re-indent whole file" }) -- '``' makes it stay at current line+column position -- Thank you @ThePrimeagen for those -- https://github.com/ThePrimeagen/init.lua/blob/master/lua/theprimeagen/remap.lua