cameron-wags / rainbow_csv.nvim

Neovim port of mechatroner/rainbow_csv
MIT License
80 stars 4 forks source link

A better way to find script_folder_path #23

Closed eduardomezencio closed 2 months ago

eduardomezencio commented 3 months ago

This fixes https://github.com/cameron-wags/rainbow_csv.nvim/issues/22

This issue doesn't happen only in Windows, I think it has more to do with how you install the plugin. I believe this will work with any setup, but it would be nice if others could test it.

eduardomezencio commented 2 months ago

Great! I was not satisfied in using lua debug function either, but also was not aware of this alternative. Will change it as soon as I can

eduardomezencio commented 2 months ago

@cameron-wags, I tried this code, but with this approach, vim.fn.expand('') returns my config/init.lua file, instead of returning the actual script the code is in. I also don't like the fact that my original code used debug.getinfo, but I couldn't find other function that returns the path we actually want. Do you have other ideas?

cameron-wags commented 2 months ago

I set up a windows environment and found that too... my bad. I'm noticing vim.fn.globpath(vim.o.rtp, 'rbql_core/', 0, 1) actually returns the child path we're looking for on windows, just with \ path separators. My instinct is to vim.fs.normalize() path(s) before doing the string.find().

This is still all assuming everyone installing the plugin cloned to rainbow_csv.nvim. Now I'm not actually sure how plugin authors are meant to locate their own files. So I looked at how treesitter does it: they use debug.getinfo() as well, so I'm going to assume this is a decent way of doing so.

Opinion changed, merging.✌️