From 3344f33104796f3743daaa4a75cbf95e4a5c9eff Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Wed, 29 Oct 2025 13:25:45 -0400 Subject: [PATCH] Use xdg-mime to set nvim as default As @abenz1267 pointed out, the previous solution wasn't the greatest. This is the proper solution. --- install/config/mimetypes.sh | 19 +++++++++++++++++++ migrations/1761583837.sh | 7 ------- migrations/1761758552.sh | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 7 deletions(-) delete mode 100644 migrations/1761583837.sh create mode 100644 migrations/1761758552.sh diff --git a/install/config/mimetypes.sh b/install/config/mimetypes.sh index ee662f55..ea8e1aff 100644 --- a/install/config/mimetypes.sh +++ b/install/config/mimetypes.sh @@ -36,3 +36,22 @@ xdg-mime default mpv.desktop application/ogg # Use Hey for mailto: links xdg-mime default HEY.desktop x-scheme-handler/mailto + +# Open text files with nvim +xdg-mime default nvim.desktop text/plain +xdg-mime default nvim.desktop text/english +xdg-mime default nvim.desktop text/x-makefile +xdg-mime default nvim.desktop text/x-c++hdr +xdg-mime default nvim.desktop text/x-c++src +xdg-mime default nvim.desktop text/x-chdr +xdg-mime default nvim.desktop text/x-csrc +xdg-mime default nvim.desktop text/x-java +xdg-mime default nvim.desktop text/x-moc +xdg-mime default nvim.desktop text/x-pascal +xdg-mime default nvim.desktop text/x-tcl +xdg-mime default nvim.desktop text/x-tex +xdg-mime default nvim.desktop application/x-shellscript +xdg-mime default nvim.desktop text/x-c +xdg-mime default nvim.desktop text/x-c++ +xdg-mime default nvim.desktop application/xml +xdg-mime default nvim.desktop text/xml diff --git a/migrations/1761583837.sh b/migrations/1761583837.sh deleted file mode 100644 index 0e32981d..00000000 --- a/migrations/1761583837.sh +++ /dev/null @@ -1,7 +0,0 @@ -echo "Ensure nvim started from app launcher always starts nvim not $EDITOR" - -if [ -f /usr/share/applications/nvim.desktop ]; then - rm ~/.local/share/applications/nvim.desktop - ln -s /usr/share/applications/nvim.desktop ~/.local/share/applications/nvim.desktop - update-desktop-database ~/.local/share/applications -fi diff --git a/migrations/1761758552.sh b/migrations/1761758552.sh new file mode 100644 index 00000000..49680d09 --- /dev/null +++ b/migrations/1761758552.sh @@ -0,0 +1,21 @@ +echo "Set nvim as default via xdg-mime" + +rm ~/.local/share/applications/nvim.desktop || true + +xdg-mime default nvim.desktop text/plain +xdg-mime default nvim.desktop text/english +xdg-mime default nvim.desktop text/x-makefile +xdg-mime default nvim.desktop text/x-c++hdr +xdg-mime default nvim.desktop text/x-c++src +xdg-mime default nvim.desktop text/x-chdr +xdg-mime default nvim.desktop text/x-csrc +xdg-mime default nvim.desktop text/x-java +xdg-mime default nvim.desktop text/x-moc +xdg-mime default nvim.desktop text/x-pascal +xdg-mime default nvim.desktop text/x-tcl +xdg-mime default nvim.desktop text/x-tex +xdg-mime default nvim.desktop application/x-shellscript +xdg-mime default nvim.desktop text/x-c +xdg-mime default nvim.desktop text/x-c++ +xdg-mime default nvim.desktop application/xml +xdg-mime default nvim.desktop text/xml