A lightweight Neovim plugin for inserting structured console.* statements in JavaScript and TypeScript files.
rocketlog.nvim adds labeled logs with a consistent format that includes the file name and line number, and it can keep those labels updated as your code moves.
For details on how to help improve this tool, see CONTRIBUTING.md. For submitting an issue or feature request, see issues.
console.log(`🚀[ROCKETLOG] ~ file.ts:123 ~ variableName:`, variableName);
console.warn(`🚀[ROCKETLOG] ~ file.ts:123 ~ variableName:`, variableName);
console.error(`🚀[ROCKETLOG] ~ file.ts:123 ~ variableName:`, variableName);
console.info(`🚀[ROCKETLOG] ~ file.ts:123 ~ variableName:`, variableName);
console.logconsole.errorconsole.warnconsole.info
ea57bb
Use the motions mapping followed by a motion or text object.
<leader>rl → console.log<leader>re → console.error<leader>rw → console.warn<leader>ri → console.info<leader>rL → console.log<leader>rE → console.error<leader>rW → console.warn<leader>rI → console.info<leader>rd → delete next RocketLog below the cursor<leader>rD → delete nearest RocketLog above the cursor<leader>ra → delete ALL RocketLogs in the current buffer{
"evanmcpheron/rocketlog.nvim",
dependencies = {
-- Recommended for syntax-aware insertion
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("rocketlog").setup()
end,
}
require("rocketlog").setup({
keymaps = {
motions = "<leader>rl",
word = "<leader>rL",
error_motions = "<leader>re",
error_word = "<leader>rE",
warn_motions = "<leader>rw",
warn_word = "<leader>rW",
info_motions = "<leader>ri",
info_word = "<leader>rI",
delete_below = "<leader>rd",
delete_above = "<leader>rD",
delete_all_buffer = "<leader>ra",
},
enabled = true,
label = "ROCKETLOG", -- customize your label that goes in the []
-- Refresh RocketLog file:line labels automatically
refresh_on_save = true, -- updates line numbers on file save when true
refresh_on_insert = true, -- updates line numbers for entire file when adding a new log
-- Insertion strategy
prefer_treesitter = true, -- Highly recommended to keep true... It may not work if it's false.
fallback_to_heuristics = true, -- this is a "fail-safe" (recommended to keep true)
-- Filetypes allowed for insertion
allowed_filetypes = {
javascript = true,
javascriptreact = true,
typescript = true,
typescriptreact = true,
},
})
Press the motions mapping, then a motion/text object:
<leader>rliw → log inner word<leader>rla" → log around quotes<leader>rli( → log inside parentheses<leader>rL<leader>rE (word under cursor)<leader>reiw (motions + text object)RocketLog inserts logs in a consistent format that includes:
When code shifts and line numbers change, RocketLog can refresh the labels automatically so they stay accurate.
By default, the plugin can auto-initialize with default settings.
To disable that and call setup() manually, set this before the plugin loads:
vim.g.rocketlog_disable_auto_setup = true
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.