From ec27ae8a227f908896053f78829e9c1f249b332a Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Thu, 25 Aug 2022 17:03:52 +0200 Subject: [PATCH] [NeoVim] Open binary files with xdg-open --- .config/nvim/fnl/settings/neo-tree.fnl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.config/nvim/fnl/settings/neo-tree.fnl b/.config/nvim/fnl/settings/neo-tree.fnl index e1297c8..7f2e1b4 100644 --- a/.config/nvim/fnl/settings/neo-tree.fnl +++ b/.config/nvim/fnl/settings/neo-tree.fnl @@ -16,8 +16,15 @@ :f "noop" :ff (fn [] (exec [[:Telescope "find_files"]])) :fg (fn [] (exec [[:Telescope "live_grep"]])) + : "custom_open" : (fn []) - : (fn [])}}} + : (fn [])}} + :commands {:custom_open (fn [state] + (let [node (state.tree.get_node state.tree) + quoted_path (.. "'" (.. (node.get_id node) "'"))] + (do (exec [[:silent "!file -bL --mime" quoted_path "| grep -qv '^text\\|^inode' && xdg-open" quoted_path "&"]]) + (if (= vim.v.shell_error 1) + ((. (require :neo-tree.sources.filesystem.commands) :open) state)))))}} :renderers {:directory [[:indent] [:icon] [:current_filter]