[NeoVim] Open binary files with xdg-open

This commit is contained in:
2022-08-25 17:03:52 +02:00
committed by Pierre Jeanjean
parent 3501b0b633
commit ec27ae8a22

View File

@@ -16,8 +16,15 @@
:f "noop" :f "noop"
:ff (fn [] (exec [[:Telescope "find_files"]])) :ff (fn [] (exec [[:Telescope "find_files"]]))
:fg (fn [] (exec [[:Telescope "live_grep"]])) :fg (fn [] (exec [[:Telescope "live_grep"]]))
:<CR> "custom_open"
:<S-Right> (fn []) :<S-Right> (fn [])
:<S-Left> (fn [])}}} :<S-Left> (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] :renderers {:directory [[:indent]
[:icon] [:icon]
[:current_filter] [:current_filter]