-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1bac68
commit a983472
Showing
19 changed files
with
347 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,8 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
|
Validating CODEOWNERS rules …
This file contains 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 @@ | ||
* @gorillamoe |
This file contains 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,21 @@ | ||
--- | ||
changelog: | ||
exclude: | ||
labels: | ||
- ignore-for-release | ||
categories: | ||
- title: Breaking Changes 💥 | ||
labels: | ||
- breaking-change | ||
- title: Documentation 📚 | ||
labels: | ||
- documentation | ||
- title: Exciting New Features ✨ | ||
labels: | ||
- enhancement | ||
- title: Bug Fixes 🐛 | ||
labels: | ||
- bug | ||
- title: Dependencies 📦 | ||
labels: | ||
- dependencies |
This file contains 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,24 @@ | ||
--- | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
jobs: | ||
create-release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up env | ||
run: | | ||
VERSION=${GITHUB_REF_NAME#v} | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Create Release | ||
run: ./scripts/release.sh | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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,3 @@ | ||
node_modules | ||
.env | ||
.nvim |
This file contains 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,20 @@ | ||
stds.nvim = { | ||
read_globals = { "jit" }, | ||
} | ||
|
||
std = "lua51+nvim" | ||
|
||
read_globals = { | ||
"vim", | ||
} | ||
|
||
globals = { | ||
"vim.g", | ||
"vim.b", | ||
"vim.w", | ||
"vim.o", | ||
"vim.bo", | ||
"vim.wo", | ||
"vim.go", | ||
"vim.env", | ||
} |
This file contains 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,15 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", | ||
"runtime.version": "LuaJIT", | ||
"diagnostics.globals": [ | ||
"vim" | ||
], | ||
"runtime.settings.path": [ | ||
"?.lua", | ||
"?/init.lua" | ||
], | ||
"workspace.checkThirdParty": false, | ||
"workspace.library": [ | ||
"$VIMRUNTIME" | ||
] | ||
} |
This file contains 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,5 @@ | ||
--- | ||
extends: default | ||
rules: | ||
truthy: | ||
check-keys: false |
This file contains 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,2 @@ | ||
version: | ||
./scripts/set-version.sh $(VERSION) |
This file contains 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 |
---|---|---|
@@ -1,2 +1,60 @@ | ||
# kikao.nvim | ||
Minimal 🤏🏾 session management ⚡ for your favorite editor Neovim ❤️. | ||
<div align="center"> | ||
|
||
![Kulala Logo](logo.svg) | ||
|
||
# kulala.nvim | ||
|
||
![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua) | ||
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/mistweaverco/kikao.nvim?style=for-the-badge)](https://github.com/mistweaverco/kikao.nvim/releases/latest) | ||
|
||
[Requirements](#requirements) • [Install](#install) • [Configuration](#configuration) • [How](#how) | ||
|
||
<p></p> | ||
|
||
A minimal session management plugin for your favorite editor. | ||
|
||
Kikao is swahili for "session". | ||
|
||
It is a simple plugin that allows you to automatically save and | ||
restore your session when you open and close neovim. | ||
|
||
<p></p> | ||
|
||
</div> | ||
|
||
## Requirements | ||
|
||
- Neovim 0.10.0+ | ||
|
||
## Install | ||
|
||
Via [lazy.nvim](https://github.com/folke/lazy.nvim): | ||
|
||
```lua | ||
{ 'mistweaverco/kikao.nvim', opts = {} }, | ||
``` | ||
|
||
> [!NOTE] | ||
> `opts` needs to be at least an empty table `{}` and can't be completely omitted. | ||
## Configuration | ||
|
||
```lua | ||
{ 'mistweaverco/kikao.nvim', | ||
opts = { | ||
-- Checks for the existence of the project root by checking for these directories | ||
project_dir_matchers = { ".git", ".hg", ".bzr", ".svn" }, | ||
-- The path to the session file | ||
-- If not provided, the session file will be stored in {{PROJECT_DIR}}/.nvim/session.vim | ||
session_file_path = nil, | ||
} | ||
}, | ||
``` | ||
|
||
## How | ||
|
||
How does it work? | ||
|
||
- When you open neovim, kikao will check if there is a session file in the project root. | ||
- If there is a session file, it will be loaded. | ||
- When you close neovim, kikao will save the session file in the project root. |
This file contains 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,62 @@ | ||
local M = {} | ||
|
||
local save_session = false | ||
|
||
local vim_leave_cb = function(session_file_path) | ||
local sessiondir = vim.fn.fnamemodify(session_file_path, ":h") | ||
vim.fn.mkdir(sessiondir, "p") | ||
vim.cmd("mksession! " .. session_file_path) | ||
end | ||
|
||
local vim_enter_cb = function(data, project_dir_matchers, session_file_path, ps) | ||
local is_oil = data.file:match("^oil://") ~= nil | ||
local is_dir = vim.fn.isdirectory(data.file) == 1 | ||
if not is_dir and not is_oil then | ||
return | ||
end | ||
|
||
local dir = is_oil and vim.fn.getcwd() or data.file | ||
|
||
for _, root in ipairs(project_dir_matchers) do | ||
if vim.fn.isdirectory(dir .. ps .. root) == 1 then | ||
save_session = true | ||
break | ||
end | ||
end | ||
|
||
if save_session then | ||
if vim.fn.filereadable(session_file_path) == 1 then | ||
vim.cmd("source " .. session_file_path) | ||
end | ||
end | ||
|
||
vim.cmd("bw " .. data.buf) | ||
end | ||
|
||
M.setup = function(config) | ||
local ps = package.config:sub(1, 1) | ||
local augroup = vim.api.nvim_create_augroup("KikaoSession", { clear = true }) | ||
local session_file_path = config.session_file_path | ||
if session_file_path == nil then | ||
session_file_path = vim.fn.getcwd() .. ps .. ".nvim" .. ps .. "session.vim" | ||
else | ||
session_file_path = session_file_path:gsub("{{PROJECT_DIR}}", vim.fn.getcwd()) | ||
end | ||
|
||
vim.api.nvim_create_autocmd("VimEnter", { | ||
callback = function(data) | ||
vim_enter_cb(data, config.project_dir_matchers, session_file_path, ps) | ||
end, | ||
group = augroup, | ||
nested = true, | ||
}) | ||
|
||
vim.api.nvim_create_autocmd("VimLeave", { | ||
callback = function() | ||
vim_leave_cb(session_file_path) | ||
end, | ||
group = augroup, | ||
}) | ||
end | ||
|
||
return M |
This file contains 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,24 @@ | ||
local AuCommands = require("kikao.config.aucommands") | ||
local M = {} | ||
|
||
M.defaults = { | ||
project_dir_matchers = { ".git", ".hg", ".bzr", ".svn" }, | ||
session_file_path = nil, | ||
} | ||
|
||
M.options = M.defaults | ||
|
||
M.setup = function(config) | ||
M.options = vim.tbl_deep_extend("force", M.defaults, config or {}) | ||
AuCommands.setup(M.options) | ||
end | ||
|
||
M.set = function(config) | ||
M.options = vim.tbl_deep_extend("force", M.options, config or {}) | ||
end | ||
|
||
M.get = function() | ||
return M.options | ||
end | ||
|
||
return M |
This file contains 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,5 @@ | ||
local M = {} | ||
|
||
M.VERSION = "1.0.0" | ||
|
||
return M |
This file contains 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,12 @@ | ||
local Globals = require("kikao.globals") | ||
|
||
local health = vim.health | ||
local info = health.info | ||
|
||
local M = {} | ||
|
||
M.check = function() | ||
info("{kikao.nvim} version " .. Globals.VERSION) | ||
end | ||
|
||
return M |
This file contains 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,15 @@ | ||
local Globals = require("kikao.globals") | ||
local Config = require("kikao.config") | ||
local Logger = require("kikao.logger") | ||
local M = {} | ||
|
||
M.setup = function(config) | ||
Config.setup(config) | ||
end | ||
|
||
M.version = function() | ||
local neovim_version = vim.fn.execute("version") or "Unknown" | ||
Logger.info("Kikao version: " .. Globals.VERSION .. "\n\n" .. "Neovim version: " .. neovim_version) | ||
end | ||
|
||
return M |
This file contains 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,25 @@ | ||
local M = {} | ||
|
||
local default_options = { | ||
title = "kikao", | ||
} | ||
|
||
local log_levels = vim.log.levels | ||
|
||
M.log = function(message) | ||
vim.notify(message, log_levels.INFO, default_options) | ||
end | ||
|
||
M.info = function(message) | ||
vim.notify(message, log_levels.INFO, default_options) | ||
end | ||
|
||
M.warn = function(message) | ||
vim.notify(message, log_levels.WARN, default_options) | ||
end | ||
|
||
M.error = function(message) | ||
vim.notify(message, log_levels.ERROR, default_options) | ||
end | ||
|
||
return M |
This file contains 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,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
GH_TAG="v$VERSION" | ||
|
||
set_version() { | ||
./scripts/set-version.sh | ||
} | ||
|
||
check_git_dirty() { | ||
if [[ -n $(git status -s) ]]; then | ||
echo "Working directory is dirty. Please commit or stash your changes before releasing." | ||
exit 1 | ||
fi | ||
} | ||
|
||
do_gh_release() { | ||
echo "Creating new release $GH_TAG" | ||
gh release create --generate-notes "$GH_TAG" | ||
} | ||
|
||
boot() { | ||
set_version | ||
check_git_dirty | ||
do_gh_release | ||
} | ||
|
||
boot |
This file contains 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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
update_lua_globals_version() { | ||
local tmp | ||
tmp=$(mktemp) | ||
sed -e "s/VERSION = \".*\"/VERSION = \"$VERSION\"/" ./lua/kikao/globals/init.lua > "$tmp" && mv "$tmp" ./lua/kikao/globals/init.lua | ||
} | ||
|
||
update_lua_globals_version |
This file contains 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,5 @@ | ||
indent_type = "Spaces" | ||
indent_width = 2 | ||
column_width = 120 | ||
[sort_requires] | ||
enabled = false |