Skip to content

Commit

Permalink
Revert "feat: Add description to keymaps and WhichKey (#8)"
Browse files Browse the repository at this point in the history
This reverts commit 576e774.
  • Loading branch information
johmsalas authored Jun 9, 2022
1 parent 576e774 commit 0c67a09
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 102 deletions.
28 changes: 0 additions & 28 deletions lua/textcase/extensions/whichkey.lua

This file was deleted.

28 changes: 11 additions & 17 deletions lua/textcase/plugin/plugin.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local utils = require("textcase.shared.utils")
local constants = require("textcase.shared.constants")
local conversion = require("textcase.plugin.conversion")
local config = require("textcase.plugin.config")
local flag_incremental_preview = vim.fn.has("nvim-0.8-dev+374-ge13dcdf16") == 1

local M = {}
Expand All @@ -15,7 +16,7 @@ M.state = {
substitute = {},
}

function M.register_keybindings(prefix, method_table, keybindings, opts)
function M.register_keybindings(method_table, keybindings, opts)
-- TODO: validate method_table
M.state.methods_by_desc[method_table.desc] = method_table
M.state.methods_by_desc[method_table.desc].opts = opts
Expand All @@ -33,30 +34,19 @@ function M.register_keybindings(prefix, method_table, keybindings, opts)
if feature == 'visual' then
mode = 'v'
end
local desc = method_table.desc

if feature == 'current_word' then
desc = 'Convert ' .. desc
elseif feature == 'lsp_rename' then
desc = 'LSP rename ' .. desc
end

vim.keymap.set(
vim.api.nvim_set_keymap(
mode,
prefix .. keybindings[feature],
keybindings[feature],
"<cmd>lua require('" .. constants.namespace .. "')." .. feature .. "('" .. method_table.desc .. "')<cr>",
{ desc = desc }
{ noremap = true }
)

end
end

-- whichkey.register_batch(prefix)
end

function M.register_keys(prefix, method_table, keybindings)
function M.register_keys(method_table, keybindings)
-- Sugar syntax
M.register_keybindings(prefix, method_table, {
M.register_keybindings(method_table, {
line = keybindings[1],
eol = keybindings[2],
visual = keybindings[3],
Expand Down Expand Up @@ -123,6 +113,10 @@ function M.incremental_substitute(opts, preview_ns, preview_buf)
local source, dest = params[2], params[3]
local buf = (preview_ns ~= nil) and preview_buf or vim.api.nvim_get_current_buf()

if M.state.substitute.list == nil then

end

local cursor_pos = vim.fn.getpos(".")
vim.api.nvim_buf_clear_namespace(buf, 1, 0, -1)

Expand Down
92 changes: 35 additions & 57 deletions lua/textcase/plugin/presets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,45 @@ local M = {}

local plugin = require('textcase.plugin.plugin')
local api = require('textcase.plugin.api')
local whichkey = require("textcase.extensions.whichkey")

M.setup = function(opts)
local prefix = opts and opts.prefix or 'ga'

whichkey.register('v', {
[prefix] = {
name = 'text-case',
}
})

whichkey.register('n', {
[prefix] = {
name = 'text-case',
o = {
name = 'Pending mode operator'
}
}
})

plugin.register_keybindings(prefix, api.to_constant_case, {
prefix = prefix,
current_word = 'n',
visual = 'n',
operator = 'on',
lsp_rename = 'N',
})
plugin.register_keybindings(prefix, api.to_camel_case, {
prefix = prefix,
current_word = 'c',
visual = 'c',
operator = 'oc',
lsp_rename = 'C',
})
plugin.register_keybindings(prefix, api.to_dash_case, {
prefix = prefix,
current_word = 'd',
visual = 'd',
operator = 'od',
lsp_rename = 'D',
})
plugin.register_keybindings(prefix, api.to_pascal_case, {
prefix = prefix,
current_word = 'p',
visual = 'p',
operator = 'op',
lsp_rename = 'P',
})
plugin.register_keybindings(prefix, api.to_upper_case, {
prefix = prefix,
current_word = 'u',
visual = 'u',
operator = 'ou',
lsp_rename = 'U',
})
plugin.register_keybindings(prefix, api.to_lower_case, {
prefix = prefix,
current_word = 'l',
visual = 'l',
operator = 'ol',
lsp_rename = 'L',
plugin.register_keybindings(api.to_constant_case, {
current_word = prefix .. 'n',
visual = prefix .. 'n',
operator = prefix .. 'on',
lsp_rename = prefix .. 'N',
})
plugin.register_keybindings(api.to_camel_case, {
current_word = prefix .. 'c',
visual = prefix .. 'c',
operator = prefix .. 'oc',
lsp_rename = prefix .. 'C',
})
plugin.register_keybindings(api.to_dash_case, {
current_word = prefix .. 'd',
visual = prefix .. 'd',
operator = prefix .. 'od',
lsp_rename = prefix .. 'D',
})
plugin.register_keybindings(api.to_pascal_case, {
current_word = prefix .. 'p',
visual = prefix .. 'p',
operator = prefix .. 'op',
lsp_rename = prefix .. 'P',
})
plugin.register_keybindings(api.to_upper_case, {
current_word = prefix .. 'u',
visual = prefix .. 'u',
operator = prefix .. 'ou',
lsp_rename = prefix .. 'U',
})
plugin.register_keybindings(api.to_lower_case, {
current_word = prefix .. 'l',
visual = prefix .. 'l',
operator = prefix .. 'ol',
lsp_rename = prefix .. 'L',
})

plugin.register_replace_command('Subs', {
Expand Down

0 comments on commit 0c67a09

Please sign in to comment.