From cb84cd5d9fbae40313f4fb9fd8bf715511c9ca28 Mon Sep 17 00:00:00 2001 From: alex-tdrn Date: Sun, 30 Jun 2024 10:57:29 +0200 Subject: [PATCH] feat(win32): embed executable icon Problem: on windows, the neovim executable (and thus the filetypes associated to open with neovim) has no embedded icon Solution: create a windows resource file pointing to the icon, and add it to the nvim binary target --- runtime/windows_icon.rc | 4 ++++ src/nvim/CMakeLists.txt | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 runtime/windows_icon.rc diff --git a/runtime/windows_icon.rc b/runtime/windows_icon.rc new file mode 100644 index 0000000000..87b79e9ea7 --- /dev/null +++ b/runtime/windows_icon.rc @@ -0,0 +1,4 @@ +// NOTE: this resource file *must* be in the same folder as the icon. +// Otherwise, absolute paths would need to be used. +// see https://learn.microsoft.com/en-us/windows/win32/menurc/icon-resource +NEOVIM_ICON ICON "neovim.ico" diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 950e4d54a0..56a09ec734 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -708,6 +708,12 @@ target_sources(main_lib INTERFACE ${EXTERNAL_SOURCES} ${EXTERNAL_HEADERS}) +if(WIN32) + # add windows resource file pointing to the neovim icon + # this makes the icon appear for the neovim exe and associated filetypes + target_sources(nvim_bin PRIVATE ${NVIM_RUNTIME_DIR}/windows_icon.rc) +endif() + target_sources(nlua0 PUBLIC ${NLUA0_SOURCES}) target_link_libraries(nvim_bin PRIVATE main_lib PUBLIC libuv)