Wiki updates
thallada opened this issue Β· comments
Just want to say that I love this plugin and it's working way better as a vim-vinegar replacement than the more popular plugins like nvim-tree, thanks π !
I noticed an issue in the wiki though, this code block on this page needs to be updated (I would update it but I see no edit button):
local drex = require('drex')
local elements = require('drex.elements')
-- open the home directory
vim.keymap.set('n', '~', '<CMD>Drex ~<CR>', {})
-- open parent DREX buffer and focus current file
vim.keymap.set('n', '-', function()
local path = vim.fn.expand('%:p')
if path == '' then
drex.open_directory_buffer() -- open at cwd
else
drex.open_directory_buffer(vim.fn.fnamemodify(path, ':h'))
elements.focus_element(0, path)
end
end, {})
require('drex.config').configure {
keybindings = {
['n'] = {
['~'] = '<CMD>Drex ~<CR>',
['-'] = '<CMD>lua require("drex.elements").open_parent_directory()<CR>',
['.'] = function()
local element = require('drex.utils').get_element(vim.api.nvim_get_current_line())
local left = vim.api.nvim_replace_termcodes('<left>', true, false, true)
vim.api.nvim_feedkeys(': ' .. element .. string.rep(left, #element + 1), 'n', true)
end,
['<CR>'] = function()
local line = vim.api.nvim_get_current_line()
if require('drex.utils').is_open_directory(line) then
elements.collapse_directory()
else
elements.expand_element()
end
end
}
}
}
Note the change in the <CMD>lua require("drex.elements").open_parent_directory()<CR>
mapping (from require("drex")
previously). I also added the <CR>
custom action since I feel like that's necessary for a proper vim-vinegar replacement.
Also, it might be a good idea to put similar docs in the help page for the plugin in case people miss the github wiki.
Thank you for your kind words π
Good catch. Unfortunately there is no PR feature for the Github Wiki of a project as far as I know. I will fix it.
Regarding the <CR>
custom action: Is this really part of the "native vinegar experience"? I could not find anything about a custom <CR>
mapping in the repository (but maybe I just missed it) π€
Putting all the examples from the wiki into the help page would probably blow that one up a little too much, but I just realized that the wiki is never even mentioned there. To avoid having to maintain all examples twice I would rather add a prominent mentioning about it so that more people find it and have a look
Ah, you're right, the <CR>
mapping I was remembering came from nerd-tree, not vim-vinegar.