Skip to content

Latest commit

History

34 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

This is my personal fork of printer.nvim

printer.nvim

printer_demo

Neovim plugin that adds an operator which allows adding printing/logging statements with text from textobjects / visual range based on the filetype

Installation

{
'rareitems/printer.nvim',
config=function()
require('printer').setup({
keymap="gp" -- default keymap is `gp`
})
end
}
use {
'rareitems/printer.nvim',
config=function()
require('printer').setup({
keymap="gp" -- default keymap is `gp`
})
end
}

Usage

Use your keymap followed by a motion to quickly print/log the text from the motion.

Default Configuration

{
behavior="insert_below", -- default behaviour either "insert_below" for inserting the debug print below or "yank" for yanking the debug printformatters= {}, -- check lua/formatters.lua for default value of formattersadd_to_inside=functiondefault_addtoinside(text) returnstring.format("[%s:%s] %s", vim.fn.expand("%"), vim.fn.line("."), text) end,
-- function with signature (string) -> string which adds some text to the string inside print statement by default it adds the filename and line fromdefault_register=[["]], -- if register is not specified to which register should "yank" put debug print
}

More Configuration Stuffs

use {
'rareitems/printer.nvim',
config=function()
require('printer').setup({
keymap="gp", -- Plugin doesn't have any keymaps by defaultbehavior="insert_below", -- how operator should behave-- "insert_below" will insert the text below the cursor-- "yank" will not insert but instead put text into the default '"' registerformatters= {
-- you can define your formatters for specific filetypes-- by assigning function that takes two strings-- one text modified by 'add_to_inside' function-- second the variable (thing) you want to print out-- see examples in lua/formatters.lualua=function(inside, variable)
returnstring.format('print("%s: " .. %s)', inside, variable)
end,
},
-- function which modifies the text inside string in the print statement, by default it adds the path and line numberadd_to_inside=function(text)
returnstring.format("[%s:%s] %s", vim.fn.expand("%"), vim.fn.line("."), text)
end,
-- to turn off default behaviour and add nothing-- add_to_inside = function(text)-- return text-- end,
})
-- keymap to always yank the debug printvim.keymap.set("n", "gp", "<Plug>(printer_yank)")
vim.keymap.set("v", "gp", "<Plug>(printer_yank)")
-- keymap to always insert below the debug printvim.keymap.set("n", "gp", "<Plug>(printer_below)")
vim.keymap.set("v", "gp", "<Plug>(printer_below)")
-- You can use use '<Plug>printer_print' to call the pluging inside more advanced keymaps-- for example a keymap that always adds a prnt statement based on 'iw'vim.keymap.set("n", "gP", "<Plug>(printer_print)iw")
end
}

About

Neovim plugin adding debug printing operator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages