Repository navigation
feat: add neovim lua plugin scaffold #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dkarter
merged 2 commits into
main
from
dorian/rms-67-add-neovim-only-lua-plugin-scaffold
Jun 12, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,40 @@ | ||
| local M = {} | ||
|
|
||
| function M.insert_new_bullet() | ||
| if vim.fn.mode() == "n" then | ||
| local lnum = vim.api.nvim_win_get_cursor(0)[1] | ||
| vim.api.nvim_buf_set_lines(0, lnum, lnum, false, { "" }) | ||
| vim.api.nvim_win_set_cursor(0, { lnum + 1, 0 }) | ||
| vim.cmd.startinsert() | ||
| else | ||
| return "\r" | ||
| end | ||
|
|
||
| return "" | ||
| end | ||
|
|
||
| function M.renumber_list() end | ||
|
|
||
| function M.renumber_selection() end | ||
|
|
||
| function M.toggle_checkbox() end | ||
|
|
||
| function M.recompute_checkboxes() end | ||
|
|
||
| function M.demote() end | ||
|
|
||
| function M.promote() end | ||
|
|
||
| function M.demote_visual() end | ||
|
|
||
| function M.promote_visual() end | ||
|
|
||
| function M.select_checkbox() end | ||
|
|
||
| function M.select_checkbox_inside() end | ||
|
|
||
| function M.select_bullet() end | ||
|
|
||
| function M.select_bullet_text() end | ||
|
|
||
| return M |
This file contains hidden or 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,31 @@ | ||
| local M = {} | ||
|
|
||
| M.defaults = { | ||
| enabled_file_types = { "markdown", "text", "gitcommit" }, | ||
| enable_in_empty_buffers = false, | ||
| set_mappings = true, | ||
| mapping_leader = "", | ||
| custom_mappings = {}, | ||
| delete_last_bullet_if_empty = 1, | ||
| line_spacing = 1, | ||
| pad_right = true, | ||
| max_alpha_characters = 2, | ||
| enable_roman_list = true, | ||
| list_item_styles = { "-", "*+", ".+", "#.", "+", "\\item" }, | ||
| outline_levels = { "ROM", "ABC", "num", "abc", "rom", "std-", "std*", "std+" }, | ||
| renumber_on_change = true, | ||
| nested_checkboxes = true, | ||
| enable_wrapped_lines = true, | ||
| checkbox_markers = " .oOX", | ||
| checkbox_partials_toggle = 1, | ||
| auto_indent_after_colon = true, | ||
| } | ||
|
|
||
| M.options = vim.deepcopy(M.defaults) | ||
|
|
||
| function M.setup(options) | ||
| M.options = vim.tbl_deep_extend("force", vim.deepcopy(M.defaults), options or {}) | ||
| return M.options | ||
| end | ||
|
|
||
| return M |
This file contains hidden or 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,166 @@ | ||
| local config = require("bullets.config") | ||
|
|
||
| local M = {} | ||
| M.did_setup = false | ||
|
|
||
| local augroup = vim.api.nvim_create_augroup("bullets.nvim", { clear = true }) | ||
|
|
||
| local function actions() | ||
| return require("bullets.actions") | ||
| end | ||
|
|
||
| local function command(name, fn, opts) | ||
| vim.api.nvim_create_user_command(name, fn, vim.tbl_extend("force", { force = true }, opts or {})) | ||
| end | ||
|
|
||
| local function map(mode, lhs, rhs, opts) | ||
| vim.keymap.set(mode, lhs, rhs, vim.tbl_extend("force", { silent = true }, opts or {})) | ||
| end | ||
|
|
||
| local function map_buffer(buf, mode, lhs, rhs, opts) | ||
| vim.keymap.set(mode, lhs, rhs, vim.tbl_extend("force", { buffer = buf, silent = true }, opts or {})) | ||
| end | ||
|
|
||
| local function add_commands() | ||
| command("InsertNewBullet", function() | ||
| actions().insert_new_bullet() | ||
| end) | ||
| command("RenumberList", function() | ||
| actions().renumber_list() | ||
| end) | ||
| command("RenumberSelection", function() | ||
| actions().renumber_selection() | ||
| end, { range = true }) | ||
| command("ToggleCheckbox", function() | ||
| actions().toggle_checkbox() | ||
| end) | ||
| command("RecomputeCheckboxes", function() | ||
| actions().recompute_checkboxes() | ||
| end) | ||
| command("BulletDemote", function() | ||
| actions().demote() | ||
| end) | ||
| command("BulletPromote", function() | ||
| actions().promote() | ||
| end) | ||
| command("BulletDemoteVisual", function() | ||
| actions().demote_visual() | ||
| end, { range = true }) | ||
| command("BulletPromoteVisual", function() | ||
| actions().promote_visual() | ||
| end, { range = true }) | ||
| command("SelectCheckbox", function() | ||
| actions().select_checkbox() | ||
| end) | ||
| command("SelectCheckboxInside", function() | ||
| actions().select_checkbox_inside() | ||
| end) | ||
| command("SelectBullet", function() | ||
| actions().select_bullet() | ||
| end) | ||
| command("SelectBulletText", function() | ||
| actions().select_bullet_text() | ||
| end) | ||
| end | ||
|
|
||
| local function add_plug_mappings() | ||
| map("i", "<Plug>(bullets-newline)", function() | ||
| return actions().insert_new_bullet() | ||
| end, { expr = true }) | ||
| map("n", "<Plug>(bullets-newline)", function() | ||
| actions().insert_new_bullet() | ||
| end) | ||
| map("n", "<Plug>(bullets-renumber)", function() | ||
| actions().renumber_list() | ||
| end) | ||
| map("x", "<Plug>(bullets-renumber)", function() | ||
| actions().renumber_selection() | ||
| end) | ||
| map("n", "<Plug>(bullets-toggle-checkbox)", function() | ||
| actions().toggle_checkbox() | ||
| end) | ||
| map("n", "<Plug>(bullets-recompute-checkboxes)", function() | ||
| actions().recompute_checkboxes() | ||
| end) | ||
| map({ "i", "n" }, "<Plug>(bullets-demote)", function() | ||
| actions().demote() | ||
| end) | ||
| map("x", "<Plug>(bullets-demote)", function() | ||
| actions().demote_visual() | ||
| end) | ||
| map({ "i", "n" }, "<Plug>(bullets-promote)", function() | ||
| actions().promote() | ||
| end) | ||
| map("x", "<Plug>(bullets-promote)", function() | ||
| actions().promote_visual() | ||
| end) | ||
| end | ||
|
|
||
| local function add_default_mappings(buf) | ||
| local opts = config.options | ||
| local leader = opts.mapping_leader | ||
|
|
||
| map_buffer(buf, "i", leader .. "<CR>", "<Plug>(bullets-newline)", { remap = true }) | ||
| map_buffer(buf, "i", leader .. "<C-CR>", "<CR>") | ||
| map_buffer(buf, "n", leader .. "o", "<Plug>(bullets-newline)", { remap = true }) | ||
| map_buffer(buf, "n", leader .. "gN", "<Plug>(bullets-renumber)", { remap = true }) | ||
| map_buffer(buf, "x", leader .. "gN", "<Plug>(bullets-renumber)", { remap = true }) | ||
| map_buffer(buf, "n", leader .. "<leader>x", "<Plug>(bullets-toggle-checkbox)", { remap = true }) | ||
| end | ||
|
|
||
| local function should_configure_buffer(buf) | ||
| return vim.tbl_contains(config.options.enabled_file_types, vim.bo[buf].filetype) | ||
| or (config.options.enable_in_empty_buffers and vim.bo[buf].filetype == "") | ||
| end | ||
|
|
||
| local function add_custom_mappings(buf) | ||
| for _, item in ipairs(config.options.custom_mappings) do | ||
| map_buffer(buf, item[1], item[2], item[3], { remap = true }) | ||
| end | ||
| end | ||
|
|
||
| local function configure_buffer(buf) | ||
| if config.options.set_mappings then | ||
| add_default_mappings(buf) | ||
| end | ||
| add_custom_mappings(buf) | ||
| end | ||
|
|
||
| local function add_autocmds() | ||
| vim.api.nvim_clear_autocmds({ group = augroup }) | ||
|
|
||
| vim.api.nvim_create_autocmd("FileType", { | ||
| group = augroup, | ||
| pattern = config.options.enabled_file_types, | ||
| callback = function(event) | ||
| configure_buffer(event.buf) | ||
| end, | ||
| }) | ||
|
|
||
| if config.options.enable_in_empty_buffers then | ||
| vim.api.nvim_create_autocmd({ "BufNew", "BufRead" }, { | ||
| group = augroup, | ||
| pattern = "*", | ||
| callback = function(event) | ||
| if vim.bo[event.buf].filetype == "" then | ||
| configure_buffer(event.buf) | ||
| end | ||
| end, | ||
| }) | ||
| end | ||
| end | ||
|
|
||
| function M.setup(options) | ||
| M.did_setup = true | ||
| config.setup(options) | ||
| add_commands() | ||
| add_plug_mappings() | ||
| add_autocmds() | ||
|
|
||
| local current_buf = vim.api.nvim_get_current_buf() | ||
| if should_configure_buffer(current_buf) then | ||
| configure_buffer(current_buf) | ||
| end | ||
| end | ||
|
|
||
| return M |
This file contains hidden or 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 hidden or 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,10 @@ | ||
| if vim.g.loaded_bullets_nvim then | ||
| return | ||
| end | ||
|
|
||
| vim.g.loaded_bullets_nvim = true | ||
|
|
||
| local bullets = require("bullets") | ||
| if not bullets.did_setup then | ||
| bullets.setup() | ||
| end | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this for neovim plugins - right?