I would like to open a file like a pdf with my default mime program. Could you implement this?
I used a hacky solution by adding this to M.open_file(mode, file) in lib.lua
if mode == 'open_with_system' then
api.nvim_command('!xdg-open "'..filename..'" 2>/dev/null&')
else
api.nvim_command('wincmd '..window_opts.open_command)
end
Feature Request: I would like the git ignore icon for folders to be gray not bolded. The icon is highlighted the same as the folder which makes it hard to differentiate.
you can change the color of the icon with:
hi! def NvimTreeGitIgnore guifg=grey gui=NONE
For 1 you can bind a function yourself:
vim.g.nvim_tree_bindings = {
["somekeymap"] = ':lua vim.fn.system("xdg-open "..require"nvim-tree.lib".get_node_at_cursor().absolute_path)<CR>'
}
I can't get that function to work for some reason. Nor did the highlight setting work. I wrapped it in vim.cmd, not sure if that made a difference.
just tried this by copy pasting and it work just fine.
for the highlight:
require'nvim-tree.events'.on_nvim_tree_ready(function()
vim.cmd"hi! NvimTreeGitIgnored guifg=blue"
end)
just tried this by copy pasting and it work just fine.
for the highlight:require'nvim-tree.events'.on_nvim_tree_ready(function() vim.cmd"hi! NvimTreeGitIgnored guifg=blue" end)
This only works for files not folders. As for the other command mapping, it didn't work on my Mac (I replaced xdg-open with open). I'll try it on my Linux machine.
I couldn't get this to work.
vim.g.nvim_tree_bindings = {
["somekeymap"] = ':lua vim.fn.system("xdg-open "..require"nvim-tree.lib".get_node_at_cursor().absolute_path)<CR>'
}
I modified the plugin source code by wrapping everything inside M.open_file(mode, filename) in an if-else statement.
function M.open_file(mode, filename)
if mode == 'open_with_system' then
vim.fn.system('xdg-open "'..filename..'" 2>/dev/null&')
else
-- original code
end
end
Thanks for your help.
@kaykay38 I use this config to call xdg-open without modifying the source code:
function NvimTreeXdgOpen()
local lib = require'nvim-tree.lib'
local node = lib.get_node_at_cursor()
if node then
vim.fn.jobstart("xdg-open '" .. node.absolute_path .. "' &", { detach = true })
end
end
vim.g.nvim_tree_bindings = {
-- other mappings...
["o"] = ":lua NvimTreeXdgOpen()<CR>",
}
This only works for files not folders
not sure what you mean, this is used to highlight the git ignored icon
@sindrets Thanks! I also implemented another version of your code to allow the user to choose which program to open with.
function NvimTreeOpenWith()
local lib = require'nvim-tree.lib'
local utils = require'nvim-tree.utils'
local node = lib.get_node_at_cursor()
if node then
local command = vim.fn.input('Open \''.. utils.path_basename(node.absolute_path).. '\' with: ')
vim.fn.jobstart(command.. " '" .. node.absolute_path .. "' 2>/dev/null&", { detach = true })
end
end
@kyazdani42
Here is the issue. The gitignore ! is grey on a file, but highlighted yellow on folders.

looks like a bug, i'm opening a new issue for that
Most helpful comment
@kaykay38 I use this config to call xdg-open without modifying the source code: