Initial commit

This commit is contained in:
deytenit committed 2024-10-30 19:20:36 +03:00
commit 1eb9a11002
6 files changed
+244

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
# Lua bytecode
*.luac
# Lua language server and package manager files
.sumneko-lua/
.lua-dev/
.vscode/
# Temporary files
*.bak
*.swp
*.tmp
*.temp
*.DS_Store
# Neovim backup, swap, undo, and session files
*.sw?
*.swo
*.swn
*.swr
*.swp
*.swx
*.un~
*.un~
session.vim
# Output from builds or dependencies
dist/
build/
*.out
*.log
# Neovim plugins' lazy.nvim and packer.nvim related
site/
plugin/packer_compiled.lua
lazy-lock.json
node_modules/
# Cache directories
.cache/
.logs/
.venv/
.env/
__pycache__/
# Operating system files
Thumbs.db
desktop.ini
.DS_Store
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024-present Vladimir Eremin
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.
+71
View File
@@ -0,0 +1,71 @@
# sixty.nvim
Neovim plugin that disables arrow keys
and encourages using a 60% keyboard layout by displaying reminders.
## About
Remaps following keys to `<Nop>` as well notifying user to use 60% layout keys:
```lua
vim.keymap.set(
"{n,i,v,c}",
"{<Up>,<Down>,<Left>,<Right>}",
notifications.notify_arrow_usage,
{ remap = false, silent = true }
)
```
Also enables *tcsh-style* command line controls:
```lua
vim.keymap.set("c", "<C-A>", "<Home>", { remap = false })
vim.keymap.set("c", "<C-F>", "<Right>", { remap = false })
vim.keymap.set("c", "<C-B>", "<Left>", { remap = false })
```
## Installation
Using `lazy.nvim`, add this plugin as follows:
```lua
{
"deytenit/sixty.nvim",
config = function()
require("sixty").setup()
end,
}
```
> [!IMPORTANT]
> If you are using LazyVim, add the following to your `keymaps.lua`
> to ensure the arrow keys are disabled in normal mode:
```lua
-- sixty.nvim
local status, sixty = pcall(require, "sixty")
if status and sixty then
sixty.set("n", "<Up>")
sixty.set("n", "<Down>")
end
```
## Setup Options
You can pass options to `sixty.setup()` to customize the plugin's behavior:
- `notify_timeout` (default: `2000`):
Set the duration of the notification display in milliseconds.
Example:
```lua
require("sixty").setup({
notify_timeout = 3000, -- Notification will display for 3 seconds
})
```
## License
This project is licensed under the MIT License.
See the [LICENSE](./LICENSE) file for details.
+21
View File
@@ -0,0 +1,21 @@
--[[
sixty.nvim Configurations
Handles user configuration for the sixty.nvim plugin, specifically for notification settings.
Variables:
- notify_timeout: Timeout duration (in milliseconds) for notifications.
]]
local M = {}
--- Configures sixty.nvim with user-defined options or applies defaults.
-- If `notify_timeout` is not provided in `opts`, defaults to 2000 ms.
-- @param opts table User configuration options. Fields:
-- - notify_timeout (number): Sets the duration of the notification display in milliseconds.
function M.setup(opts)
M.notify_timeout = opts.notify_timeout or 2000
end
return M
+62
View File
@@ -0,0 +1,62 @@
--[[
sixty.nvim - Disables arrow keys and encourages using a 60% keyboard layout by displaying reminders.
Modules:
- config.lua: Stores and manages default configurations and custom options.
- notifications.lua: Contains notification logic for alerting users to use 60% layout.
Example Usage:
require("sixty").setup({
notify_timeout = 2000, -- Customize notification timeout in milliseconds
})
]]
local M = {}
local config = require("sixty.config")
local notifications = require("sixty.notifications")
--- Configures sixty.nvim using user-defined options or defaults.
-- Calls setup_keymaps to disable arrow keys across specified modes.
-- @param opts table User configuration options. See `config.lua` for available options.
function M.setup(opts)
opts = opts or {} -- Ensure opts is a table, even if nil
config.setup(opts)
M.setup_keymaps()
end
--- Disables arrow keys across specified modes (normal, insert, visual, and command)
-- and sets command-line keymaps for "tcsh"-style control movements.
function M.setup_keymaps()
local keys = { "<Up>", "<Down>", "<Left>", "<Right>" }
local modes = { "n", "i", "v", "c" } -- Normal, Insert, Visual, and Command modes
-- Set arrow key mappings in each specified mode
for _, key in ipairs(keys) do
for _, mode in ipairs(modes) do
M.set(mode, key)
end
end
-- Set command-line mode mappings for "tcsh"-style movement controls
vim.keymap.set("c", "<C-A>", "<Home>", { remap = false })
vim.keymap.set("c", "<C-F>", "<Right>", { remap = false })
vim.keymap.set("c", "<C-B>", "<Left>", { remap = false })
end
--- Disables a specific key in given mode(s) with a notification callback.
-- Calls `notifications.notify_arrow_usage` on key press to show an alert.
-- @param mode string|string[] Mode short-name (e.g., "n" for normal, "i" for insert, etc.).
-- @param lhs string Left-hand side (LHS) of the mapping to be disabled (e.g., "<Up>", "<Down>").
-- @param opts table? Options table for `vim.keymap.set`. Defaults to `{ remap = false, silent = true }`.
function M.set(mode, lhs, opts)
vim.keymap.set(
mode,
lhs,
notifications.notify_arrow_usage,
opts or { remap = false, silent = true }
)
end
return M
+20
View File
@@ -0,0 +1,20 @@
--[[
sixty.nvim Notifications
Displays notification messages of using non-60% keys
to encourage the user to adopt a 60% keyboard layout.
]]
local M = {}
--- Displays a notification reminding the user to use 60% layout keys.
-- The notification timeout is configured in `sixty.config`.
function M.notify_arrow_usage()
vim.notify("Use 60% keyboard keys for movement!", vim.log.levels.INFO, {
title = "sixty.nvim",
timeout = require("sixty.config").notify_timeout,
})
end
return M