Skip to content

Commit

Permalink
Issue 806: Remove hard coded NVIM_QT_RUNTIME_PATH
Browse files Browse the repository at this point in the history
Hard coding the compile-time install path is sub-optimal.

This can cause issues when the intended install location is changed. For
example the program is compiled on Windows with D:\Program Files. The
users installs to C:\Program Files.

This can impact Linux too, but is less likely: extract package image to /opt.

This has already been removed for MacOS. Removing for Linux/Windows
allows us to use the same code for all platforms.
  • Loading branch information
statiolake authored and jgehrig committed Dec 29, 2020
1 parent a731245 commit 8e167e1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 63 deletions.
12 changes: 6 additions & 6 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include_directories(.. shellwidget)
qt5_add_resources(NEOVIM_RCC_SOURCES data.qrc)
if(WIN32)
set(SRCS_PLATFORM
app_runtime.cpp
arguments_qwindowgeometry.cpp
input_win32.cpp
printinfo_msgbox.cpp
Expand All @@ -18,7 +17,6 @@ if(WIN32)
enable_language(RC)
elseif(APPLE)
set(SRCS_PLATFORM
app_runtime_mac.cpp
arguments_qwindowgeometry.cpp
input_mac.cpp
printinfo_stdout.cpp
Expand All @@ -29,7 +27,6 @@ elseif(APPLE)
set(MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in)
else()
set(SRCS_PLATFORM
app_runtime.cpp
arguments_geometry.cpp
input_unix.cpp
printinfo_stdout.cpp
Expand All @@ -55,9 +52,12 @@ add_library(neovim-qt-gui
${NEOVIM_RCC_SOURCES})
target_link_libraries(neovim-qt-gui ${QTLIBS} qshellwidget neovim-qt)

if(NOT APPLE)
set_property(SOURCE app_runtime.cpp PROPERTY COMPILE_DEFINITIONS
NVIM_QT_RUNTIME_PATH="${CMAKE_INSTALL_FULL_DATADIR}/nvim-qt/runtime")
if(APPLE)
set_property(SOURCE app.cpp PROPERTY COMPILE_DEFINITIONS
NVIM_QT_RELATIVE_RUNTIME_PATH="../Resources/runtime")
else()
set_property(SOURCE app.cpp PROPERTY COMPILE_DEFINITIONS
NVIM_QT_RELATIVE_RUNTIME_PATH="../share/nvim-qt/runtime")
endif()

add_executable(nvim-qt WIN32 MACOSX_BUNDLE main.cpp
Expand Down
19 changes: 18 additions & 1 deletion src/gui/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,24 @@ void App::setupRequestTimeout() noexcept
m_connector->setRequestTimeout(m_parser.value("timeout").toInt());
}

QStringList App::getNeovimArgs() noexcept
/*static*/ QString App::getRuntimePath() noexcept
{
QString path{ QString::fromLocal8Bit(qgetenv("NVIM_QT_RUNTIME_PATH")) };

if (QFileInfo(path).isDir()) {
return path;
}

// Look for the runtime relative to the nvim-qt binary
const QDir d{ QDir{ applicationDirPath() }.filePath(NVIM_QT_RELATIVE_RUNTIME_PATH) };
if (d.exists()) {
return d.path();
}

return {};
}

/*static*/ QStringList App::getNeovimArgs() noexcept
{
QStringList neovimArgs{ "--cmd","set termguicolors" };

Expand Down
30 changes: 0 additions & 30 deletions src/gui/app_runtime.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions src/gui/app_runtime_mac.cpp

This file was deleted.

0 comments on commit 8e167e1

Please sign in to comment.