rktjmp / hotpot.nvim

:stew: Carl Weathers #1 Neovim Plugin.
MIT License
360 stars 9 forks source link

Windows RUNNER~1 paths #118

Closed rktjmp closed 1 year ago

rktjmp commented 1 year ago

Windows has a max path length of 260 chars and will truncate long user names to 6~N names, so runneradmin becomes RUNNER~1.

We do not have any control over when these paths are given to us, and when we request stdpath("cache") it can return in this form depending on the system setup (username, etc).

This has a few issues:

RTP initially, with RUNNER~1,

pre-rtp-patch rtp-list C:/Users/RUNNER~1/AppData/Local/Temp/5_20230904160348/hotpot/compiled/*,D:\a\hotpot.nvim\hotpot.nvim,C:\Users\runneradmin\AppData\Local\5_20230904160348,C:\Users\runneradmin\AppData\Local\5_20230904160348-data\site,c:\tools\neovim\nvim-win64\share\nvim\runtime,c:\tools\neovim\nvim-win64\lib\nvim,C:\Users\runneradmin\AppData\Local\5_20230904160348-data\site\after,C:\Users\runneradmin\AppData\Local\5_20230904160348\after,C:/Users/RUNNER~1/AppData/Local/Temp/5_20230904160348/hotpot/compiled/vim-loader-cache-buster-1

nvim_get_runtime_file "" true

pre-rtp-patch nvim_get_runtime_file-empty { "D:\\a\\hotpot.nvim\\hotpot.nvim", "C:\\Users\\runneradmin\\AppData\\Local\\5_20230904160348", "c:\\tools\\neovim\\nvim-win64\\share\\nvim\\runtime", "c:\\tools\\neovim\\nvim-win64\\lib\\nvim" }

nvim_get_runtime_file "lua/abc.lua" true, no results

pre-rtp-patch nvim_get_runtime_file-abc.lua {}

Force replace RUNNER~1 with runneradmin,

post-rtp-patch rtp-list C:/Users/runneradmin/AppData/Local/Temp/5_20230904160348/hotpot/compiled/*,D:\a\hotpot.nvim\hotpot.nvim,C:\Users\runneradmin\AppData\Local\5_20230904160348,C:\Users\runneradmin\AppData\Local\5_20230904160348-data\site,c:\tools\neovim\nvim-win64\share\nvim\runtime,c:\tools\neovim\nvim-win64\lib\nvim,C:\Users\runneradmin\AppData\Local\5_20230904160348-data\site\after,C:\Users\runneradmin\AppData\Local\5_20230904160348\after,C:/Users/runneradmin/AppData/Local/Temp/5_20230904160348/hotpot/compiled/vim-loader-cache-buster-1
post-rtp-patch nvim_get_runtime_file-empty { "C:\\Users\\runneradmin\\AppData\\Local\\Temp\\5_20230904160348\\hotpot\\compiled\\5_20230904160348", "D:\\a\\hotpot.nvim\\hotpot.nvim", "C:\\Users\\runneradmin\\AppData\\Local\\5_20230904160348", "c:\\tools\\neovim\\nvim-win64\\share\\nvim\\runtime", "c:\\tools\\neovim\\nvim-win64\\lib\\nvim" }

File is found:

post-rtp-patch nvim_get_runtime_file-abc.lua { "C:\\Users\\runneradmin\\AppData\\Local\\Temp\\5_20230904160348\\hotpot\\compiled\\5_20230904160348\\lua\\abc.lua" }
rktjmp commented 1 year ago

https://github.com/neovim/neovim/issues/25019

rktjmp commented 1 year ago

Calling uv.fs_realpath will expand the path. We can either call this when we first generate the cache prefix, or (and?) call it everywhere. I am vaguely hesitant of calling it everywhere because it will convert symlink paths to their ... real paths, which might not be what we want for cache readability, or for files that get relinked a lot. We also must take care to call it first, then normalise everytime, else we end up with backslash paths.

Note also fs_realpath can return nil if the file does not exist, where as normalise will just "clean up" a path.