my demo first config lua
This commit is contained in:
9
after/ftplugin/cucumber.lua
Normal file
9
after/ftplugin/cucumber.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
local set = vim.bo
|
||||||
|
|
||||||
|
set.expandtab = true
|
||||||
|
set.tabstop = 2
|
||||||
|
set.softtabstop = 2
|
||||||
|
set.shiftwidth = 2
|
||||||
|
set.smartindent = false
|
||||||
|
set.cindent = false
|
||||||
|
set.indentexpr = ""
|
||||||
2
after/ftplugin/dbout.vim
Normal file
2
after/ftplugin/dbout.vim
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
set nofoldenable
|
||||||
|
set colorcolumn=
|
||||||
3
after/ftplugin/go.vim
Normal file
3
after/ftplugin/go.vim
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set listchars=tab:\ \ ,trail:-
|
||||||
|
set makeprg=go\ build
|
||||||
|
set efm=%-G%f:%l:%c:W:\ %m,%-G%f:%l::W:\ %m,%f:%l:%c:%t:\ %m,%f:%l:%c::\ %m,%f:%l::%t:\ %m
|
||||||
4
after/ftplugin/json.vim
Normal file
4
after/ftplugin/json.vim
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
setlocal expandtab
|
||||||
|
setlocal tabstop=2
|
||||||
|
setlocal softtabstop=2
|
||||||
|
setlocal shiftwidth=2
|
||||||
6
after/ftplugin/lua.lua
Normal file
6
after/ftplugin/lua.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
local set = vim.bo
|
||||||
|
|
||||||
|
set.tabstop = 2
|
||||||
|
set.softtabstop = 2
|
||||||
|
set.expandtab = true
|
||||||
|
set.shiftwidth = 2
|
||||||
2
after/ftplugin/make.vim
Normal file
2
after/ftplugin/make.vim
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
setl listchars=tab:\ \ ,trail:-
|
||||||
|
setl noexpandtab
|
||||||
6
after/ftplugin/nix.lua
Normal file
6
after/ftplugin/nix.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
local set = vim.bo
|
||||||
|
|
||||||
|
set.tabstop = 2
|
||||||
|
set.softtabstop = 2
|
||||||
|
set.expandtab = true
|
||||||
|
set.shiftwidth = 2
|
||||||
5
after/ftplugin/yaml.vim
Normal file
5
after/ftplugin/yaml.vim
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
setlocal expandtab
|
||||||
|
setlocal tabstop=2
|
||||||
|
setlocal softtabstop=2
|
||||||
|
setlocal shiftwidth=2
|
||||||
|
setlocal indentkeys -=<:>
|
||||||
6
after/queries/yaml/captures.scm
Normal file
6
after/queries/yaml/captures.scm
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
;; extends
|
||||||
|
|
||||||
|
(block_mapping_pair
|
||||||
|
key: (flow_node) @key.resolve (#eq? @key.resolve "resolve")
|
||||||
|
value: (flow_node) @resolver
|
||||||
|
)
|
||||||
50
back/lua/alpha/animations.lua
Normal file
50
back/lua/alpha/animations.lua
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
local redraw_buffer = function()
|
||||||
|
local Animation = require "animation"
|
||||||
|
local fps = 45 -- frames per second
|
||||||
|
local easing = require "animation.easing"
|
||||||
|
|
||||||
|
local buffer = 0
|
||||||
|
local len = 0
|
||||||
|
local place_holder = {}
|
||||||
|
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true)
|
||||||
|
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
len = len + string.len(line)
|
||||||
|
table.insert(place_holder, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, 0, #lines, true, place_holder)
|
||||||
|
|
||||||
|
local duration = math.ceil(len / fps * 1000)
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
local line_nr = 1
|
||||||
|
local insertLine = ""
|
||||||
|
|
||||||
|
local function callback()
|
||||||
|
if lines[line_nr] == nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local char = string.sub(lines[line_nr], i, i)
|
||||||
|
if char == nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
insertLine = insertLine .. char
|
||||||
|
i = i + 1
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { insertLine })
|
||||||
|
|
||||||
|
if insertLine == lines[line_nr] then
|
||||||
|
i = 1
|
||||||
|
line_nr = line_nr + 1
|
||||||
|
insertLine = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local animation = Animation(duration, fps, easing.line, callback)
|
||||||
|
animation:run()
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
redraw_buffer = redraw_buffer,
|
||||||
|
}
|
||||||
133
back/lua/alpha/completition/init.lua
Normal file
133
back/lua/alpha/completition/init.lua
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
local cmp = require "cmp"
|
||||||
|
local lspkind = require "lspkind"
|
||||||
|
local luasnip = require "luasnip"
|
||||||
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||||
|
local compare = require "cmp.config.compare"
|
||||||
|
|
||||||
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
mapping = {
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-e>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.close()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-n>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.choice_active() then
|
||||||
|
luasnip.change_choice(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-y>"] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
["<c-space>"] = cmp.mapping.complete(),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "copilot" },
|
||||||
|
{
|
||||||
|
name = "buffer",
|
||||||
|
keyword_length = 4,
|
||||||
|
option = {
|
||||||
|
get_bufnrs = function()
|
||||||
|
local bufs = {}
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
local bufnr = vim.api.nvim_win_get_buf(win)
|
||||||
|
if vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal" then
|
||||||
|
bufs[bufnr] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return vim.tbl_keys(bufs)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
format = lspkind.cmp_format {
|
||||||
|
with_text = true,
|
||||||
|
menu = {
|
||||||
|
buffer = "[buf]",
|
||||||
|
nvim_lsp = "[ ]",
|
||||||
|
nvim_lua = "[api]",
|
||||||
|
path = "[path]",
|
||||||
|
luasnip = "[snip]",
|
||||||
|
copilot = "[ﮧ ]",
|
||||||
|
["vim-dadbod-completion"] = "[DB]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
sorting = {
|
||||||
|
priority_weight = 2,
|
||||||
|
comparators = {
|
||||||
|
compare.kind,
|
||||||
|
compare.sort_text,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
experimental = {
|
||||||
|
native_menu = false,
|
||||||
|
|
||||||
|
ghost_text = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
|
||||||
|
|
||||||
|
-- Set configuration for specific filetype.
|
||||||
|
cmp.setup.filetype("gitcommit", {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline("/", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(":", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.filetype({ "sql", "mysql", "plsql" }, {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "vim-dadbod-completion" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
1
back/lua/alpha/dap/configs/golang.lua
Normal file
1
back/lua/alpha/dap/configs/golang.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("dap-go").setup()
|
||||||
45
back/lua/alpha/dap/configs/javascript.lua
Normal file
45
back/lua/alpha/dap/configs/javascript.lua
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
require("dap-vscode-js").setup {
|
||||||
|
debugger_cmd = { "js-debug-adapter" },
|
||||||
|
adapters = { "pwa-node", "pwa-chrome", "node-terminal" },
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, language in ipairs { "typescript", "javascript" } do
|
||||||
|
require("dap").configurations[language] = {
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "launch",
|
||||||
|
name = "Launch file",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "attach",
|
||||||
|
name = "Attach",
|
||||||
|
processId = require("dap.utils").pick_process,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, language in ipairs { "typescriptreact", "javascriptreact" } do
|
||||||
|
require("dap").configurations[language] = {
|
||||||
|
{
|
||||||
|
type = "pwa-chrome",
|
||||||
|
name = "Attach - Remote Debugging",
|
||||||
|
request = "attach",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = vim.fn.getcwd(),
|
||||||
|
sourceMaps = true,
|
||||||
|
protocol = "inspector",
|
||||||
|
port = 9222,
|
||||||
|
webRoot = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-chrome",
|
||||||
|
name = "Launch Chrome",
|
||||||
|
request = "launch",
|
||||||
|
url = "http://localhost:3000",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
27
back/lua/alpha/dap/configs/php.lua
Normal file
27
back/lua/alpha/dap/configs/php.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
local dap = require("dap")
|
||||||
|
|
||||||
|
dap.adapters.php = {
|
||||||
|
type = "executable",
|
||||||
|
command = "php-debug-adapter",
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.php = {
|
||||||
|
{
|
||||||
|
type = "php",
|
||||||
|
request = "launch",
|
||||||
|
name = "Laravel",
|
||||||
|
port = 9003,
|
||||||
|
pathMappings = {
|
||||||
|
["/var/www/html"] = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "php",
|
||||||
|
request = "launch",
|
||||||
|
name = "Symfony",
|
||||||
|
port = 9003,
|
||||||
|
pathMappings = {
|
||||||
|
["/app"] = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
57
back/lua/alpha/dap/configs/rust.lua
Normal file
57
back/lua/alpha/dap/configs/rust.lua
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
local dap = require("dap")
|
||||||
|
|
||||||
|
local rust_adapter = nil
|
||||||
|
local rust_adapters = { "lldb-vscode", "codelldb" }
|
||||||
|
for _, adapter in pairs(rust_adapters) do
|
||||||
|
if vim.fn.executable(adapter) then
|
||||||
|
rust_adapter = adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if rust_adapter ~= nil then
|
||||||
|
dap.adapters.lldb = {
|
||||||
|
type = "executable",
|
||||||
|
command = rust_adapter,
|
||||||
|
name = "lldb",
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.rust = {
|
||||||
|
{
|
||||||
|
name = "launch",
|
||||||
|
type = "lldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
local dir = vim.fn.getcwd()
|
||||||
|
return dir .. "/target/debug/" .. vim.fs.basename(dir)
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
args = function()
|
||||||
|
local resp = vim.fn.input "Arguments: "
|
||||||
|
if resp == "" then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.fn.split(resp, " ")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "custom",
|
||||||
|
type = "lldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
args = function()
|
||||||
|
local resp = vim.fn.input "Arguments: "
|
||||||
|
if resp == "" then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.fn.split(resp, " ")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
106
back/lua/alpha/dap/init.lua
Normal file
106
back/lua/alpha/dap/init.lua
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
local dap, dapui, hydra = require "dap", require "dapui", require "hydra"
|
||||||
|
|
||||||
|
-- Setup Virtual Text
|
||||||
|
require("nvim-dap-virtual-text").setup {}
|
||||||
|
|
||||||
|
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/alpha/dap/configs/*.lua", true)) do
|
||||||
|
loadfile(ft_path)()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Signs
|
||||||
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapBreakpointRejected", { text = "🚫", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapBreakpointCondition", { text = "❓", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapLogPoint", { text = "💬", texthl = "", linehl = "", numhl = "" })
|
||||||
|
|
||||||
|
-- UI structure
|
||||||
|
dapui.setup {
|
||||||
|
icons = { expanded = "▾", collapsed = "▸" },
|
||||||
|
layouts = {
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
"scopes",
|
||||||
|
"breakpoints",
|
||||||
|
"stacks",
|
||||||
|
"watches",
|
||||||
|
},
|
||||||
|
size = 80,
|
||||||
|
position = "right",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
"repl",
|
||||||
|
"console",
|
||||||
|
},
|
||||||
|
size = 10,
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Events Listeners
|
||||||
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
dapui.open {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local hint = [[
|
||||||
|
Nvim DAP
|
||||||
|
_d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^
|
||||||
|
_bp_: Toogle Breakpoint _bc_: Conditional Breakpoint ^
|
||||||
|
_?_: log point ^
|
||||||
|
_c_: Run To Cursor ^
|
||||||
|
_h_: Show information of the variable under the cursor ^
|
||||||
|
_x_: Stop Debbuging ^
|
||||||
|
^^ _<Esc>_
|
||||||
|
]]
|
||||||
|
|
||||||
|
hydra {
|
||||||
|
name = "dap",
|
||||||
|
hint = hint,
|
||||||
|
mode = "n",
|
||||||
|
config = {
|
||||||
|
color = "blue",
|
||||||
|
invoke_on_body = true,
|
||||||
|
hint = {
|
||||||
|
border = "rounded",
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
body = "<leader>d",
|
||||||
|
heads = {
|
||||||
|
{ "d", dap.continue },
|
||||||
|
{ "bp", dap.toggle_breakpoint },
|
||||||
|
{ "l", dap.step_into },
|
||||||
|
{ "j", dap.step_over },
|
||||||
|
{ "k", dap.step_out },
|
||||||
|
{ "h", dapui.eval },
|
||||||
|
{ "c", dap.run_to_cursor },
|
||||||
|
{
|
||||||
|
"bc",
|
||||||
|
function()
|
||||||
|
vim.ui.input({ prompt = "Condition: " }, function(condition)
|
||||||
|
dap.set_breakpoint(condition)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"?",
|
||||||
|
function()
|
||||||
|
vim.ui.input({ prompt = "Log: " }, function(log)
|
||||||
|
dap.set_breakpoint(nil, nil, log)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x",
|
||||||
|
function()
|
||||||
|
dap.terminate()
|
||||||
|
dapui.close {}
|
||||||
|
dap.clear_breakpoints()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{ "<Esc>", nil, { exit = true } },
|
||||||
|
},
|
||||||
|
}
|
||||||
23
back/lua/alpha/globals.lua
Normal file
23
back/lua/alpha/globals.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
--- Dumps all values into pretty print
|
||||||
|
---@vararg any
|
||||||
|
---@return any
|
||||||
|
dump = function(...)
|
||||||
|
local args = {...}
|
||||||
|
|
||||||
|
local mapped = {}
|
||||||
|
for _, v in ipairs(args) do
|
||||||
|
table.insert(mapped, vim.inspect(v))
|
||||||
|
end
|
||||||
|
print(unpack(mapped))
|
||||||
|
|
||||||
|
return unpack(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
Reload = function(...)
|
||||||
|
return require("plenary.reload").reload_module(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
R = function(name)
|
||||||
|
Reload(name)
|
||||||
|
return require(name)
|
||||||
|
end
|
||||||
64
back/lua/alpha/laravel-tinker.lua
Normal file
64
back/lua/alpha/laravel-tinker.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.runCode = function()
|
||||||
|
local curBuff = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
|
local stats = vim.api.nvim_list_uis()[1]
|
||||||
|
|
||||||
|
local width = stats.width
|
||||||
|
local height = stats.height
|
||||||
|
|
||||||
|
local bufh = vim.api.nvim_create_buf(false, true)
|
||||||
|
local winId = vim.api.nvim_open_win(bufh, true, {
|
||||||
|
relative = "editor",
|
||||||
|
width = width * 0.75,
|
||||||
|
height = height * 0.75,
|
||||||
|
col = 2,
|
||||||
|
row = 2,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- get the start and end lines of selection
|
||||||
|
local startLine = vim.api.nvim_buf_get_mark(curBuff, "<")[1] - 1
|
||||||
|
local endLine = vim.api.nvim_buf_get_mark(curBuff, ">")[1]
|
||||||
|
-- print("range: ", startLine, endLine)
|
||||||
|
|
||||||
|
local code = vim.api.nvim_buf_get_lines(curBuff, startLine, endLine, false)
|
||||||
|
|
||||||
|
-- print (vim.inspect(code))
|
||||||
|
|
||||||
|
local codeText = vim.fn.shellescape(table.concat(code, " "))
|
||||||
|
-- print(codeText)
|
||||||
|
|
||||||
|
local result = vim.fn.systemlist("php artisan tinker --execute=" .. codeText)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_text(bufh, 0, 0, 0, 0, result)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.backTerminal = function()
|
||||||
|
local bufh = vim.api.nvim_create_buf(false, true)
|
||||||
|
local term = vim.api.nvim_open_term(bufh, {})
|
||||||
|
|
||||||
|
local winId = vim.api.nvim_open_win(bufh, true, {
|
||||||
|
relative = "editor",
|
||||||
|
width = 80,
|
||||||
|
height = 80,
|
||||||
|
col = 2,
|
||||||
|
row = 2,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
})
|
||||||
|
|
||||||
|
local jobId = vim.fn.jobstart("php artisan tinker", {
|
||||||
|
on_stdout = function(err, data)
|
||||||
|
print(err, vim.inspect(data))
|
||||||
|
vim.api.nvim_chan_send(term, table.concat(data, "\n"))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_chan_send(jobId, "$ub = UploadBatch::find(1);\n")
|
||||||
|
vim.api.nvim_chan_send(jobId, "dump($ub);\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
29
back/lua/alpha/lsp/attach.lua
Normal file
29
back/lua/alpha/lsp/attach.lua
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
local telescope_mapper = require "alpha.telescope.mappings"
|
||||||
|
|
||||||
|
return function(client, bufnr)
|
||||||
|
-- keymaps for lsp
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0, desc = "LSP Help information of symbol under the cursor" })
|
||||||
|
vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0, desc = "LSP Rename symbol under cursor" })
|
||||||
|
vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0, desc = "LSP Signature help" })
|
||||||
|
vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true, desc = "LSP Restart Server" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, { buffer = 0, desc = "LSP Code actions" })
|
||||||
|
vim.keymap.set("n", "<leader>vf", function()
|
||||||
|
return vim.lsp.buf.format {
|
||||||
|
async = true,
|
||||||
|
filter = function(cli)
|
||||||
|
return cli.name ~= "lua_ls"
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end, { buffer = 0, desc = "LSP format file" })
|
||||||
|
|
||||||
|
telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" })
|
||||||
|
telescope_mapper("<leader>pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" })
|
||||||
|
telescope_mapper("<leader>pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" })
|
||||||
|
telescope_mapper("gd", "lsp_definitions", { buffer = true, desc = "LSP go to definition" })
|
||||||
|
|
||||||
|
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||||
|
|
||||||
|
if client.server_capabilities.inlayHintProvider then
|
||||||
|
vim.lsp.inlay_hint(bufnr, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
26
back/lua/alpha/lsp/default.lua
Normal file
26
back/lua/alpha/lsp/default.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
return {
|
||||||
|
mason = {
|
||||||
|
enable = true,
|
||||||
|
auto_install = false,
|
||||||
|
},
|
||||||
|
servers = {
|
||||||
|
emmet_ls = { enable = true },
|
||||||
|
gopls = { enable = true },
|
||||||
|
html = { enable = true },
|
||||||
|
jsonls = { enable = true },
|
||||||
|
lua_ls = { enable = true, neodev = true },
|
||||||
|
nil_ls = { enable = true },
|
||||||
|
phpactor = {enable = true },
|
||||||
|
rust_analyzer = { enable = true },
|
||||||
|
svelte = { enable = true },
|
||||||
|
tailwindcss = { enable = true, filetypes = {"blade", "html", "svelte"} },
|
||||||
|
tsserver = { enable = true },
|
||||||
|
volar = { enable = true },
|
||||||
|
},
|
||||||
|
default_options = function (options)
|
||||||
|
return vim.tbl_deep_extend("force", {
|
||||||
|
on_attach = require"alpha.lsp.attach",
|
||||||
|
flags = require "alpha.lsp.flags",
|
||||||
|
}, options)
|
||||||
|
end,
|
||||||
|
}
|
||||||
3
back/lua/alpha/lsp/flags.lua
Normal file
3
back/lua/alpha/lsp/flags.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
65
back/lua/alpha/lsp/init.lua
Normal file
65
back/lua/alpha/lsp/init.lua
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
return {
|
||||||
|
setup = function(ops)
|
||||||
|
ops = vim.tbl_deep_extend("force", require "alpha.lsp.default", ops)
|
||||||
|
|
||||||
|
local lspconfig = require "lspconfig"
|
||||||
|
|
||||||
|
local mason_servers = {}
|
||||||
|
for server, options in pairs(ops.servers) do
|
||||||
|
if options.enable == true then
|
||||||
|
local ok, definition = pcall(require, "alpha.lsp.servers." .. server)
|
||||||
|
local server_options
|
||||||
|
if not ok then
|
||||||
|
server_options = ops.default_options(options)
|
||||||
|
else
|
||||||
|
server_options = definition(options)
|
||||||
|
end
|
||||||
|
lspconfig[server].setup(server_options)
|
||||||
|
table.insert(mason_servers, server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Mason
|
||||||
|
if ops.mason.enable then
|
||||||
|
local mason_ops = {}
|
||||||
|
if ops.mason.auto_install == true then
|
||||||
|
mason_ops.ensure_installed = mason_servers
|
||||||
|
end
|
||||||
|
local mason_lspconfig = require "mason-lspconfig"
|
||||||
|
mason_lspconfig.setup(mason_ops)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: implement null ls with options
|
||||||
|
require "alpha.lsp.null-ls"
|
||||||
|
|
||||||
|
local servers = {}
|
||||||
|
for server, options in pairs(ops.servers) do
|
||||||
|
table.insert(servers, string.format("%s <%s>", server, options.enable))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: create an auto command that on write of the configuration, calls again the setup and restart the server if it's up.
|
||||||
|
-- can get the client by name of the file
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("AlphaLSP", function()
|
||||||
|
vim.ui.select(servers, { prompt = "LSP Servers" }, function(server)
|
||||||
|
if server == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
server = string.match(server, "^(.+) <")
|
||||||
|
local path = string.format("%s/lua/alpha/lsp/servers/%s.lua", vim.fn.stdpath "config", server)
|
||||||
|
if vim.fn.filereadable(path) == 0 then
|
||||||
|
local create = vim.fn.confirm("Server Does Not exist. Create new server?", "&Yes\n&No\n&Cancel")
|
||||||
|
if create ~= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local uri = vim.uri_from_fname(path)
|
||||||
|
local buffer = vim.uri_to_bufnr(uri)
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_buf(0, buffer)
|
||||||
|
end)
|
||||||
|
end, {})
|
||||||
|
end,
|
||||||
|
}
|
||||||
23
back/lua/alpha/lsp/mason.lua
Normal file
23
back/lua/alpha/lsp/mason.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
local mason_lspconfig = require "mason-lspconfig"
|
||||||
|
local servers = require "alpha.lsp.servers"
|
||||||
|
local lspconfig = require "lspconfig"
|
||||||
|
|
||||||
|
local mason_servers = {}
|
||||||
|
|
||||||
|
for server, _ in pairs(servers) do
|
||||||
|
local cmd = lspconfig[server].cmd[1]
|
||||||
|
if vim.fn.executable(cmd) == 0 then
|
||||||
|
table.insert(mason_servers, server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mason_lspconfig.setup {
|
||||||
|
-- ensure_installed = mason_servers,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- filter the list for the ones not globally installed
|
||||||
|
-- require("mason-tool-installer").setup {
|
||||||
|
-- ensure_installed = vim.tbl_filter(function (tool)
|
||||||
|
-- return vim.fn.executable(tool) == 0
|
||||||
|
-- end, require "alpha.lsp.tools"),
|
||||||
|
-- }
|
||||||
53
back/lua/alpha/lsp/null-ls.lua
Normal file
53
back/lua/alpha/lsp/null-ls.lua
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
local null_ls = require "null-ls"
|
||||||
|
-- local php_actions = require "php-code-actions"
|
||||||
|
-- local laravel_actions = require("laravel.code-actions")
|
||||||
|
|
||||||
|
null_ls.setup {
|
||||||
|
sources = {
|
||||||
|
-- null_ls.builtins.code_actions.gitsigns,
|
||||||
|
null_ls.builtins.formatting.jq,
|
||||||
|
null_ls.builtins.code_actions.refactoring,
|
||||||
|
null_ls.builtins.formatting.alejandra,
|
||||||
|
null_ls.builtins.diagnostics.luacheck,
|
||||||
|
null_ls.builtins.formatting.stylua,
|
||||||
|
|
||||||
|
null_ls.builtins.diagnostics.yamllint,
|
||||||
|
|
||||||
|
-- php_actions.getter_setter,
|
||||||
|
-- php_actions.file_creator,
|
||||||
|
|
||||||
|
-- null_ls.builtins.diagnostics.phpstan.with {
|
||||||
|
-- to_temp_file = false,
|
||||||
|
-- method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||||
|
-- -- command = "./bin/phpstan",
|
||||||
|
-- -- condition = function ()
|
||||||
|
-- -- return vim.fn.findfile("bin/phpstan") ~= ""
|
||||||
|
-- -- end
|
||||||
|
-- },
|
||||||
|
null_ls.builtins.diagnostics.phpcs.with {
|
||||||
|
method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||||
|
condition = function(utils)
|
||||||
|
return utils.root_has_file "phpcs.xml"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
null_ls.builtins.formatting.pint,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LSP (null ls) Code actions"})
|
||||||
|
vim.keymap.set("n", "<leader>vf", function()
|
||||||
|
return vim.lsp.buf.format { async = true }
|
||||||
|
end, {desc = "LSP (null ls) Format file"})
|
||||||
|
|
||||||
|
-- function to toogle and possible restart it
|
||||||
|
vim.api.nvim_create_user_command("NullLsToggle", function()
|
||||||
|
local sources = vim.tbl_map(function(el)
|
||||||
|
return el.name
|
||||||
|
end, null_ls.get_sources())
|
||||||
|
vim.ui.select(sources, {}, function(selected)
|
||||||
|
if not selected then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
null_ls.toggle(selected)
|
||||||
|
end)
|
||||||
|
end, {})
|
||||||
12
back/lua/alpha/lsp/servers/emmet_ls.lua
Normal file
12
back/lua/alpha/lsp/servers/emmet_ls.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
capabilities = capabilities,
|
||||||
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" },
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
14
back/lua/alpha/lsp/servers/html.lua
Normal file
14
back/lua/alpha/lsp/servers/html.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local config = {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
}
|
||||||
|
if vim.fn.executable "html-languageserver" == 1 then
|
||||||
|
config.cmd = { "html-languageserver", "--stdio" }
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", config, ops)
|
||||||
|
end
|
||||||
14
back/lua/alpha/lsp/servers/jsonls.lua
Normal file
14
back/lua/alpha/lsp/servers/jsonls.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local config = {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
}
|
||||||
|
if vim.fn.executable "json-languageserver" == 1 then
|
||||||
|
config.cmd = { "json-languageserver", "--stdio" }
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", config, ops)
|
||||||
|
end
|
||||||
36
back/lua/alpha/lsp/servers/lua_ls.lua
Normal file
36
back/lua/alpha/lsp/servers/lua_ls.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
if ops.neodev == true then
|
||||||
|
require("neodev").setup()
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = "LuaJIT",
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
hint = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
80
back/lua/alpha/lsp/servers/phpactor.lua
Normal file
80
back/lua/alpha/lsp/servers/phpactor.lua
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
local function phpactor_attach(_, bufnr)
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorReindex", function()
|
||||||
|
vim.lsp.buf_notify(bufnr, "phpactor/index/reindex", {})
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorStatus", function()
|
||||||
|
local results, _ = vim.lsp.buf_request_sync(bufnr, "phpactor/status", { ["return"] = true })
|
||||||
|
|
||||||
|
local content = ""
|
||||||
|
|
||||||
|
for _, res in pairs(results or {}) do
|
||||||
|
if res ~= nil and res["result"] ~= nil then
|
||||||
|
content = content .. res["result"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local Popup = require "nui.popup"
|
||||||
|
local event = require("nui.utils.autocmd").event
|
||||||
|
|
||||||
|
local popup = Popup {
|
||||||
|
enter = true,
|
||||||
|
focusable = true,
|
||||||
|
border = {
|
||||||
|
style = "rounded",
|
||||||
|
},
|
||||||
|
position = "50%",
|
||||||
|
size = {
|
||||||
|
width = "80%",
|
||||||
|
height = "60%",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- mount/open the component
|
||||||
|
popup:mount()
|
||||||
|
|
||||||
|
-- unmount component when cursor leaves buffer
|
||||||
|
popup:on(event.BufLeave, function()
|
||||||
|
popup:unmount()
|
||||||
|
end)
|
||||||
|
local out = {}
|
||||||
|
for match in string.gmatch(content, "[^\n]+") do
|
||||||
|
table.insert(out, match)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_option(popup.bufnr, "filetype", "markdown")
|
||||||
|
vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, out)
|
||||||
|
end, {})
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
lsp_attach(client, bufnr)
|
||||||
|
phpactor_attach(client, bufnr)
|
||||||
|
end,
|
||||||
|
flags = lsp_flags,
|
||||||
|
filetypes = { "php", "blade" },
|
||||||
|
init_options = {
|
||||||
|
["language_server_worse_reflection.inlay_hints.enable"] = true,
|
||||||
|
["language_server_worse_reflection.inlay_hints.params"] = true,
|
||||||
|
-- ["language_server_worse_reflection.inlay_hints.types"] = true,
|
||||||
|
["language_server_configuration.auto_config"] = false,
|
||||||
|
["code_transform.import_globals"] = true,
|
||||||
|
["language_server_phpstan.enabled"] = true,
|
||||||
|
["language_server_phpstan.level"] = 7,
|
||||||
|
["language_server_phpstan.bin"] = "phpstan",
|
||||||
|
},
|
||||||
|
handlers = {
|
||||||
|
["textDocument/inlayHint"] = function(err, result, ...)
|
||||||
|
for _, res in ipairs(result) do
|
||||||
|
res.label = res.label .. ": "
|
||||||
|
end
|
||||||
|
vim.lsp.handlers["textDocument/inlayHint"](err, result, ...)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
24
back/lua/alpha/lsp/servers/rust_analyzer.lua
Normal file
24
back/lua/alpha/lsp/servers/rust_analyzer.lua
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
allFeatures = true,
|
||||||
|
overrideCommand = {
|
||||||
|
"cargo",
|
||||||
|
"clippy",
|
||||||
|
"--workspace",
|
||||||
|
"--message-format=json",
|
||||||
|
"--all-targets",
|
||||||
|
"--all-features",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
33
back/lua/alpha/lsp/servers/tsserver.lua
Normal file
33
back/lua/alpha/lsp/servers/tsserver.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
typescript = {
|
||||||
|
inlayHints = {
|
||||||
|
includeInlayParameterNameHints = "all",
|
||||||
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
javascript = {
|
||||||
|
inlayHints = {
|
||||||
|
includeInlayParameterNameHints = "all",
|
||||||
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
8
back/lua/alpha/lsp/tools.lua
Normal file
8
back/lua/alpha/lsp/tools.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
"codelldb",
|
||||||
|
"go-debug-adapter",
|
||||||
|
"js-debug-adapter",
|
||||||
|
"php-debug-adapter",
|
||||||
|
"phpcs",
|
||||||
|
"phpstan",
|
||||||
|
}
|
||||||
27
back/lua/alpha/packer_install.lua
Normal file
27
back/lua/alpha/packer_install.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
local download_packer = function()
|
||||||
|
if vim.fn.input "Download Packer? (y for yes)" ~= "y" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local directory = string.format("%s/site/pack/packer/start/", vim.fn.stdpath "data")
|
||||||
|
|
||||||
|
vim.fn.mkdir(directory, "p")
|
||||||
|
|
||||||
|
local out = vim.fn.system(
|
||||||
|
string.format("git clone %s %s", "https://github.com/wbthomason/packer.nvim", directory .. "/packer.nvim")
|
||||||
|
)
|
||||||
|
|
||||||
|
print(out)
|
||||||
|
print "Downloading packer.nvim..."
|
||||||
|
print "( You'll need to restart now )"
|
||||||
|
end
|
||||||
|
|
||||||
|
return function()
|
||||||
|
if not pcall(require, "packer") then
|
||||||
|
download_packer()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
137
back/lua/alpha/php/gateway.lua
Normal file
137
back/lua/alpha/php/gateway.lua
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
local pickers = require "telescope.pickers"
|
||||||
|
local finders = require "telescope.finders"
|
||||||
|
local conf = require("telescope.config").values
|
||||||
|
local action_state = require "telescope.actions.state"
|
||||||
|
local action_set = require "telescope.actions.set"
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
local get_node_text = vim.treesitter.get_node_text
|
||||||
|
|
||||||
|
local gateway = {}
|
||||||
|
|
||||||
|
local get_definition_buffer = function(type)
|
||||||
|
local uri = vim.uri_from_fname(vim.fn.getcwd() .. "/config/graphql/_" .. type .. ".yaml")
|
||||||
|
local buff = vim.uri_to_bufnr(uri)
|
||||||
|
vim.fn.bufload(buff)
|
||||||
|
|
||||||
|
return buff
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_all_definitions = function()
|
||||||
|
local mutations_definitions = gateway.get_graphql_definitions(get_definition_buffer "mutation")
|
||||||
|
local queries_definitions = gateway.get_graphql_definitions(get_definition_buffer "query")
|
||||||
|
for _, definition in ipairs(queries_definitions) do
|
||||||
|
table.insert(mutations_definitions, definition)
|
||||||
|
end
|
||||||
|
|
||||||
|
return mutations_definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
-- "'@=mutation(\"App\\\\GraphQL\\\\Mutations\\\\Mutation::action\", ...)'",
|
||||||
|
local open_resolver = function(resolver)
|
||||||
|
-- need to parse to get this values
|
||||||
|
local args = string.match(resolver, "'@=mutation%((.+)%)'")
|
||||||
|
if args == nil then
|
||||||
|
args = string.match(resolver, "'@=query%((.+)%)'")
|
||||||
|
end
|
||||||
|
if args == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local args_tbl = vim.split(args, ", ")
|
||||||
|
local fqn = string.match(args_tbl[1], '"(.+)"')
|
||||||
|
fqn = string.gsub(fqn, "\\\\", "\\")
|
||||||
|
-- P(fqn)
|
||||||
|
|
||||||
|
require("alpha.php.lsp").find(fqn, "phpactor")
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param bufnr integer Buff id
|
||||||
|
gateway.get_graphql_definitions = function(bufnr)
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"yaml",
|
||||||
|
"GraphQL_endpoints",
|
||||||
|
[[
|
||||||
|
(document (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
key: (flow_node) @mutation
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
key: (flow_node) @resolve (#eq? @resolve "resolve")
|
||||||
|
value: (flow_node) @resolver
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
))))
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get("yaml", "GraphQL_endpoints")
|
||||||
|
|
||||||
|
local elements = {}
|
||||||
|
|
||||||
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
|
local parser = parsers.get_parser(bufnr)
|
||||||
|
local tree = parser:parse()[1]
|
||||||
|
|
||||||
|
for id, node in query:iter_captures(tree:root(), bufnr) do
|
||||||
|
if query.captures[id] == "mutation" then
|
||||||
|
table.insert(elements, {
|
||||||
|
value = get_node_text(node, bufnr),
|
||||||
|
lnum = node:start() + 1,
|
||||||
|
buffer = bufnr,
|
||||||
|
})
|
||||||
|
elseif query.captures[id] == "resolver" then
|
||||||
|
elements[#elements].resolver = get_node_text(node, bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return elements
|
||||||
|
end
|
||||||
|
|
||||||
|
--- gets the graphql function defined on a given buffer
|
||||||
|
--- @param opts table: options to pass to the picker
|
||||||
|
gateway.graphql_definitions = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
pickers
|
||||||
|
.new(opts, {
|
||||||
|
promt_title = "Queries",
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = get_all_definitions(),
|
||||||
|
entry_maker = function(entry)
|
||||||
|
-- buffer = 43,
|
||||||
|
-- lnum = 82,
|
||||||
|
-- resolver = "'@=mutation(\"App\\\\GraphQL\\\\Mutation\\\\Mutation::action\", ...)'",
|
||||||
|
-- value = "deleteVehicleImage"
|
||||||
|
return {
|
||||||
|
value = entry,
|
||||||
|
display = entry.value,
|
||||||
|
ordinal = entry.value,
|
||||||
|
path = vim.api.nvim_buf_get_name(entry.buffer),
|
||||||
|
lnum = entry.lnum,
|
||||||
|
resolver = entry.resolver,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sorter = conf.generic_sorter(opts),
|
||||||
|
previewer = conf.grep_previewer(opts),
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
action_set.select:enhance {
|
||||||
|
post = function()
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
map("i", "<c-o>", function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
open_resolver(selection.resolver)
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
|
end
|
||||||
|
|
||||||
|
return gateway
|
||||||
151
back/lua/alpha/php/lsp.lua
Normal file
151
back/lua/alpha/php/lsp.lua
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
local Path = require "plenary.path"
|
||||||
|
|
||||||
|
local lsp = {}
|
||||||
|
|
||||||
|
local open_filename = function(filename)
|
||||||
|
if vim.api.nvim_buf_get_name(0) ~= filename then
|
||||||
|
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
|
||||||
|
pcall(vim.cmd, string.format("%s %s", "edit", filename))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param server_name string
|
||||||
|
---@return table|nil, boolean
|
||||||
|
local get_client = function(server_name)
|
||||||
|
local clients = vim.lsp.get_active_clients { name = server_name }
|
||||||
|
local client = clients[1] or nil
|
||||||
|
local new_instance = false
|
||||||
|
|
||||||
|
if not client then
|
||||||
|
local server = require("lspconfig")[server_name]
|
||||||
|
local config = server.make_config(vim.fn.getcwd())
|
||||||
|
local client_id = vim.lsp.start(config)
|
||||||
|
client = vim.lsp.get_client_by_id(client_id)
|
||||||
|
new_instance = true
|
||||||
|
end
|
||||||
|
|
||||||
|
return client, new_instance
|
||||||
|
end
|
||||||
|
|
||||||
|
local function go_to(client, is_new_instance, full_class, method)
|
||||||
|
local class_parts = vim.split(full_class, "\\")
|
||||||
|
local class = class_parts[#class_parts]
|
||||||
|
|
||||||
|
local resp = client.request_sync("workspace/symbol", { query = class }, nil)
|
||||||
|
|
||||||
|
local locations = vim.lsp.util.symbols_to_items(resp.result or {}, nil) or {}
|
||||||
|
if vim.tbl_isempty(locations) then
|
||||||
|
vim.api.nvim_err_writeln("Empty response looking for class: " .. full_class)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local class_location = nil
|
||||||
|
for idx, location in pairs(locations) do
|
||||||
|
if location.text == string.format("[Class] %s", full_class) then
|
||||||
|
class_location = locations[idx]
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if class_location == nil then
|
||||||
|
vim.api.nvim_err_writeln("Could not find class for : " .. full_class)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
open_filename(class_location.filename)
|
||||||
|
|
||||||
|
local params = vim.lsp.util.make_position_params(0)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.buf_attach_client(0, client.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.buf_request(0, "textDocument/documentSymbol", params, function(method_err, method_server_result, _, _)
|
||||||
|
if method_err then
|
||||||
|
vim.api.nvim_err_writeln("Error when finding workspace symbols: " .. method_err.message)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local method_locations = vim.lsp.util.symbols_to_items(method_server_result or {}, 0) or {}
|
||||||
|
if vim.tbl_isempty(method_locations) then
|
||||||
|
vim.api.nvim_err_writeln(string.format("empty response looking for method: %s", method or "__invoke"))
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local method_location = nil
|
||||||
|
for _, value in ipairs(method_locations) do
|
||||||
|
if value.text == string.format("[Method] %s", method or "__invoke") then
|
||||||
|
method_location = value
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if method_location == nil then
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local row = method_location.lnum
|
||||||
|
local col = method_location.col - 1
|
||||||
|
|
||||||
|
if row and col then
|
||||||
|
local ok, err_msg = pcall(vim.api.nvim_win_set_cursor, 0, { row, col })
|
||||||
|
if not ok then
|
||||||
|
vim.api.nvim_err_writeln("Erro setting row and col " .. err_msg)
|
||||||
|
end
|
||||||
|
vim.cmd "normal zt"
|
||||||
|
end
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Return a buffer id for the given client
|
||||||
|
---@param server_name string
|
||||||
|
---@return integer|nil
|
||||||
|
lsp.get_lsp_buffer = function(server_name)
|
||||||
|
local clients = vim.lsp.get_active_clients { name = server_name }
|
||||||
|
if #clients == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local buffers = vim.lsp.get_buffers_by_client_id(clients[1].id)
|
||||||
|
|
||||||
|
if #buffers == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return buffers[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param fqn string: fully name to search Class::method
|
||||||
|
lsp.find = function(fqn, server_name)
|
||||||
|
local search = vim.split(fqn, "::")
|
||||||
|
local fqn_class = search[1]
|
||||||
|
local method = search[2]
|
||||||
|
|
||||||
|
local client, is_new_instance = get_client(server_name)
|
||||||
|
|
||||||
|
if not client then
|
||||||
|
vim.api.nvim_err_writeln "Could not get lsp client"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
go_to(client, is_new_instance, fqn_class, method)
|
||||||
|
end
|
||||||
|
|
||||||
|
return lsp
|
||||||
38
back/lua/alpha/php/servers.lua
Normal file
38
back/lua/alpha/php/servers.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
local phpactor = {}
|
||||||
|
|
||||||
|
-- TODO possible improvement look how it works underline
|
||||||
|
-- use the client directly to call, no need for the buffer
|
||||||
|
-- to find a class.
|
||||||
|
-- vim.lsp.start() should return the client
|
||||||
|
|
||||||
|
function phpactor.findclass(buffer, fqn, callback)
|
||||||
|
local class_parts = vim.split(fqn, "\\")
|
||||||
|
local class = class_parts[#class_parts]
|
||||||
|
|
||||||
|
vim.lsp.buf_request(buffer, "workspace/symbol", { query = class }, function(err, server_result, _, _)
|
||||||
|
if err then
|
||||||
|
callback(nil, "Error when finding workspace symbols: " .. err.message)
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local locations = vim.lsp.util.symbols_to_items(server_result or {}, buffer) or {}
|
||||||
|
if vim.tbl_isempty(locations) then
|
||||||
|
vim.api.nvim_err_writeln("Empty response looking for class: " .. fqn)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- getting the config I can re use the client
|
||||||
|
-- the next thing is to make the request with the client
|
||||||
|
local config = require("lspconfig").phpactor
|
||||||
|
config.root_dir = vim.fn.getcwd()
|
||||||
|
local client_id = vim.lsp.start(config)
|
||||||
|
|
||||||
|
vim.lsp.get_client_by_id(client_id)
|
||||||
|
-- use client.request or request_sync
|
||||||
|
-- look for the direct of the symbol
|
||||||
|
return {
|
||||||
|
phpactor = phpactor,
|
||||||
|
}
|
||||||
53
back/lua/alpha/select_to_quickfix.lua
Normal file
53
back/lua/alpha/select_to_quickfix.lua
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local function create_quickfix_entry(selection)
|
||||||
|
local filename, linenumber = selection:match "([^:]+):(%d+)"
|
||||||
|
|
||||||
|
return {
|
||||||
|
filename = vim.fn.getcwd() .. "/" .. filename,
|
||||||
|
lnum = tonumber(linenumber),
|
||||||
|
col = 1,
|
||||||
|
text = filename,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function add_selections_to_quickfix(selections)
|
||||||
|
local quickfix_list = {}
|
||||||
|
|
||||||
|
for _, selection in ipairs(selections) do
|
||||||
|
local entry = create_quickfix_entry(selection)
|
||||||
|
table.insert(quickfix_list, entry)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.fn.setqflist(quickfix_list, "r")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_selections()
|
||||||
|
local _, end_line, _, _ = unpack(vim.fn.getpos "'>")
|
||||||
|
local _, start_line, _, _ = unpack(vim.fn.getpos "'<")
|
||||||
|
local lines = api.nvim_buf_get_lines(0, start_line - 1, end_line, false)
|
||||||
|
|
||||||
|
local selections = {}
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
for selection in line:gmatch "%S+" do
|
||||||
|
table.insert(selections, selection)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return selections
|
||||||
|
end
|
||||||
|
|
||||||
|
local function select_to_quickfix()
|
||||||
|
local selections = get_selections()
|
||||||
|
|
||||||
|
if #selections > 0 then
|
||||||
|
add_selections_to_quickfix(selections)
|
||||||
|
print "Selections added to quickfix list"
|
||||||
|
else
|
||||||
|
print "No selections found"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
handle = select_to_quickfix,
|
||||||
|
}
|
||||||
71
back/lua/alpha/snips/ft/cucumber.lua
Normal file
71
back/lua/alpha/snips/ft/cucumber.lua
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
clean = t [[Given clean stubs list]],
|
||||||
|
all = t [[And all stubs should be matched]],
|
||||||
|
status_code = fmt([[Then the response status code should be {}]], { i(1, "200") }),
|
||||||
|
no_error = t [[And the JSON path expression errors should not have result]],
|
||||||
|
json_data = fmt([[And the JSON path expression "data" should be equal to:
|
||||||
|
"""
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
]], {i(1)}),
|
||||||
|
feature = fmt(
|
||||||
|
[[Feature: {}
|
||||||
|
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "Feature Name"),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
scenario = fmt(
|
||||||
|
[[Scenario: {}
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, "Scenario name"),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
stub = fmt([[And the APIClient will send a request with a stub from "{}"]], { i(1) }),
|
||||||
|
request = fmt(
|
||||||
|
[[When I send the GraphQL request:
|
||||||
|
"""
|
||||||
|
{}
|
||||||
|
"""]],
|
||||||
|
{ i(1) }
|
||||||
|
),
|
||||||
|
result = fmt(
|
||||||
|
[[And the JSON path expression "data" should be equal to:
|
||||||
|
"""
|
||||||
|
{{
|
||||||
|
"result": {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
"""]],
|
||||||
|
{ i(1) }
|
||||||
|
),
|
||||||
|
query = fmt(
|
||||||
|
[[{} {{
|
||||||
|
result: {}({}) {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
}}]],
|
||||||
|
{ c(1, { t "mutation", t "query" }), i(2, "mutation"), i(3, ""), i(4) }
|
||||||
|
),
|
||||||
|
access = fmt(
|
||||||
|
[[And the Access Cache has Allowed the userId "{}" for inspectionId "{}"]],
|
||||||
|
{ i(1, "3414054"), i(2, "42") }
|
||||||
|
),
|
||||||
|
branch_access = fmt([[And the Access Cache has branch "{}" for userId "{}"]], { i(1, "1"), i(2, "3414054") }),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
134
back/lua/alpha/snips/ft/go.lua
Normal file
134
back/lua/alpha/snips/ft/go.lua
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
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 get_node_text = vim.treesitter.get_node_text
|
||||||
|
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"go",
|
||||||
|
"LuaSnip_Result",
|
||||||
|
[[
|
||||||
|
[
|
||||||
|
(method_declaration result: (_) @id)
|
||||||
|
(function_declaration result: (_) @id)
|
||||||
|
(func_literal result: (_) @id)
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
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('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,
|
||||||
|
}
|
||||||
|
|
||||||
|
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.query.get("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))
|
||||||
|
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),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.f = fmt("func {}({}) {} {{\n\t{}\n}}", { i(1, "name"), i(2), i(3), i(0) })
|
||||||
|
|
||||||
|
return M
|
||||||
69
back/lua/alpha/snips/ft/lua.lua
Normal file
69
back/lua/alpha/snips/ft/lua.lua
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
-- local snippet = ls.s
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local t = ls.text_node
|
||||||
|
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local require_var = function(args, _)
|
||||||
|
local text = args[1][1] or ""
|
||||||
|
local split = vim.split(text, ".", { plain = true })
|
||||||
|
|
||||||
|
local options = {}
|
||||||
|
for len = 0, #split - 1 do
|
||||||
|
table.insert(options, t(table.concat(vim.list_slice(split, #split - len, #split), "_")))
|
||||||
|
end
|
||||||
|
|
||||||
|
return snippet_from_nodes(nil, {
|
||||||
|
c(1, options),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local newline = function(text)
|
||||||
|
return t { "", text }
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
req = fmt([[local {} = require("{}")]], {
|
||||||
|
d(2, require_var, { 1 }),
|
||||||
|
i(1),
|
||||||
|
}),
|
||||||
|
lf = {
|
||||||
|
desc = "table function",
|
||||||
|
"local ",
|
||||||
|
i(1),
|
||||||
|
" = function(",
|
||||||
|
i(2),
|
||||||
|
")",
|
||||||
|
newline " ",
|
||||||
|
i(0),
|
||||||
|
newline "end",
|
||||||
|
},
|
||||||
|
|
||||||
|
preq = fmt(
|
||||||
|
[[local ok, {} = pcall(require, "{}")
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end]],
|
||||||
|
{
|
||||||
|
f(function(args)
|
||||||
|
return args[1][1]
|
||||||
|
end, { 1 }),
|
||||||
|
i(1),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
plugin = fmt(
|
||||||
|
[[return {{
|
||||||
|
"{}"
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
i(1, "plugin"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}
|
||||||
163
back/lua/alpha/snips/ft/php.lua
Normal file
163
back/lua/alpha/snips/ft/php.lua
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
local composer = require "composer"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local visibility = function(position, default)
|
||||||
|
local possibles = { "private", "protected", "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
|
||||||
|
|
||||||
|
return c(position, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
local var_name = function(args)
|
||||||
|
return snippet_from_nodes(nil, {
|
||||||
|
i(1, args[1][1]:gsub("^%u", string.lower):gsub("Interface", "") or ""),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local class_name = function()
|
||||||
|
return vim.fn.expand "%:t:r"
|
||||||
|
end
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.v = fmt(
|
||||||
|
[[
|
||||||
|
/**
|
||||||
|
* @var {}
|
||||||
|
*/
|
||||||
|
{} {} ${};
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "type"),
|
||||||
|
visibility(2, "private"),
|
||||||
|
i(3, "Type"),
|
||||||
|
i(4, "var"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.class = fmt(
|
||||||
|
[[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace {};
|
||||||
|
|
||||||
|
class {}
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
f(composer.resolve_php_namespace),
|
||||||
|
f(class_name),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.pro = fmt([[{} {}{} ${},]], {
|
||||||
|
visibility(1, "private"),
|
||||||
|
c(2, {
|
||||||
|
t "readonly ",
|
||||||
|
t "",
|
||||||
|
}),
|
||||||
|
i(3, "Type"),
|
||||||
|
d(4, var_name, { 3 }),
|
||||||
|
})
|
||||||
|
|
||||||
|
M.op = fmt(
|
||||||
|
[[
|
||||||
|
/**
|
||||||
|
* @var ObjectProphecy<{}>
|
||||||
|
*/
|
||||||
|
private ObjectProphecy ${};
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "Type"),
|
||||||
|
d(2, var_name, { 1 }),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.iop = fmt(
|
||||||
|
[[$this->{} = $this->prophesize({}::class);]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.arg = fmt([[{} ${}]], {
|
||||||
|
i(1, "Type"),
|
||||||
|
d(2, var_name, { 1 }),
|
||||||
|
})
|
||||||
|
|
||||||
|
M._c = fmt(
|
||||||
|
[[{} function __construct({}) {{
|
||||||
|
{}
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
visibility(1, "public"),
|
||||||
|
i(2),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M._p = fmt(
|
||||||
|
[[{} function __construct(
|
||||||
|
{}
|
||||||
|
) {{
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
visibility(1, "public"),
|
||||||
|
i(2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.strict = t "declare(strict_types=1);"
|
||||||
|
|
||||||
|
M["fn"] = fmt(
|
||||||
|
[[{} function {}({}): {}
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}]],
|
||||||
|
{ visibility(1, "public"), i(2), i(3), i(4, "void"), i(0) }
|
||||||
|
)
|
||||||
|
|
||||||
|
M["then"] = fmt(
|
||||||
|
[[->then(
|
||||||
|
function ({}) {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
)]],
|
||||||
|
{ i(1, ""), i(2, "") }
|
||||||
|
)
|
||||||
|
|
||||||
|
M.test = fmt(
|
||||||
|
[[/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_{}(): void
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{ i(1, ""), i(0, "") }
|
||||||
|
)
|
||||||
|
|
||||||
|
return M
|
||||||
225
back/lua/alpha/snips/ft/yaml.lua
Normal file
225
back/lua/alpha/snips/ft/yaml.lua
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
local rep = require("luasnip.extras").rep
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
str = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: string
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
bool = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: boolean
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
float = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
int = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: integer
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
id = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
class = fmt(
|
||||||
|
[[{}:
|
||||||
|
$ref: '#/components/schemas/{}'
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
date = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
arr = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
{}
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
ref = fmt([[$ref: '#/components/schemas/{}']], { i(1, "") }),
|
||||||
|
obj = fmt(
|
||||||
|
[[type: object
|
||||||
|
properties:
|
||||||
|
{}]],
|
||||||
|
i(1, "")
|
||||||
|
),
|
||||||
|
aint = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: int
|
||||||
|
format: int64
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
astr = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
mut = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: "{}"
|
||||||
|
resolve: '@=mutation("App\\GraphQL\\Mutation\\{}::{}", {}, info)'
|
||||||
|
args:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
rep(1),
|
||||||
|
i(5, ""),
|
||||||
|
i(6, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
input = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: input-object
|
||||||
|
config:
|
||||||
|
fields:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
f = fmt([[{}: {{ type: "{}" }}]], { i(1, ""), i(2, "") }),
|
||||||
|
|
||||||
|
api = fmt(
|
||||||
|
[[openapi: 3.0.2
|
||||||
|
info:
|
||||||
|
title: {}
|
||||||
|
contact:
|
||||||
|
name: eva-team-be
|
||||||
|
version: {}
|
||||||
|
x-bundle-apis: true
|
||||||
|
tags:
|
||||||
|
- name: {}
|
||||||
|
description: {}
|
||||||
|
]],
|
||||||
|
{ i(1, "my app"), i(2, "1.0.0"), i(3, "tag"), i(4, "tag description") }
|
||||||
|
),
|
||||||
|
paths = fmt(
|
||||||
|
[[paths:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(0, "") }
|
||||||
|
),
|
||||||
|
param = fmt(
|
||||||
|
[[parameters:
|
||||||
|
- name: {}
|
||||||
|
description: {}
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
]],
|
||||||
|
{ i(1, ""), i(2, "") }
|
||||||
|
),
|
||||||
|
get = fmt(
|
||||||
|
[[get:
|
||||||
|
operationId: {}
|
||||||
|
description: {}
|
||||||
|
tags: [ {} ]
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Response
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1, "GetOperation"), i(2, "description"), i(3, "tag"), i(4, "") }
|
||||||
|
),
|
||||||
|
|
||||||
|
put = fmt(
|
||||||
|
[[put:
|
||||||
|
operationId: {}
|
||||||
|
tags: [ {} ]
|
||||||
|
description: {}
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: {}
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1, "PutOperation"), i(2, "tag"), i(3, "description"), i(4, ""), i(5, "description"), i(6, "") }
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
186
back/lua/alpha/telescope/init.lua
Normal file
186
back/lua/alpha/telescope/init.lua
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
local SHOULD_RELOAD_TELESCOPE = false
|
||||||
|
|
||||||
|
local reloader = function()
|
||||||
|
if SHOULD_RELOAD_TELESCOPE then
|
||||||
|
Reload "plenary"
|
||||||
|
Reload "telescope"
|
||||||
|
Reload "alpha.telescope.setup"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local fb_actions = require("telescope").extensions.file_browser.actions
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
local my_actions = require "alpha.telescope.my_actions"
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.project_files()
|
||||||
|
local opts = { show_untracked = true } -- 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,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.search_config()
|
||||||
|
require("telescope.builtin").git_files {
|
||||||
|
prompt_title = "< Dotfiles >",
|
||||||
|
cwd = "$HOME/.dotfiles",
|
||||||
|
show_untracked = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.find_nvim_config = function()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "< Neovim >",
|
||||||
|
cwd = "$HOME/.config/nvim/",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.find_nvim_plugin = function()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "< Plugins >",
|
||||||
|
cwd = "$HOME/.config/nvim/lua/plugins/",
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<C-y>", my_actions.create_plugin)
|
||||||
|
map("i", "<C-w>", my_actions.disable_plugin)
|
||||||
|
map("i", "<C-e>", my_actions.enable_plugin)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.grep_string()
|
||||||
|
vim.ui.input({ prompt = "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>" }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.find_symbol()
|
||||||
|
vim.ui.input({ prompt = "Symbol for > " }, function(input)
|
||||||
|
if input == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").lsp_workspace_symbols { query = input }
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.my_plugins()
|
||||||
|
if vim.fn.isdirectory(vim.fn.getenv "HOME" .. "/code/plugins/") == 0 then
|
||||||
|
vim.notify("Directory ~/code/plugins does not exists", vim.log.levels.WARN, { title = "Telescope Mappings" })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
cwd = "~/code/plugins/",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.scratchs()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "Scratchs",
|
||||||
|
no_ignore = true,
|
||||||
|
cwd = "~/.config/nvim/lua/scratchs/",
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-t>", my_actions.create_scratch_file)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.projectionist()
|
||||||
|
return require("telescope").extensions.projectionist.projectionist()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.laravel_commands()
|
||||||
|
return require("telescope").extensions.laravel.laravel()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.api_specs()
|
||||||
|
if vim.fn.isdirectory "./api-specification" == 0 then
|
||||||
|
vim.notify("Directory api-specification does not exists", vim.log.levels.WARN, { title = "Telescope Mappings" })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").git_files {
|
||||||
|
cwd = "./api-specification",
|
||||||
|
show_untracked = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
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()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.refactor()
|
||||||
|
return require("telescope").extensions.refactoring.refactors()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.gateway()
|
||||||
|
return require("alpha.php.gateway").graphql_definitions {
|
||||||
|
layout_config = {
|
||||||
|
horizontal = {
|
||||||
|
preview_width = function(_, cols, _)
|
||||||
|
return math.floor(cols * 0.7)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.file_browser_relative()
|
||||||
|
return M.file_browser { path = "%:p:h" }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.file_browser(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
opts = {
|
||||||
|
path = opts.path,
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
scroll_strategy = "cycle",
|
||||||
|
layout_config = {
|
||||||
|
prompt_position = "top",
|
||||||
|
},
|
||||||
|
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", fb_actions.create_from_prompt)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
})
|
||||||
55
back/lua/alpha/telescope/mappings.lua
Normal file
55
back/lua/alpha/telescope/mappings.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
local map_tele = function(key, f, opts)
|
||||||
|
local default = {
|
||||||
|
mode = "n",
|
||||||
|
options = {},
|
||||||
|
buffer = nil,
|
||||||
|
desc = nil,
|
||||||
|
}
|
||||||
|
opts = opts or {}
|
||||||
|
opts = vim.tbl_deep_extend("force", default, opts or {})
|
||||||
|
|
||||||
|
local rhs = function()
|
||||||
|
R("alpha.telescope")[f](opts.options)
|
||||||
|
end
|
||||||
|
|
||||||
|
local map_options = {
|
||||||
|
remap = false,
|
||||||
|
silent = true,
|
||||||
|
}
|
||||||
|
if opts.buffer then
|
||||||
|
map_options.buffer = opts.buffer
|
||||||
|
end
|
||||||
|
if opts.desc then
|
||||||
|
map_options.desc = "Telescope: " .. opts.desc
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set(opts.mode, key, rhs, map_options)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- not shure what this line does
|
||||||
|
vim.api.nvim_set_keymap(
|
||||||
|
"c",
|
||||||
|
"<c-r><c-r>",
|
||||||
|
"<Plug>(TelescopeFuzzyCommandSearch)",
|
||||||
|
{ noremap = false, nowait = true, desc = "In comand look for previous commands" }
|
||||||
|
)
|
||||||
|
|
||||||
|
map_tele("<leader>pp", "project_files", { desc = "Open Project files" })
|
||||||
|
map_tele("<leader>gc", "branches", { desc = "Git Branches selector" })
|
||||||
|
map_tele("<leader>pw", "grep_word", { desc = "Grep word under cursor" })
|
||||||
|
map_tele("<leader>ps", "grep_string", { desc = "Grep provided input string" })
|
||||||
|
map_tele("<leader>rc", "search_config", { desc = "Search Files in .dotfiles directory" })
|
||||||
|
map_tele("<leader>rn", "find_nvim_config", { desc = "Search Files in nvim config directory" })
|
||||||
|
map_tele("<leader>rp", "find_nvim_plugin", { desc = "Search Neovim plugins" })
|
||||||
|
map_tele("<leader>rs", "scratchs", { desc = "Search Neovim Scratchs files" })
|
||||||
|
map_tele("<leader>ph", "help_tags", { desc = "Neovim Help" })
|
||||||
|
map_tele("<leader>pe", "buffers", { desc = "Open buffers" })
|
||||||
|
map_tele("<leader>pr", "treesitter", { desc = "Treesitter buffer elements" })
|
||||||
|
map_tele("<leader>bb", "file_browser_relative", { desc = "Current directory" })
|
||||||
|
map_tele("<leader>bp", "file_browser", { desc = "Project directory" })
|
||||||
|
map_tele("<leader>gs", "git_status", { desc = "Git status" })
|
||||||
|
map_tele("<leader>ve", "diagnostics", { desc = "Diagnostic of the buffer" })
|
||||||
|
map_tele("<leader>po", "api_specs", { desc = "Openapi directory" })
|
||||||
|
map_tele("<leader>pm", "gateway", { desc = "Graphql mutations and queries" })
|
||||||
|
|
||||||
|
return map_tele
|
||||||
170
back/lua/alpha/telescope/my_actions.lua
Normal file
170
back/lua/alpha/telescope/my_actions.lua
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local action_state = require "telescope.actions.state"
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
|
||||||
|
M.create_plugin = function(prompt_bufnr)
|
||||||
|
local new_plugin = action_state.get_current_line()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
vim.cmd(string.format("edit ~/.config/nvim/lua/plugins/%s.lua", new_plugin))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local get_disable_stm_node = function(bufnr, tree)
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"lua",
|
||||||
|
"alpha_plugin_is_disabled",
|
||||||
|
[[
|
||||||
|
(return_statement
|
||||||
|
(expression_list
|
||||||
|
(table_constructor
|
||||||
|
(field
|
||||||
|
name: (identifier) @enabled (#eq? @enabled "enabled")
|
||||||
|
value: (false) @is_false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get("lua", "alpha_plugin_is_disabled")
|
||||||
|
|
||||||
|
for id, node in query:iter_captures(tree:root(), bufnr) do
|
||||||
|
if query.captures[id] == "enabled" then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_enabled_node = function(bufnr, tree)
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"lua",
|
||||||
|
"alpha_plugin_has_enable_property",
|
||||||
|
[[
|
||||||
|
(return_statement
|
||||||
|
(expression_list
|
||||||
|
(table_constructor
|
||||||
|
(field
|
||||||
|
name: (identifier) @enabled (#eq? @enabled "enabled")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get("lua", "alpha_plugin_has_enable_property")
|
||||||
|
|
||||||
|
for id, node in query:iter_captures(tree:root(), bufnr) do
|
||||||
|
if query.captures[id] == "enabled" then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_return_node = function(bufnr, tree)
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"lua",
|
||||||
|
"alpha_plugin_return_table_constructor",
|
||||||
|
[[
|
||||||
|
(return_statement
|
||||||
|
(expression_list
|
||||||
|
(table_constructor) @table_constructor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get("lua", "alpha_plugin_return_table_constructor")
|
||||||
|
|
||||||
|
for id, node in query:iter_captures(tree:root(), bufnr) do
|
||||||
|
if query.captures[id] == "table_constructor" then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
M.disable_plugin = function(prompt_bufnr)
|
||||||
|
local entry = action_state.get_selected_entry()
|
||||||
|
local uri = vim.uri_from_fname(entry.cwd .. entry[1])
|
||||||
|
local bufnr = vim.uri_to_bufnr(uri)
|
||||||
|
vim.fn.bufload(bufnr)
|
||||||
|
|
||||||
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
|
local parser = parsers.get_parser(bufnr)
|
||||||
|
local tree = parser:parse()[1]
|
||||||
|
|
||||||
|
local disabled_stm_node = get_disable_stm_node(bufnr, tree)
|
||||||
|
if disabled_stm_node ~= nil then
|
||||||
|
vim.notify("Plugin is already disable", vim.log.levels.WARN, {})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local start_line
|
||||||
|
local end_line
|
||||||
|
|
||||||
|
local enable_node = get_enabled_node(bufnr, tree)
|
||||||
|
if enable_node == nil then
|
||||||
|
-- node does not exists need to assume line
|
||||||
|
local return_node = get_return_node(bufnr, tree)
|
||||||
|
|
||||||
|
if return_node == nil then
|
||||||
|
vim.notify("Can determine how to diable the plugin", vim.log.levels.ERROR, {})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
start_line = return_node:start() + 2
|
||||||
|
end_line = start_line
|
||||||
|
else
|
||||||
|
start_line = enable_node:start()
|
||||||
|
end_line = start_line + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, start_line, end_line, false, { " enabled = false," })
|
||||||
|
vim.notify("Plugin " .. entry[1] .. " Disabled", vim.log.levels.INFO, {})
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
vim.api.nvim_buf_call(bufnr, function()
|
||||||
|
vim.cmd "write"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.enable_plugin = function(prompt_bufnr)
|
||||||
|
local entry = action_state.get_selected_entry()
|
||||||
|
local uri = vim.uri_from_fname(entry.cwd .. entry[1])
|
||||||
|
local bufnr = vim.uri_to_bufnr(uri)
|
||||||
|
vim.fn.bufload(bufnr)
|
||||||
|
|
||||||
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
|
local parser = parsers.get_parser(bufnr)
|
||||||
|
|
||||||
|
local tree = parser:parse()[1]
|
||||||
|
|
||||||
|
local disabled_stm_node = get_disable_stm_node(bufnr, tree)
|
||||||
|
if disabled_stm_node == nil then
|
||||||
|
vim.notify("Plugin is already Enable", vim.log.levels.WARN, {})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local enable_line = disabled_stm_node:start()
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, enable_line, enable_line + 1, false, {})
|
||||||
|
vim.notify("Plugin " .. entry[1] .. " Enabled", vim.log.levels.INFO, {})
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
vim.api.nvim_buf_call(bufnr, function()
|
||||||
|
vim.cmd "write"
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.create_scratch_file = function(prompt_bufnr)
|
||||||
|
local new_scratch = action_state.get_current_line()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
vim.cmd(string.format("edit ~/.config/nvim/lua/scratchs/%s.lua", new_scratch))
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
222
back/lua/alpha/telescope/setup.lua
Normal file
222
back/lua/alpha/telescope/setup.lua
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
local actions = require "telescope.actions"
|
||||||
|
local action_state = require "telescope.actions.state"
|
||||||
|
local action_layout = require "telescope.actions.layout"
|
||||||
|
|
||||||
|
local set_prompt_to_entry_value = function(prompt_bufnr)
|
||||||
|
local entry = action_state.get_selected_entry()
|
||||||
|
if not entry or not type(entry) == "table" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
action_state.get_current_picker(prompt_bufnr):reset_prompt(entry.ordinal)
|
||||||
|
end
|
||||||
|
|
||||||
|
local filetype_hook = function(filepath, bufnr, opts)
|
||||||
|
-- Here for example you can say: if ft == "xyz" then this_regex_highlighing else nothing end
|
||||||
|
--
|
||||||
|
local is_image = function(filepath)
|
||||||
|
local image_extensions = { "png", "jpg" } -- Supported image formats
|
||||||
|
local split_path = vim.split(filepath:lower(), ".", { plain = true })
|
||||||
|
local extension = split_path[#split_path]
|
||||||
|
return vim.tbl_contains(image_extensions, extension)
|
||||||
|
end
|
||||||
|
if not is_image(filepath) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local ui = require "image.ui"
|
||||||
|
local options = require "image.options"
|
||||||
|
local dimensions = require "image.dimensions"
|
||||||
|
local api = require "image.api"
|
||||||
|
local config = require "image.config"
|
||||||
|
local user_opts = {
|
||||||
|
render = {
|
||||||
|
foreground_color = true,
|
||||||
|
background_color = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local global_opts = vim.tbl_deep_extend("force", config.DEFAULT_OPTS, user_opts)
|
||||||
|
|
||||||
|
local ascii_width, ascii_height, horizontal_padding, vertical_padding, img_width, img_height =
|
||||||
|
dimensions.calculate_ascii_width_height(opts.winid, filepath, global_opts)
|
||||||
|
options.set_options_before_render(bufnr)
|
||||||
|
ui.buf_clear(bufnr)
|
||||||
|
local label = ui.create_label(
|
||||||
|
filepath,
|
||||||
|
ascii_width,
|
||||||
|
horizontal_padding,
|
||||||
|
global_opts.render.show_image_dimensions,
|
||||||
|
img_width,
|
||||||
|
img_height
|
||||||
|
)
|
||||||
|
|
||||||
|
api.get_ascii_data_sync(filepath, ascii_width, ascii_height, global_opts, function(ascii_data)
|
||||||
|
ui.buf_insert_data_with_padding(bufnr, ascii_data, horizontal_padding, vertical_padding, label, global_opts)
|
||||||
|
|
||||||
|
options.set_options_after_render(bufnr)
|
||||||
|
end)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
require("telescope").setup {
|
||||||
|
defaults = {
|
||||||
|
preview = {
|
||||||
|
filetype_hook = filetype_hook,
|
||||||
|
},
|
||||||
|
prompt_prefix = "❯ ",
|
||||||
|
selection_caret = "❯ ",
|
||||||
|
|
||||||
|
winblend = 0,
|
||||||
|
|
||||||
|
layout_strategy = "horizontal",
|
||||||
|
layout_config = {
|
||||||
|
width = 0.95,
|
||||||
|
height = 0.85,
|
||||||
|
-- preview_cutoff = 120,
|
||||||
|
prompt_position = "bottom",
|
||||||
|
|
||||||
|
horizontal = {
|
||||||
|
preview_width = function(_, cols, _)
|
||||||
|
if cols > 200 then
|
||||||
|
return math.floor(cols * 0.5)
|
||||||
|
else
|
||||||
|
return math.floor(cols * 0.7)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
vertical = {
|
||||||
|
width = 0.9,
|
||||||
|
height = 0.95,
|
||||||
|
preview_height = 0.5,
|
||||||
|
},
|
||||||
|
|
||||||
|
flex = {
|
||||||
|
horizontal = {
|
||||||
|
preview_width = 0.9,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
selection_strategy = "reset",
|
||||||
|
sorting_strategy = "descending",
|
||||||
|
scroll_strategy = "cycle",
|
||||||
|
color_devicons = true,
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
-- ["<C-x>"] = false,
|
||||||
|
-- ["<C-s>"] = actions.select_horizontal,
|
||||||
|
["<C-n>"] = "move_selection_next",
|
||||||
|
|
||||||
|
["<C-y>"] = set_prompt_to_entry_value,
|
||||||
|
|
||||||
|
-- These are new :)
|
||||||
|
["<M-p>"] = action_layout.toggle_preview,
|
||||||
|
["<M-m>"] = action_layout.toggle_mirror,
|
||||||
|
-- ["<M-p>"] = action_layout.toggle_prompt_position,
|
||||||
|
|
||||||
|
-- ["<M-m>"] = actions.master_stack,
|
||||||
|
|
||||||
|
-- ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||||
|
-- ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||||
|
|
||||||
|
-- This is nicer when used with smart-history plugin.
|
||||||
|
["<C-k>"] = actions.cycle_history_next,
|
||||||
|
["<C-j>"] = actions.cycle_history_prev,
|
||||||
|
|
||||||
|
-- ["<c-space>"] = function(prompt_bufnr)
|
||||||
|
-- local opts = {
|
||||||
|
-- callback = actions.toggle_selection,
|
||||||
|
-- loop_callback = actions.send_selected_to_qflist,
|
||||||
|
-- }
|
||||||
|
-- require("telescope").extensions.hop._hop_loop(prompt_bufnr, opts)
|
||||||
|
-- end,
|
||||||
|
|
||||||
|
-- ["<C-w>"] = function()
|
||||||
|
-- vim.api.nvim_input("<c-s-w>")
|
||||||
|
-- end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||||
|
-- file_ignore_patterns = nil,
|
||||||
|
|
||||||
|
file_previewer = require("telescope.previewers").vim_buffer_cat.new,
|
||||||
|
grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new,
|
||||||
|
qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new,
|
||||||
|
|
||||||
|
history = {
|
||||||
|
path = "~/.local/share/nvim/databases/telescope_history.sqlite3",
|
||||||
|
limit = 100,
|
||||||
|
},
|
||||||
|
-- buffer_previewer_maker = new_maker,
|
||||||
|
},
|
||||||
|
|
||||||
|
pickers = {
|
||||||
|
fd = {
|
||||||
|
mappings = {
|
||||||
|
n = {
|
||||||
|
["kj"] = "close",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
git_branches = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<C-a>"] = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
fzy_native = {
|
||||||
|
override_generic_sorter = true,
|
||||||
|
override_file_sorter = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
fzf_writer = {
|
||||||
|
use_highlighter = false,
|
||||||
|
minimum_grep_characters = 6,
|
||||||
|
},
|
||||||
|
|
||||||
|
hop = {
|
||||||
|
-- keys define your hop keys in order; defaults to roughly lower- and uppercased home row
|
||||||
|
keys = { "a", "s", "d", "f", "g", "h", "j", "k", "l", ";" }, -- ... and more
|
||||||
|
|
||||||
|
-- Highlight groups to link to signs and lines; the below configuration refers to demo
|
||||||
|
-- sign_hl typically only defines foreground to possibly be combined with line_hl
|
||||||
|
sign_hl = { "WarningMsg", "Title" },
|
||||||
|
|
||||||
|
-- optional, typically a table of two highlight groups that are alternated between
|
||||||
|
line_hl = { "CursorLine", "Normal" },
|
||||||
|
|
||||||
|
-- options specific to `hop_loop`
|
||||||
|
-- true temporarily disables Telescope selection highlighting
|
||||||
|
clear_selection_hl = false,
|
||||||
|
-- highlight hopped to entry with telescope selection highlight
|
||||||
|
-- note: mutually exclusive with `clear_selection_hl`
|
||||||
|
trace_entry = true,
|
||||||
|
-- jump to entry where hoop loop was started from
|
||||||
|
reset_selection = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
["ui-select"] = {
|
||||||
|
require("telescope.themes").get_dropdown {
|
||||||
|
borderchars = {
|
||||||
|
prompt = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||||
|
results = { "─", "│", "─", "│", "╭", "╮", "┤", "├" },
|
||||||
|
preview = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||||
|
},
|
||||||
|
width = 0.8,
|
||||||
|
previewer = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope").load_extension "notify"
|
||||||
|
require("telescope").load_extension "file_browser"
|
||||||
|
require("telescope").load_extension "ui-select"
|
||||||
|
require("telescope").load_extension "fzf"
|
||||||
50
back/lua/alpha/test_menu.lua
Normal file
50
back/lua/alpha/test_menu.lua
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
local hydra = require "hydra"
|
||||||
|
|
||||||
|
local hint = [[
|
||||||
|
Vim Tests
|
||||||
|
_n_: Near test _h_: Harpoon ^
|
||||||
|
_f_: Current file _s_: Test Suit ^
|
||||||
|
_l_: Test Last _g_: Visit
|
||||||
|
_w_: Watch last Test _p_: stop watch
|
||||||
|
^ ^ _<Esc>_ ^
|
||||||
|
]]
|
||||||
|
local auto_cmd_id = nil
|
||||||
|
local stopAutoCommand = function()
|
||||||
|
if auto_cmd_id ~= nil then
|
||||||
|
vim.api.nvim_del_autocmd(auto_cmd_id)
|
||||||
|
auto_cmd_id = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local startAutoCommand = function()
|
||||||
|
stopAutoCommand()
|
||||||
|
auto_cmd_id = vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
|
pattern = { "*.php", "*.feature", "*.yaml" },
|
||||||
|
command = "TestLast",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
hydra {
|
||||||
|
name = "vimtest",
|
||||||
|
hint = hint,
|
||||||
|
mode = "n",
|
||||||
|
config = {
|
||||||
|
color = "teal",
|
||||||
|
invoke_on_body = true,
|
||||||
|
hint = {
|
||||||
|
border = "rounded",
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
body = "<leader>t",
|
||||||
|
heads = {
|
||||||
|
{ "n", ":TestNearest<CR>" },
|
||||||
|
{ "h", ":TestNearest -strategy=harpoon<CR>" },
|
||||||
|
{ "f", ":TestFile<CR>" },
|
||||||
|
{ "s", ":TestSuit<CR>" },
|
||||||
|
{ "l", ":TestLast<CR>" },
|
||||||
|
{ "g", ":TestVisit<CR>" },
|
||||||
|
{ "w", startAutoCommand },
|
||||||
|
{ "p", stopAutoCommand },
|
||||||
|
{ "<Esc>", nil, { exit = true } },
|
||||||
|
},
|
||||||
|
}
|
||||||
65
back/lua/alpha/test_strategy.lua
Normal file
65
back/lua/alpha/test_strategy.lua
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
local Job = require "plenary.job"
|
||||||
|
|
||||||
|
local function splitString(input_string)
|
||||||
|
local parts = {}
|
||||||
|
local in_quote = false
|
||||||
|
local part_start = 1
|
||||||
|
|
||||||
|
for i = 1, #input_string do
|
||||||
|
local char = input_string:sub(i, i)
|
||||||
|
|
||||||
|
if char == "'" then
|
||||||
|
in_quote = not in_quote
|
||||||
|
elseif char == " " and not in_quote then
|
||||||
|
local part = input_string:sub(part_start, i - 1)
|
||||||
|
-- Remove surrounding quotes if they exist
|
||||||
|
if part:sub(1, 1) == "'" and part:sub(-1) == "'" then
|
||||||
|
part = part:sub(2, -2)
|
||||||
|
end
|
||||||
|
table.insert(parts, part)
|
||||||
|
part_start = i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the last part (and remove surrounding quotes if they exist)
|
||||||
|
local part = input_string:sub(part_start)
|
||||||
|
if part:sub(1, 1) == "'" and part:sub(-1) == "'" then
|
||||||
|
part = part:sub(2, -2)
|
||||||
|
end
|
||||||
|
table.insert(parts, part)
|
||||||
|
|
||||||
|
return parts
|
||||||
|
end
|
||||||
|
|
||||||
|
local function myStrategy(cmd)
|
||||||
|
--convert cmd from string to table
|
||||||
|
if type(cmd) == "string" then
|
||||||
|
-- do not split quoted parts of the string
|
||||||
|
cmd = splitString(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- get first element of cmd and remove from the cmd
|
||||||
|
local cmd_name = table.remove(cmd, 1)
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
Job:new({
|
||||||
|
command = cmd_name,
|
||||||
|
args = cmd,
|
||||||
|
on_exit = function(j, return_val)
|
||||||
|
-- in case of result val 0 show success message
|
||||||
|
if return_val == 0 then
|
||||||
|
vim.notify("Test run successfully", vim.log.levels.INFO, { title = "Test" })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local result = j:stderr_result() or j:stdout_result()
|
||||||
|
-- join result in a single string
|
||||||
|
result = table.concat(result, "\n")
|
||||||
|
-- escape / characters
|
||||||
|
result = result:gsub("/", "\\/")
|
||||||
|
vim.notify(result, vim.log.levels.ERROR, { title = "Test" })
|
||||||
|
end,
|
||||||
|
}):start()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.g["test#custom_strategies"] = { myStrategy = myStrategy }
|
||||||
|
vim.g["test#strategy"] = "myStrategy"
|
||||||
11
back/lua/alpha/utils.lua
Normal file
11
back/lua/alpha/utils.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.save_and_exec = function()
|
||||||
|
vim.api.nvim_command "silent w"
|
||||||
|
vim.api.nvim_command "so"
|
||||||
|
|
||||||
|
local current_file_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t")
|
||||||
|
vim.notify(string.format("File %s Sourced", current_file_name), vim.log.levels.INFO, { title = "Alpha Developer" })
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
14
back/lua/config/autocmds.lua
Normal file
14
back/lua/config/autocmds.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
-- Autocmds are automatically loaded on the VeryLazy event
|
||||||
|
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||||
|
-- Add any additional autocmds here
|
||||||
|
|
||||||
|
-- https://www.reddit.com/r/neovim/comments/13zd9sc/is_there_a_way_to_configure_indentation_per/
|
||||||
|
-- https://www.reddit.com/r/neovim/comments/vu1y6e/correct_way_to_set_language_specific_settings_in/
|
||||||
|
vim.cmd([[
|
||||||
|
augroup myfiletypes
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType ruby,lua,eruby,yaml,javascript,typescript,html,css set ai sw=2 sts=2 et
|
||||||
|
autocmd FileType java,kotlin,xml set ai sw=4 sts=4 et
|
||||||
|
autocmd FileType asciidoc setlocal wrap
|
||||||
|
augroup END
|
||||||
|
]])
|
||||||
20
back/lua/config/keymaps.lua
Normal file
20
back/lua/config/keymaps.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-- Keymaps are automatically loaded on the VeryLazy event
|
||||||
|
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||||
|
-- Add any additional keymaps here
|
||||||
|
|
||||||
|
local bind = vim.keymap.set
|
||||||
|
local opts = { silent = true, noremap = true }
|
||||||
|
|
||||||
|
-- for russian layout
|
||||||
|
bind("i", "<c-х>", "<C-[>", opts)
|
||||||
|
bind("n", "л", "gk", opts)
|
||||||
|
bind("n", "о", "gj", opts)
|
||||||
|
bind("i", "<C-г>", "<C-G>u<C-U>", opts)
|
||||||
|
bind("i", "<C-ц>", "<C-G>u<C-W>", opts)
|
||||||
|
|
||||||
|
bind("n", "[c", function()
|
||||||
|
require("treesitter-context").go_to_context()
|
||||||
|
end)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>[", "<Cmd>call append(line('.') - 1, repeat([''], v:count1))<CR>")
|
||||||
|
vim.keymap.set("n", "<leader>]", "<Cmd>call append(line('.'), repeat([''], v:count1))<CR>")
|
||||||
57
back/lua/config/lazy.lua
Normal file
57
back/lua/config/lazy.lua
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
-- bootstrap lazy.nvim
|
||||||
|
-- stylua: ignore
|
||||||
|
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||||
|
|
||||||
|
require('lazy').setup({
|
||||||
|
change_detection = { notify = false },
|
||||||
|
spec = {
|
||||||
|
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||||
|
{ import = "lazyvim.plugins.extras.formatting.prettier" },
|
||||||
|
-- { import = "lazyvim.plugins.extras.linting.eslint" },
|
||||||
|
-- { import = "lazyvim.plugins.extras.lsp.none-ls" },
|
||||||
|
{ import = "lazyvim.plugins.extras.dap.core" },
|
||||||
|
{ import = "lazyvim.plugins.extras.coding.yanky" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.markdown" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.docker" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.go" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.elixir" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.java" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.python" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.ruby" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.terraform" },
|
||||||
|
{ import = "lazyvim.plugins.extras.lang.yaml" },
|
||||||
|
{ import = "plugins" },
|
||||||
|
},
|
||||||
|
defaults = {
|
||||||
|
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||||
|
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||||
|
lazy = false,
|
||||||
|
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||||
|
-- have outdated releases, which may break your Neovim install.
|
||||||
|
version = false, -- always use the latest git commit
|
||||||
|
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||||
|
},
|
||||||
|
-- install = { colorscheme = { "tokyonight", "habamax" } },
|
||||||
|
checker = { enabled = true }, -- automatically check for plugin updates
|
||||||
|
performance = {
|
||||||
|
rtp = {
|
||||||
|
-- disable some rtp plugins
|
||||||
|
disabled_plugins = {
|
||||||
|
"gzip",
|
||||||
|
-- "matchit",
|
||||||
|
-- "matchparen",
|
||||||
|
-- "netrwPlugin",
|
||||||
|
"tarPlugin",
|
||||||
|
"tohtml",
|
||||||
|
"tutor",
|
||||||
|
"zipPlugin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
13
back/lua/config/options.lua
Normal file
13
back/lua/config/options.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- Options are automatically loaded before lazy.nvim startup
|
||||||
|
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||||
|
-- Add any additional options here
|
||||||
|
|
||||||
|
vim.o.langmap =
|
||||||
|
"ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz"
|
||||||
|
|
||||||
|
vim.o.relativenumber = false
|
||||||
|
vim.o.spelllang = "ru_ru,en_us"
|
||||||
|
vim.o.linebreak = true
|
||||||
|
vim.g.autoformat = false
|
||||||
|
|
||||||
|
require("lazyvim.util").get_root = vim.loop.cwd
|
||||||
0
back/lua/config/usercmds.lua
Normal file
0
back/lua/config/usercmds.lua
Normal file
75
back/lua/plugins/cmp.lua
Normal file
75
back/lua/plugins/cmp.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
keys = function()
|
||||||
|
return {}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-emoji",
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
-- cmp.setup.cmdline(":", {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
-- sources = cmp.config.sources({
|
||||||
|
-- { name = "path" },
|
||||||
|
-- }, {
|
||||||
|
-- {
|
||||||
|
-- name = "cmdline",
|
||||||
|
-- option = {
|
||||||
|
-- ignore_cmds = { "Man", "!" },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- }),
|
||||||
|
-- })
|
||||||
|
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
-- @param opts cmp.ConfigSchema
|
||||||
|
opts = function(_, opts)
|
||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
opts.preselect = cmp.PreselectMode.None
|
||||||
|
opts.completion = {
|
||||||
|
completeopt = "noselect",
|
||||||
|
}
|
||||||
|
|
||||||
|
local has_words_before = function()
|
||||||
|
unpack = unpack or table.unpack
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
|
opts.mapping = vim.tbl_extend("force", opts.mapping, {
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||||
|
-- this way you will only jump inside the snippet region
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
11
back/lua/plugins/colorscheme.lua
Normal file
11
back/lua/plugins/colorscheme.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
return {
|
||||||
|
"neanias/everforest-nvim",
|
||||||
|
lazy = false,
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
vim.cmd.colorscheme "everforest"
|
||||||
|
vim.cmd "let g:everforest_better_performance = 1"
|
||||||
|
vim.cmd "let g:everforest_background = 'soft'"
|
||||||
|
vim.cmd "let g:airline_theme = 'everforest'"
|
||||||
|
end,
|
||||||
|
}
|
||||||
8
back/lua/plugins/core.lua
Normal file
8
back/lua/plugins/core.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"LazyVim/LazyVim",
|
||||||
|
opts = {
|
||||||
|
colorscheme = "catppuccin"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
8
back/lua/plugins/disabled.lua
Normal file
8
back/lua/plugins/disabled.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
{ "echasnovski/mini.indentscope", enabled = false },
|
||||||
|
{ "folke/noice.nvim", enabled = false },
|
||||||
|
{ "rcarriga/nvim-notify", enabled = false },
|
||||||
|
{ "folke/flash.nvim", enabled = false },
|
||||||
|
{ "ggandor/flit.nvim", enabled = false },
|
||||||
|
-- { "ggandor/leap.nvim", enabled = false },
|
||||||
|
}
|
||||||
15
back/lua/plugins/init.lua
Normal file
15
back/lua/plugins/init.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"jwalton512/vim-blade",
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tpope/vim-dispatch",
|
||||||
|
cmd = { "Make", "Dispatch" },
|
||||||
|
},
|
||||||
|
"tpope/vim-surround",
|
||||||
|
"tpope/vim-repeat",
|
||||||
|
"tpope/vim-rhubarb",
|
||||||
|
"tpope/vim-dotenv",
|
||||||
|
"tpope/vim-eunuch",
|
||||||
|
}
|
||||||
26
back/lua/plugins/lspconfig.lua
Normal file
26
back/lua/plugins/lspconfig.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
diagnostics = {
|
||||||
|
underline = true,
|
||||||
|
virtual_text = false,
|
||||||
|
float = {
|
||||||
|
border = "rounded",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
servers = {
|
||||||
|
kotlin_language_server = {},
|
||||||
|
bashls = {},
|
||||||
|
lemminx = {},
|
||||||
|
ltex = {
|
||||||
|
settings = {
|
||||||
|
ltex = {
|
||||||
|
language = "ru-RU",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
8
back/lua/plugins/mason.lua
Normal file
8
back/lua/plugins/mason.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
opts = function(_, opts)
|
||||||
|
-- table.insert(opts.ensure_installed, "google-java-format")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
254
back/lua/plugins/neo-tree.lua
Normal file
254
back/lua/plugins/neo-tree.lua
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
return {
|
||||||
|
"nvim-neo-tree/neo-tree.nvim",
|
||||||
|
branch = "v2.x",
|
||||||
|
reqrires = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
|
||||||
|
"MunifTanjim/nui.nvim",
|
||||||
|
{
|
||||||
|
-- only needed if you want to use the commands with "_with_window_picker" suffix
|
||||||
|
's1n7ax/nvim-window-picker',
|
||||||
|
tag = "v1.*",
|
||||||
|
config = function()
|
||||||
|
require 'window-picker'.setup({
|
||||||
|
autoselect_one = true,
|
||||||
|
include_current = false,
|
||||||
|
filter_rules = {
|
||||||
|
-- filter using buffer options
|
||||||
|
bo = {
|
||||||
|
-- if the file type is one of following, the window will be ignored
|
||||||
|
filetype = { 'neo-tree', "neo-tree-popup", "notify" },
|
||||||
|
|
||||||
|
-- if the buffer type is one of following, the window will be ignored
|
||||||
|
buftype = { 'terminal', "quickfix" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
other_win_hl_color = '#e35e4f',
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
-- Unless you are still migrating, remove the deprecated commands from v1.x
|
||||||
|
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
|
||||||
|
|
||||||
|
-- If you want icons for diagnostic errors, you'll need to define them somewhere:
|
||||||
|
vim.fn.sign_define("DiagnosticSignError",
|
||||||
|
{ text = " ", texthl = "DiagnosticSignError" })
|
||||||
|
vim.fn.sign_define("DiagnosticSignWarn",
|
||||||
|
{ text = " ", texthl = "DiagnosticSignWarn" })
|
||||||
|
vim.fn.sign_define("DiagnosticSignInfo",
|
||||||
|
{ text = " ", texthl = "DiagnosticSignInfo" })
|
||||||
|
vim.fn.sign_define("DiagnosticSignHint",
|
||||||
|
{ text = "", texthl = "DiagnosticSignHint" })
|
||||||
|
-- NOTE: this is changed from v1.x, which used the old style of highlight groups
|
||||||
|
-- in the form "LspDiagnosticsSignWarning"
|
||||||
|
|
||||||
|
require("neo-tree").setup({
|
||||||
|
close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
|
||||||
|
popup_border_style = "rounded",
|
||||||
|
enable_git_status = true,
|
||||||
|
enable_diagnostics = true,
|
||||||
|
sort_case_insensitive = false, -- used when sorting files and directories in the tree
|
||||||
|
sort_function = nil, -- use a custom function for sorting files and directories in the tree
|
||||||
|
-- sort_function = function (a,b)
|
||||||
|
-- if a.type == b.type then
|
||||||
|
-- return a.path > b.path
|
||||||
|
-- else
|
||||||
|
-- return a.type > b.type
|
||||||
|
-- end
|
||||||
|
-- end , -- this sorts files and directories descendantly
|
||||||
|
default_component_configs = {
|
||||||
|
container = {
|
||||||
|
enable_character_fade = true
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
indent_size = 2,
|
||||||
|
padding = 1, -- extra padding on left hand side
|
||||||
|
-- indent guides
|
||||||
|
with_markers = true,
|
||||||
|
indent_marker = "│",
|
||||||
|
last_indent_marker = "└",
|
||||||
|
highlight = "NeoTreeIndentMarker",
|
||||||
|
-- expander config, needed for nesting files
|
||||||
|
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
|
||||||
|
expander_collapsed = "",
|
||||||
|
expander_expanded = "",
|
||||||
|
expander_highlight = "NeoTreeExpander",
|
||||||
|
},
|
||||||
|
icon = {
|
||||||
|
folder_closed = "",
|
||||||
|
folder_open = "",
|
||||||
|
folder_empty = "ﰊ",
|
||||||
|
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
|
||||||
|
-- then these will never be used.
|
||||||
|
default = "*",
|
||||||
|
highlight = "NeoTreeFileIcon"
|
||||||
|
},
|
||||||
|
modified = {
|
||||||
|
symbol = "[+]",
|
||||||
|
highlight = "NeoTreeModified",
|
||||||
|
},
|
||||||
|
name = {
|
||||||
|
trailing_slash = false,
|
||||||
|
use_git_status_colors = true,
|
||||||
|
highlight = "NeoTreeFileName",
|
||||||
|
},
|
||||||
|
git_status = {
|
||||||
|
symbols = {
|
||||||
|
-- Change type
|
||||||
|
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
|
||||||
|
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
|
||||||
|
deleted = "✖", -- this can only be used in the git_status source
|
||||||
|
renamed = "", -- this can only be used in the git_status source
|
||||||
|
-- Status type
|
||||||
|
untracked = "",
|
||||||
|
ignored = "",
|
||||||
|
unstaged = "",
|
||||||
|
staged = "",
|
||||||
|
conflict = "",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
position = "left",
|
||||||
|
width = 40,
|
||||||
|
mapping_options = {
|
||||||
|
noremap = true,
|
||||||
|
nowait = true,
|
||||||
|
},
|
||||||
|
mappings = {
|
||||||
|
["<space>"] = {
|
||||||
|
"toggle_node",
|
||||||
|
nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
|
||||||
|
},
|
||||||
|
["<2-LeftMouse>"] = "open",
|
||||||
|
["<cr>"] = "open",
|
||||||
|
["<esc>"] = "revert_preview",
|
||||||
|
["P"] = { "toggle_preview", config = { use_float = true } },
|
||||||
|
["l"] = "focus_preview",
|
||||||
|
["S"] = "open_split",
|
||||||
|
["s"] = "open_vsplit",
|
||||||
|
-- ["S"] = "split_with_window_picker",
|
||||||
|
-- ["s"] = "vsplit_with_window_picker",
|
||||||
|
["t"] = "open_tabnew",
|
||||||
|
-- ["<cr>"] = "open_drop",
|
||||||
|
-- ["t"] = "open_tab_drop",
|
||||||
|
["w"] = "open_with_window_picker",
|
||||||
|
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
|
||||||
|
["C"] = "close_node",
|
||||||
|
-- ['C'] = 'close_all_subnodes',
|
||||||
|
["z"] = "close_all_nodes",
|
||||||
|
--["Z"] = "expand_all_nodes",
|
||||||
|
["a"] = {
|
||||||
|
"add",
|
||||||
|
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
|
||||||
|
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
|
||||||
|
config = {
|
||||||
|
show_path = "none" -- "none", "relative", "absolute"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
|
||||||
|
["d"] = "delete",
|
||||||
|
["r"] = "rename",
|
||||||
|
["y"] = "copy_to_clipboard",
|
||||||
|
["x"] = "cut_to_clipboard",
|
||||||
|
["p"] = "paste_from_clipboard",
|
||||||
|
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
|
||||||
|
-- ["c"] = {
|
||||||
|
-- "copy",
|
||||||
|
-- config = {
|
||||||
|
-- show_path = "none" -- "none", "relative", "absolute"
|
||||||
|
-- }
|
||||||
|
--}
|
||||||
|
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
|
||||||
|
["q"] = "close_window",
|
||||||
|
["R"] = "refresh",
|
||||||
|
["?"] = "show_help",
|
||||||
|
["<"] = "prev_source",
|
||||||
|
[">"] = "next_source",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
nesting_rules = {},
|
||||||
|
filesystem = {
|
||||||
|
filtered_items = {
|
||||||
|
visible = false, -- when true, they will just be displayed differently than normal items
|
||||||
|
hide_dotfiles = true,
|
||||||
|
hide_gitignored = true,
|
||||||
|
hide_hidden = true, -- only works on Windows for hidden files/directories
|
||||||
|
hide_by_name = {
|
||||||
|
--"node_modules"
|
||||||
|
},
|
||||||
|
hide_by_pattern = { -- uses glob style patterns
|
||||||
|
--"*.meta",
|
||||||
|
--"*/src/*/tsconfig.json",
|
||||||
|
},
|
||||||
|
always_show = { -- remains visible even if other settings would normally hide it
|
||||||
|
--".gitignored",
|
||||||
|
},
|
||||||
|
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
|
||||||
|
--".DS_Store",
|
||||||
|
--"thumbs.db"
|
||||||
|
},
|
||||||
|
never_show_by_pattern = { -- uses glob style patterns
|
||||||
|
--".null-ls_*",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
follow_current_file = false, -- This will find and focus the file in the active buffer every
|
||||||
|
-- time the current file is changed while the tree is open.
|
||||||
|
group_empty_dirs = false, -- when true, empty folders will be grouped together
|
||||||
|
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
|
||||||
|
-- in whatever position is specified in window.position
|
||||||
|
-- "open_current", -- netrw disabled, opening a directory opens within the
|
||||||
|
-- window like netrw would, regardless of window.position
|
||||||
|
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
|
||||||
|
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
|
||||||
|
-- instead of relying on nvim autocmd events.
|
||||||
|
window = {
|
||||||
|
mappings = {
|
||||||
|
["<bs>"] = "navigate_up",
|
||||||
|
["."] = "set_root",
|
||||||
|
["H"] = "toggle_hidden",
|
||||||
|
["/"] = "fuzzy_finder",
|
||||||
|
["D"] = "fuzzy_finder_directory",
|
||||||
|
["#"] = "fuzzy_sorter", -- fuzzy sorting using the fzy algorithm
|
||||||
|
-- ["D"] = "fuzzy_sorter_directory",
|
||||||
|
["f"] = "filter_on_submit",
|
||||||
|
["<c-x>"] = "clear_filter",
|
||||||
|
["[g"] = "prev_git_modified",
|
||||||
|
["]g"] = "next_git_modified",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buffers = {
|
||||||
|
follow_current_file = true, -- This will find and focus the file in the active buffer every
|
||||||
|
-- time the current file is changed while the tree is open.
|
||||||
|
group_empty_dirs = true, -- when true, empty folders will be grouped together
|
||||||
|
show_unloaded = true,
|
||||||
|
window = {
|
||||||
|
mappings = {
|
||||||
|
["bd"] = "buffer_delete",
|
||||||
|
["<bs>"] = "navigate_up",
|
||||||
|
["."] = "set_root",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
git_status = {
|
||||||
|
window = {
|
||||||
|
position = "float",
|
||||||
|
mappings = {
|
||||||
|
["A"] = "git_add_all",
|
||||||
|
["gu"] = "git_unstage_file",
|
||||||
|
["ga"] = "git_add_file",
|
||||||
|
["gr"] = "git_revert_file",
|
||||||
|
["gc"] = "git_commit",
|
||||||
|
["gp"] = "git_push",
|
||||||
|
["gg"] = "git_commit_and_push",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.cmd([[nnoremap \ :Neotree reveal<cr>]])
|
||||||
|
end
|
||||||
|
}
|
||||||
46
back/lua/plugins/others.lua
Normal file
46
back/lua/plugins/others.lua
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"tigion/nvim-asciidoc-preview",
|
||||||
|
ft = { "asciidoc" },
|
||||||
|
-- opts = {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"windwp/nvim-autopairs",
|
||||||
|
event = "InsertEnter",
|
||||||
|
opts = {}, -- this is equalent to setup({}) function
|
||||||
|
},
|
||||||
|
{ "isobit/vim-caddyfile" },
|
||||||
|
{ -- maybe https://github.com/0x00-ketsu/autosave.nvim
|
||||||
|
"0x00-ketsu/autosave.nvim",
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Wansmer/treesj",
|
||||||
|
keys = {
|
||||||
|
{ "<leader>j", "<cmd>TSJToggle<cr>", desc = "Join Toggle" },
|
||||||
|
},
|
||||||
|
opts = { use_default_keymaps = false, max_join_length = 150 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"s1n7ax/nvim-window-picker",
|
||||||
|
name = "window-picker",
|
||||||
|
event = "VeryLazy",
|
||||||
|
version = "2.*",
|
||||||
|
config = function()
|
||||||
|
require("window-picker").setup()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ "slim-template/vim-slim" },
|
||||||
|
{ "tpope/vim-rails" },
|
||||||
|
-- use 'slim-template/vim-slim'
|
||||||
|
{ "dhruvasagar/vim-table-mode" },
|
||||||
|
{ "tree-sitter/tree-sitter-embedded-template" },
|
||||||
|
{ "RRethy/nvim-treesitter-endwise" },
|
||||||
|
{ "dyng/ctrlsf.vim" },
|
||||||
|
{
|
||||||
|
"kylechui/nvim-surround",
|
||||||
|
version = "*", -- Use for stability; omit to use `main` branch for the latest features
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
24
back/lua/plugins/telescope.lua
Normal file
24
back/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
opts = {
|
||||||
|
defaults = {
|
||||||
|
-- sorting_strategy = "ascending",
|
||||||
|
mappings = {
|
||||||
|
-- restore default behavior
|
||||||
|
i = {
|
||||||
|
["<C-u>"] = false,
|
||||||
|
["<C-d>"] = false,
|
||||||
|
},
|
||||||
|
n = {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pickers = {
|
||||||
|
buffers = {
|
||||||
|
ignore_current_buffer = true,
|
||||||
|
sort_mru = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
10
back/lua/plugins/treesitter.lua
Normal file
10
back/lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
opts = {
|
||||||
|
endwise = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
0
back/lua/scratchs/.gitkeep
Normal file
0
back/lua/scratchs/.gitkeep
Normal file
50
current_config/lua/alpha/animations.lua
Normal file
50
current_config/lua/alpha/animations.lua
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
local redraw_buffer = function()
|
||||||
|
local Animation = require "animation"
|
||||||
|
local fps = 45 -- frames per second
|
||||||
|
local easing = require "animation.easing"
|
||||||
|
|
||||||
|
local buffer = 0
|
||||||
|
local len = 0
|
||||||
|
local place_holder = {}
|
||||||
|
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true)
|
||||||
|
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
len = len + string.len(line)
|
||||||
|
table.insert(place_holder, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, 0, #lines, true, place_holder)
|
||||||
|
|
||||||
|
local duration = math.ceil(len / fps * 1000)
|
||||||
|
|
||||||
|
local i = 1
|
||||||
|
local line_nr = 1
|
||||||
|
local insertLine = ""
|
||||||
|
|
||||||
|
local function callback()
|
||||||
|
if lines[line_nr] == nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local char = string.sub(lines[line_nr], i, i)
|
||||||
|
if char == nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
insertLine = insertLine .. char
|
||||||
|
i = i + 1
|
||||||
|
vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { insertLine })
|
||||||
|
|
||||||
|
if insertLine == lines[line_nr] then
|
||||||
|
i = 1
|
||||||
|
line_nr = line_nr + 1
|
||||||
|
insertLine = ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local animation = Animation(duration, fps, easing.line, callback)
|
||||||
|
animation:run()
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
redraw_buffer = redraw_buffer,
|
||||||
|
}
|
||||||
133
current_config/lua/alpha/completition/init.lua
Normal file
133
current_config/lua/alpha/completition/init.lua
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
local cmp = require "cmp"
|
||||||
|
local lspkind = require "lspkind"
|
||||||
|
local luasnip = require "luasnip"
|
||||||
|
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||||
|
local compare = require "cmp.config.compare"
|
||||||
|
|
||||||
|
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
mapping = {
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-e>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.close()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-n>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.choice_active() then
|
||||||
|
luasnip.change_choice(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-y>"] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
["<c-space>"] = cmp.mapping.complete(),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "copilot" },
|
||||||
|
{
|
||||||
|
name = "buffer",
|
||||||
|
keyword_length = 4,
|
||||||
|
option = {
|
||||||
|
get_bufnrs = function()
|
||||||
|
local bufs = {}
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
local bufnr = vim.api.nvim_win_get_buf(win)
|
||||||
|
if vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal" then
|
||||||
|
bufs[bufnr] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return vim.tbl_keys(bufs)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
format = lspkind.cmp_format {
|
||||||
|
with_text = true,
|
||||||
|
menu = {
|
||||||
|
buffer = "[buf]",
|
||||||
|
nvim_lsp = "[ ]",
|
||||||
|
nvim_lua = "[api]",
|
||||||
|
path = "[path]",
|
||||||
|
luasnip = "[snip]",
|
||||||
|
copilot = "[ﮧ ]",
|
||||||
|
["vim-dadbod-completion"] = "[DB]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
sorting = {
|
||||||
|
priority_weight = 2,
|
||||||
|
comparators = {
|
||||||
|
compare.kind,
|
||||||
|
compare.sort_text,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
experimental = {
|
||||||
|
native_menu = false,
|
||||||
|
|
||||||
|
ghost_text = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
|
||||||
|
|
||||||
|
-- Set configuration for specific filetype.
|
||||||
|
cmp.setup.filetype("gitcommit", {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline("/", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(":", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.filetype({ "sql", "mysql", "plsql" }, {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "vim-dadbod-completion" },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
|
})
|
||||||
1
current_config/lua/alpha/dap/configs/golang.lua
Normal file
1
current_config/lua/alpha/dap/configs/golang.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("dap-go").setup()
|
||||||
45
current_config/lua/alpha/dap/configs/javascript.lua
Normal file
45
current_config/lua/alpha/dap/configs/javascript.lua
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
require("dap-vscode-js").setup {
|
||||||
|
debugger_cmd = { "js-debug-adapter" },
|
||||||
|
adapters = { "pwa-node", "pwa-chrome", "node-terminal" },
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, language in ipairs { "typescript", "javascript" } do
|
||||||
|
require("dap").configurations[language] = {
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "launch",
|
||||||
|
name = "Launch file",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "attach",
|
||||||
|
name = "Attach",
|
||||||
|
processId = require("dap.utils").pick_process,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, language in ipairs { "typescriptreact", "javascriptreact" } do
|
||||||
|
require("dap").configurations[language] = {
|
||||||
|
{
|
||||||
|
type = "pwa-chrome",
|
||||||
|
name = "Attach - Remote Debugging",
|
||||||
|
request = "attach",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = vim.fn.getcwd(),
|
||||||
|
sourceMaps = true,
|
||||||
|
protocol = "inspector",
|
||||||
|
port = 9222,
|
||||||
|
webRoot = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-chrome",
|
||||||
|
name = "Launch Chrome",
|
||||||
|
request = "launch",
|
||||||
|
url = "http://localhost:3000",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
27
current_config/lua/alpha/dap/configs/php.lua
Normal file
27
current_config/lua/alpha/dap/configs/php.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
local dap = require("dap")
|
||||||
|
|
||||||
|
dap.adapters.php = {
|
||||||
|
type = "executable",
|
||||||
|
command = "php-debug-adapter",
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.php = {
|
||||||
|
{
|
||||||
|
type = "php",
|
||||||
|
request = "launch",
|
||||||
|
name = "Laravel",
|
||||||
|
port = 9003,
|
||||||
|
pathMappings = {
|
||||||
|
["/var/www/html"] = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "php",
|
||||||
|
request = "launch",
|
||||||
|
name = "Symfony",
|
||||||
|
port = 9003,
|
||||||
|
pathMappings = {
|
||||||
|
["/app"] = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
57
current_config/lua/alpha/dap/configs/rust.lua
Normal file
57
current_config/lua/alpha/dap/configs/rust.lua
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
local dap = require("dap")
|
||||||
|
|
||||||
|
local rust_adapter = nil
|
||||||
|
local rust_adapters = { "lldb-vscode", "codelldb" }
|
||||||
|
for _, adapter in pairs(rust_adapters) do
|
||||||
|
if vim.fn.executable(adapter) then
|
||||||
|
rust_adapter = adapter
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if rust_adapter ~= nil then
|
||||||
|
dap.adapters.lldb = {
|
||||||
|
type = "executable",
|
||||||
|
command = rust_adapter,
|
||||||
|
name = "lldb",
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.configurations.rust = {
|
||||||
|
{
|
||||||
|
name = "launch",
|
||||||
|
type = "lldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
local dir = vim.fn.getcwd()
|
||||||
|
return dir .. "/target/debug/" .. vim.fs.basename(dir)
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
args = function()
|
||||||
|
local resp = vim.fn.input "Arguments: "
|
||||||
|
if resp == "" then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.fn.split(resp, " ")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "custom",
|
||||||
|
type = "lldb",
|
||||||
|
request = "launch",
|
||||||
|
program = function()
|
||||||
|
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||||
|
end,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
stopOnEntry = false,
|
||||||
|
args = function()
|
||||||
|
local resp = vim.fn.input "Arguments: "
|
||||||
|
if resp == "" then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.fn.split(resp, " ")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
106
current_config/lua/alpha/dap/init.lua
Normal file
106
current_config/lua/alpha/dap/init.lua
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
local dap, dapui, hydra = require "dap", require "dapui", require "hydra"
|
||||||
|
|
||||||
|
-- Setup Virtual Text
|
||||||
|
require("nvim-dap-virtual-text").setup {}
|
||||||
|
|
||||||
|
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/alpha/dap/configs/*.lua", true)) do
|
||||||
|
loadfile(ft_path)()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Signs
|
||||||
|
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapBreakpointRejected", { text = "🚫", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapBreakpointCondition", { text = "❓", texthl = "", linehl = "", numhl = "" })
|
||||||
|
vim.fn.sign_define("DapLogPoint", { text = "💬", texthl = "", linehl = "", numhl = "" })
|
||||||
|
|
||||||
|
-- UI structure
|
||||||
|
dapui.setup {
|
||||||
|
icons = { expanded = "▾", collapsed = "▸" },
|
||||||
|
layouts = {
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
"scopes",
|
||||||
|
"breakpoints",
|
||||||
|
"stacks",
|
||||||
|
"watches",
|
||||||
|
},
|
||||||
|
size = 80,
|
||||||
|
position = "right",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
elements = {
|
||||||
|
"repl",
|
||||||
|
"console",
|
||||||
|
},
|
||||||
|
size = 10,
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Events Listeners
|
||||||
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
dapui.open {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local hint = [[
|
||||||
|
Nvim DAP
|
||||||
|
_d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^
|
||||||
|
_bp_: Toogle Breakpoint _bc_: Conditional Breakpoint ^
|
||||||
|
_?_: log point ^
|
||||||
|
_c_: Run To Cursor ^
|
||||||
|
_h_: Show information of the variable under the cursor ^
|
||||||
|
_x_: Stop Debbuging ^
|
||||||
|
^^ _<Esc>_
|
||||||
|
]]
|
||||||
|
|
||||||
|
hydra {
|
||||||
|
name = "dap",
|
||||||
|
hint = hint,
|
||||||
|
mode = "n",
|
||||||
|
config = {
|
||||||
|
color = "blue",
|
||||||
|
invoke_on_body = true,
|
||||||
|
hint = {
|
||||||
|
border = "rounded",
|
||||||
|
position = "bottom",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
body = "<leader>d",
|
||||||
|
heads = {
|
||||||
|
{ "d", dap.continue },
|
||||||
|
{ "bp", dap.toggle_breakpoint },
|
||||||
|
{ "l", dap.step_into },
|
||||||
|
{ "j", dap.step_over },
|
||||||
|
{ "k", dap.step_out },
|
||||||
|
{ "h", dapui.eval },
|
||||||
|
{ "c", dap.run_to_cursor },
|
||||||
|
{
|
||||||
|
"bc",
|
||||||
|
function()
|
||||||
|
vim.ui.input({ prompt = "Condition: " }, function(condition)
|
||||||
|
dap.set_breakpoint(condition)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"?",
|
||||||
|
function()
|
||||||
|
vim.ui.input({ prompt = "Log: " }, function(log)
|
||||||
|
dap.set_breakpoint(nil, nil, log)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x",
|
||||||
|
function()
|
||||||
|
dap.terminate()
|
||||||
|
dapui.close {}
|
||||||
|
dap.clear_breakpoints()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
{ "<Esc>", nil, { exit = true } },
|
||||||
|
},
|
||||||
|
}
|
||||||
23
current_config/lua/alpha/globals.lua
Normal file
23
current_config/lua/alpha/globals.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
--- Dumps all values into pretty print
|
||||||
|
---@vararg any
|
||||||
|
---@return any
|
||||||
|
dump = function(...)
|
||||||
|
local args = {...}
|
||||||
|
|
||||||
|
local mapped = {}
|
||||||
|
for _, v in ipairs(args) do
|
||||||
|
table.insert(mapped, vim.inspect(v))
|
||||||
|
end
|
||||||
|
print(unpack(mapped))
|
||||||
|
|
||||||
|
return unpack(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
Reload = function(...)
|
||||||
|
return require("plenary.reload").reload_module(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
R = function(name)
|
||||||
|
Reload(name)
|
||||||
|
return require(name)
|
||||||
|
end
|
||||||
64
current_config/lua/alpha/laravel-tinker.lua
Normal file
64
current_config/lua/alpha/laravel-tinker.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.runCode = function()
|
||||||
|
local curBuff = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
|
local stats = vim.api.nvim_list_uis()[1]
|
||||||
|
|
||||||
|
local width = stats.width
|
||||||
|
local height = stats.height
|
||||||
|
|
||||||
|
local bufh = vim.api.nvim_create_buf(false, true)
|
||||||
|
local winId = vim.api.nvim_open_win(bufh, true, {
|
||||||
|
relative = "editor",
|
||||||
|
width = width * 0.75,
|
||||||
|
height = height * 0.75,
|
||||||
|
col = 2,
|
||||||
|
row = 2,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- get the start and end lines of selection
|
||||||
|
local startLine = vim.api.nvim_buf_get_mark(curBuff, "<")[1] - 1
|
||||||
|
local endLine = vim.api.nvim_buf_get_mark(curBuff, ">")[1]
|
||||||
|
-- print("range: ", startLine, endLine)
|
||||||
|
|
||||||
|
local code = vim.api.nvim_buf_get_lines(curBuff, startLine, endLine, false)
|
||||||
|
|
||||||
|
-- print (vim.inspect(code))
|
||||||
|
|
||||||
|
local codeText = vim.fn.shellescape(table.concat(code, " "))
|
||||||
|
-- print(codeText)
|
||||||
|
|
||||||
|
local result = vim.fn.systemlist("php artisan tinker --execute=" .. codeText)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_text(bufh, 0, 0, 0, 0, result)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.backTerminal = function()
|
||||||
|
local bufh = vim.api.nvim_create_buf(false, true)
|
||||||
|
local term = vim.api.nvim_open_term(bufh, {})
|
||||||
|
|
||||||
|
local winId = vim.api.nvim_open_win(bufh, true, {
|
||||||
|
relative = "editor",
|
||||||
|
width = 80,
|
||||||
|
height = 80,
|
||||||
|
col = 2,
|
||||||
|
row = 2,
|
||||||
|
style = "minimal",
|
||||||
|
border = "rounded",
|
||||||
|
})
|
||||||
|
|
||||||
|
local jobId = vim.fn.jobstart("php artisan tinker", {
|
||||||
|
on_stdout = function(err, data)
|
||||||
|
print(err, vim.inspect(data))
|
||||||
|
vim.api.nvim_chan_send(term, table.concat(data, "\n"))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_chan_send(jobId, "$ub = UploadBatch::find(1);\n")
|
||||||
|
vim.api.nvim_chan_send(jobId, "dump($ub);\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
29
current_config/lua/alpha/lsp/attach.lua
Normal file
29
current_config/lua/alpha/lsp/attach.lua
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
local telescope_mapper = require "alpha.telescope.mappings"
|
||||||
|
|
||||||
|
return function(client, bufnr)
|
||||||
|
-- keymaps for lsp
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0, desc = "LSP Help information of symbol under the cursor" })
|
||||||
|
vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0, desc = "LSP Rename symbol under cursor" })
|
||||||
|
vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0, desc = "LSP Signature help" })
|
||||||
|
vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true, desc = "LSP Restart Server" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, { buffer = 0, desc = "LSP Code actions" })
|
||||||
|
vim.keymap.set("n", "<leader>vf", function()
|
||||||
|
return vim.lsp.buf.format {
|
||||||
|
async = true,
|
||||||
|
filter = function(cli)
|
||||||
|
return cli.name ~= "lua_ls"
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end, { buffer = 0, desc = "LSP format file" })
|
||||||
|
|
||||||
|
telescope_mapper("gr", "lsp_references", { buffer = true, desc = "LSP References of symbol on cursor" })
|
||||||
|
telescope_mapper("<leader>pv", "find_symbol", { buffer = true, desc = "LSP find symbol on the project" })
|
||||||
|
telescope_mapper("<leader>pd", "lsp_document_symbols", { buffer = true, desc = "LSP document symbols" })
|
||||||
|
telescope_mapper("gd", "lsp_definitions", { buffer = true, desc = "LSP go to definition" })
|
||||||
|
|
||||||
|
vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||||
|
|
||||||
|
if client.server_capabilities.inlayHintProvider then
|
||||||
|
vim.lsp.inlay_hint(bufnr, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
26
current_config/lua/alpha/lsp/default.lua
Normal file
26
current_config/lua/alpha/lsp/default.lua
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
return {
|
||||||
|
mason = {
|
||||||
|
enable = true,
|
||||||
|
auto_install = false,
|
||||||
|
},
|
||||||
|
servers = {
|
||||||
|
emmet_ls = { enable = true },
|
||||||
|
gopls = { enable = true },
|
||||||
|
html = { enable = true },
|
||||||
|
jsonls = { enable = true },
|
||||||
|
lua_ls = { enable = true, neodev = true },
|
||||||
|
nil_ls = { enable = true },
|
||||||
|
phpactor = {enable = true },
|
||||||
|
rust_analyzer = { enable = true },
|
||||||
|
svelte = { enable = true },
|
||||||
|
tailwindcss = { enable = true, filetypes = {"blade", "html", "svelte"} },
|
||||||
|
tsserver = { enable = true },
|
||||||
|
volar = { enable = true },
|
||||||
|
},
|
||||||
|
default_options = function (options)
|
||||||
|
return vim.tbl_deep_extend("force", {
|
||||||
|
on_attach = require"alpha.lsp.attach",
|
||||||
|
flags = require "alpha.lsp.flags",
|
||||||
|
}, options)
|
||||||
|
end,
|
||||||
|
}
|
||||||
3
current_config/lua/alpha/lsp/flags.lua
Normal file
3
current_config/lua/alpha/lsp/flags.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
65
current_config/lua/alpha/lsp/init.lua
Normal file
65
current_config/lua/alpha/lsp/init.lua
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
return {
|
||||||
|
setup = function(ops)
|
||||||
|
ops = vim.tbl_deep_extend("force", require "alpha.lsp.default", ops)
|
||||||
|
|
||||||
|
local lspconfig = require "lspconfig"
|
||||||
|
|
||||||
|
local mason_servers = {}
|
||||||
|
for server, options in pairs(ops.servers) do
|
||||||
|
if options.enable == true then
|
||||||
|
local ok, definition = pcall(require, "alpha.lsp.servers." .. server)
|
||||||
|
local server_options
|
||||||
|
if not ok then
|
||||||
|
server_options = ops.default_options(options)
|
||||||
|
else
|
||||||
|
server_options = definition(options)
|
||||||
|
end
|
||||||
|
lspconfig[server].setup(server_options)
|
||||||
|
table.insert(mason_servers, server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Mason
|
||||||
|
if ops.mason.enable then
|
||||||
|
local mason_ops = {}
|
||||||
|
if ops.mason.auto_install == true then
|
||||||
|
mason_ops.ensure_installed = mason_servers
|
||||||
|
end
|
||||||
|
local mason_lspconfig = require "mason-lspconfig"
|
||||||
|
mason_lspconfig.setup(mason_ops)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: implement null ls with options
|
||||||
|
require "alpha.lsp.null-ls"
|
||||||
|
|
||||||
|
local servers = {}
|
||||||
|
for server, options in pairs(ops.servers) do
|
||||||
|
table.insert(servers, string.format("%s <%s>", server, options.enable))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: create an auto command that on write of the configuration, calls again the setup and restart the server if it's up.
|
||||||
|
-- can get the client by name of the file
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("AlphaLSP", function()
|
||||||
|
vim.ui.select(servers, { prompt = "LSP Servers" }, function(server)
|
||||||
|
if server == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
server = string.match(server, "^(.+) <")
|
||||||
|
local path = string.format("%s/lua/alpha/lsp/servers/%s.lua", vim.fn.stdpath "config", server)
|
||||||
|
if vim.fn.filereadable(path) == 0 then
|
||||||
|
local create = vim.fn.confirm("Server Does Not exist. Create new server?", "&Yes\n&No\n&Cancel")
|
||||||
|
if create ~= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local uri = vim.uri_from_fname(path)
|
||||||
|
local buffer = vim.uri_to_bufnr(uri)
|
||||||
|
|
||||||
|
vim.api.nvim_win_set_buf(0, buffer)
|
||||||
|
end)
|
||||||
|
end, {})
|
||||||
|
end,
|
||||||
|
}
|
||||||
23
current_config/lua/alpha/lsp/mason.lua
Normal file
23
current_config/lua/alpha/lsp/mason.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
local mason_lspconfig = require "mason-lspconfig"
|
||||||
|
local servers = require "alpha.lsp.servers"
|
||||||
|
local lspconfig = require "lspconfig"
|
||||||
|
|
||||||
|
local mason_servers = {}
|
||||||
|
|
||||||
|
for server, _ in pairs(servers) do
|
||||||
|
local cmd = lspconfig[server].cmd[1]
|
||||||
|
if vim.fn.executable(cmd) == 0 then
|
||||||
|
table.insert(mason_servers, server)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mason_lspconfig.setup {
|
||||||
|
-- ensure_installed = mason_servers,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- filter the list for the ones not globally installed
|
||||||
|
-- require("mason-tool-installer").setup {
|
||||||
|
-- ensure_installed = vim.tbl_filter(function (tool)
|
||||||
|
-- return vim.fn.executable(tool) == 0
|
||||||
|
-- end, require "alpha.lsp.tools"),
|
||||||
|
-- }
|
||||||
53
current_config/lua/alpha/lsp/null-ls.lua
Normal file
53
current_config/lua/alpha/lsp/null-ls.lua
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
local null_ls = require "null-ls"
|
||||||
|
-- local php_actions = require "php-code-actions"
|
||||||
|
-- local laravel_actions = require("laravel.code-actions")
|
||||||
|
|
||||||
|
null_ls.setup {
|
||||||
|
sources = {
|
||||||
|
-- null_ls.builtins.code_actions.gitsigns,
|
||||||
|
null_ls.builtins.formatting.jq,
|
||||||
|
null_ls.builtins.code_actions.refactoring,
|
||||||
|
null_ls.builtins.formatting.alejandra,
|
||||||
|
null_ls.builtins.diagnostics.luacheck,
|
||||||
|
null_ls.builtins.formatting.stylua,
|
||||||
|
|
||||||
|
null_ls.builtins.diagnostics.yamllint,
|
||||||
|
|
||||||
|
-- php_actions.getter_setter,
|
||||||
|
-- php_actions.file_creator,
|
||||||
|
|
||||||
|
-- null_ls.builtins.diagnostics.phpstan.with {
|
||||||
|
-- to_temp_file = false,
|
||||||
|
-- method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||||
|
-- -- command = "./bin/phpstan",
|
||||||
|
-- -- condition = function ()
|
||||||
|
-- -- return vim.fn.findfile("bin/phpstan") ~= ""
|
||||||
|
-- -- end
|
||||||
|
-- },
|
||||||
|
null_ls.builtins.diagnostics.phpcs.with {
|
||||||
|
method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||||
|
condition = function(utils)
|
||||||
|
return utils.root_has_file "phpcs.xml"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
null_ls.builtins.formatting.pint,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LSP (null ls) Code actions"})
|
||||||
|
vim.keymap.set("n", "<leader>vf", function()
|
||||||
|
return vim.lsp.buf.format { async = true }
|
||||||
|
end, {desc = "LSP (null ls) Format file"})
|
||||||
|
|
||||||
|
-- function to toogle and possible restart it
|
||||||
|
vim.api.nvim_create_user_command("NullLsToggle", function()
|
||||||
|
local sources = vim.tbl_map(function(el)
|
||||||
|
return el.name
|
||||||
|
end, null_ls.get_sources())
|
||||||
|
vim.ui.select(sources, {}, function(selected)
|
||||||
|
if not selected then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
null_ls.toggle(selected)
|
||||||
|
end)
|
||||||
|
end, {})
|
||||||
12
current_config/lua/alpha/lsp/servers/emmet_ls.lua
Normal file
12
current_config/lua/alpha/lsp/servers/emmet_ls.lua
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
capabilities = capabilities,
|
||||||
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" },
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
14
current_config/lua/alpha/lsp/servers/html.lua
Normal file
14
current_config/lua/alpha/lsp/servers/html.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local config = {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
}
|
||||||
|
if vim.fn.executable "html-languageserver" == 1 then
|
||||||
|
config.cmd = { "html-languageserver", "--stdio" }
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", config, ops)
|
||||||
|
end
|
||||||
14
current_config/lua/alpha/lsp/servers/jsonls.lua
Normal file
14
current_config/lua/alpha/lsp/servers/jsonls.lua
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
local config = {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
}
|
||||||
|
if vim.fn.executable "json-languageserver" == 1 then
|
||||||
|
config.cmd = { "json-languageserver", "--stdio" }
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", config, ops)
|
||||||
|
end
|
||||||
36
current_config/lua/alpha/lsp/servers/lua_ls.lua
Normal file
36
current_config/lua/alpha/lsp/servers/lua_ls.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
if ops.neodev == true then
|
||||||
|
require("neodev").setup()
|
||||||
|
end
|
||||||
|
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = "LuaJIT",
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
workspace = {
|
||||||
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
hint = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
80
current_config/lua/alpha/lsp/servers/phpactor.lua
Normal file
80
current_config/lua/alpha/lsp/servers/phpactor.lua
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
local function phpactor_attach(_, bufnr)
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorReindex", function()
|
||||||
|
vim.lsp.buf_notify(bufnr, "phpactor/index/reindex", {})
|
||||||
|
end, {})
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorStatus", function()
|
||||||
|
local results, _ = vim.lsp.buf_request_sync(bufnr, "phpactor/status", { ["return"] = true })
|
||||||
|
|
||||||
|
local content = ""
|
||||||
|
|
||||||
|
for _, res in pairs(results or {}) do
|
||||||
|
if res ~= nil and res["result"] ~= nil then
|
||||||
|
content = content .. res["result"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local Popup = require "nui.popup"
|
||||||
|
local event = require("nui.utils.autocmd").event
|
||||||
|
|
||||||
|
local popup = Popup {
|
||||||
|
enter = true,
|
||||||
|
focusable = true,
|
||||||
|
border = {
|
||||||
|
style = "rounded",
|
||||||
|
},
|
||||||
|
position = "50%",
|
||||||
|
size = {
|
||||||
|
width = "80%",
|
||||||
|
height = "60%",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- mount/open the component
|
||||||
|
popup:mount()
|
||||||
|
|
||||||
|
-- unmount component when cursor leaves buffer
|
||||||
|
popup:on(event.BufLeave, function()
|
||||||
|
popup:unmount()
|
||||||
|
end)
|
||||||
|
local out = {}
|
||||||
|
for match in string.gmatch(content, "[^\n]+") do
|
||||||
|
table.insert(out, match)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_option(popup.bufnr, "filetype", "markdown")
|
||||||
|
vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, out)
|
||||||
|
end, {})
|
||||||
|
end
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
lsp_attach(client, bufnr)
|
||||||
|
phpactor_attach(client, bufnr)
|
||||||
|
end,
|
||||||
|
flags = lsp_flags,
|
||||||
|
filetypes = { "php", "blade" },
|
||||||
|
init_options = {
|
||||||
|
["language_server_worse_reflection.inlay_hints.enable"] = true,
|
||||||
|
["language_server_worse_reflection.inlay_hints.params"] = true,
|
||||||
|
-- ["language_server_worse_reflection.inlay_hints.types"] = true,
|
||||||
|
["language_server_configuration.auto_config"] = false,
|
||||||
|
["code_transform.import_globals"] = true,
|
||||||
|
["language_server_phpstan.enabled"] = true,
|
||||||
|
["language_server_phpstan.level"] = 7,
|
||||||
|
["language_server_phpstan.bin"] = "phpstan",
|
||||||
|
},
|
||||||
|
handlers = {
|
||||||
|
["textDocument/inlayHint"] = function(err, result, ...)
|
||||||
|
for _, res in ipairs(result) do
|
||||||
|
res.label = res.label .. ": "
|
||||||
|
end
|
||||||
|
vim.lsp.handlers["textDocument/inlayHint"](err, result, ...)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
24
current_config/lua/alpha/lsp/servers/rust_analyzer.lua
Normal file
24
current_config/lua/alpha/lsp/servers/rust_analyzer.lua
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
allFeatures = true,
|
||||||
|
overrideCommand = {
|
||||||
|
"cargo",
|
||||||
|
"clippy",
|
||||||
|
"--workspace",
|
||||||
|
"--message-format=json",
|
||||||
|
"--all-targets",
|
||||||
|
"--all-features",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
33
current_config/lua/alpha/lsp/servers/tsserver.lua
Normal file
33
current_config/lua/alpha/lsp/servers/tsserver.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
local lsp_attach = require "alpha.lsp.attach"
|
||||||
|
local lsp_flags = require "alpha.lsp.flags"
|
||||||
|
|
||||||
|
return function(ops)
|
||||||
|
return vim.tbl_extend("force", {
|
||||||
|
on_attach = lsp_attach,
|
||||||
|
flags = lsp_flags,
|
||||||
|
settings = {
|
||||||
|
typescript = {
|
||||||
|
inlayHints = {
|
||||||
|
includeInlayParameterNameHints = "all",
|
||||||
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
javascript = {
|
||||||
|
inlayHints = {
|
||||||
|
includeInlayParameterNameHints = "all",
|
||||||
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, ops)
|
||||||
|
end
|
||||||
8
current_config/lua/alpha/lsp/tools.lua
Normal file
8
current_config/lua/alpha/lsp/tools.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
"codelldb",
|
||||||
|
"go-debug-adapter",
|
||||||
|
"js-debug-adapter",
|
||||||
|
"php-debug-adapter",
|
||||||
|
"phpcs",
|
||||||
|
"phpstan",
|
||||||
|
}
|
||||||
27
current_config/lua/alpha/packer_install.lua
Normal file
27
current_config/lua/alpha/packer_install.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
local download_packer = function()
|
||||||
|
if vim.fn.input "Download Packer? (y for yes)" ~= "y" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local directory = string.format("%s/site/pack/packer/start/", vim.fn.stdpath "data")
|
||||||
|
|
||||||
|
vim.fn.mkdir(directory, "p")
|
||||||
|
|
||||||
|
local out = vim.fn.system(
|
||||||
|
string.format("git clone %s %s", "https://github.com/wbthomason/packer.nvim", directory .. "/packer.nvim")
|
||||||
|
)
|
||||||
|
|
||||||
|
print(out)
|
||||||
|
print "Downloading packer.nvim..."
|
||||||
|
print "( You'll need to restart now )"
|
||||||
|
end
|
||||||
|
|
||||||
|
return function()
|
||||||
|
if not pcall(require, "packer") then
|
||||||
|
download_packer()
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
137
current_config/lua/alpha/php/gateway.lua
Normal file
137
current_config/lua/alpha/php/gateway.lua
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
local pickers = require "telescope.pickers"
|
||||||
|
local finders = require "telescope.finders"
|
||||||
|
local conf = require("telescope.config").values
|
||||||
|
local action_state = require "telescope.actions.state"
|
||||||
|
local action_set = require "telescope.actions.set"
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
local get_node_text = vim.treesitter.get_node_text
|
||||||
|
|
||||||
|
local gateway = {}
|
||||||
|
|
||||||
|
local get_definition_buffer = function(type)
|
||||||
|
local uri = vim.uri_from_fname(vim.fn.getcwd() .. "/config/graphql/_" .. type .. ".yaml")
|
||||||
|
local buff = vim.uri_to_bufnr(uri)
|
||||||
|
vim.fn.bufload(buff)
|
||||||
|
|
||||||
|
return buff
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_all_definitions = function()
|
||||||
|
local mutations_definitions = gateway.get_graphql_definitions(get_definition_buffer "mutation")
|
||||||
|
local queries_definitions = gateway.get_graphql_definitions(get_definition_buffer "query")
|
||||||
|
for _, definition in ipairs(queries_definitions) do
|
||||||
|
table.insert(mutations_definitions, definition)
|
||||||
|
end
|
||||||
|
|
||||||
|
return mutations_definitions
|
||||||
|
end
|
||||||
|
|
||||||
|
-- "'@=mutation(\"App\\\\GraphQL\\\\Mutations\\\\Mutation::action\", ...)'",
|
||||||
|
local open_resolver = function(resolver)
|
||||||
|
-- need to parse to get this values
|
||||||
|
local args = string.match(resolver, "'@=mutation%((.+)%)'")
|
||||||
|
if args == nil then
|
||||||
|
args = string.match(resolver, "'@=query%((.+)%)'")
|
||||||
|
end
|
||||||
|
if args == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local args_tbl = vim.split(args, ", ")
|
||||||
|
local fqn = string.match(args_tbl[1], '"(.+)"')
|
||||||
|
fqn = string.gsub(fqn, "\\\\", "\\")
|
||||||
|
-- P(fqn)
|
||||||
|
|
||||||
|
require("alpha.php.lsp").find(fqn, "phpactor")
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param bufnr integer Buff id
|
||||||
|
gateway.get_graphql_definitions = function(bufnr)
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"yaml",
|
||||||
|
"GraphQL_endpoints",
|
||||||
|
[[
|
||||||
|
(document (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
key: (flow_node) @mutation
|
||||||
|
value: (block_node (block_mapping (block_mapping_pair
|
||||||
|
key: (flow_node) @resolve (#eq? @resolve "resolve")
|
||||||
|
value: (flow_node) @resolver
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
)))
|
||||||
|
))))
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
local query = vim.treesitter.query.get("yaml", "GraphQL_endpoints")
|
||||||
|
|
||||||
|
local elements = {}
|
||||||
|
|
||||||
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
|
local parser = parsers.get_parser(bufnr)
|
||||||
|
local tree = parser:parse()[1]
|
||||||
|
|
||||||
|
for id, node in query:iter_captures(tree:root(), bufnr) do
|
||||||
|
if query.captures[id] == "mutation" then
|
||||||
|
table.insert(elements, {
|
||||||
|
value = get_node_text(node, bufnr),
|
||||||
|
lnum = node:start() + 1,
|
||||||
|
buffer = bufnr,
|
||||||
|
})
|
||||||
|
elseif query.captures[id] == "resolver" then
|
||||||
|
elements[#elements].resolver = get_node_text(node, bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return elements
|
||||||
|
end
|
||||||
|
|
||||||
|
--- gets the graphql function defined on a given buffer
|
||||||
|
--- @param opts table: options to pass to the picker
|
||||||
|
gateway.graphql_definitions = function(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
pickers
|
||||||
|
.new(opts, {
|
||||||
|
promt_title = "Queries",
|
||||||
|
finder = finders.new_table {
|
||||||
|
results = get_all_definitions(),
|
||||||
|
entry_maker = function(entry)
|
||||||
|
-- buffer = 43,
|
||||||
|
-- lnum = 82,
|
||||||
|
-- resolver = "'@=mutation(\"App\\\\GraphQL\\\\Mutation\\\\Mutation::action\", ...)'",
|
||||||
|
-- value = "deleteVehicleImage"
|
||||||
|
return {
|
||||||
|
value = entry,
|
||||||
|
display = entry.value,
|
||||||
|
ordinal = entry.value,
|
||||||
|
path = vim.api.nvim_buf_get_name(entry.buffer),
|
||||||
|
lnum = entry.lnum,
|
||||||
|
resolver = entry.resolver,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
sorter = conf.generic_sorter(opts),
|
||||||
|
previewer = conf.grep_previewer(opts),
|
||||||
|
attach_mappings = function(prompt_bufnr, map)
|
||||||
|
action_set.select:enhance {
|
||||||
|
post = function()
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
map("i", "<c-o>", function()
|
||||||
|
actions.close(prompt_bufnr)
|
||||||
|
local selection = action_state.get_selected_entry()
|
||||||
|
open_resolver(selection.resolver)
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
:find()
|
||||||
|
end
|
||||||
|
|
||||||
|
return gateway
|
||||||
151
current_config/lua/alpha/php/lsp.lua
Normal file
151
current_config/lua/alpha/php/lsp.lua
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
local Path = require "plenary.path"
|
||||||
|
|
||||||
|
local lsp = {}
|
||||||
|
|
||||||
|
local open_filename = function(filename)
|
||||||
|
if vim.api.nvim_buf_get_name(0) ~= filename then
|
||||||
|
filename = Path:new(vim.fn.fnameescape(filename)):normalize(vim.loop.cwd())
|
||||||
|
pcall(vim.cmd, string.format("%s %s", "edit", filename))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param server_name string
|
||||||
|
---@return table|nil, boolean
|
||||||
|
local get_client = function(server_name)
|
||||||
|
local clients = vim.lsp.get_active_clients { name = server_name }
|
||||||
|
local client = clients[1] or nil
|
||||||
|
local new_instance = false
|
||||||
|
|
||||||
|
if not client then
|
||||||
|
local server = require("lspconfig")[server_name]
|
||||||
|
local config = server.make_config(vim.fn.getcwd())
|
||||||
|
local client_id = vim.lsp.start(config)
|
||||||
|
client = vim.lsp.get_client_by_id(client_id)
|
||||||
|
new_instance = true
|
||||||
|
end
|
||||||
|
|
||||||
|
return client, new_instance
|
||||||
|
end
|
||||||
|
|
||||||
|
local function go_to(client, is_new_instance, full_class, method)
|
||||||
|
local class_parts = vim.split(full_class, "\\")
|
||||||
|
local class = class_parts[#class_parts]
|
||||||
|
|
||||||
|
local resp = client.request_sync("workspace/symbol", { query = class }, nil)
|
||||||
|
|
||||||
|
local locations = vim.lsp.util.symbols_to_items(resp.result or {}, nil) or {}
|
||||||
|
if vim.tbl_isempty(locations) then
|
||||||
|
vim.api.nvim_err_writeln("Empty response looking for class: " .. full_class)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local class_location = nil
|
||||||
|
for idx, location in pairs(locations) do
|
||||||
|
if location.text == string.format("[Class] %s", full_class) then
|
||||||
|
class_location = locations[idx]
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if class_location == nil then
|
||||||
|
vim.api.nvim_err_writeln("Could not find class for : " .. full_class)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
open_filename(class_location.filename)
|
||||||
|
|
||||||
|
local params = vim.lsp.util.make_position_params(0)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.buf_attach_client(0, client.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.buf_request(0, "textDocument/documentSymbol", params, function(method_err, method_server_result, _, _)
|
||||||
|
if method_err then
|
||||||
|
vim.api.nvim_err_writeln("Error when finding workspace symbols: " .. method_err.message)
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local method_locations = vim.lsp.util.symbols_to_items(method_server_result or {}, 0) or {}
|
||||||
|
if vim.tbl_isempty(method_locations) then
|
||||||
|
vim.api.nvim_err_writeln(string.format("empty response looking for method: %s", method or "__invoke"))
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local method_location = nil
|
||||||
|
for _, value in ipairs(method_locations) do
|
||||||
|
if value.text == string.format("[Method] %s", method or "__invoke") then
|
||||||
|
method_location = value
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if method_location == nil then
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local row = method_location.lnum
|
||||||
|
local col = method_location.col - 1
|
||||||
|
|
||||||
|
if row and col then
|
||||||
|
local ok, err_msg = pcall(vim.api.nvim_win_set_cursor, 0, { row, col })
|
||||||
|
if not ok then
|
||||||
|
vim.api.nvim_err_writeln("Erro setting row and col " .. err_msg)
|
||||||
|
end
|
||||||
|
vim.cmd "normal zt"
|
||||||
|
end
|
||||||
|
if is_new_instance then
|
||||||
|
vim.lsp.stop_client(client.id)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
---Return a buffer id for the given client
|
||||||
|
---@param server_name string
|
||||||
|
---@return integer|nil
|
||||||
|
lsp.get_lsp_buffer = function(server_name)
|
||||||
|
local clients = vim.lsp.get_active_clients { name = server_name }
|
||||||
|
if #clients == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local buffers = vim.lsp.get_buffers_by_client_id(clients[1].id)
|
||||||
|
|
||||||
|
if #buffers == 0 then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return buffers[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param fqn string: fully name to search Class::method
|
||||||
|
lsp.find = function(fqn, server_name)
|
||||||
|
local search = vim.split(fqn, "::")
|
||||||
|
local fqn_class = search[1]
|
||||||
|
local method = search[2]
|
||||||
|
|
||||||
|
local client, is_new_instance = get_client(server_name)
|
||||||
|
|
||||||
|
if not client then
|
||||||
|
vim.api.nvim_err_writeln "Could not get lsp client"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
go_to(client, is_new_instance, fqn_class, method)
|
||||||
|
end
|
||||||
|
|
||||||
|
return lsp
|
||||||
38
current_config/lua/alpha/php/servers.lua
Normal file
38
current_config/lua/alpha/php/servers.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
local phpactor = {}
|
||||||
|
|
||||||
|
-- TODO possible improvement look how it works underline
|
||||||
|
-- use the client directly to call, no need for the buffer
|
||||||
|
-- to find a class.
|
||||||
|
-- vim.lsp.start() should return the client
|
||||||
|
|
||||||
|
function phpactor.findclass(buffer, fqn, callback)
|
||||||
|
local class_parts = vim.split(fqn, "\\")
|
||||||
|
local class = class_parts[#class_parts]
|
||||||
|
|
||||||
|
vim.lsp.buf_request(buffer, "workspace/symbol", { query = class }, function(err, server_result, _, _)
|
||||||
|
if err then
|
||||||
|
callback(nil, "Error when finding workspace symbols: " .. err.message)
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local locations = vim.lsp.util.symbols_to_items(server_result or {}, buffer) or {}
|
||||||
|
if vim.tbl_isempty(locations) then
|
||||||
|
vim.api.nvim_err_writeln("Empty response looking for class: " .. fqn)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- getting the config I can re use the client
|
||||||
|
-- the next thing is to make the request with the client
|
||||||
|
local config = require("lspconfig").phpactor
|
||||||
|
config.root_dir = vim.fn.getcwd()
|
||||||
|
local client_id = vim.lsp.start(config)
|
||||||
|
|
||||||
|
vim.lsp.get_client_by_id(client_id)
|
||||||
|
-- use client.request or request_sync
|
||||||
|
-- look for the direct of the symbol
|
||||||
|
return {
|
||||||
|
phpactor = phpactor,
|
||||||
|
}
|
||||||
53
current_config/lua/alpha/select_to_quickfix.lua
Normal file
53
current_config/lua/alpha/select_to_quickfix.lua
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local function create_quickfix_entry(selection)
|
||||||
|
local filename, linenumber = selection:match "([^:]+):(%d+)"
|
||||||
|
|
||||||
|
return {
|
||||||
|
filename = vim.fn.getcwd() .. "/" .. filename,
|
||||||
|
lnum = tonumber(linenumber),
|
||||||
|
col = 1,
|
||||||
|
text = filename,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function add_selections_to_quickfix(selections)
|
||||||
|
local quickfix_list = {}
|
||||||
|
|
||||||
|
for _, selection in ipairs(selections) do
|
||||||
|
local entry = create_quickfix_entry(selection)
|
||||||
|
table.insert(quickfix_list, entry)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.fn.setqflist(quickfix_list, "r")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_selections()
|
||||||
|
local _, end_line, _, _ = unpack(vim.fn.getpos "'>")
|
||||||
|
local _, start_line, _, _ = unpack(vim.fn.getpos "'<")
|
||||||
|
local lines = api.nvim_buf_get_lines(0, start_line - 1, end_line, false)
|
||||||
|
|
||||||
|
local selections = {}
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
for selection in line:gmatch "%S+" do
|
||||||
|
table.insert(selections, selection)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return selections
|
||||||
|
end
|
||||||
|
|
||||||
|
local function select_to_quickfix()
|
||||||
|
local selections = get_selections()
|
||||||
|
|
||||||
|
if #selections > 0 then
|
||||||
|
add_selections_to_quickfix(selections)
|
||||||
|
print "Selections added to quickfix list"
|
||||||
|
else
|
||||||
|
print "No selections found"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
handle = select_to_quickfix,
|
||||||
|
}
|
||||||
71
current_config/lua/alpha/snips/ft/cucumber.lua
Normal file
71
current_config/lua/alpha/snips/ft/cucumber.lua
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
local t = ls.text_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local c = ls.choice_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
clean = t [[Given clean stubs list]],
|
||||||
|
all = t [[And all stubs should be matched]],
|
||||||
|
status_code = fmt([[Then the response status code should be {}]], { i(1, "200") }),
|
||||||
|
no_error = t [[And the JSON path expression errors should not have result]],
|
||||||
|
json_data = fmt([[And the JSON path expression "data" should be equal to:
|
||||||
|
"""
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
]], {i(1)}),
|
||||||
|
feature = fmt(
|
||||||
|
[[Feature: {}
|
||||||
|
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "Feature Name"),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
scenario = fmt(
|
||||||
|
[[Scenario: {}
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, "Scenario name"),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
stub = fmt([[And the APIClient will send a request with a stub from "{}"]], { i(1) }),
|
||||||
|
request = fmt(
|
||||||
|
[[When I send the GraphQL request:
|
||||||
|
"""
|
||||||
|
{}
|
||||||
|
"""]],
|
||||||
|
{ i(1) }
|
||||||
|
),
|
||||||
|
result = fmt(
|
||||||
|
[[And the JSON path expression "data" should be equal to:
|
||||||
|
"""
|
||||||
|
{{
|
||||||
|
"result": {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
"""]],
|
||||||
|
{ i(1) }
|
||||||
|
),
|
||||||
|
query = fmt(
|
||||||
|
[[{} {{
|
||||||
|
result: {}({}) {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
}}]],
|
||||||
|
{ c(1, { t "mutation", t "query" }), i(2, "mutation"), i(3, ""), i(4) }
|
||||||
|
),
|
||||||
|
access = fmt(
|
||||||
|
[[And the Access Cache has Allowed the userId "{}" for inspectionId "{}"]],
|
||||||
|
{ i(1, "3414054"), i(2, "42") }
|
||||||
|
),
|
||||||
|
branch_access = fmt([[And the Access Cache has branch "{}" for userId "{}"]], { i(1, "1"), i(2, "3414054") }),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
134
current_config/lua/alpha/snips/ft/go.lua
Normal file
134
current_config/lua/alpha/snips/ft/go.lua
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
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 get_node_text = vim.treesitter.get_node_text
|
||||||
|
|
||||||
|
vim.treesitter.query.set(
|
||||||
|
"go",
|
||||||
|
"LuaSnip_Result",
|
||||||
|
[[
|
||||||
|
[
|
||||||
|
(method_declaration result: (_) @id)
|
||||||
|
(function_declaration result: (_) @id)
|
||||||
|
(func_literal result: (_) @id)
|
||||||
|
]
|
||||||
|
]]
|
||||||
|
)
|
||||||
|
|
||||||
|
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('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,
|
||||||
|
}
|
||||||
|
|
||||||
|
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.query.get("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))
|
||||||
|
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),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
M.f = fmt("func {}({}) {} {{\n\t{}\n}}", { i(1, "name"), i(2), i(3), i(0) })
|
||||||
|
|
||||||
|
return M
|
||||||
69
current_config/lua/alpha/snips/ft/lua.lua
Normal file
69
current_config/lua/alpha/snips/ft/lua.lua
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
-- local snippet = ls.s
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local t = ls.text_node
|
||||||
|
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local require_var = function(args, _)
|
||||||
|
local text = args[1][1] or ""
|
||||||
|
local split = vim.split(text, ".", { plain = true })
|
||||||
|
|
||||||
|
local options = {}
|
||||||
|
for len = 0, #split - 1 do
|
||||||
|
table.insert(options, t(table.concat(vim.list_slice(split, #split - len, #split), "_")))
|
||||||
|
end
|
||||||
|
|
||||||
|
return snippet_from_nodes(nil, {
|
||||||
|
c(1, options),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local newline = function(text)
|
||||||
|
return t { "", text }
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
req = fmt([[local {} = require("{}")]], {
|
||||||
|
d(2, require_var, { 1 }),
|
||||||
|
i(1),
|
||||||
|
}),
|
||||||
|
lf = {
|
||||||
|
desc = "table function",
|
||||||
|
"local ",
|
||||||
|
i(1),
|
||||||
|
" = function(",
|
||||||
|
i(2),
|
||||||
|
")",
|
||||||
|
newline " ",
|
||||||
|
i(0),
|
||||||
|
newline "end",
|
||||||
|
},
|
||||||
|
|
||||||
|
preq = fmt(
|
||||||
|
[[local ok, {} = pcall(require, "{}")
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end]],
|
||||||
|
{
|
||||||
|
f(function(args)
|
||||||
|
return args[1][1]
|
||||||
|
end, { 1 }),
|
||||||
|
i(1),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
plugin = fmt(
|
||||||
|
[[return {{
|
||||||
|
"{}"
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
i(1, "plugin"),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}
|
||||||
163
current_config/lua/alpha/snips/ft/php.lua
Normal file
163
current_config/lua/alpha/snips/ft/php.lua
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
local composer = require "composer"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
local visibility = function(position, default)
|
||||||
|
local possibles = { "private", "protected", "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
|
||||||
|
|
||||||
|
return c(position, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
local var_name = function(args)
|
||||||
|
return snippet_from_nodes(nil, {
|
||||||
|
i(1, args[1][1]:gsub("^%u", string.lower):gsub("Interface", "") or ""),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local class_name = function()
|
||||||
|
return vim.fn.expand "%:t:r"
|
||||||
|
end
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.v = fmt(
|
||||||
|
[[
|
||||||
|
/**
|
||||||
|
* @var {}
|
||||||
|
*/
|
||||||
|
{} {} ${};
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "type"),
|
||||||
|
visibility(2, "private"),
|
||||||
|
i(3, "Type"),
|
||||||
|
i(4, "var"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.class = fmt(
|
||||||
|
[[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace {};
|
||||||
|
|
||||||
|
class {}
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
f(composer.resolve_php_namespace),
|
||||||
|
f(class_name),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.pro = fmt([[{} {}{} ${},]], {
|
||||||
|
visibility(1, "private"),
|
||||||
|
c(2, {
|
||||||
|
t "readonly ",
|
||||||
|
t "",
|
||||||
|
}),
|
||||||
|
i(3, "Type"),
|
||||||
|
d(4, var_name, { 3 }),
|
||||||
|
})
|
||||||
|
|
||||||
|
M.op = fmt(
|
||||||
|
[[
|
||||||
|
/**
|
||||||
|
* @var ObjectProphecy<{}>
|
||||||
|
*/
|
||||||
|
private ObjectProphecy ${};
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "Type"),
|
||||||
|
d(2, var_name, { 1 }),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.iop = fmt(
|
||||||
|
[[$this->{} = $this->prophesize({}::class);]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.arg = fmt([[{} ${}]], {
|
||||||
|
i(1, "Type"),
|
||||||
|
d(2, var_name, { 1 }),
|
||||||
|
})
|
||||||
|
|
||||||
|
M._c = fmt(
|
||||||
|
[[{} function __construct({}) {{
|
||||||
|
{}
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
visibility(1, "public"),
|
||||||
|
i(2),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M._p = fmt(
|
||||||
|
[[{} function __construct(
|
||||||
|
{}
|
||||||
|
) {{
|
||||||
|
}}]],
|
||||||
|
{
|
||||||
|
visibility(1, "public"),
|
||||||
|
i(2),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
M.strict = t "declare(strict_types=1);"
|
||||||
|
|
||||||
|
M["fn"] = fmt(
|
||||||
|
[[{} function {}({}): {}
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}]],
|
||||||
|
{ visibility(1, "public"), i(2), i(3), i(4, "void"), i(0) }
|
||||||
|
)
|
||||||
|
|
||||||
|
M["then"] = fmt(
|
||||||
|
[[->then(
|
||||||
|
function ({}) {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
)]],
|
||||||
|
{ i(1, ""), i(2, "") }
|
||||||
|
)
|
||||||
|
|
||||||
|
M.test = fmt(
|
||||||
|
[[/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_{}(): void
|
||||||
|
{{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{ i(1, ""), i(0, "") }
|
||||||
|
)
|
||||||
|
|
||||||
|
return M
|
||||||
225
current_config/lua/alpha/snips/ft/yaml.lua
Normal file
225
current_config/lua/alpha/snips/ft/yaml.lua
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local snippet_from_nodes = ls.sn
|
||||||
|
local c = ls.choice_node
|
||||||
|
local t = ls.text_node
|
||||||
|
local d = ls.dynamic_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
local rep = require("luasnip.extras").rep
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
str = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: string
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
bool = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: boolean
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
float = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
int = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: integer
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
id = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
class = fmt(
|
||||||
|
[[{}:
|
||||||
|
$ref: '#/components/schemas/{}'
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
date = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
arr = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
{}
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
ref = fmt([[$ref: '#/components/schemas/{}']], { i(1, "") }),
|
||||||
|
obj = fmt(
|
||||||
|
[[type: object
|
||||||
|
properties:
|
||||||
|
{}]],
|
||||||
|
i(1, "")
|
||||||
|
),
|
||||||
|
aint = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: int
|
||||||
|
format: int64
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
astr = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
{}]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
mut = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: "{}"
|
||||||
|
resolve: '@=mutation("App\\GraphQL\\Mutation\\{}::{}", {}, info)'
|
||||||
|
args:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
i(3, ""),
|
||||||
|
rep(1),
|
||||||
|
i(5, ""),
|
||||||
|
i(6, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
input = fmt(
|
||||||
|
[[{}:
|
||||||
|
type: input-object
|
||||||
|
config:
|
||||||
|
fields:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, ""),
|
||||||
|
i(2, ""),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
f = fmt([[{}: {{ type: "{}" }}]], { i(1, ""), i(2, "") }),
|
||||||
|
|
||||||
|
api = fmt(
|
||||||
|
[[openapi: 3.0.2
|
||||||
|
info:
|
||||||
|
title: {}
|
||||||
|
contact:
|
||||||
|
name: eva-team-be
|
||||||
|
version: {}
|
||||||
|
x-bundle-apis: true
|
||||||
|
tags:
|
||||||
|
- name: {}
|
||||||
|
description: {}
|
||||||
|
]],
|
||||||
|
{ i(1, "my app"), i(2, "1.0.0"), i(3, "tag"), i(4, "tag description") }
|
||||||
|
),
|
||||||
|
paths = fmt(
|
||||||
|
[[paths:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(0, "") }
|
||||||
|
),
|
||||||
|
param = fmt(
|
||||||
|
[[parameters:
|
||||||
|
- name: {}
|
||||||
|
description: {}
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
]],
|
||||||
|
{ i(1, ""), i(2, "") }
|
||||||
|
),
|
||||||
|
get = fmt(
|
||||||
|
[[get:
|
||||||
|
operationId: {}
|
||||||
|
description: {}
|
||||||
|
tags: [ {} ]
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Response
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1, "GetOperation"), i(2, "description"), i(3, "tag"), i(4, "") }
|
||||||
|
),
|
||||||
|
|
||||||
|
put = fmt(
|
||||||
|
[[put:
|
||||||
|
operationId: {}
|
||||||
|
tags: [ {} ]
|
||||||
|
description: {}
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: {}
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1, "PutOperation"), i(2, "tag"), i(3, "description"), i(4, ""), i(5, "description"), i(6, "") }
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
186
current_config/lua/alpha/telescope/init.lua
Normal file
186
current_config/lua/alpha/telescope/init.lua
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
local SHOULD_RELOAD_TELESCOPE = false
|
||||||
|
|
||||||
|
local reloader = function()
|
||||||
|
if SHOULD_RELOAD_TELESCOPE then
|
||||||
|
Reload "plenary"
|
||||||
|
Reload "telescope"
|
||||||
|
Reload "alpha.telescope.setup"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local fb_actions = require("telescope").extensions.file_browser.actions
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
local my_actions = require "alpha.telescope.my_actions"
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.project_files()
|
||||||
|
local opts = { show_untracked = true } -- 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,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.search_config()
|
||||||
|
require("telescope.builtin").git_files {
|
||||||
|
prompt_title = "< Dotfiles >",
|
||||||
|
cwd = "$HOME/.dotfiles",
|
||||||
|
show_untracked = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.find_nvim_config = function()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "< Neovim >",
|
||||||
|
cwd = "$HOME/.config/nvim/",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
M.find_nvim_plugin = function()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "< Plugins >",
|
||||||
|
cwd = "$HOME/.config/nvim/lua/plugins/",
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<C-y>", my_actions.create_plugin)
|
||||||
|
map("i", "<C-w>", my_actions.disable_plugin)
|
||||||
|
map("i", "<C-e>", my_actions.enable_plugin)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.grep_string()
|
||||||
|
vim.ui.input({ prompt = "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>" }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.find_symbol()
|
||||||
|
vim.ui.input({ prompt = "Symbol for > " }, function(input)
|
||||||
|
if input == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").lsp_workspace_symbols { query = input }
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.my_plugins()
|
||||||
|
if vim.fn.isdirectory(vim.fn.getenv "HOME" .. "/code/plugins/") == 0 then
|
||||||
|
vim.notify("Directory ~/code/plugins does not exists", vim.log.levels.WARN, { title = "Telescope Mappings" })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
cwd = "~/code/plugins/",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.scratchs()
|
||||||
|
require("telescope.builtin").find_files {
|
||||||
|
prompt_title = "Scratchs",
|
||||||
|
no_ignore = true,
|
||||||
|
cwd = "~/.config/nvim/lua/scratchs/",
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-t>", my_actions.create_scratch_file)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.projectionist()
|
||||||
|
return require("telescope").extensions.projectionist.projectionist()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.laravel_commands()
|
||||||
|
return require("telescope").extensions.laravel.laravel()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.api_specs()
|
||||||
|
if vim.fn.isdirectory "./api-specification" == 0 then
|
||||||
|
vim.notify("Directory api-specification does not exists", vim.log.levels.WARN, { title = "Telescope Mappings" })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
require("telescope.builtin").git_files {
|
||||||
|
cwd = "./api-specification",
|
||||||
|
show_untracked = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
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()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.refactor()
|
||||||
|
return require("telescope").extensions.refactoring.refactors()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.gateway()
|
||||||
|
return require("alpha.php.gateway").graphql_definitions {
|
||||||
|
layout_config = {
|
||||||
|
horizontal = {
|
||||||
|
preview_width = function(_, cols, _)
|
||||||
|
return math.floor(cols * 0.7)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.file_browser_relative()
|
||||||
|
return M.file_browser { path = "%:p:h" }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.file_browser(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
opts = {
|
||||||
|
path = opts.path,
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
scroll_strategy = "cycle",
|
||||||
|
layout_config = {
|
||||||
|
prompt_position = "top",
|
||||||
|
},
|
||||||
|
|
||||||
|
attach_mappings = function(_, map)
|
||||||
|
map("i", "<c-y>", fb_actions.create_from_prompt)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
})
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user