mirror of https://github.com/LazyVim/starter
Initial setup
parent
a7a17af9c0
commit
91dd2a1c6d
|
@ -1,4 +1,8 @@
|
||||||
# 💤 LazyVim
|
# My neovim config
|
||||||
|
|
||||||
A starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
|
```sh
|
||||||
|
./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Forked starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
|
||||||
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.
|
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.
|
||||||
|
|
|
@ -33,10 +33,11 @@ map("n", "<leader>on", ":e ~/.tmp/notes/notes.md<cr>", { desc = "Open notes" })
|
||||||
map("n", "<leader>con", ":e ~/.tmp/notes/notes.md<cr>", { desc = "Open notes" })
|
map("n", "<leader>con", ":e ~/.tmp/notes/notes.md<cr>", { desc = "Open notes" })
|
||||||
|
|
||||||
map("n", "<leader>j", function()
|
map("n", "<leader>j", function()
|
||||||
CloseTerminalBuffer(true)
|
require("mj.utils").close_terminal_buffer(true)
|
||||||
end, { desc = "Close terminal buffer (true)" })
|
end, { desc = "Close terminal buffer (true)" })
|
||||||
|
|
||||||
map("n", "<leader>k", function()
|
map("n", "<leader>k", function()
|
||||||
CloseTerminalBuffer(false)
|
require("mj.utils").close_terminal_buffer(false)
|
||||||
end, { desc = "Close terminal buffer (false)" })
|
end, { desc = "Close terminal buffer (false)" })
|
||||||
|
|
||||||
-- Search mappings
|
-- Search mappings
|
||||||
|
@ -65,7 +66,18 @@ end, { desc = "Previous alternative file" })
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
vim.diagnostic.config({ virtual_text = false })
|
||||||
|
|
||||||
-- Running tests
|
-- Running tests
|
||||||
map("n", "<Leader>T", ":lua RunTestFile()<CR>", { desc = "Run test file" })
|
map("n", "<Leader><leader>at", function()
|
||||||
map("n", "<Leader>t", ":lua RunTestLineByLine()<CR>", { desc = "Run test for current line" })
|
require("mj.test_runner").run_all_tests()
|
||||||
map("n", "<Leader>at", ":lua RunAllTests()<CR>", { desc = "Run all tests" })
|
end, { desc = "Run all tests" })
|
||||||
map("n", "s.t", ":lua RunShellTest()<CR>", { desc = "Run ./shell_test" })
|
|
||||||
|
map("n", "<Leader><leader>t", function()
|
||||||
|
require("mj.test_runner").test_line()
|
||||||
|
end, { desc = "Run test for current line" })
|
||||||
|
|
||||||
|
map("n", "<Leader>T", function()
|
||||||
|
require("mj.test_runner").run_test_file()
|
||||||
|
end, { desc = "Run test file" })
|
||||||
|
|
||||||
|
map("n", "<leader><leader>st", function()
|
||||||
|
require("mj.test_runner").run_shell_test()
|
||||||
|
end, { desc = "Run ./shell_test" })
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
-- Options are automatically loaded before lazy.nvim startup
|
-- Options are automatically loaded before lazy.nvim startup
|
||||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||||
-- Add any additional options here
|
-- Add any additional options here
|
||||||
|
vim.g.swap = false
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
local runner = require("mj.command_runner")
|
local runner = require("mj.command_runner")
|
||||||
M = {}
|
M = {}
|
||||||
|
|
||||||
|
M._mj_alternative_file = function(file, subcommand, options)
|
||||||
|
local cmd = "mj alternative_file " .. subcommand .. " " .. file .. " " .. options
|
||||||
|
return runner.run(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
M.open = function(subcommand, options)
|
M.open = function(subcommand, options)
|
||||||
local file_path = vim.fn.expand("%")
|
local file_path = vim.fn.expand("%")
|
||||||
file_path = vim.fn.fnamemodify(file_path, ":~:.")
|
file_path = vim.fn.fnamemodify(file_path, ":~:.")
|
||||||
local files = mj_alternative_file(file_path, subcommand, options)
|
local files = M._mj_alternative_file(file_path, subcommand, options)
|
||||||
files = vim.split(files, " ")
|
files = vim.split(files, " ")
|
||||||
local file = files[1]
|
local file = files[1]
|
||||||
|
|
||||||
|
@ -13,9 +18,4 @@ M.open = function(subcommand, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mj_alternative_file(file, subcommand, options)
|
|
||||||
local cmd = "mj alternative_file " .. subcommand .. " " .. file .. " " .. options
|
|
||||||
return runner.run(cmd)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -6,40 +6,6 @@ function RunInTerminal(cmd, open_new_tab)
|
||||||
runner.run_in_terminal(cmd, open_new_tab)
|
runner.run_in_terminal(cmd, open_new_tab)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RunTestFile()
|
|
||||||
local current_path = vim.fn.expand("%")
|
|
||||||
local cmd = "run_test " .. current_path
|
|
||||||
RunInTerminal(cmd, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function RunTestLineByLine()
|
|
||||||
local current_line, _ = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
local current_path = vim.fn.expand("%")
|
|
||||||
local cmd = "run_test " .. current_path .. " --line=" .. current_line
|
|
||||||
RunInTerminal(cmd, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function RunAllTests()
|
|
||||||
local current_path = vim.fn.expand("%")
|
|
||||||
local cmd = "run_test " .. current_path .. " --all"
|
|
||||||
RunInTerminal(cmd, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function CloseTerminalBuffer(new_tab)
|
|
||||||
local name = vim.api.nvim_buf_get_name(0)
|
|
||||||
|
|
||||||
if string.find(name, "term://") then
|
|
||||||
if not new_tab then
|
|
||||||
local number = vim.api.nvim_buf_get_number(0)
|
|
||||||
vim.api.nvim_exec("buffer #", true)
|
|
||||||
vim.api.nvim_buf_delete(number, { force = true })
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.api.nvim_command("bdelete!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function RunShellTest()
|
function RunShellTest()
|
||||||
RunInTerminal("./shell_test", true)
|
RunInTerminal("./shell_test", true)
|
||||||
end
|
end
|
||||||
|
@ -48,3 +14,5 @@ function RunRubocop()
|
||||||
local file = vim.fn.expand("%")
|
local file = vim.fn.expand("%")
|
||||||
RunInTerminal("bundle exec rubocop -A " .. file, false)
|
RunInTerminal("bundle exec rubocop -A " .. file, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
local M = {}
|
|
||||||
|
|
||||||
M.alternate_file = require("mj.alternate_file")
|
|
||||||
|
|
||||||
return M
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local runner = require("mj.command_runner")
|
||||||
|
|
||||||
|
M.run_test_file = function()
|
||||||
|
local current_path = vim.fn.expand("%")
|
||||||
|
local cmd = "run_test " .. current_path
|
||||||
|
runner.run_in_terminal(cmd, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.test_line = function()
|
||||||
|
local current_line, _ = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
local current_path = vim.fn.expand("%")
|
||||||
|
local cmd = "run_test " .. current_path .. " --line=" .. current_line
|
||||||
|
runner.run_in_terminal(cmd, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.run_all_tests = function()
|
||||||
|
local current_path = vim.fn.expand("%")
|
||||||
|
local cmd = "run_test " .. current_path .. " --all"
|
||||||
|
runner.run_in_terminal(cmd, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.run_shell_test = function()
|
||||||
|
runner.run_in_terminal("./shell_test", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.run_rubocop = function()
|
||||||
|
local file = vim.fn.expand("%")
|
||||||
|
runner.run_in_terminal("bundle exec rubocop -A ", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
|
@ -0,0 +1,18 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.close_terminal_buffer = function(new_tab)
|
||||||
|
local name = vim.api.nvim_buf_get_name(0)
|
||||||
|
|
||||||
|
if string.find(name, "term://") then
|
||||||
|
if not new_tab then
|
||||||
|
local number = vim.api.nvim_buf_get_number(0)
|
||||||
|
vim.api.nvim_exec("buffer #", true)
|
||||||
|
vim.api.nvim_buf_delete(number, { force = true })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_command("bdelete!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Reference in New Issue