From 551222f87707b39d48a496691f7e66d65ac2eb7c Mon Sep 17 00:00:00 2001 From: Attila Repka Date: Sat, 23 May 2026 17:00:32 +0200 Subject: [PATCH] refactor(languages): unify language categories and simplify documentation --- README.md | 47 ++++++++++++---------------------------- lua/header/filetypes.lua | 38 -------------------------------- 2 files changed, 14 insertions(+), 71 deletions(-) delete mode 100644 lua/header/filetypes.lua diff --git a/README.md b/README.md index 1384712..9934c72 100644 --- a/README.md +++ b/README.md @@ -167,43 +167,37 @@ vim.keymap.set("n", "hm", function() header.add_license_header("mit") en ## Supported Languages -### Simple Languages +### Standard Languages -Headers are inserted at the beginning of the file (or after existing headers). +For most languages, headers are inserted at the top of the file (or after existing headers/comments if detected): - C / C++ - Java -- JavaScript -- TypeScript +- JavaScript / TypeScript - C# +- Go +- Rust - Swift - Kotlin - Scala -- Go -- Rust -- Groovy - Dart - Lua - Ruby - Perl - Haskell +- Groovy - CoffeeScript - R --- -### Context-Aware Languages - -Headers are intelligently placed according to language-specific rules. - -#### Bash / Shell (`sh`, `bash`, `zsh`) +### Bash / Shell (`sh`, `bash`, `zsh`) -Headers are inserted after the shebang: +Headers are inserted after the shebang if present: ```bash #!/bin/bash # Copyright (c) 2026 Your Name -# License information echo "Hello, World!" ``` @@ -212,32 +206,21 @@ If no shebang exists, the header is placed at the top of the file. --- -#### Python (`py`) +### Python -Headers are inserted after the shebang and encoding declaration: +Headers are inserted after shebang and encoding declarations: ```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2026 Your Name -# License information import os ``` -Both encoding declaration styles are supported: - -```python -# coding: utf-8 -``` - -```python -# -*- coding: utf-8 -*- -``` - --- -#### PHP (`php`) +### PHP Headers are inserted inside the PHP opening tag: @@ -245,24 +228,22 @@ Headers are inserted inside the PHP opening tag: diff --git a/lua/header/filetypes.lua b/lua/header/filetypes.lua deleted file mode 100644 index 40327e9..0000000 --- a/lua/header/filetypes.lua +++ /dev/null @@ -1,38 +0,0 @@ -local languages = require("header.languages") - -local filetype_table = { - ["c"] = languages.cpp, - ["cc"] = languages.cpp, - ["cpp"] = languages.cpp, - ["h"] = languages.cpp, - ["hh"] = languages.cpp, - ["hpp"] = languages.cpp, - ["py"] = languages.python, - ["robot"] = languages.python, - ["lua"] = languages.lua, - ["java"] = languages.java, - ["js"] = languages.javascript, - ["cs"] = languages.csharp, - ["swift"] = languages.swift, - ["rb"] = languages.ruby, - ["kt"] = languages.kotlin, - ["sc"] = languages.scala, - ["go"] = languages.go, - ["rs"] = languages.rust, - ["php"] = languages.php, - ["sh"] = languages.shell, - ["hs"] = languages.haskell, - ["lhs"] = languages.haskell, - ["pl"] = languages.perl, - ["ts"] = languages.typescript, - ["tsx"] = languages.typescript, - ["coffee"] = languages.coffeescript, - ["groovy"] = languages.groovy, - ["gvy"] = languages.groovy, - ["gy"] = languages.groovy, - ["gsh"] = languages.groovy, - ["dart"] = languages.dart, - ["r"] = languages.r, -} - -return filetype_table