Skip to content

Commit 737843a

Browse files
committed
a
0 parents  commit 737843a

File tree

7 files changed

+147
-0
lines changed

7 files changed

+147
-0
lines changed

.github/workflows/doc.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: Generate Docs
6+
7+
jobs:
8+
docs:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: panvimdoc
15+
uses: kdheepak/panvimdoc@main
16+
with:
17+
vimdoc: term
18+
version: "Neovim <= infinity(i think)"
19+
demojify: true
20+
treesitter: true
21+
- name: Push changes
22+
uses: stefanzweifel/git-auto-commit-action@v6
23+
with:
24+
commit_message: "chore: autgenerate vimdoc"
25+
commit_user_name: "github-actions[bot]"
26+
commit_user_email: "github-actions[bot]@users.noreply.github.com"
27+
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/plugin/reload.vim

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## tiny.boilerplate
2+
a tiny boilerplate for a neovim plugin

doc/boilerplate.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*boilerplate.txt* For Neovim <= infinity(i think) Last change: 2025 August 16
2+
3+
==============================================================================
4+
Table of Contents *boilerplate-table-of-contents*
5+
6+
- tiny.boilerplate |boilerplate-tiny.boilerplate|
7+
8+
TINY.BOILERPLATE *boilerplate-tiny.boilerplate*
9+
10+
a tiny boilerplate for a neovim plugin
11+
12+
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
13+
14+
vim:tw=78:ts=8:noet:ft=help:norl:

lua/term.lua

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
local M = {}
2+
local config = { enabled = true }
3+
local vim = vim
4+
5+
M.term_buf = nil
6+
M.term_win = nil
7+
8+
local function create_buffer()
9+
return vim.api.nvim_create_buf(false, true)
10+
end
11+
12+
local function open_window(buf, mode)
13+
local win
14+
15+
if mode == "vertical" then
16+
vim.cmd("vsplit")
17+
win = vim.api.nvim_get_current_win()
18+
vim.api.nvim_win_set_buf(win, buf)
19+
elseif mode == "floating" then
20+
local width = math.floor(vim.o.columns * 0.8)
21+
local height = math.floor(vim.o.lines * 0.8)
22+
local row = math.floor((vim.o.lines - height) / 2)
23+
local col = math.floor((vim.o.columns - width) / 2)
24+
25+
win = vim.api.nvim_open_win(buf, true, {
26+
relative = "editor",
27+
width = width,
28+
height = height,
29+
row = row,
30+
col = col,
31+
style = "minimal",
32+
border = "rounded",
33+
})
34+
else
35+
vim.cmd("split")
36+
win = vim.api.nvim_get_current_win()
37+
vim.api.nvim_win_set_buf(win, buf)
38+
vim.cmd("resize 10")
39+
end
40+
41+
return win
42+
end
43+
44+
local function setup_terminal(buf, win)
45+
vim.fn.termopen(vim.o.shell)
46+
vim.bo[buf].buflisted = false
47+
vim.api.nvim_set_current_win(win)
48+
vim.cmd("startinsert")
49+
end
50+
51+
function M.toggle_term(mode)
52+
mode = mode or "floating"
53+
54+
if M.term_win and vim.api.nvim_win_is_valid(M.term_win) then
55+
vim.api.nvim_win_close(M.term_win, true)
56+
M.term_win = nil
57+
return
58+
end
59+
60+
if not (M.term_buf and vim.api.nvim_buf_is_valid(M.term_buf)) then
61+
M.term_buf = create_buffer()
62+
end
63+
64+
M.term_win = open_window(M.term_buf, mode)
65+
setup_terminal(M.term_buf, M.term_win)
66+
end
67+
68+
function M.new_term(mode)
69+
local buf = create_buffer()
70+
local win = open_window(buf, mode)
71+
setup_terminal(buf, win)
72+
end
73+
74+
local function create_terminal_command(name, func)
75+
vim.api.nvim_create_user_command(name, function(opts)
76+
func(opts.args)
77+
end, {
78+
nargs = "?",
79+
complete = function()
80+
return { "floating", "horizontal", "vertical", "plain" }
81+
end,
82+
})
83+
end
84+
85+
function M.setup(opts)
86+
if opts then
87+
config = vim.tbl_deep_extend("force", config, opts)
88+
end
89+
90+
if config.enabled then
91+
create_terminal_command("Terminal", M.toggle_term)
92+
create_terminal_command("NewTerminal", M.new_term)
93+
create_terminal_command("Term", M.toggle_term)
94+
create_terminal_command("NewTerm", M.new_term)
95+
end
96+
end
97+
98+
return M

plugin/term.lua

Whitespace-only changes.

stylua.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
indent_type = "Spaces"
2+
indent_width = 2
3+
column_width = 100
4+
quote_style = "AutoPreferDouble"
5+
no_call_parentheses = false

0 commit comments

Comments
 (0)