Comments (2)
For reference, here is the config that I used to override the default one provided by lazvim (as far as I can tell, there's no way to say "call the default config" from inside the config call so I have to completely overwrite it?
(collapsed because I have a PR with a better version of this)
config = function(_, opts)
require("mini.files").setup(opts)
local show_dotfiles = true
local filter_show = function(fs_entry)
return true
end
local filter_hide = function(fs_entry)
return not vim.startswith(fs_entry.name, ".")
end
local toggle_dotfiles = function()
show_dotfiles = not show_dotfiles
local new_filter = show_dotfiles and filter_show or filter_hide
require("mini.files").refresh({ content = { filter = new_filter } })
end
local map_split = function(buf_id, lhs, direction)
local rhs = function()
-- Make new window and set it as target
local new_target_window
local cur_target_window = require("mini.files").get_target_window()
if cur_target_window ~= nil then
vim.api.nvim_win_call(cur_target_window, function()
vim.cmd(direction .. " split")
new_target_window = vim.api.nvim_get_current_win()
end)
require("mini.files").set_target_window(new_target_window)
require("mini.files").go_in({ close_on_file = true })
end
end
local desc = "Split " .. direction
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
local files_set_cwd = function()
local cur_entry_path = MiniFiles.get_fs_entry().path
local cur_directory = vim.fs.dirname(cur_entry_path)
if cur_directory ~= nil then
vim.fn.chdir(cur_directory)
end
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id, desc = "Toggle dotfiles" })
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
-- Tweak keys to your liking
map_split(buf_id, "gs", "belowright horizontal")
map_split(buf_id, "gv", "belowright vertical")
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
vim.keymap.set("n", "gc", files_set_cwd, { buffer = args.data.buf_id, desc = "Set cwd" })
end,
})
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
require("lazyvim.util").lsp.on_rename(event.data.from, event.data.to)
end,
})
end,
Some notes:
- I added a desc to the existing
g.
keybinding so it has a description in the menu. This is a no-brainer so I'll put up a PR for it. - I modified the mini.files-provided examples a bit because it was giving me some lua warnings. Mostly added some
if
clauses to ensure that something is actually there. - The
gv
keybinding collides with LazyVim. It seem to work in the mini.files buffer, but if you useg
and look a the menu it has the "wrong" description. - The
gc
keybinding also collides with LazyVim, but seems to work in the mini.files buffer. It has the right description, but if you pressg
, wait for the menu, then pressc
, it will both change the cwd and show up ac
menu that you have to escape. - I added a "go_in" call to the split view so that it open the files no split.
- There's no way to customize the keybindings without overriding the config. Maybe it could have some extra mappings in opts?
from lazyvim.
Created the linked PR to implement all of the above, though I'm cautious about the keybindings.
from lazyvim.
Related Issues (20)
- feature: Standardize all WhichKey shortcut names to have their first character capitalized. HOT 3
- bug: bad argument #1 to 'get_line_col' (string expected, got nil) HOT 3
- bug: The latest version of lualine will be lost when the file is opened HOT 7
- bug: `<leader>m` not working with `neo-tree` opened HOT 2
- bug: `vtsls` crashes when `lang.vue` extra is enabled without `lang.typescript` HOT 3
- bug(LazyExtras lang.yaml): error whenever buffer have array of objects HOT 3
- bug: outline.nvim extra keymap conflicts with trouble.nvim's symbols keymap
- bug: Overriding Copilot-Chat edgy config does not work HOT 4
- bug: Crashed when execute LazyHealth HOT 4
- feature: lazydocker HOT 1
- bug: `recommended` not working after removing specs for some plugins HOT 2
- feature: add supermaven HOT 5
- bug: Failed to run config for nvim-snippets HOT 1
- bug: Unable to restore the maximized Neo-tree window HOT 1
- bug: latex snippet fails to preview and expand HOT 10
- bug: cmp menu doesn't appear when typing punctuation characetrs HOT 2
- bug: lsp not working after installing vtsls. HOT 3
- feature: Ask for users permission before removing or adding new plugins over lazyvim update HOT 1
- bug: default indent adds wrong indentline in nested functions HOT 5
- bug: `gitsigns.nvim` makes Neovim randomly freeze when scrolling/switching buffers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lazyvim.