system_open command cannot open certain types of files properly #2528
-
DescriptionI use nvim-tree's system open on the Linux desktop, but some types of files cannot be opened, while others can. Neovim version
Operating system and versionLinux 6.1.56-1-lts x86_64 rolling n/a Windows variantNo response nvim-tree versionClean room replication-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true
-- empty setup using defaults
require("nvim-tree").setup() Steps to reproduce
Expected behaviorNo response Actual behaviorNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
I think it may be related to input and output, so I tried to disable output redirection and it worked properly, but I don't know why. system-open-test.mp4 |
Beta Was this translation helpful? Give feedback.
-
That's... just how Run Long ago I overrode xdg-open and have never looked back: : ; cat /usr/local/bin/xdg-open
#!/bin/sh
# Suppress any spurious output from noisy apps like chrome.
# Invoke /usr/bin/xdg-open directly for more interactive operations.
/usr/bin/xdg-open "${@}" > /dev/null 2>&1 |
Beta Was this translation helpful? Give feedback.
-
I think I have a related problem. On ubuntu I've changed default pdf viewer from Document Viewer to Okular, and now I cannot open pdf's anymore with system open. I've tried to change to xdg-open but again nothing happens when pressing -- this is a local function
local function my_on_attach(bufnr)
local api = require 'nvim-tree.api'
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set('n', 'u', api.tree.change_root_to_parent, opts 'Up') -- changed from default <C-t>
vim.keymap.set('n', '?', api.tree.toggle_help, opts 'Help')
end
-- pass to setup along with your other options
return {
'nvim-tree/nvim-tree.lua',
version = '*',
lazy = false,
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
require('nvim-tree').setup {
vim.keymap.set('n', '<leader>st', '<cmd>NvimTreeOpen<cr>'),
sort = {
sorter = 'case_sensitive',
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
on_attach = my_on_attach,
system_open = {
cmd = '/usr/bin/xdg-open',
},
}
end,
} Many thanks for the support |
Beta Was this translation helpful? Give feedback.
That's... just how
xdg-open
works. nvim-tree will simply callsystem_open.cmd
with the absolute file path as the argument.Run
xdg-open something.js
directly from a terminal to see what is going on.Long ago I overrode xdg-open and have never looked back: