mirror of
https://github.com/chenasraf/text-transform.nvim.git
synced 2026-05-18 01:48:57 +00:00
@@ -8,3 +8,6 @@ trim_trailing_whitespace = true
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
|
||||
39
.github/workflows/develop.yml
vendored
39
.github/workflows/develop.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Release
|
||||
name: Dev Release
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -42,14 +42,43 @@ jobs:
|
||||
|
||||
- name: check docs diff
|
||||
run: exit $(git status --porcelain doc | wc -l | tr -d " ")
|
||||
release:
|
||||
name: release
|
||||
if: ${{ github.ref == 'refs/heads/develop' }}
|
||||
permissions: write-all
|
||||
tests:
|
||||
needs:
|
||||
- lint
|
||||
- documentation
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 2
|
||||
strategy:
|
||||
matrix:
|
||||
neovim_version: ['v0.7.2', 'v0.8.3', 'v0.9.0', 'nightly']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- run: date +%F > todays-date
|
||||
|
||||
- name: restore cache for today's nightly.
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: _neovim
|
||||
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
|
||||
|
||||
- name: setup neovim
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
with:
|
||||
neovim: true
|
||||
version: ${{ matrix.neovim_version }}
|
||||
|
||||
- name: run tests
|
||||
run: make test-ci
|
||||
|
||||
release:
|
||||
name: dev-release
|
||||
if: ${{ github.ref == 'refs/heads/develop' }}
|
||||
permissions: write-all
|
||||
needs:
|
||||
- tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
51
.github/workflows/main.yml
vendored
51
.github/workflows/main.yml
vendored
@@ -43,43 +43,42 @@ jobs:
|
||||
- name: check docs diff
|
||||
run: exit $(git status --porcelain doc | wc -l | tr -d " ")
|
||||
|
||||
# tests:
|
||||
# needs:
|
||||
# - lint
|
||||
# - documentation
|
||||
# runs-on: ubuntu-latest
|
||||
# timeout-minutes: 2
|
||||
# strategy:
|
||||
# matrix:
|
||||
# neovim_version: ['v0.7.2', 'v0.8.3', 'v0.9.0', 'nightly']
|
||||
tests:
|
||||
needs:
|
||||
- lint
|
||||
- documentation
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 2
|
||||
strategy:
|
||||
matrix:
|
||||
neovim_version: ['v0.7.2', 'v0.8.3', 'v0.9.0', 'nightly']
|
||||
|
||||
# steps:
|
||||
# - uses: actions/checkout@v3
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# - run: date +%F > todays-date
|
||||
- run: date +%F > todays-date
|
||||
|
||||
# - name: restore cache for today's nightly.
|
||||
# uses: actions/cache@v3
|
||||
# with:
|
||||
# path: _neovim
|
||||
# key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
|
||||
- name: restore cache for today's nightly.
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: _neovim
|
||||
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
|
||||
|
||||
# - name: setup neovim
|
||||
# uses: rhysd/action-setup-vim@v1
|
||||
# with:
|
||||
# neovim: true
|
||||
# version: ${{ matrix.neovim_version }}
|
||||
- name: setup neovim
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
with:
|
||||
neovim: true
|
||||
version: ${{ matrix.neovim_version }}
|
||||
|
||||
# - name: run tests
|
||||
# run: make test-ci
|
||||
- name: run tests
|
||||
run: make test-ci
|
||||
|
||||
release:
|
||||
name: release
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
permissions: write-all
|
||||
needs:
|
||||
- lint
|
||||
- documentation
|
||||
- tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
16
Makefile
16
Makefile
@@ -14,6 +14,8 @@ test:
|
||||
deps:
|
||||
@mkdir -p deps
|
||||
git clone --depth 1 https://github.com/echasnovski/mini.nvim deps/mini.nvim
|
||||
echo "#!/usr/bin/env bash\n\nmake precommit" > .git/hooks/pre-commit
|
||||
chmod +x .git/hooks/pre-commit
|
||||
|
||||
# installs deps before running tests, useful for the CI.
|
||||
test-ci: deps test
|
||||
@@ -29,6 +31,14 @@ documentation-ci: deps documentation
|
||||
lint:
|
||||
stylua .
|
||||
|
||||
# setup
|
||||
setup:
|
||||
./scripts/setup.sh
|
||||
# precommit
|
||||
precommit:
|
||||
stylua .
|
||||
git add .
|
||||
make lint
|
||||
# make test
|
||||
make documentation
|
||||
git add doc
|
||||
|
||||
clean:
|
||||
rm -rf deps
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
Transform the current word or selection between multiple case types. Need to easily replace myVar
|
||||
with my_var or vice versa? This plugin is for you!
|
||||
|
||||
- Works on current word in **Normal Mode**
|
||||
- Works on selection in **Visual Mode**
|
||||
|
||||
| Transformation | Example Inputs | Output |
|
||||
| -------------- | --------------------------- | -------- |
|
||||
| `camelCase` | `my_var`, `my-var`, `MyVar` | `myVar` |
|
||||
@@ -117,7 +120,7 @@ To get started, [install](#-installation) the plugin via your favorite package m
|
||||
<details>
|
||||
<summary>Click to unfold the full list of options with their default values</summary>
|
||||
|
||||
> **Note**: The options are also available in Neovim by calling `:h text-transform.options`
|
||||
> **Note**: The options are also available in Neovim by calling `:h TextTransform.options`
|
||||
|
||||
```lua
|
||||
require("text-transform").setup({
|
||||
|
||||
@@ -26,6 +26,18 @@ function TextTransform.setup(options)
|
||||
|
||||
TextTransform.options = vim.tbl_deep_extend("keep", options, TextTransform.options)
|
||||
|
||||
if vim.api.nvim_get_vvar("vim_did_enter") == 0 then
|
||||
vim.defer_fn(function()
|
||||
TextTransform._setup()
|
||||
end, 0)
|
||||
else
|
||||
TextTransform._setup()
|
||||
end
|
||||
|
||||
return TextTransform.options
|
||||
end
|
||||
|
||||
function TextTransform._setup()
|
||||
local map = {
|
||||
["&camelCase"] = "TextTransform.camel_case",
|
||||
["&snake_case"] = "TextTransform.snake_case",
|
||||
@@ -55,8 +67,6 @@ function TextTransform.setup(options)
|
||||
"<cmd>popup TransformsSelection<CR>",
|
||||
{ silent = true }
|
||||
)
|
||||
|
||||
return TextTransform.options
|
||||
end
|
||||
|
||||
return TextTransform
|
||||
|
||||
@@ -36,6 +36,18 @@ function TextTransform.setup(opts)
|
||||
_G.TextTransform.config = require("text-transform.config").setup(opts)
|
||||
end
|
||||
|
||||
TextTransform.into_words = M.into_words
|
||||
TextTransform.replace_word = M.replace_word
|
||||
TextTransform.replace_selection = M.replace_selection
|
||||
|
||||
TextTransform.camel_case = M.camel_case
|
||||
TextTransform.snake_case = M.snake_case
|
||||
TextTransform.pascal_case = M.pascal_case
|
||||
TextTransform.kebab_case = M.kebab_case
|
||||
TextTransform.dot_case = M.dot_case
|
||||
TextTransform.title_case = M.title_case
|
||||
TextTransform.const_case = M.const_case
|
||||
|
||||
_G.TextTransform = TextTransform
|
||||
|
||||
return _G.TextTransform
|
||||
|
||||
@@ -46,4 +46,165 @@ function TextTransform.disable()
|
||||
return S
|
||||
end
|
||||
|
||||
function TextTransform.into_words(str)
|
||||
local words = {}
|
||||
local word = ""
|
||||
|
||||
local previous_is_upper = false
|
||||
for i = 1, #str do
|
||||
local char = str:sub(i, i)
|
||||
-- split on uppercase letters
|
||||
if char:match("%u") and not previous_is_upper then
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
end
|
||||
previous_is_upper = true
|
||||
word = char
|
||||
-- split on underscores, hyphens, and spaces
|
||||
elseif char:match("[%_%-%s]") then
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
previous_is_upper = false
|
||||
end
|
||||
word = ""
|
||||
else
|
||||
word = word .. char
|
||||
previous_is_upper = char:match("%u")
|
||||
end
|
||||
end
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
previous_is_upper = false
|
||||
end
|
||||
return words
|
||||
end
|
||||
|
||||
function TextTransform.camel_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local camel_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
camel_case = camel_case .. word:lower()
|
||||
else
|
||||
camel_case = camel_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
end
|
||||
end
|
||||
return camel_case
|
||||
end
|
||||
|
||||
function TextTransform.snake_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local snake_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
snake_case = snake_case .. word:lower()
|
||||
else
|
||||
snake_case = snake_case .. "_" .. word:lower()
|
||||
end
|
||||
end
|
||||
return snake_case
|
||||
end
|
||||
|
||||
function TextTransform.pascal_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local pascal_case = ""
|
||||
for _, word in ipairs(words) do
|
||||
pascal_case = pascal_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
end
|
||||
return pascal_case
|
||||
end
|
||||
|
||||
function TextTransform.kebab_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local kebab_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
kebab_case = kebab_case .. word:lower()
|
||||
else
|
||||
kebab_case = kebab_case .. "-" .. word:lower()
|
||||
end
|
||||
end
|
||||
return kebab_case
|
||||
end
|
||||
|
||||
function TextTransform.dot_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local dot_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
dot_case = dot_case .. word:lower()
|
||||
else
|
||||
dot_case = dot_case .. "." .. word:lower()
|
||||
end
|
||||
end
|
||||
return dot_case
|
||||
end
|
||||
|
||||
function TextTransform.title_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local title_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
title_case = title_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
if i ~= #words then
|
||||
title_case = title_case .. " "
|
||||
end
|
||||
end
|
||||
return title_case
|
||||
end
|
||||
|
||||
function TextTransform.const_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local const_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
const_case = const_case .. word:upper()
|
||||
else
|
||||
const_case = const_case .. "_" .. word:upper()
|
||||
end
|
||||
end
|
||||
return const_case
|
||||
end
|
||||
|
||||
function TextTransform.replace_selection(transform)
|
||||
-- get the current visual selection, and transform the line, only replacing the selected text itself
|
||||
local _, start_line, start_col = unpack(vim.fn.getpos("'<"))
|
||||
local _, end_line, end_col = unpack(vim.fn.getpos("'>"))
|
||||
-- print(vim.inspect(vim.fn.getpos("'<")), vim.inspect(vim.fn.getpos("'>")),
|
||||
-- start_line, start_col, end_line, end_col)
|
||||
local lines = vim.fn.getline(start_line, end_line)
|
||||
-- print(vim.inspect(lines))
|
||||
|
||||
-- transform all included lines
|
||||
local transformed = ""
|
||||
|
||||
if #lines == 1 then
|
||||
transformed = lines[1]:sub(1, start_col - 1)
|
||||
.. transform(lines[1]:sub(start_col, end_col))
|
||||
.. lines[1]:sub(end_col + 1)
|
||||
else
|
||||
transformed = lines[1]:sub(1, start_col - 1) .. transform(lines[1]:sub(start_col)) .. "\n"
|
||||
for i = 2, #lines - 1 do
|
||||
transformed = transformed .. transform(lines[i]) .. "\n"
|
||||
end
|
||||
transformed = transformed
|
||||
.. transform(lines[#lines]:sub(1, end_col))
|
||||
.. lines[#lines]:sub(end_col + 1)
|
||||
end
|
||||
|
||||
-- replace the lines with the transformed lines
|
||||
vim.fn.setline(start_line, transformed)
|
||||
for i = start_line + 1, end_line do
|
||||
vim.fn.setline(i, "")
|
||||
end
|
||||
|
||||
-- move the cursor to the end of the transformed text
|
||||
vim.fn.cursor(end_line, end_col)
|
||||
end
|
||||
|
||||
function TextTransform.replace_word(transform)
|
||||
local word = vim.fn.expand("<cword>")
|
||||
local transformed = transform(word)
|
||||
vim.cmd("normal ciw" .. transformed)
|
||||
end
|
||||
|
||||
return TextTransform
|
||||
|
||||
@@ -4,185 +4,3 @@ if _G.TextTransformLoaded then
|
||||
end
|
||||
|
||||
_G.TextTransformLoaded = true
|
||||
|
||||
function TextTransform.into_words(str)
|
||||
local words = {}
|
||||
local word = ""
|
||||
|
||||
local previous_is_upper = false
|
||||
for i = 1, #str do
|
||||
local char = str:sub(i, i)
|
||||
-- split on uppercase letters
|
||||
if char:match("%u") and not previous_is_upper then
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
end
|
||||
previous_is_upper = true
|
||||
word = char
|
||||
-- split on underscores, hyphens, and spaces
|
||||
elseif char:match("[%_%-%s]") then
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
previous_is_upper = false
|
||||
end
|
||||
word = ""
|
||||
else
|
||||
word = word .. char
|
||||
previous_is_upper = char:match("%u")
|
||||
end
|
||||
end
|
||||
if word ~= "" then
|
||||
table.insert(words, word)
|
||||
previous_is_upper = false
|
||||
end
|
||||
return words
|
||||
end
|
||||
|
||||
function TextTransform.camel_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local camel_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
camel_case = camel_case .. word:lower()
|
||||
else
|
||||
camel_case = camel_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
end
|
||||
end
|
||||
return camel_case
|
||||
end
|
||||
|
||||
function TextTransform.snake_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local snake_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
snake_case = snake_case .. word:lower()
|
||||
else
|
||||
snake_case = snake_case .. "_" .. word:lower()
|
||||
end
|
||||
end
|
||||
return snake_case
|
||||
end
|
||||
|
||||
function TextTransform.pascal_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local pascal_case = ""
|
||||
for _, word in ipairs(words) do
|
||||
pascal_case = pascal_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
end
|
||||
return pascal_case
|
||||
end
|
||||
|
||||
function TextTransform.kebab_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local kebab_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
kebab_case = kebab_case .. word:lower()
|
||||
else
|
||||
kebab_case = kebab_case .. "-" .. word:lower()
|
||||
end
|
||||
end
|
||||
return kebab_case
|
||||
end
|
||||
|
||||
function TextTransform.dot_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local dot_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
dot_case = dot_case .. word:lower()
|
||||
else
|
||||
dot_case = dot_case .. "." .. word:lower()
|
||||
end
|
||||
end
|
||||
return dot_case
|
||||
end
|
||||
|
||||
function TextTransform.title_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local title_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
title_case = title_case .. word:sub(1, 1):upper() .. word:sub(2):lower()
|
||||
if i ~= #words then
|
||||
title_case = title_case .. " "
|
||||
end
|
||||
end
|
||||
return title_case
|
||||
end
|
||||
|
||||
function TextTransform.const_case(string)
|
||||
local words = TextTransform.into_words(string)
|
||||
local const_case = ""
|
||||
for i, word in ipairs(words) do
|
||||
if i == 1 then
|
||||
const_case = const_case .. word:upper()
|
||||
else
|
||||
const_case = const_case .. "_" .. word:upper()
|
||||
end
|
||||
end
|
||||
return const_case
|
||||
end
|
||||
|
||||
function TextTransform.replace_selection(transform)
|
||||
-- get the current visual selection, and transform the line, only replacing the selected text itself
|
||||
local _, start_line, start_col = unpack(vim.fn.getpos("'<"))
|
||||
local _, end_line, end_col = unpack(vim.fn.getpos("'>"))
|
||||
-- print(vim.inspect(vim.fn.getpos("'<")), vim.inspect(vim.fn.getpos("'>")),
|
||||
-- start_line, start_col, end_line, end_col)
|
||||
local lines = vim.fn.getline(start_line, end_line)
|
||||
-- print(vim.inspect(lines))
|
||||
|
||||
-- transform all included lines
|
||||
local transformed = ""
|
||||
|
||||
if #lines == 1 then
|
||||
transformed = lines[1]:sub(1, start_col - 1)
|
||||
.. transform(lines[1]:sub(start_col, end_col))
|
||||
.. lines[1]:sub(end_col + 1)
|
||||
else
|
||||
transformed = lines[1]:sub(1, start_col - 1) .. transform(lines[1]:sub(start_col)) .. "\n"
|
||||
for i = 2, #lines - 1 do
|
||||
transformed = transformed .. transform(lines[i]) .. "\n"
|
||||
end
|
||||
transformed = transformed
|
||||
.. transform(lines[#lines]:sub(1, end_col))
|
||||
.. lines[#lines]:sub(end_col + 1)
|
||||
end
|
||||
|
||||
-- replace the lines with the transformed lines
|
||||
vim.fn.setline(start_line, transformed)
|
||||
for i = start_line + 1, end_line do
|
||||
vim.fn.setline(i, "")
|
||||
end
|
||||
|
||||
-- move the cursor to the end of the transformed text
|
||||
vim.fn.cursor(end_line, end_col)
|
||||
end
|
||||
|
||||
function TextTransform.replace_word(transform)
|
||||
local word = vim.fn.expand("<cword>")
|
||||
local transformed = transform(word)
|
||||
vim.cmd("normal ciw" .. transformed)
|
||||
end
|
||||
|
||||
local should_test = false
|
||||
|
||||
if should_test then
|
||||
local map = {
|
||||
["CamelCase"] = TextTransform.camel_case,
|
||||
["SnakeCase"] = TextTransform.snake_case,
|
||||
["PascalCase"] = TextTransform.pascal_case,
|
||||
["KebabCase"] = TextTransform.kebab_case,
|
||||
["DotCase"] = TextTransform.dot_case,
|
||||
["TitleCase"] = TextTransform.title_case,
|
||||
["ConstCase"] = TextTransform.title_case,
|
||||
}
|
||||
|
||||
for k, tst in pairs(map) do
|
||||
print(k .. ": " .. "hello_world" .. " => " .. tst("hello_world"))
|
||||
print(k .. ": " .. "HELLO_WORLD" .. " => " .. tst("HELLO_WORLD"))
|
||||
print(k .. ": " .. "HelloWorld" .. " => " .. tst("HelloWorld"))
|
||||
print(k .. ": " .. "Hello-World" .. " => " .. tst("Hello-World"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
USAGE="\033[0;37m[INFO] - usage: USERNAME=my-github-username PLUGIN_NAME=my-awesome-plugin REPOSITORY_NAME=my-awesome-plugin.nvim make setup\n\033[0m"
|
||||
|
||||
echo -e "$USAGE"
|
||||
|
||||
if [[ -z "$USERNAME" ]]; then
|
||||
echo -e "\t> No USERNAME provided, what's your GitHub/GitLab username?"
|
||||
read -r USERNAME
|
||||
fi
|
||||
|
||||
if [[ -z "$REPOSITORY_NAME" ]]; then
|
||||
REPOSITORY_NAME=$(basename -s .git "$(git config --get remote.origin.url)")
|
||||
|
||||
read -rp $'\t> No REPOSITORY_NAME provided, is \033[1;32m'"$REPOSITORY_NAME"$'\033[0m good? [Y/n]\n' yn
|
||||
case $yn in
|
||||
[Yy]* );;
|
||||
[Nn]* )
|
||||
echo -e "\t> Enter your repository name"
|
||||
read -r REPOSITORY_NAME
|
||||
;;
|
||||
* )
|
||||
echo -e "$USAGE"
|
||||
exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ -z "$PLUGIN_NAME" ]]; then
|
||||
DEFAULT_REPOSITORY_NAME=$(echo "$REPOSITORY_NAME" | sed -e "s/\.nvim//")
|
||||
read -rp $'\t> No PLUGIN_NAME provided, defaulting to \033[1;32m'"$DEFAULT_REPOSITORY_NAME"$'\033[0m, continue? [Y/n]\n' yn
|
||||
case $yn in
|
||||
[Yy]* )
|
||||
PLUGIN_NAME=$DEFAULT_REPOSITORY_NAME
|
||||
;;
|
||||
[Nn]* )
|
||||
echo -e "\t> Enter your plugin name"
|
||||
read -r PLUGIN_NAME
|
||||
;;
|
||||
* )
|
||||
echo -e "$USAGE"
|
||||
exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo -e "Username: \033[1;32m$USERNAME\033[0m\nRepository: \033[1;32m$REPOSITORY_NAME\033[0m\nPlugin: \033[1;32m$PLUGIN_NAME\033[0m\n\n\tRenaming placeholder files..."
|
||||
|
||||
rm -rf doc
|
||||
mv plugin/your-plugin-name.lua "plugin/$PLUGIN_NAME.lua"
|
||||
mv lua/your-plugin-name "lua/$PLUGIN_NAME"
|
||||
mv README_TEMPLATE.md README.md
|
||||
|
||||
echo -e "\tReplacing placeholder names..."
|
||||
|
||||
PASCAL_CASE_PLUGIN_NAME=$(echo "$PLUGIN_NAME" | perl -pe 's/(^|-)./uc($&)/ge;s/-//g')
|
||||
|
||||
grep -rl "YourPluginName" .github/ plugin/ tests/ lua/ | xargs sed -i "" -e "s/YourPluginName/$PASCAL_CASE_PLUGIN_NAME/g"
|
||||
grep -rl "your-plugin-name" README.md .github/ plugin/ tests/ lua/ | xargs sed -i "" -e "s/your-plugin-name/$PLUGIN_NAME/g"
|
||||
grep -rl "YOUR_GITHUB_USERNAME" README.md .github/ | xargs sed -i "" -e "s/YOUR_GITHUB_USERNAME/$USERNAME/g"
|
||||
grep -rl "YOUR_REPOSITORY_NAME" README.md .github/ | xargs sed -i "" -e "s/YOUR_REPOSITORY_NAME/$REPOSITORY_NAME/g"
|
||||
|
||||
echo -e "\n\033[1;32mOK.\033[0m"
|
||||
|
||||
echo -e "\tFetching dependencies (tests and documentation generator)..."
|
||||
|
||||
make deps
|
||||
|
||||
echo -e "\n\033[1;32mOK.\033[0m"
|
||||
|
||||
echo -e "\tGenerating docs..."
|
||||
|
||||
make documentation
|
||||
|
||||
echo -e "\n\033[1;32mOK.\033[0m"
|
||||
|
||||
echo -e "\tRunning tests..."
|
||||
|
||||
make test
|
||||
|
||||
echo -e "\n\033[1;32mOK.\033[0m"
|
||||
Reference in New Issue
Block a user