英文:
Why do I get different runtimepaths depending on which API I use?
问题
我尝试在Windows 11环境上运行Neovim 0.8.1。
我的设置非常简单:
- 我从Neovim的发布页面上下载了
nvim-win64.zip
(版本0.8.1)。 - 解压并将其移动到
C:\test\nvim-win64
文件夹。 - 通过执行
C:\test\nvim-win64\bin\nvim.exe
启动了Neovim。
没有使用任何自定义配置。
检查我的运行时路径时,有两种方式:
- 使用
:set runtimepath?
(Vimscript方式)。这给我以下结果:
runtimepath=~\AppData\Local\nvim,~\AppData\Local\nvim-data\site,C:\test\nvim-win64\share\nvim\runtime,C:\test\nvim-win64\share\nvim\runtime\pack\dist\opt\matchit,C:\test\nvim-win64\lib\nvim,~\AppData\Local\nvim-data\site\after,~\AppData\Local\nvim\after
- 使用
:lua print(vim.inspect(vim.api.nvim_list_runtime_paths()))
(Lua方式)。这给我以下结果:
{ "C:\\test\\nvim-win64\\share\\nvim\\runtime", "C:\\test\\nvim-win64\\share\\nvim\\runtime\\pack\\dist\\opt\\matchit", "C:\\test\\nvim-win64\\lib\\nvim" }
如您所见,使用Lua方式似乎会导致我在运行时路径中丢失本地配置目录(~\AppData\Local\*
路径)。
为什么会出现这种差异?这阻止我使用XDG_CONFIG_HOME
来使用我通常使用的自定义配置,因为它似乎没有包含在nvim_list_runtime_paths
列表中,但它出现在:set runtimepath?
中。
英文:
I'm trying to run Neovim 0.8.1. on a Windows 11 environment.
My setup is really minimal:
- I downloaded
nvim-win64.zip
(of version 0.8.1) from Neovim's releases page on Github. - Extracted it and moved it to a folder at
C:\test\nvim-win64
- Started up Neovim by executing
C:\test\nvim-win64\bin\nvim.exe
Not using any custom config.
When inspecting my runtimepath, there are 2 ways of doing this:
- Using
:set runtimepath?
(the Vimscript way). This gives me:
runtimepath=~\AppData\Local\nvim,~\AppData\Local\nvim-data\site,C:\test\nvim-win64\share\nvim\runtime,C:\test\nvim-win64\share\nvim\runtime\pack\dist\opt\matchit,C:\test\nvim-win64\lib\nvim,~\AppData\Local\nvim-data\site\after,~\AppData\Local\nvim\after
- Using
:lua print(vim.inspect(vim.api.nvim_list_runtime_paths()))
(the Lua way). this gives me:
{ "C:\\test\\nvim-win64\\share\\nvim\\runtime", "C:\\test\\nvim-win64\\share\\nvim\\runtime\\pack\\dist\\opt\\matchit", "C:\\test\\nvim-win64\\lib\\nvim" }
As you can see, it seems like using the Lua way I'm missing the local config directories in my runtimepath (the ~\AppData\Local\*
paths).
Why am I seeing this difference? This is blocking me from using XDG_CONFIG_HOME
to use my own config that I typically use, because it seems like it does not get included in the nvim_list_runtime_paths
list, but it does appear in :set runtimepath?
.
答案1
得分: 1
Nvim的API函数会过滤掉不存在的目录。所以确实有所不同。
英文:
Nvim api function filters out non-existent directories. So there's a difference.
答案2
得分: 0
我的问题是,我的雇主决定在我的 %USERPROFILE%
环境变量中放置 (
和 )
字符,结果导致许多问题(包括我从 nvim_list_runtime_paths
获取的列表)。
在 %USERPROFILE%
中放置这些字符是一个糟糕的主意,所以我将所有文件和文件夹从 %USERPROFILE%
的任何(子)目录移出,直接放在 C:\
中。
我还必须定义 XDG_CONFIG_HOME
、XDG_DATA_HOME
和 XDG_STATE_HOME
,将它们指向与默认位置不同的位置(默认位置在 %USERPROFILE%
内)。
这样一来,所有的问题都迎刃而解!
英文:
My issue was that my employer had decided to put (
and )
characters in my %USERPROFILE%
environment variable, which ended up breaking a bunch of stuff (including the list I got from nvim_list_runtime_paths
).
Putting those characters in %USERPROFILE%
is a bad idea for many reasons, so I moved all of my files and folders out of any (sub)directory in %USERPROFILE%
and right in C:\
.
I also had to define XDG_CONFIG_HOME
, XDG_DATA_HOME
and XDG_STATE_HOME
to point to a different location than the default location (which default within %USERPROFILE%
).
This made all of my troubles go away!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论