-
Notifications
You must be signed in to change notification settings - Fork 267
Open
Labels
P2Not a priority. PRs welcomeNot a priority. PRs welcome
Description
I made this in my local config:
local function create_stree_formatter()
-- Check if Gemfile.lock exists and contains syntax_tree using grep
local has_stree_in_bundle = function()
local gemfile_lock = vim.fn.findfile("Gemfile.lock", ".;")
if gemfile_lock ~= "" then
local grep_result = vim.fn.system("grep -q syntax_tree " .. vim.fn.shellescape(gemfile_lock))
return vim.v.shell_error == 0
end
return false
end
return {
command = function()
if has_stree_in_bundle() then
return "bundle"
else
return "stree"
end
end,
args = function()
if has_stree_in_bundle() then
return { "exec", "stree", "write", "$FILENAME" }
else
return { "write", "$FILENAME" }
end
end,
stdin = false,
cwd = util.root_file({ ".streerc" }),
}
end
Idea is to look in Gemfile.lock to see if syntax tree is there, if it is then use it via bundle exec, otherwise fallback to the installed gem.
should we make this default behavior ? It seems similar to a degree to what we do for node but the downside with ruby is that we need to grep inside a file (and it makes conform info a bit ugly cause it says:
syntax_tree ready (ruby) /home/sam/.gem/ruby/3.3.6/bin/bundle
vs this which would be a bit nicer
syntax_tree ready (ruby) /home/sam/.gem/ruby/3.3.6/bin/bundle exec stree
Metadata
Metadata
Assignees
Labels
P2Not a priority. PRs welcomeNot a priority. PRs welcome