Skip to content

tunachip/casket.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

casket.nvim

casket is a Neovim naming-convention toolkit built around three workflows:

  • manual case conversion for the identifier under the cursor
  • codebase auditing and direct repair of naming-convention violations
  • review-first fixes through Telescope

It uses Treesitter highlight captures to identify symbols, applies language-aware naming defaults, and exposes an API for overriding profiles or registering entirely new rules.

Features

  • Manual identifier conversion with a Telescope picker preview
  • Built-in language profiles for Lua, Python, JavaScript, TypeScript, TSX, JSX, Rust, Go, Java, C#, and Ruby
  • Treesitter-backed audits for variables, parameters, fields, properties, methods, functions, constants, namespaces, and types
  • Buffer and project audit / repair / review commands
  • Optional automatic enforcement with autocmds
  • Public APIs for registering custom profiles and custom rules

Setup

require('casket').setup({
  auto = {
    enabled = false,
    mode = 'repair',
    events = { 'BufWritePre' },
  },
  profiles = {
    lua = {
      variable = 'camelCase',
    },
  },
})

Commands

  • :CasketCase [target]
  • :CasketCasePicker
  • :CasketAudit
  • :CasketRepair
  • :CasketReview
  • :CasketAuditProject
  • :CasketRepairProject
  • :CasketReviewProject

Compatibility aliases are also provided for the earlier command set:

  • :CaseShift [target]
  • :CaseShiftPicker
  • :ToCamelCase
  • :ToSnakeCase
  • :ToPascalCase
  • :ToKebabCase
  • :ToConstantCase
  • :ToDunderCase
  • :ToPrivateCase

API

local casket = require('casket')

casket.register_profile('zig', {
  variable = 'camelCase',
  function = 'camelCase',
  type = 'PascalCase',
  constant = 'CONSTANT_CASE',
})

casket.register_rule('no_tmp_prefix', function(ctx)
  if ctx.name:match('^tmp') then
    return {
      rule = 'no_tmp_prefix',
      message = 'Avoid tmp-prefixed identifiers',
    }
  end
end)

Rule callbacks receive a context with the symbol name, kind, language, buffer, file path, and Treesitter range. They may return a finding table containing a message and optional replacement.

About

Dead Simple Case-Kit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages