Add `detect_from_pattern` function

Open
#431 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
lua
Domain
tooling

Research direction

Start by locating the existing extension, file_name, and shebang detection entry points in plenary.nvim; the issue does not name a file or test. Done means pattern-based rules can classify paths such as templates/*.yaml as gotmpl while preserving the existing detection rules.

Written by the indexing model from the issue text.

Description

It would be nice to add to the existing extension, file_name, shebang new function based on patterns. Something like that:

return {
  extension = {
    ['jl'] = 'julia',
  },
  file_name = {
    ['.bashrc'] = 'bash',
  },
  shebang = {
    ['/usr/bin/node'] = 'javascript',
  },
  pattern = {
    ['.*/templates/.%.yaml'] = 'gotmpl',
  }
}

For example, I have a set of Helm Charts that I can't change by specifying a modeline, and I can't specify a name because it matches a valid yaml files which is not a yaml-based go-templates.
Something like this:

kubenurse/
├── Chart.yaml
├── templates
│   ├── NOTES.txt
│   ├── _helpers.tpl
│   ├── daemonset.yaml
│   ├── ingress.yaml
│   ├── rbac.yaml
│   ├── service.yaml
│   └── serviceaccount.yaml
└── values.yaml
Dominant language
Lua
Stars
3.5k
Forks
340
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nvim-lua/plenary.nvim

All issues in nvim-lua/plenary.nvim

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.