feat: initial release
This commit is contained in:
17 files changed
+251
No files matched your search
@@ -0,0 +1 @@
|
||||
github: swaits
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Environment**
|
||||
- Neovim version:
|
||||
- OS:
|
||||
- Config (if relevant):
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem?**
|
||||
A clear and concise description of what the problem is.
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the feature request here.
|
||||
@@ -0,0 +1,30 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: JohnnyMorganz/stylua-action@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
version: latest
|
||||
args: --check lua/ plugin/
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install Neovim
|
||||
run: |
|
||||
wget -q https://github.com/neovim/neovim/releases/download/v0.12.0/nvim-linux-x86_64.appimage -O /tmp/nvim.appimage
|
||||
chmod +x /tmp/nvim.appimage
|
||||
/tmp/nvim.appimage --appimage-extract > /dev/null 2>&1
|
||||
echo "$PWD/squashfs-root/usr/bin" >> $GITHUB_PATH
|
||||
- name: Run tests
|
||||
run: ./scripts/test.sh
|
||||
@@ -0,0 +1,6 @@
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
.DS_Store
|
||||
tags
|
||||
deps/
|
||||
@@ -0,0 +1,14 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.1.0] - 2026-04-09
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release
|
||||
|
||||
[0.1.0]: https://github.com/swaits/tiny-lastplace.nvim/releases/tag/v0.1.0
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Stephen Waits
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,38 @@
|
||||
# tiny-lastplace.nvim
|
||||
|
||||
A tiny plugin for Neovim 0.12+ that restores the cursor to its last position
|
||||
when reopening a file.
|
||||
|
||||
Zero config. ~20 lines of Lua.
|
||||
|
||||
## Features
|
||||
|
||||
- Restores cursor to last edit position on file open
|
||||
- Skips excluded filetypes (e.g. gitcommit)
|
||||
- Works out of the box — no setup call required
|
||||
|
||||
## Requirements
|
||||
|
||||
- Neovim >= 0.12
|
||||
|
||||
## Installation
|
||||
|
||||
Add to your `vim.pack.add()` call:
|
||||
|
||||
```lua
|
||||
"https://github.com/swaits/tiny-lastplace.nvim",
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
All options are optional. Call `setup()` only if you want to customize:
|
||||
|
||||
```lua
|
||||
require("tiny-lastplace").setup({
|
||||
exclude = { "gitcommit" }, -- filetypes to skip
|
||||
})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
@@ -0,0 +1,34 @@
|
||||
*tiny-lastplace.txt* Restore cursor to last position on file open
|
||||
|
||||
Author: Stephen Waits <https://github.com/swaits>
|
||||
License: MIT
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *tiny-lastplace-contents*
|
||||
|
||||
1. Introduction .......................... |tiny-lastplace-introduction|
|
||||
2. Configuration ......................... |tiny-lastplace-configuration|
|
||||
|
||||
==============================================================================
|
||||
1. INTRODUCTION *tiny-lastplace-introduction*
|
||||
|
||||
tiny-lastplace.nvim restores the cursor to its last known position when
|
||||
reopening a file. Works out of the box with zero configuration.
|
||||
|
||||
==============================================================================
|
||||
2. CONFIGURATION *tiny-lastplace-configuration*
|
||||
|
||||
*tiny-lastplace.setup()*
|
||||
setup({opts})
|
||||
|
||||
Optional. All options shown with defaults: >lua
|
||||
|
||||
require("tiny-lastplace").setup({
|
||||
exclude = { "gitcommit" },
|
||||
})
|
||||
<
|
||||
Fields: ~
|
||||
{exclude} (table) Filetypes to skip. Default: { "gitcommit" }
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
@@ -0,0 +1,23 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
local exclude = opts.exclude or { "gitcommit" }
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
group = vim.api.nvim_create_augroup("tiny-lastplace", { clear = true }),
|
||||
callback = function(event)
|
||||
local buf = event.buf
|
||||
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].tiny_lastplace then
|
||||
return
|
||||
end
|
||||
vim.b[buf].tiny_lastplace = true
|
||||
local mark = vim.api.nvim_buf_get_mark(buf, '"')
|
||||
local lcount = vim.api.nvim_buf_line_count(buf)
|
||||
if mark[1] > 0 and mark[1] <= lcount then
|
||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1 @@
|
||||
require("tiny-lastplace").setup()
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Minimal init for testing tiny-lastplace.nvim
|
||||
vim.opt.rtp:prepend(".")
|
||||
vim.opt.rtp:prepend("deps/mini.nvim")
|
||||
vim.cmd("runtime plugin/tiny-lastplace.lua")
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Clone mini.nvim for test framework (if not cached)
|
||||
if [ ! -d deps/mini.nvim ]; then
|
||||
mkdir -p deps
|
||||
git clone --depth 1 https://github.com/echasnovski/mini.nvim deps/mini.nvim
|
||||
fi
|
||||
|
||||
# Run tests
|
||||
nvim --headless -u scripts/minimal_init.lua -c "lua require('mini.test').setup(); MiniTest.run_file('tests/test_init.lua')"
|
||||
@@ -0,0 +1 @@
|
||||
std = "vim"
|
||||
@@ -0,0 +1,4 @@
|
||||
column_width = 100
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferDouble"
|
||||
@@ -0,0 +1,24 @@
|
||||
local T = MiniTest.new_set()
|
||||
local eq = MiniTest.expect.equality
|
||||
|
||||
T["setup"] = MiniTest.new_set()
|
||||
|
||||
T["setup"]["creates augroup"] = function()
|
||||
local groups = vim.api.nvim_get_autocmds({ group = "tiny-lastplace" })
|
||||
eq(#groups > 0, true)
|
||||
end
|
||||
|
||||
T["setup"]["is idempotent"] = function()
|
||||
require("tiny-lastplace").setup()
|
||||
require("tiny-lastplace").setup()
|
||||
local groups = vim.api.nvim_get_autocmds({ group = "tiny-lastplace" })
|
||||
eq(#groups > 0, true)
|
||||
end
|
||||
|
||||
T["setup"]["respects custom exclude"] = function()
|
||||
require("tiny-lastplace").setup({ exclude = { "gitcommit", "rebase" } })
|
||||
local groups = vim.api.nvim_get_autocmds({ group = "tiny-lastplace" })
|
||||
eq(#groups > 0, true)
|
||||
end
|
||||
|
||||
return T
|
||||
Reference in new issue
Block a user