commit cba60e8cf46970f4a6df417bb99498ced988bc02
parent bcef0f29d1c088d05cdb8abab29657951fc28022
Author: Tomas Nemec <owl@gtms.dev>
Date: Mon, 18 Mar 2024 16:12:31 +0100
update
Diffstat:
5 files changed, 92 insertions(+), 17 deletions(-)
diff --git a/after/plugin/format.lua b/after/plugin/format.lua
@@ -5,8 +5,9 @@ end
local prettier = { { --[[ 'prettierd', ]] 'prettier' } }
-- local util = require 'conform.util'
require 'conform'.setup {
- formatters_by_ft = { html = prettier, css = prettier, scss = prettier },
+ formatters_by_ft = { sh = { 'shfmt' }, bash = { 'shfmt' }, zsh = { 'shfmt' }, yaml = prettier, html = prettier, css = prettier, scss = prettier },
formatters = {
+ shfmt = {},
prettier = {
prepend_args = {
'--plugin=/home/tms/.local/share/npm/lib/node_modules/prettier-plugin-organize-attributes/lib/index.js',
diff --git a/after/plugin/leap.lua b/after/plugin/leap.lua
@@ -20,7 +20,7 @@ leap.add_default_mappings()
if pcall(require, 'tms.p.leap.ast') then
vim.keymap.set({ 'n', 'x', 'o' }, 'gp', function()
- require('tms.p.leap.ast').parent()
+ require 'tms.p.leap.ast'.parent()
end, { desc = 'Leap AST Parent' })
local leap_ast_group = vim.api.nvim_create_augroup('leap-ast', {})
@@ -28,7 +28,7 @@ if pcall(require, 'tms.p.leap.ast') then
group = leap_ast_group,
pattern = 'LeapEnter',
callback = function()
- if require('leap').state.args.ast then
+ if require 'leap'.state.args.ast then
ast_highlights()
end
end,
@@ -46,17 +46,21 @@ if pcall(require, 'tms.p.leap.ast') then
})
end
-if pcall(require, 'leap-spooky') then
- require('leap-spooky').setup {
- affixes = {
- -- These will generate mappings for all native text objects, like:
- -- (ir|ar|iR|aR|im|am|iM|aM){obj}.
- -- Special line objects will also be added, by repeating the affixes.
- -- E.g. `yrr<leap>` and `ymm<leap>` will yank a line in the current
- -- window.
- -- You can also use 'rest' & 'move' as mnemonics.
- remote = { window = 'r', cross_window = 'R' },
- -- magnetic = { window = 'm', cross_window = 'M' },
- },
- }
+if pcall(require, 'telepath') then
+ require 'telepath'.use_default_mappings()
end
+
+-- if pcall(require, 'leap-spooky') then
+-- require 'leap-spooky'.setup {
+-- affixes = {
+-- -- These will generate mappings for all native text objects, like:
+-- -- (ir|ar|iR|aR|im|am|iM|aM){obj}.
+-- -- Special line objects will also be added, by repeating the affixes.
+-- -- E.g. `yrr<leap>` and `ymm<leap>` will yank a line in the current
+-- -- window.
+-- -- You can also use 'rest' & 'move' as mnemonics.
+-- remote = { window = 'r', cross_window = 'R' },
+-- -- magnetic = { window = 'm', cross_window = 'M' },
+-- },
+-- }
+-- end
diff --git a/after/plugin/qmk.lua b/after/plugin/qmk.lua
@@ -286,7 +286,6 @@ if pcall(require, 'qmk') then
'x x x x x x _ _ _ _ x x x x x x',
'x x x x x x x _ _ x x x x x x x',
'x x x x x _ _ _ _ _ _ x x x x x',
- '_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _',
'_ _ _ _ _ x x _ _ x x _ _ _ _ _',
'_ _ _ _ _ _ x _ _ x _ _ _ _ _ _',
'_ _ _ _ x x x _ _ x x x _ _ _ _',
diff --git a/lua/plugins.lua b/lua/plugins.lua
@@ -9,6 +9,7 @@ return require('paq') {
'xxdavid/bez-diakritiky.vim',
'ggandor/leap.nvim',
'ggandor/leap-spooky.nvim',
+ 'rasulomaroff/telepath.nvim',
'tpope/vim-repeat',
'kylechui/nvim-surround',
'chaoren/vim-wordmotion',
diff --git a/lua/tms/p/manual_pairs.lua b/lua/tms/p/manual_pairs.lua
@@ -0,0 +1,70 @@
+-- © 2024 Adam Blažek <adam@whizzmot.dev>
+-- SPDX-License-Identifier: GPL-3.0-or-later
+
+-- Constants
+local modes = { "c", "i" }
+local key_left = { c = "<left>", i = "<c-g>U<left>" }
+local key_right = { c = "<right>", i = "<c-g>U<right>" }
+
+-- Escapes a string for vim.keymap.set().
+local function escape_keycodes(str)
+ return str:gsub("<", "<lt>")
+end
+
+-- Escapes a string for vim.fn.search().
+local function escape_search(str)
+ return [[\V\C]] .. str:gsub([[\]], [[\\]])
+end
+
+-- Creates a mapping for inserting a pair of delimiters.
+local function map_pair(key, left, right)
+ local right_len = vim.fn.strcharlen(right)
+ for _, mode in ipairs(modes) do
+ local mapping = escape_keycodes(left .. right) .. key_left[mode]:rep(right_len)
+ vim.keymap.set(mode, key, mapping, {
+ desc = "[manual-pairs] Pair: " .. left .. "•" .. right,
+ })
+ end
+end
+
+-- Creates a mapping for skipping past the nearest delimiter.
+local function map_fly(key, right)
+ vim.keymap.set("i", key, function()
+ if vim.fn.search(right, "ceWz", 1000) ~= 0 then
+ vim.api.nvim_input(key_right["i"])
+ end
+ end, {
+ desc = "[manual-pairs] Fly: " .. right,
+ })
+end
+
+-- Creates a mapping for creating an empty line at the current cursor position.
+local function map_cr(key)
+ vim.keymap.set("i", key, "<cr><c-o>O", {
+ desc = "[manual-pairs] CR",
+ })
+end
+
+-- Creates a mapping for moving the cursor to the right.
+local function map_right(key)
+ for _, mode in ipairs(modes) do
+ vim.keymap.set(mode, key, key_right[mode], {
+ desc = "[manual-pairs] Right",
+ })
+ end
+end
+
+-- Creates a mappping for deleting one character to the left and right of the cursor.
+local function map_backspace(key)
+ vim.keymap.set(modes, key, "<bs><del>", {
+ desc = "[manual-pairs] Backspace",
+ })
+end
+
+return {
+ map_pair = map_pair,
+ map_fly = map_fly,
+ map_cr = map_cr,
+ map_right = map_right,
+ map_backspace = map_backspace,
+}