Skip to content

Commit

Permalink
refactor: rename plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
2KAbhishek committed Nov 15, 2024
1 parent 2119cc9 commit 16a5d20
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: template
vimdoc: exercism
version: "Neovim >= 0.8.0"
demojify: true
treesitter: true
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<a href="https://github.com/2KAbhishek/exercism.nvim/pulse">
<img alt="Last Updated" src="https://img.shields.io/github/last-commit/2kabhishek/exercism.nvim?style=flat&color=e06c75&label="> </a>

<h3>Ready to go Neovim template 🏗️✈️</h3>
<h3>Ready to go Neovim exercism 🏗️✈️</h3>

<figure>
<img src="doc/images/screenshot.png" alt="exercism.nvim in action">
Expand All @@ -34,10 +34,10 @@ exercism.nvim is a neovim plugin that allows neovim users to `<action>`.

## ✨ Features

- Includes a ready to go neovim plugin template
- Includes a ready to go neovim plugin exercism
- Comes with a lint and test CI action
- Includes a Github action to auto generate vimdocs
- Comes with a ready to go README template
- Comes with a ready to go README exercism
- Works with [mkrepo](https://github.com/2kabhishek/mkrepo)

## ⚡ Setup
Expand All @@ -52,7 +52,7 @@ exercism.nvim is a neovim plugin that allows neovim users to `<action>`.
-- Lazy
{
'2kabhishek/exercism.nvim',
cmd = 'TemplateHello',
cmd = 'ExercismHello',
-- Add your custom configs here, keep it blank for default configs (required)
opts = {},
-- Use this for local development
Expand All @@ -63,12 +63,12 @@ exercism.nvim is a neovim plugin that allows neovim users to `<action>`.
## 🚀 Usage

1. Fork the `exercism.nvim` repo
2. Update the plugin name, file names etc, change `template` to `your-plugin-name`
2. Update the plugin name, file names etc, change `exercism` to `your-plugin-name`
3. Add the code required for your plugin,
- Code entrypoint is [template.lua](./lua/template.lua)
- Add user configs to [config.lua](./lua/template/config.lua)
- For adding commands and keybindngs use [commands.lua](./lua/template/commands.lua)
- Separate plugin logic into modules under [modules](./lua/template/) dir
- Code entrypoint is [exercism.lua](./lua/exercism.lua)
- Add user configs to [config.lua](./lua/exercism/config.lua)
- For adding commands and keybindngs use [commands.lua](./lua/exercism/commands.lua)
- Separate plugin logic into modules under [modules](./lua/exercism/) dir
4. Add test code to the [tests](./tests/) directory
5. Update the README
6. Tweak the [docs action](./.github/workflows/docs.yml) file to reflect your username, commit message and plugin name
Expand All @@ -80,7 +80,7 @@ exercism.nvim is a neovim plugin that allows neovim users to `<action>`.
exercism.nvim can be configured using the following options:

```lua
template.setup({
exercism.setup({
name = 'exercism.nvim', -- Name to be greeted, 'World' by default
})
```
Expand All @@ -89,19 +89,19 @@ template.setup({

`exercism.nvim` adds the following commands:

- `TemplateHello`: Shows a hello message with the confugred name.
- `ExercismHello`: Shows a hello message with the confugred name.

### Keybindings

It is recommended to use:

- `<leader>th,` for `TemplateHello`
- `<leader>th,` for `ExercismHello`

> NOTE: By default there are no configured keybindings.
### Help

Run `:help template.txt` for more details.
Run `:help exercism.txt` for more details.

## 🏗️ What's Next

Expand All @@ -117,7 +117,7 @@ Planning to add `<feature/module>`.

### 🌈 Inspiration

exercism.nvim was inspired by [nvim-plugin-template](https://github.com/ellisonleao/nvim-plugin-template), I added some changes on top to make setting up a new plugin faster.
exercism.nvim was inspired by [nvim-plugin-exercism](https://github.com/ellisonleao/nvim-plugin-exercism), I added some changes on top to make setting up a new plugin faster.

### 💡 Challenges/Learnings

Expand Down
66 changes: 33 additions & 33 deletions doc/template.txt → doc/exercism.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
*template.txt* For Neovim >= 0.8.0 Last change: 2024 November 10
*exercism.txt* For Neovim >= 0.8.0 Last change: 2024 November 10

==============================================================================
Table of Contents *template-table-of-contents*
Table of Contents *exercism-table-of-contents*

- Features |template-features|
- Setup |template-setup|
- Usage |template-usage|
- What’s Next |template-what’s-next|
- Behind The Code |template-behind-the-code|
- Features |exercism-features|
- Setup |exercism-setup|
- Usage |exercism-usage|
- What’s Next |exercism-what’s-next|
- Behind The Code |exercism-behind-the-code|

template.nvim is a neovim plugin that allows neovim users to `<action>`.
exercism.nvim is a neovim plugin that allows neovim users to `<action>`.


FEATURES *template-features*
FEATURES *exercism-features*

- Includes a ready to go neovim plugin template
- Includes a ready to go neovim plugin exercism
- Comes with a lint and test CI action
- Includes a Github action to auto generate vimdocs
- Comes with a ready to go README template
- Comes with a ready to go README exercism
- Works with mkrepo <https://github.com/2kabhishek/mkrepo>


SETUP *template-setup*
SETUP *exercism-setup*


REQUIREMENTS ~
Expand All @@ -34,30 +34,30 @@ INSTALLATION ~
>lua
-- Lazy
{
'2kabhishek/template.nvim',
cmd = 'TemplateHello',
'2kabhishek/exercism.nvim',
cmd = 'ExercismHello',
-- Add your custom configs here, keep it blank for default configs (required)
opts = {},
-- Use this for local development
-- dir = '~/path-to/template.nvim',
-- dir = '~/path-to/exercism.nvim',
},
<


USAGE *template-usage*
USAGE *exercism-usage*

1. Fork the `template.nvim` repo
1. Fork the `exercism.nvim` repo


2. Update the plugin name, file names etc, change `template` to `your-plugin-name`
2. Update the plugin name, file names etc, change `exercism` to `your-plugin-name`


3. Add the code required for your plugin,

- Code entrypoint is template.lua <./lua/template.lua>
- Add user configs to config.lua <./lua/template/config.lua>
- For adding commands and keybindngs use commands.lua <./lua/template/commands.lua>
- Separate plugin logic into modules under modules <./lua/template/> dir
- Code entrypoint is exercism.lua <./lua/exercism.lua>
- Add user configs to config.lua <./lua/exercism/config.lua>
- For adding commands and keybindngs use commands.lua <./lua/exercism/commands.lua>
- Separate plugin logic into modules under modules <./lua/exercism/> dir


4. Add test code to the tests <./tests/> directory
Expand All @@ -76,37 +76,37 @@ username, commit message and plugin name

CONFIGURATION ~

template.nvim can be configured using the following options:
exercism.nvim can be configured using the following options:

>lua
template.setup({
name = 'template.nvim', -- Name to be greeted, 'World' by default
exercism.setup({
name = 'exercism.nvim', -- Name to be greeted, 'World' by default
})
<


COMMANDS ~

`template.nvim` adds the following commands:
`exercism.nvim` adds the following commands:

- `TemplateHello`Shows a hello message with the confugred name.
- `ExercismHello`Shows a hello message with the confugred name.


KEYBINDINGS ~

It is recommended to use:

- `<leader>th,` for `TemplateHello`
- `<leader>th,` for `ExercismHello`


NOTE: By default there are no configured keybindings.

HELP ~

Run `:help template.txt` for more details.
Run `:help exercism.txt` for more details.


WHAT’S NEXT *template-what’s-next*
WHAT’S NEXT *exercism-what’s-next*

Planning to add `<feature/module>`.

Expand All @@ -118,13 +118,13 @@ TO-DO ~
- Start typing


BEHIND THE CODE *template-behind-the-code*
BEHIND THE CODE *exercism-behind-the-code*


INSPIRATION ~

template.nvim was inspired by nvim-plugin-template
<https://github.com/ellisonleao/nvim-plugin-template>, I added some changes on
exercism.nvim was inspired by nvim-plugin-exercism
<https://github.com/ellisonleao/nvim-plugin-exercism>, I added some changes on
top to make setting up a new plugin faster.


Expand Down
6 changes: 6 additions & 0 deletions lua/exercism.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
setup = function(opts)
require('exercism.config').setup(opts)
require('exercism.commands').setup()
end,
}
10 changes: 5 additions & 5 deletions lua/template/commands.lua → lua/exercism/commands.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
local template_module = require('template.module')
local config = require('template.config')
local exercism_module = require('exercism.module')
local config = require('exercism.config')

local M = {}

M.setup = function()
-- Add all user commands here
vim.api.nvim_create_user_command('TemplateHello', function(opts)
template_module.greet(opts.args)
vim.api.nvim_create_user_command('ExercismHello', function(opts)
exercism_module.greet(opts.args)
end, { nargs = '?' })

if config.add_default_keybindings then
Expand All @@ -15,7 +15,7 @@ M.setup = function()
end

-- Add all keybindings here
add_keymap('<leader>Th', ':TemplateHello Neovim (btw!)<CR>', 'Template says hi')
add_keymap('<leader>Th', ':ExercismHello Neovim (btw!)<CR>', 'Exercism says hi')
end
end

Expand Down
9 changes: 5 additions & 4 deletions lua/template/config.lua → lua/exercism/config.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
-- Define config structure here, setup function will override defaults with user config
---@class TemplateModule
---@class ExercismModule
local M = {}

---@class TemplateConfig
---@class ExercismConfig
---@field name string
---@field add_default_keybindings boolean
local config = {
name = 'World!',
exercism_workspace = vim.fn.expand('~/exercism'),
add_default_keybindings = true,
}

---@type TemplateConfig
---@type ExercismConfig
M.config = config

---@param args TemplateConfig?
---@param args ExercismConfig?
M.setup = function(args)
M.config = vim.tbl_deep_extend('force', M.config, args or {})
end
Expand Down
4 changes: 2 additions & 2 deletions lua/template/module.lua → lua/exercism/module.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---@class CustomModule
local M = {}
local config = require('template.config').config
local config = require('exercism.config').config

---@return string
M.greet = function(name)
Expand All @@ -12,7 +12,7 @@ end

M.show_notification = function(message)
vim.notify(message, vim.log.levels.INFO, {
title = 'Template',
title = 'Exercism',
timeout = 5000,
})
end
Expand Down
6 changes: 0 additions & 6 deletions lua/template.lua

This file was deleted.

8 changes: 4 additions & 4 deletions tests/module_spec.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
local template = require('template')
local module = require('template.module')
local exercism = require('exercism')
local module = require('exercism.module')

describe('greet', function()
it('returns message with config value', function()
template.setup()
exercism.setup()
assert(module.greet() == 'Hello World!')
end)

it('returns message with user arg', function()
template.setup()
exercism.setup()
assert(module.greet('Neovim') == 'Hello Neovim')
end)
end)

0 comments on commit 16a5d20

Please sign in to comment.