weizheheng / ror.nvim

Have FUN builiding Ruby on Rails applications with Neovim!
MIT License
132 stars 15 forks source link

feat: setup for custom messages #1

Closed troyizzle closed 2 years ago

troyizzle commented 2 years ago

Awesome plugin!

This was a pretty quick approach to expand it to allow for configured messages and icons!

Example use case

require("ror.minitest_reporter").setup({
  notification_messages = {
    file = "Running entire file..."
  }
})
local Remap = require("config.keymap")
local nnoremap = Remap.nnoremap

nnoremap("<Leader>mf", ":MinitestRun File<CR>")
nnoremap("<Leader>ml", ":MinitestRun Line<CR>")
weizheheng commented 2 years ago

Thanks for the PR, this is great! There are a few other features that I want to add in like rspec_reporter. I am not super familiar with building plugin with Lua (this is my second plugin), but can we achieve something like:

require("ror").setup({
  minitest_reporter = {
    notification_messages = {
      file = "Running entire file..."
    }
  },
  rspec_reporter = {
    success_icon = "🎉"
  }
  -- Future features
})

I think this is doable? I am guessing we need a init.lua that requires all the other features available and provide a setup method there. However, I am not sure how I can access the settings set in my other file (but I think it's doable).

Otherwise, it will be an opt-in style for the user to decide what to use. Would love to hear your opinion on this.

require("ror.minitest_reporter").setup({
  notification_messages = {
    file = "Running entire file..."
  }
})

require("ror.rspec_reporter").setup({
  success_icon = "🎉"
})

-- Do the same for future features
weizheheng commented 2 years ago

@troyizzle Thank you for the PR again, I spent some time figuring out how I would want to do it, and did some restructuring of the code base. You should be able to customize the setting using this now:

require("ror").setup({
  minitest = {
    message = {
      file = "Running all the tests...",
      -- This will be follow by a space, current cursor line number and ...
      -- E.g. Running test on line 10...
      line = "Running test on line"
    },
    pass_icon = "✅",
    fail_icon = "❌"
  }
})
troyizzle commented 2 years ago

@troyizzle Thank you for the PR again, I spent some time figuring out how I would want to do it, and did some restructuring of the code base. You should be able to customize the setting using this now:

require("ror").setup({
  minitest = {
    message = {
      file = "Running all the tests...",
      -- This will be follow by a space, current cursor line number and ...
      -- E.g. Running test on line 10...
      line = "Running test on line"
    },
    pass_icon = "✅",
    fail_icon = "❌"
  }
})

This looks awesome!