chore: use stylua for formatting (#1040)

* chore: stylua job and config

* reformat with stylua
This commit is contained in:
Simon Hauser
2021-07-23 17:42:37 +02:00
committed by GitHub
parent 664690029f
commit 79644ab677
75 changed files with 3201 additions and 2809 deletions

View File

@@ -1,12 +1,13 @@
-- TODO: Customize keymap
local a = vim.api
local actions = require('telescope.actions')
local config = require('telescope.config')
local actions = require "telescope.actions"
local config = require "telescope.config"
local mappings = {}
mappings.default_mappings = config.values.default_mappings or {
mappings.default_mappings = config.values.default_mappings
or {
i = {
["<C-n>"] = actions.move_selection_next,
["<C-p>"] = actions.move_selection_previous,
@@ -28,7 +29,7 @@ mappings.default_mappings = config.values.default_mappings or {
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
["<C-l>"] = actions.complete_tag
["<C-l>"] = actions.complete_tag,
},
n = {
@@ -58,13 +59,14 @@ mappings.default_mappings = config.values.default_mappings or {
},
}
__TelescopeKeymapStore = __TelescopeKeymapStore or setmetatable({}, {
__index = function(t, k)
rawset(t, k, {})
__TelescopeKeymapStore = __TelescopeKeymapStore
or setmetatable({}, {
__index = function(t, k)
rawset(t, k, {})
return rawget(t, k)
end
})
return rawget(t, k)
end,
})
local keymap_store = __TelescopeKeymapStore
local _mapping_key_id = 0
@@ -81,7 +83,6 @@ local assign_function = function(prompt_bufnr, func)
return func_id
end
--[[
Usage:
@@ -107,22 +108,20 @@ local telescope_map = function(prompt_bufnr, mode, key_bind, key_func, opts)
end
opts = opts or {}
if opts.noremap == nil then opts.noremap = true end
if opts.silent == nil then opts.silent = true end
if opts.noremap == nil then
opts.noremap = true
end
if opts.silent == nil then
opts.silent = true
end
if type(key_func) == "string" then
key_func = actions[key_func]
elseif type(key_func) == "table" then
if key_func.type == "command" then
a.nvim_buf_set_keymap(
prompt_bufnr,
mode,
key_bind,
key_func[1],
opts or {
silent = true
}
)
a.nvim_buf_set_keymap(prompt_bufnr, mode, key_bind, key_func[1], opts or {
silent = true,
})
return
elseif key_func.type == "action_key" then
key_func = actions[key_func[1]]
@@ -158,13 +157,7 @@ local telescope_map = function(prompt_bufnr, mode, key_bind, key_func, opts)
)
end
a.nvim_buf_set_keymap(
prompt_bufnr,
mode,
key_bind,
map_string,
opts
)
a.nvim_buf_set_keymap(prompt_bufnr, mode, key_bind, map_string, opts)
end
mappings.apply_keymap = function(prompt_bufnr, attach_mappings, buffer_keymap)
@@ -184,7 +177,7 @@ mappings.apply_keymap = function(prompt_bufnr, attach_mappings, buffer_keymap)
if attach_results == nil then
error(
"Attach mappings must always return a value. `true` means use default mappings, "
.. "`false` means only use attached mappings"
.. "`false` means only use attached mappings"
)
end
@@ -218,24 +211,15 @@ mappings.apply_keymap = function(prompt_bufnr, attach_mappings, buffer_keymap)
end
end
vim.cmd(string.format(
[[autocmd BufDelete %s :lua require('telescope.mappings').clear(%s)]],
prompt_bufnr,
prompt_bufnr
))
vim.cmd(
string.format([[autocmd BufDelete %s :lua require('telescope.mappings').clear(%s)]], prompt_bufnr, prompt_bufnr)
)
end
mappings.execute_keymap = function(prompt_bufnr, keymap_identifier)
local key_func = keymap_store[prompt_bufnr][keymap_identifier]
assert(
key_func,
string.format(
"Unsure of how we got this failure: %s %s",
prompt_bufnr,
keymap_identifier
)
)
assert(key_func, string.format("Unsure of how we got this failure: %s %s", prompt_bufnr, keymap_identifier))
key_func(prompt_bufnr)
end