GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - blevantovych/printer.nvim: Smartly puts a print statement for a variable using treesitter

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
lua
lua
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

printer.nvim

Neovim plugin that inserts a console.log() statement for the identifier under the cursor at a syntactically valid position. Uses tree-sitter to walk up the AST and find the right insertion point — handles cases where the cursor is inside an array, object, JSX, return statement, etc.

Scoped to JavaScript/TypeScript only.

Installation

Requires nvim-treesitter with a JavaScript or TypeScript parser installed.

lazy.nvim

{
  "blevantovych/printer.nvim",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  keys = {
    { "<leader>p", function() require("printer").add_console_log() end, desc = "Add console.log" },
  },
}

packer.nvim

use {
  "blevantovych/printer.nvim",
  requires = { "nvim-treesitter/nvim-treesitter" },
  config = function()
    vim.keymap.set("n", "<leader>p", function() require("printer").add_console_log() end, { desc = "Add console.log" })
  end,
}

vim-plug

Plug 'nvim-treesitter/nvim-treesitter'
Plug 'blevantovych/printer.nvim'

" After plug#end():
nnoremap <leader>p <cmd>lua require("printer").add_console_log()<cr>

Usage

Place your cursor on any identifier in a JavaScript/TypeScript file and trigger the keymap (<leader>p with the suggested config). The plugin will insert:

console.log({ variableName })

The statement is placed at a syntactically valid position — if the identifier is inside an array, object, JSX element, function parameters, or return statement, the print is inserted outside that construct rather than inline.

Tests

Tests use plenary.nvim. The test runner automatically clones dependencies (plenary.nvim and nvim-treesitter) on first run.

Requirements: Neovim and git.

./tests/run_tests.sh

About

Smartly puts a print statement for a variable using treesitter

Topics

loggingluaneovimneovim-lua-pluginneovim-pluginprintertree-sitter

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.