Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# live-command.nvim
![version](https://img.shields.io/badge/version-1.0.0-brightgreen)
![version](https://img.shields.io/badge/version-1.1.0-brightgreen)

Text editing in Neovim with immediate visual feedback: view the effects of any command on your buffer contents live. Preview macros, the `:norm` command & more!

<div align="center">
<video alt="lel" src="https://user-images.githubusercontent.com/40792180/194180320-691efe71-0743-40e5-b0d7-454f142a9235.mp4"></video>
<video alt="live-command demo video" src="https://user-images.githubusercontent.com/40792180/194180320-691efe71-0743-40e5-b0d7-454f142a9235.mp4"></video>
</div>
<p><sub>Theme: <a href="https://github.com/folke/tokyonight.nvim">tokyonight.nvim</a></sub></p>

Expand Down Expand Up @@ -85,8 +85,8 @@ require("live-command").setup {
deletion = "DiffDelete",
change = "DiffChange",
},
debug = false,
},
debug = false,
}
```

Expand Down
10 changes: 3 additions & 7 deletions lua/live-command/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@ M.defaults = {
deletion = "DiffDelete",
change = "DiffChange",
},
debug = false,
}

local debug = false

local should_cache_lines = true
local cached_lines
local prev_lazyredraw

local logs = {}
local function log(msg, level)
level = level or "TRACE"
if debug or level ~= "TRACE" then
if M.debug or level ~= "TRACE" then
msg = type(msg) == "function" and msg() or msg
logs[level] = logs[level] or {}
for _, line in ipairs(vim.split(msg .. "\n", "\n")) do
Expand Down Expand Up @@ -341,7 +338,6 @@ M.setup = function(user_config)
return
end

-- assert(false, vim.inspect(user_config))
local config = vim.tbl_deep_extend("force", M.defaults, user_config or {})
validate_config(config)
create_user_commands(config.commands)
Expand All @@ -356,7 +352,7 @@ M.setup = function(user_config)
end),
})

debug = config.defaults.debug
M.debug = user_config.debug

vim.api.nvim_create_user_command("LiveCommandLog", function()
local msg = ("live-command log\n================\n\n%s%s"):format(
Expand All @@ -367,6 +363,6 @@ M.setup = function(user_config)
end, { nargs = 0 })
end

M.version = "1.0.0"
M.version = "1.1.0"

return M