-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Diogo-ss/dev
feat: add git support, rewrite part of the code, add new checking and CI and new error handling.
- Loading branch information
Showing
9 changed files
with
343 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,80 +3,102 @@ | |
This plugin is whole re-write of [42header](https://github.com/42Paris/42header) in Lua. | ||
|
||
## ✨ Features | ||
|
||
- Command: `Stdheader` | ||
- Customizable options | ||
- Modulate | ||
- Auto update on save (optional) | ||
- Support many [file types](https://github.com/Diogo-ss/42-header.nvim/blob/main/lua/42header/config/init.lua) by default | ||
- Supports `commentstring` | ||
- Supports Git | ||
|
||
## 🚀 Showcase | ||
|
||
 | ||
|
||
## 🎈 Setup | ||
|
||
### 📦 Packer.nvim | ||
```lua | ||
use { "Diogo-ss/42-header.nvim" } | ||
``` | ||
<details> | ||
<summary>📦 Packer.nvim</summary> | ||
|
||
### 💤 Lazy.nvim | ||
```lua | ||
{ "Diogo-ss/42-header.nvim" } | ||
use { | ||
"Diogo-ss/42-header.nvim", | ||
cmd = { "Stdheader" }, | ||
config = function() | ||
require "42header"setup { | ||
default_map = true, -- Default mapping <F1> in normal mode. | ||
auto_update = true, -- Update header when saving. | ||
user = "username", -- Your user. | ||
mail = "[email protected]", -- Your mail. | ||
-- add other options. | ||
} | ||
end, | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>💤 Lazy.nvim</summary> | ||
|
||
```lua | ||
{ | ||
"Diogo-ss/42-header.nvim", | ||
lazy = false, | ||
config = function() | ||
local header = require("42header") | ||
header.setup({ | ||
default_map = true, -- default Mapping <F1> in normal mode | ||
auto_update = true, -- update header when saving | ||
user = "Diogo-ss", -- your user | ||
mail = "[email protected]", -- your mail | ||
}) | ||
end | ||
return { | ||
"Diogo-ss/42-header.nvim", | ||
cmd = { "Stdheader" }, | ||
keys = {"<F1>"}, | ||
opts = { | ||
default_map = true, -- Default mapping <F1> in normal mode. | ||
auto_update = true, -- Update header when saving. | ||
user = "username", -- Your user. | ||
mail = "[email protected]", -- Your mail. | ||
-- add other options. | ||
}, | ||
config = function(_, opts) | ||
require("42header").setup(opts) | ||
end, | ||
} | ||
``` | ||
|
||
### 🔌 Vim-plug | ||
```lua | ||
call plug#begin() | ||
Plug 'Diogo-ss/42-header.nvim' | ||
call plug#end() | ||
``` | ||
</details> | ||
|
||
## ⚙ Options | ||
|
||
```lua | ||
local header = require("42header") | ||
header.setup({ | ||
length = 80, -- headers of different sizes are incompatible with each other | ||
margin = 5, | ||
default_map = true, -- default Mapping <F1> in normal mode | ||
auto_update = true, -- update header when saving | ||
user = "Diogo-ss", -- your user | ||
mail = "[email protected]", -- your mail | ||
-- asciiart = { "......", "......",} -- headers with different ascii arts are incompatible with each other | ||
}) | ||
{ | ||
---Max header size (not recommended change). | ||
--length = 80, | ||
---Header margin (not recommended change). | ||
--margin = 5, | ||
---Activate default mapping (e.g. F1). | ||
default_map = true, | ||
---Enable auto-update of headers. | ||
auto_update = true, | ||
---Default user.name. | ||
user = "username", | ||
---Default user.email. | ||
mail = "[email protected]", | ||
---ASCII art. | ||
--asciiart = { "---", "---", ... }, | ||
---Git config. | ||
git = { | ||
---Enable Git support. | ||
enabled = false, | ||
---PATH to the Git binary. | ||
bin = "git", | ||
---Use global user.name, otherwise use local user.name. | ||
user_global = true, | ||
---Use global user.email, otherwise use local user.email. | ||
email_global = true, | ||
}, | ||
} | ||
``` | ||
|
||
## 🌐 User and Mail | ||
|
||
`user` and `mail` can be defined using global variables. | ||
|
||
```lua | ||
vim.g.user = "Diogo-ss" | ||
vim.g.mail = "[email protected]" | ||
vim.g.user = "username" | ||
vim.g.mail = "[email protected]" | ||
``` | ||
> **_NOTE:_** global variables have higher priority than setup values | ||
## 🍦 Credits | ||
Lua version by [Diogo-ss](https://github.com/Diogo-ss) | ||
|
||
Original VimScript version: | ||
<br> | ||
[zazard](https://github.com/zazard) - creator | ||
[alexandregv](https://github.com/alexandregv) - contributor | ||
[mjacq42](https://github.com/mjacq42) - contributor | ||
[sungmcho](https://github.com/lordtomi0325) - contributor | ||
|
||
|
||
> **_NOTE:_** The order of priority: `global variables` > `git config (if support enabled)` > `user config`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: check | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
paths: | ||
- "lua/**/*.lua" | ||
pull_request: | ||
paths: | ||
- "lua/**/*.lua" | ||
workflow_call: | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create Luacheck config | ||
run: echo 'globals = { "vim" }' > .luacheckrc | ||
|
||
- name: Luacheck | ||
uses: lunarmodules/luacheck@v1 | ||
with: | ||
args: . | ||
|
||
- name: Stylua check | ||
uses: JohnnyMorganz/stylua-action@v4 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
version: latest | ||
args: --color always --check lua/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: ci | ||
on: | ||
push: | ||
paths-ignore: | ||
- ".github/**" | ||
- ".stylua.toml" | ||
- ".gitignore" | ||
branches: | ||
- main | ||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: create luacheck config | ||
run: echo 'globals = { "vim" }' > .luacheckrc | ||
|
||
- name: luacheck | ||
uses: lunarmodules/luacheck@v1 | ||
with: | ||
args: . | ||
|
||
- name: stylua check | ||
uses: johnnymorganz/stylua-action@v4 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
version: latest | ||
args: --color always --check lua/ | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
needs: check | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: create release | ||
uses: google-github-actions/release-please-action@v4 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
release-type: simple |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,12 @@ | ||
--- Module for managing configuration options for the 42header plugin. | ||
-- This module defines default configuration options and allows users to set custom options. | ||
local M = {} | ||
|
||
--- Default configuration options for the 42header plugin. | ||
-- Users can customize these options by setting their own values. | ||
-- @field length (number) The maximum line length for the header. | ||
-- @field margin (number) The margin size. | ||
-- @field default_map (boolean) Whether to enable the default key mapping. | ||
-- @field auto_update (boolean) Whether to enable automatic header updates on file save. | ||
-- @field types (table) A table mapping file extensions to their corresponding comment symbols. | ||
-- - Each entry consists of a table of file extensions and a table of comment symbols. | ||
-- - The comment symbols include the start, fill, and end symbols. | ||
-- @field asciiart (table) A table containing ASCII art lines for the header decoration. | ||
M.opts = { | ||
length = 80, | ||
margin = 5, | ||
default_map = true, | ||
auto_update = true, | ||
user = "username", | ||
mail = "[email protected]", | ||
types = { | ||
[{ | ||
"c", | ||
"cc", | ||
"cpp", | ||
"cxx", | ||
"tpp", | ||
"glsl", | ||
"h", | ||
"hh", | ||
"hxx", | ||
"hpp", | ||
"cs", | ||
"d", | ||
"php", | ||
"css", | ||
"sql", | ||
"swift", | ||
"kt", | ||
"kts", | ||
}] = { | ||
"/*", | ||
"*", | ||
"*/", | ||
}, | ||
[{ "go" }] = { "//", "*", "//" }, | ||
[{ "lua", "hs" }] = { "--", "*", "--" }, | ||
[{ "md", "htm", "html", "xml" }] = { "<!--", "*", "-->" }, | ||
[{ "js", "ts", "rs", "java" }] = { "//", "*", "//" }, | ||
[{ "tex" }] = { "%", "*", "%" }, | ||
[{ "ml", "mli", "mll", "mly" }] = { "(*", "*", "*)" }, | ||
[{ "vim", "vimrc" }] = { '"', "*", '"' }, | ||
[{ "el", "asm", "s" }] = { ";", "*", ";" }, | ||
[{ "emacs", "f90", "f95", "f03", "f" }] = { ";", "*", ";" }, | ||
[{ "bat" }] = { "REM", "*", "REM" }, | ||
[{ "vb" }] = { "'", "*", "'" }, | ||
[{ "cob" }] = { "*", "*", "*" }, | ||
[{ "scala", "dart" }] = { "//", "*", "//" }, | ||
[{ "plsql", "vhdl" }] = { "--", "*", "--" }, | ||
}, | ||
asciiart = { | ||
" ::: ::::::::", | ||
" :+: :+: :+:", | ||
|
@@ -68,12 +16,18 @@ M.opts = { | |
" #+# #+# ", | ||
" ### ########.fr ", | ||
}, | ||
git = { | ||
enabled = false, | ||
bin = "git", | ||
user_global = true, | ||
email_global = true, | ||
}, | ||
} | ||
|
||
--- Set custom configuration options. | ||
-- @param opts (table) A table of custom configuration options to override the defaults. | ||
---Applies the user options to the default table. | ||
---@param opts table: settings | ||
M.set = function(opts) | ||
M.opts = opts | ||
M.opts = vim.tbl_deep_extend("force", M.opts, opts or {}) | ||
end | ||
|
||
return M |
Oops, something went wrong.