Add run_tests function
This commit is contained in:
parent
5005b4c667
commit
d546d74a2a
21
nvimrc
21
nvimrc
|
@ -150,6 +150,27 @@ end
|
|||
|
||||
vim.api.nvim_set_keymap("n", "<leader>uu", [[:lua _G.insert_uuid()<cr>]], {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap("i", "<c-d><c-u>", [[<esc>:lua _G.insert_uuid()<cr>a]], {noremap = true, silent = true})
|
||||
|
||||
_G.run_tests = function()
|
||||
local bufnr = vim.call("bufnr", "%")
|
||||
local filetype = vim.call("getbufvar", bufnr, "&filetype", "ERROR")
|
||||
|
||||
if filetype == "" then
|
||||
print("cannot run tests for filetype:", filetype)
|
||||
return
|
||||
end
|
||||
|
||||
if filetype == "ruby" then
|
||||
local path = vim.call("expand", "%:p")
|
||||
local altpath = path:gsub("/app/", "/spec/"):gsub([[.rb$]], "_spec.rb")
|
||||
vim.api.nvim_command([[10split +term\ bundle\ exec\ rspec\ ]] .. altpath)
|
||||
vim.api.nvim_command([[normal! G]])
|
||||
vim.api.nvim_command([[wincmd p]])
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<leader>rt", [[:lua _G.run_tests()<cr>]], {noremap = true, silent = true})
|
||||
EOF
|
||||
|
||||
" Git mappings
|
||||
|
|
Loading…
Reference in New Issue