aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
commit5f6142f224ac128d62c4cb5c7d4acf45db19e5c2 (patch)
tree3630b6d24bac761c3e0c2381112fb4ec63d83f2e /lua
parent76c51d6b471250550afd0461b4ea4316a5b4f506 (diff)
downloadnvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.tar.gz
nvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.zip
Apply stylelua and clean
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/lsp.lua83
-rw-r--r--lua/alpha/snippets/config.lua34
-rw-r--r--lua/alpha/snippets/init.lua2
-rw-r--r--lua/alpha/snippets/php.lua150
-rw-r--r--lua/alpha/snips/ft/go.lua188
-rw-r--r--lua/alpha/snips/ft/php.lua197
-rw-r--r--lua/alpha/telescope/init.lua185
-rw-r--r--lua/alpha/telescope/mappings.lua29
8 files changed, 339 insertions, 529 deletions
diff --git a/lua/alpha/lsp.lua b/lua/alpha/lsp.lua
index bd6b449..d0ac991 100644
--- a/lua/alpha/lsp.lua
+++ b/lua/alpha/lsp.lua
@@ -1,70 +1,67 @@
-local telescope_mapper = require "alpha.telescope.mappings"
+local telescope_mapper = require("alpha.telescope.mappings")
local filetype_attach = setmetatable({
- go = function(_)
- vim.cmd [[
+ go = function(_)
+ vim.cmd([[
augroup lsp_buf_format
au! BufWritePre <buffer>
autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_sync()
augroup END
- ]]
- end,
+ ]])
+ end,
}, {
- __index = function()
- return function() end
- end,
+ __index = function()
+ return function() end
+ end,
})
local function on_attach(client)
- local filetype = vim.api.nvim_buf_get_option(0, "filetype")
- -- keymaps for lsp
- vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
- vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, { buffer = 0 })
- vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
- vim.keymap.set("n", "<leader>vf", vim.lsp.buf.formatting, { buffer = 0 })
- vim.keymap.set("n", "<leader>vn", vim.lsp.diagnostic.goto_next, { buffer = 0 })
- vim.keymap.set("n", "<leader>vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 })
+ local filetype = vim.api.nvim_buf_get_option(0, "filetype")
+ -- keymaps for lsp
+ vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
+ vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vf", vim.lsp.buf.formatting, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vn", vim.lsp.diagnostic.goto_next, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 })
- telescope_mapper("gr", "lsp_references", nil, true)
- telescope_mapper("<leader>pv", "find_symbol", nil, true)
+ telescope_mapper("gr", "lsp_references", nil, true)
+ telescope_mapper("<leader>pv", "find_symbol", nil, true)
- vim.api.nvim_set_keymap('n', '<leader>vo', ':LspRestart<cr>', {noremap = true})
+ vim.api.nvim_set_keymap("n", "<leader>vo", ":LspRestart<cr>", { noremap = true })
- require "lsp_signature".on_attach()
+ require("lsp_signature").on_attach()
- vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
- -- Attach any filetype specific options to the client
- filetype_attach[filetype](client)
+ vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
+ -- Attach any filetype specific options to the client
+ filetype_attach[filetype](client)
end
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.on_server_ready(function(server)
- local opts = {}
+ local opts = {}
- -- (optional) Customize the options passed to the server
- if server.name == "emmet_ls" then
- opts.filetypes = {"html", "css", "blade", "typescriptreact"}
- end
+ -- (optional) Customize the options passed to the server
+ if server.name == "emmet_ls" then
+ opts.filetypes = { "html", "css", "blade", "typescriptreact" }
+ end
- opts.on_attach = on_attach
- -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
- server:setup(opts)
- vim.cmd [[ do User LspAttachBuffers ]]
+ opts.on_attach = on_attach
+ -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
+ server:setup(opts)
+ vim.cmd([[ do User LspAttachBuffers ]])
end)
-
-vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
- vim.lsp.diagnostic.on_publish_diagnostics, {
- underline = true,
- update_in_insert = false,
- virtual_text = { spacing = 2, prefix = "●" },
- severity_sort = true,
- }
-)
+vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ underline = true,
+ update_in_insert = false,
+ virtual_text = { spacing = 2, prefix = "●" },
+ severity_sort = true,
+})
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
- local hl = "DiagnosticSign" .. type
- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
diff --git a/lua/alpha/snippets/config.lua b/lua/alpha/snippets/config.lua
deleted file mode 100644
index e28c570..0000000
--- a/lua/alpha/snippets/config.lua
+++ /dev/null
@@ -1,34 +0,0 @@
-local ls = require"luasnip"
--- local s = ls.snippet
--- local sn = ls.snippet_node
--- local t = ls.text_node
--- local i = ls.insert_node
--- local f = ls.function_node
--- local c = ls.choice_node
--- local d = ls.dynamic_node
--- local types = require("luasnip.util.types")
-
--- Every unspecified option will be set to the default.
-ls.config.set_config({
- history = true,
- -- Update more often, :h events for more info.
- updateevents = "TextChanged,TextChangedI",
- -- ext_opts = {
- -- [types.choiceNode] = {
- -- active = {
- -- virt_text = { { "choiceNode", "Comment" } },
- -- },
- -- },
- -- },
- -- treesitter-hl has 100, use something higher (default is 200).
- ext_base_prio = 300,
- -- minimal increase in priority.
- ext_prio_increase = 1,
- enable_autosnippets = true,
-})
-
--- ls.snippets = {
--- php = require('alpha.snippets.php')
--- }
-
-vim.api.nvim_set_keymap("i", "<c-k>", "<Plug>luasnip-expand-or-jump", {})
diff --git a/lua/alpha/snippets/init.lua b/lua/alpha/snippets/init.lua
deleted file mode 100644
index 316e66b..0000000
--- a/lua/alpha/snippets/init.lua
+++ /dev/null
@@ -1,2 +0,0 @@
-require('alpha.snippets.config')
-require('alpha.snippets.php')
diff --git a/lua/alpha/snippets/php.lua b/lua/alpha/snippets/php.lua
deleted file mode 100644
index 9fd4e58..0000000
--- a/lua/alpha/snippets/php.lua
+++ /dev/null
@@ -1,150 +0,0 @@
-local ls = require"luasnip"
-local s = ls.snippet
-local sn = ls.snippet_node
-local t = ls.text_node
-local i = ls.insert_node
-local c = ls.choice_node
-local d = ls.dynamic_node
--- local f = ls.function_node
--- local l = require("luasnip.extras").lambda
--- local conds = require("luasnip.extras.expand_conditions")
-
--- visibility allows to reuse it pasing the first option to show for the
--- snippet
-local visibility
-visibility = function (_, _, _, initial_text)
- local possibles = {'private', 'public', 'protected'}
- local options = {}
-
- for _, value in pairs(possibles) do
- if value == initial_text then
- table.insert(options, 1, t(value .. ' ') )
- else
- table.insert(options, t(value .. ' '))
- end
- end
-
- return sn(nil, { c(1, options) })
-end
-
-local releation
-releation = function (_, snip,_, type)
- local relationType = type
- local relationName = snip.captures[1]
-
- return sn(nil, {
- -- I would like t o auto import the relation but for now just ommit it
- -- t({"public function ".. relationName:gsub("^%u", string.lower) .. "(): " .. relationType:gsub("^%l", string.upper) , "{", ""}),
- t({"public function ".. relationName:gsub("^%u", string.lower) .. "()" , "{", ""}),
- t({"\treturn $this->".. relationType .. "(".. relationName .. "::class);", "}"}),
- })
-end
-
-local promo_property
-promo_property = function()
- return sn(
- nil,
- c(1, {
- -- Order is important, sn(...) first would cause infinite loop of expansion.
- t(""),
- sn(nil, {
- t({ "", "\t" }),
- d(1, visibility, {}, "private"),
- i(2, '$var'),
- t(","),
- d(3, promo_property, {})
- }),
- })
- )
-end
-
-ls.snippets = {
- php = {
- -- variable
- s("v", {
- t({ "/**", " * @var " }),
- i(1, "types"),
- t({""," */", "private $"}),
- i(2, "name"),
- t(";", ""),
- }),
-
- -- __construct
- s("_c", {
- d(1, visibility, {}, "public"),
- t('function __construct('),
- c(2, {
- sn(nil, {
- i(1, '$var'),
- t({")", "{", "\t"}),
- i(2, ''),
- t({"", "}"}),
- }),
- sn(nil, {
- d(1, promo_property, {}),
- t({"",") {", "}"}),
- }),
- }),
- }),
-
- -- function
- s("fn", {
- d(1, visibility, {}, "public"),
- t("function "),
- i(2, "name"),
- t("("),
- i(3, "$arg"),
- t(")"),
- c(4, {
- sn(nil, {
- t(': '),
- i(1, "void"),
- }),
- t(""),
- }),
- t({"", "{", ""}),
- t("\t"), i(0, ""),
- t({"", "}"})
- }),
-
- -- Route
- s("ro", {
- t("Route::"),
- c(1, {
- t("get"),
- t("post"),
- t("put"),
- t("view"),
- }),
- t("('"),
- i(2, "uri"),
- t("', "),
- c(3, {
- sn(nil, {
- t({'function () {', '\t'}),
- i(1, ''),
- t({'', '});'}),
- }),
- sn(nil, {
- t('['),
- i(1, 'Controller'),
- t("::class, '"),
- i(2, 'method'),
- t("']);"),
- })
- }),
- }),
- }
-}
-
-local relationTypes = {"hasOne", "belongsTo", "hasMany", "belongsToMany"}
-for _, type in pairs(relationTypes) do
- table.insert(ls.snippets.php,
- s(
- { trig= type .. "(.*)", regTrig=true },
- {
- d(1, releation, {}, type),
- }
- )
- )
-end
diff --git a/lua/alpha/snips/ft/go.lua b/lua/alpha/snips/ft/go.lua
index 1021721..6038d52 100644
--- a/lua/alpha/snips/ft/go.lua
+++ b/lua/alpha/snips/ft/go.lua
@@ -8,15 +8,15 @@ local i = ls.insert_node
local rep = require("luasnip.extras").rep
local fmt = require("luasnip.extras.fmt").fmt
-local ts_locals = require "nvim-treesitter.locals"
-local ts_utils = require "nvim-treesitter.ts_utils"
+local ts_locals = require("nvim-treesitter.locals")
+local ts_utils = require("nvim-treesitter.ts_utils")
local get_node_text = vim.treesitter.get_node_text
vim.treesitter.set_query(
- "go",
- "LuaSnip_Result",
- [[
+ "go",
+ "LuaSnip_Result",
+ [[
[
(method_declaration result: (_) @id)
(function_declaration result: (_) @id)
@@ -26,107 +26,107 @@ vim.treesitter.set_query(
)
local transform = function(text, info)
- if text == "int" then
- return t "0"
- elseif text == "error" then
- if info then
- info.index = info.index + 1
-
- return c(info.index, {
- t(string.format('errors.Wrap(%s, "%s")', info.err_name, info.func_name)),
- t(info.err_name),
- })
- else
- return t "err"
- end
- elseif text == "bool" then
- return t "false"
- elseif text == "string" then
- return t '""'
- elseif string.find(text, "*", 1, true) then
- return t "nil"
- end
-
- return t(text)
+ if text == "int" then
+ return t("0")
+ elseif text == "error" then
+ if info then
+ info.index = info.index + 1
+
+ return c(info.index, {
+ t(string.format('fmt.Errorf("%s %%w", %s)', info.func_name, info.err_name)),
+ t(info.err_name),
+ })
+ else
+ return t("err")
+ end
+ elseif text == "bool" then
+ return t("false")
+ elseif text == "string" then
+ return t('""')
+ elseif string.find(text, "*", 1, true) then
+ return t("nil")
+ end
+
+ return t(text)
end
local handlers = {
- ["parameter_list"] = function(node, info)
- local result = {}
-
- local count = node:named_child_count()
- for idx = 0, count - 1 do
- table.insert(result, transform(get_node_text(node:named_child(idx), 0), info))
- if idx ~= count - 1 then
- table.insert(result, t { ", " })
- end
- end
-
- return result
- end,
-
- ["type_identifier"] = function(node, info)
- local text = get_node_text(node, 0)
- return { transform(text, info) }
- end,
+ ["parameter_list"] = function(node, info)
+ local result = {}
+
+ local count = node:named_child_count()
+ for idx = 0, count - 1 do
+ table.insert(result, transform(get_node_text(node:named_child(idx), 0), info))
+ if idx ~= count - 1 then
+ table.insert(result, t({ ", " }))
+ end
+ end
+
+ return result
+ end,
+
+ ["type_identifier"] = function(node, info)
+ local text = get_node_text(node, 0)
+ return { transform(text, info) }
+ end,
}
local function go_result_type(info)
- local cursor_node = ts_utils.get_node_at_cursor()
- local scope = ts_locals.get_scope_tree(cursor_node, 0)
-
- local function_node
- for _, v in ipairs(scope) do
- if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then
- function_node = v
- break
- end
- end
-
- local query = vim.treesitter.get_query("go", "LuaSnip_Result")
- for _, node in query:iter_captures(function_node, 0) do
- if handlers[node:type()] then
- return handlers[node:type()](node, info)
- end
- end
+ local cursor_node = ts_utils.get_node_at_cursor()
+ local scope = ts_locals.get_scope_tree(cursor_node, 0)
+
+ local function_node
+ for _, v in ipairs(scope) do
+ if v:type() == "function_declaration" or v:type() == "method_declaration" or v:type() == "func_literal" then
+ function_node = v
+ break
+ end
+ end
+
+ local query = vim.treesitter.get_query("go", "LuaSnip_Result")
+ for _, node in query:iter_captures(function_node, 0) do
+ if handlers[node:type()] then
+ return handlers[node:type()](node, info)
+ end
+ end
end
local go_ret_vals = function(args)
- local info = { index = 0, err_name = args[1][1], func_name = args[2][1] }
- return snippet_from_nodes(nil, go_result_type(info))
+ local info = { index = 0, err_name = args[1][1], func_name = args[2][1] }
+ return snippet_from_nodes(nil, go_result_type(info))
end
local M = {
- main = {
- t { "func main() {", "\t" },
- i(0),
- t { "", "}" },
- },
- ef = {
- i(1, { "val" }),
- t ", err := ",
- i(2, { "f" }),
- t "(",
- i(3),
- t ")",
- i(0),
- },
- efi = {
- i(1, { "val" }),
- ", ",
- i(2, { "err" }),
- " := ",
- i(3, { "f" }),
- "(",
- i(4),
- ")",
- t { "", "if " },
- rep(2),
- t { " != nil {", "\treturn " },
- d(5, go_ret_vals, { 2, 3 }),
- t { "", "}" },
- i(0),
- },
+ main = {
+ t({ "func main() {", "\t" }),
+ i(0),
+ t({ "", "}" }),
+ },
+ ef = {
+ i(1, { "val" }),
+ t(", err := "),
+ i(2, { "f" }),
+ t("("),
+ i(3),
+ t(")"),
+ i(0),
+ },
+ efi = {
+ i(1, { "val" }),
+ ", ",
+ i(2, { "err" }),
+ " := ",
+ i(3, { "f" }),
+ "(",
+ i(4),
+ ")",
+ t({ "", "if " }),
+ rep(2),
+ t({ " != nil {", "\treturn " }),
+ d(5, go_ret_vals, { 2, 3 }),
+ t({ "", "}" }),
+ i(0),
+ },
}
M.f = fmt("func {}({}) {} {{\n\t{}\n}}", { i(1, "name"), i(2), i(3), i(0) })
diff --git a/lua/alpha/snips/ft/php.lua b/lua/alpha/snips/ft/php.lua
index 40560b8..daf1e77 100644
--- a/lua/alpha/snips/ft/php.lua
+++ b/lua/alpha/snips/ft/php.lua
@@ -8,68 +8,69 @@ local f = ls.function_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
-
-function string.starts(String,Start)
- return string.sub(String,1,string.len(Start))==Start
+function string.starts(String, Start)
+ return string.sub(String, 1, string.len(Start)) == Start
end
local newline = function(text)
- return t { "", text }
+ return t({ "", text })
end
-local visibility = function (position, default)
- local possibles = {'private', 'public'}
- local options = {}
+local visibility = function(position, default)
+ local possibles = { "private", "public" }
+ local options = {}
- for _, value in pairs(possibles) do
- if value == default then
- table.insert(options, 1, t(value))
- else
- table.insert(options, t(value))
- end
- end
+ for _, value in pairs(possibles) do
+ if value == default then
+ table.insert(options, 1, t(value))
+ else
+ table.insert(options, t(value))
+ end
+ end
- return c(position, options)
+ return c(position, options)
end
-local namespace = function ()
- local dir = vim.fn.getcwd()
- local autoloads = vim.call('composer#query', 'autoload.psr-4')
- if autoloads == nil then
- return (dir:gsub("^%l", string.upper))
- end
-
- local globalNamespace
- for key, value in pairs(autoloads) do
- if string.starts(dir, value:sub(1, -2)) then
- globalNamespace = key:sub(1, -2);
- dir = dir:sub(#key + 1)
- break
- end
- end
- dir = dir:gsub("/", "\\")
-
- return string.format("%s\\%s",globalNamespace, dir )
+local namespace = function()
+ local dir = vim.fn.getcwd()
+ local autoloads = vim.call("composer#query", "autoload.psr-4")
+ if autoloads == nil then
+ return (dir:gsub("^%l", string.upper))
+ end
+
+ local globalNamespace
+ for key, value in pairs(autoloads) do
+ if string.starts(dir, value:sub(1, -2)) then
+ globalNamespace = key:sub(1, -2)
+ dir = dir:sub(#key + 1)
+ break
+ end
+ end
+ dir = dir:gsub("/", "\\")
+
+ return string.format("%s\\%s", globalNamespace, dir)
end
-local class_name = function ()
- local filename = vim.fn.expand('%:t:r')
- return filename
+local class_name = function()
+ return vim.fn.expand("%:t:r")
end
+
local M = {
- v = fmt(
-[[
+ v = fmt(
+ [[
/**
* @var {}
*/
{} ${};
-]], {
- i(1, "type"),
- d(2, visibility, {}, "private"),
- i(3, "var")
- }),
- class = fmt(
-[[
+]],
+ {
+ i(1, "type"),
+ d(2, visibility, {}, "private"),
+ i(3, "var"),
+ }
+ ),
+ class = fmt(
+ [[
<?php
declare(strict_types=1);
@@ -81,66 +82,64 @@ class {}
{}
}}
]],
- {
- f(namespace),
- f(class_name),
- i(0),
- }),
-
- pro = fmt(
- [[{} {} ${},]],
- {
- visibility(1, "private"),
- i(2, 'Type'),
- f( function (args)
- return args[1][1]:gsub("^%u", string.lower)
- end, {2}),
- }
- ),
-
- _c = fmt(
+ {
+ f(namespace),
+ f(class_name),
+ i(0),
+ }
+ ),
+
+ pro = fmt([[{} {} ${},]], {
+ visibility(1, "private"),
+ i(2, "Type"),
+ f(function(args)
+ return args[1][1]:gsub("^%u", string.lower)
+ end, { 2 }),
+ }),
+
+ _c = fmt(
[[{} function __construct({}) {{
{}
}}]],
- {
- visibility(1, "public"),
- i(2),
- i(0)
- }
- ),
-
- _p = fmt(
-[[{} function __construct(
+ {
+ visibility(1, "public"),
+ i(2),
+ i(0),
+ }
+ ),
+
+ _p = fmt(
+ [[{} function __construct(
{}
) {{
}}]],
- {
- visibility(1, "public"),
- i(2),
- }
- ),
-
- fn = {
- visibility(1, "public"),
- t(" function "),
- i(2, "name"),
- t("("),
- i(3, "$arg"),
- t(")"),
- c(4, {
- t(""),
- snippet_from_nodes(nil, {
- t(': '),
- i(1, "void"),
- }),
- }),
- newline "{",
- newline "\t",
- i(0, ""),
- newline "}",
- },
-
- strict = t "declare(strict_types=1);",
+ {
+ visibility(1, "public"),
+ i(2),
+ }
+ ),
+
+ fn = {
+ visibility(1, "public"),
+ t(" function "),
+ i(2, "name"),
+ t("("),
+ i(3, "$arg"),
+ t(")"),
+ c(4, {
+ t(""),
+ snippet_from_nodes(nil, {
+ t(": "),
+ i(1, "void"),
+ }),
+ }),
+ newline("{"),
+ newline("\t"),
+ i(0, ""),
+ newline("}"),
+ },
+
+ strict = t("declare(strict_types=1);"),
}
return M
diff --git a/lua/alpha/telescope/init.lua b/lua/alpha/telescope/init.lua
index 608e6cf..904fdbc 100644
--- a/lua/alpha/telescope/init.lua
+++ b/lua/alpha/telescope/init.lua
@@ -1,145 +1,148 @@
SHOULD_RELOAD_TELESCOPE = true
local reloader = function()
- if SHOULD_RELOAD_TELESCOPE then
- RELOAD "plenary"
- RELOAD "telescope"
- RELOAD "alpha.telescope.setup"
- end
+ if SHOULD_RELOAD_TELESCOPE then
+ RELOAD("plenary")
+ RELOAD("telescope")
+ RELOAD("alpha.telescope.setup")
+ end
end
-local action_state = require "telescope.actions.state"
-local fb_actions = require "telescope".extensions.file_browser.actions
-local actions = require('telescope.actions')
+local action_state = require("telescope.actions.state")
+local fb_actions = require("telescope").extensions.file_browser.actions
+local actions = require("telescope.actions")
local M = {}
function M.project_files()
- local opts = {} -- define here if you want to define something
- local ok = pcall(require'telescope.builtin'.git_files, opts)
- if not ok then require'telescope.builtin'.find_files(opts) end
+ local opts = {} -- define here if you want to define something
+ local ok = pcall(require("telescope.builtin").git_files, opts)
+ if not ok then
+ require("telescope.builtin").find_files(opts)
+ end
end
function M.branches()
- require'telescope.builtin'.git_branches({ attach_mappings = function(_, map)
- map('i', '<c-j>', actions.git_create_branch)
- map('n', '<c-j>', actions.git_create_branch)
- return true
- end})
+ require("telescope.builtin").git_branches({
+ attach_mappings = function(_, map)
+ map("i", "<c-j>", actions.git_create_branch)
+ map("n", "<c-j>", actions.git_create_branch)
+ return true
+ end,
+ })
end
function M.search_config()
- require("telescope.builtin").git_files({
- prompt_title = "< dotfiles >",
- cwd = "$HOME/.dotfiles",
- })
+ require("telescope.builtin").git_files({
+ prompt_title = "< dotfiles >",
+ cwd = "$HOME/.dotfiles",
+ })
end
function M.grep_string()
- vim.ui.input("Grep for > ", function (input)
- if input == nil then
- return
- end
- require('telescope.builtin').grep_string({ search = input})
- end)
+ vim.ui.input("Grep for > ", function(input)
+ if input == nil then
+ return
+ end
+ require("telescope.builtin").grep_string({ search = input })
+ end)
end
function M.grep_word()
- require('telescope.builtin').grep_string({ search = vim.fn.expand("<cword>")})
+ require("telescope.builtin").grep_string({ search = vim.fn.expand("<cword>") })
end
-function M.find_symbol ()
- vim.ui.input("Symbol for > ", function (input)
- if input == nil then
- return
- end
- require('telescope.builtin').lsp_workspace_symbols({ search = input})
- end)
+function M.find_symbol()
+ vim.ui.input("Symbol for > ", function(input)
+ if input == nil then
+ return
+ end
+ require("telescope.builtin").lsp_workspace_symbols({ search = input })
+ end)
end
function M.my_plugins()
- require("telescope.builtin").find_files {
- cwd = "~/plugins/",
- }
+ require("telescope.builtin").find_files({
+ cwd = "~/plugins/",
+ })
end
-function M.projectionist ()
- return require("telescope").extensions.projectionist.projectionist()
+function M.projectionist()
+ return require("telescope").extensions.projectionist.projectionist()
end
-
-function M.laravel ()
- vim.env.NO_TTY = 1
- return require("telescope").extensions.laravel.laravel()
+function M.laravel()
+ vim.env.NO_TTY = 1
+ return require("telescope").extensions.laravel.laravel()
end
-function M.worktree ()
- return require('telescope').extensions.git_worktree.git_worktrees()
+function M.worktree()
+ return require("telescope").extensions.git_worktree.git_worktrees()
end
-function M.worktree_create ()
- return require('telescope').extensions.git_worktree.create_git_worktree()
+function M.worktree_create()
+ return require("telescope").extensions.git_worktree.create_git_worktree()
end
-function M.refactor ()
- return require('telescope').extensions.refactoring.refactors()
+function M.refactor()
+ return require("telescope").extensions.refactoring.refactors()
end
-function M.file_browser_relative ()
- return M.file_browser({path = "%:p:h"})
+function M.file_browser_relative()
+ return M.file_browser({ path = "%:p:h" })
end
-function M.file_browser (opts)
- opts = opts or {}
+function M.file_browser(opts)
+ opts = opts or {}
- opts = {
- path = opts.path,
- sorting_strategy = "ascending",
- scroll_strategy = "cycle",
- layout_config = {
- prompt_position = "top",
- },
+ opts = {
+ path = opts.path,
+ sorting_strategy = "ascending",
+ scroll_strategy = "cycle",
+ layout_config = {
+ prompt_position = "top",
+ },
- attach_mappings = function(prompt_bufnr, map)
- local current_picker = action_state.get_current_picker(prompt_bufnr)
+ attach_mappings = function(prompt_bufnr, map)
+ local current_picker = action_state.get_current_picker(prompt_bufnr)
- local modify_cwd = function(new_cwd)
- local finder = current_picker.finder
+ local modify_cwd = function(new_cwd)
+ local finder = current_picker.finder
- finder.path = new_cwd
- finder.files = true
- current_picker:refresh(false, { reset_prompt = true })
- end
+ finder.path = new_cwd
+ finder.files = true
+ current_picker:refresh(false, { reset_prompt = true })
+ end
- map("n", "-", function()
- modify_cwd(current_picker.cwd .. "/..")
- end)
+ map("n", "-", function()
+ modify_cwd(current_picker.cwd .. "/..")
+ end)
- map("i", "~", function()
- modify_cwd(vim.fn.expand "~")
- end)
+ map("i", "~", function()
+ modify_cwd(vim.fn.expand("~"))
+ end)
- map("n", "yy", function()
- local entry = action_state.get_selected_entry()
- vim.fn.setreg("+", entry.value)
- end)
+ map("n", "yy", function()
+ local entry = action_state.get_selected_entry()
+ vim.fn.setreg("+", entry.value)
+ end)
- map("i", "<c-y>", fb_actions.create)
+ map("i", "<c-y>", fb_actions.create)
- return true
- end,
- }
+ return true
+ end,
+ }
- return require("telescope").extensions.file_browser.file_browser(opts)
+ return require("telescope").extensions.file_browser.file_browser(opts)
end
return setmetatable({}, {
- __index = function(_, k)
- reloader()
- if M[k] then
- return M[k]
- else
- return require("telescope.builtin")[k]
- end
- end,
+ __index = function(_, k)
+ reloader()
+ if M[k] then
+ return M[k]
+ else
+ return require("telescope.builtin")[k]
+ end
+ end,
})
diff --git a/lua/alpha/telescope/mappings.lua b/lua/alpha/telescope/mappings.lua
index 33b2b8c..816b141 100644
--- a/lua/alpha/telescope/mappings.lua
+++ b/lua/alpha/telescope/mappings.lua
@@ -1,29 +1,28 @@
TelescopeMapArgs = TelescopeMapArgs or {}
local map_tele = function(key, f, options, buffer)
- local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true)
+ local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true)
- TelescopeMapArgs[map_key] = options or {}
+ TelescopeMapArgs[map_key] = options or {}
- local mode = "n"
- local rhs = string.format("<cmd>lua R('alpha.telescope')['%s'](TelescopeMapArgs['%s'])<CR>", f, map_key)
+ local mode = "n"
+ local rhs = string.format("<cmd>lua R('alpha.telescope')['%s'](TelescopeMapArgs['%s'])<CR>", f, map_key)
- local map_options = {
- noremap = true,
- silent = true,
- }
+ local map_options = {
+ noremap = true,
+ silent = true,
+ }
- if not buffer then
- vim.api.nvim_set_keymap(mode, key, rhs, map_options)
- else
- vim.api.nvim_buf_set_keymap(0, mode, key, rhs, map_options)
- end
+ if not buffer then
+ vim.api.nvim_set_keymap(mode, key, rhs, map_options)
+ else
+ vim.api.nvim_buf_set_keymap(0, mode, key, rhs, map_options)
+ end
end
-- not shure what this line does
vim.api.nvim_set_keymap("c", "<c-r><c-r>", "<Plug>(TelescopeFuzzyCommandSearch)", { noremap = false, nowait = true })
-
map_tele("<leader>pp", "project_files")
map_tele("<leader>gc", "branches")
map_tele("<leader>gt", "worktree")
@@ -46,6 +45,4 @@ map_tele("<leader>rr", "refactor")
map_tele("<leader>pa", "laravel")
map_tele("<leader>vca", "lsp_code_actions")
-
-
return map_tele