diff options
Diffstat (limited to 'lua')
69 files changed, 2454 insertions, 2424 deletions
diff --git a/lua/alpha/completition/init.lua b/lua/alpha/completition/init.lua index 2951608..9955d4e 100644 --- a/lua/alpha/completition/init.lua +++ b/lua/alpha/completition/init.lua @@ -1,127 +1,127 @@ -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') +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.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 = 'nvim_lsp_signature_help' }, - { - name = "buffer", - keyword_length = 4, - option = { - get_bufnrs = function() - local bufs = {} - for _, win in ipairs(vim.api.nvim_list_wins()) do - bufs[vim.api.nvim_win_get_buf(win)] = true - end - return vim.tbl_keys(bufs) - end, - }, - }, - }, +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 = "nvim_lsp_signature_help" }, + { + name = "buffer", + keyword_length = 4, + option = { + get_bufnrs = function() + local bufs = {} + for _, win in ipairs(vim.api.nvim_list_wins()) do + bufs[vim.api.nvim_win_get_buf(win)] = true + end + return vim.tbl_keys(bufs) + end, + }, + }, + }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - 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 = "[LSP]", - nvim_lua = "[api]", - path = "[path]", - luasnip = "[snip]", - ["vim-dadbod-completion"] = "[DB]", - }, - }), - }, + formatting = { + format = lspkind.cmp_format { + with_text = true, + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + ["vim-dadbod-completion"] = "[DB]", + }, + }, + }, - sorting = { - priority_weight = 2, - comparators = { - compare.kind, - compare.sort_text, - } - }, + sorting = { + priority_weight = 2, + comparators = { + compare.kind, + compare.sort_text, + }, + }, - experimental = { - native_menu = false, + experimental = { + native_menu = false, - ghost_text = true, - }, -}) + ghost_text = true, + }, +} -- 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" }, - }), + 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" }, - }, + 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" }, - }), + 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" }, - }), + sources = cmp.config.sources({ + { name = "vim-dadbod-completion" }, + }, { + { name = "buffer" }, + }), }) diff --git a/lua/alpha/dap.lua b/lua/alpha/dap.lua index ee53443..a89d72e 100644 --- a/lua/alpha/dap.lua +++ b/lua/alpha/dap.lua @@ -1,33 +1,33 @@ -local dap, dapui, dap_go = require("dap"), require("dapui"), require("dap-go") +local dap, dapui, dap_go = require "dap", require "dapui", require "dap-go" -require("nvim-dap-virtual-text").setup({}) +require("nvim-dap-virtual-text").setup {} -- dap.set_log_level('TRACE') dap_go.setup() -dapui.setup({ - icons = { expanded = "▾", collapsed = "▸" }, - layouts = { - { - elements = { - "scopes", - "breakpoints", - "stacks", - "watches", - }, - size = 80, - position = "left", - }, - { - elements = { - "repl", - "console", - }, - size = 10, - position = "bottom", - }, - }, -}) +dapui.setup { + icons = { expanded = "▾", collapsed = "▸" }, + layouts = { + { + elements = { + "scopes", + "breakpoints", + "stacks", + "watches", + }, + size = 80, + position = "left", + }, + { + elements = { + "repl", + "console", + }, + size = 10, + position = "bottom", + }, + }, +} vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" }) vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" }) @@ -36,83 +36,83 @@ vim.fn.sign_define("DapBreakpointCondition", { text = "❓", texthl = "", linehl vim.fn.sign_define("DapLogPoint", { text = "💬", texthl = "", linehl = "", numhl = "" }) dap.adapters.php = { - type = "executable", - command = "php-debug-adapter", + 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}", - }, - }, + { + type = "php", + request = "launch", + name = "Laravel", + port = 9003, + pathMappings = { + ["/var/www/html"] = "${workspaceFolder}", + }, + }, + { + type = "php", + request = "launch", + name = "Symfony", + port = 9003, + pathMappings = { + ["/app"] = "${workspaceFolder}", + }, + }, } -require("dap-vscode-js").setup({ - debugger_cmd = { "js-debug-adapter" }, - adapters = { "pwa-node", "pwa-chrome", "node-terminal" }, -}) +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}", - }, - } +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", - }, - } +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 -- Events Listeners dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open({}) + dapui.open {} end -local hydra = require("hydra") +local hydra = require "hydra" local hint = [[ Nvim DAP _d_: Start/Continue _j_: StepOver _k_: StepOut _l_: StepInto ^ @@ -124,52 +124,52 @@ local hint = [[ ^^ _<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, - }, +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 } }, - }, -}) + { "<Esc>", nil, { exit = true } }, + }, +} diff --git a/lua/alpha/database.lua b/lua/alpha/database.lua index 32121eb..39e9769 100644 --- a/lua/alpha/database.lua +++ b/lua/alpha/database.lua @@ -1,43 +1,43 @@ vim.g.db_ui_use_nerd_fonts = 1 vim.g.db_ui_show_database_icon = 1 vim.g.db_ui_force_echo_notifications = 1 -vim.g.db_ui_win_position = 'right' +vim.g.db_ui_win_position = "right" vim.g.db_ui_winwidth = 80 vim.g.db_ui_table_helpers = { - mysql = { - Count = "select count(1) from {optional_schema}{table}", - Explain = "EXPLAIN {last_query}" - }, - sqlite = { - Describe = "PRAGMA table_info({table})" - } + mysql = { + Count = "select count(1) from {optional_schema}{table}", + Explain = "EXPLAIN {last_query}", + }, + sqlite = { + Describe = "PRAGMA table_info({table})", + }, } vim.g.db_ui_icons = { - expanded = { - db = '▾ ', - buffers = '▾ ', - saved_queries = '▾ ', - schemas = '▾ ', - schema = '▾ פּ', - tables = '▾ 藺', - table = '▾ ', - }, - collapsed = { - db = '▸ ', - buffers = '▸ ', - saved_queries = '▸ ', - schemas = '▸ ', - schema = '▸ פּ', - tables = '▸ 藺', - table = '▸ ', - }, - saved_query = '', - new_query = '璘', - tables = '離', - buffers = '', - add_connection = '', - connection_ok = '✓', - connection_error = '✕', + expanded = { + db = "▾ ", + buffers = "▾ ", + saved_queries = "▾ ", + schemas = "▾ ", + schema = "▾ פּ", + tables = "▾ 藺", + table = "▾ ", + }, + collapsed = { + db = "▸ ", + buffers = "▸ ", + saved_queries = "▸ ", + schemas = "▸ ", + schema = "▸ פּ", + tables = "▸ 藺", + table = "▸ ", + }, + saved_query = "", + new_query = "璘", + tables = "離", + buffers = "", + add_connection = "", + connection_ok = "✓", + connection_error = "✕", } diff --git a/lua/alpha/globals.lua b/lua/alpha/globals.lua index 5fcee70..d6fd70c 100644 --- a/lua/alpha/globals.lua +++ b/lua/alpha/globals.lua @@ -1,13 +1,13 @@ -P = function (v) - print(vim.inspect(v)) - return v +P = function(v) + print(vim.inspect(v)) + return v end -RELOAD = function (...) - return require("plenary.reload").reload_module(...) +RELOAD = function(...) + return require("plenary.reload").reload_module(...) end -R = function (name) - RELOAD(name) - return require(name) +R = function(name) + RELOAD(name) + return require(name) end diff --git a/lua/alpha/harpoon.lua b/lua/alpha/harpoon.lua index 209424f..78e6e9b 100644 --- a/lua/alpha/harpoon.lua +++ b/lua/alpha/harpoon.lua @@ -1,43 +1,44 @@ -local M = {}; +local M = {} -- changing this values will require re-compile packer local terms = vim.g.harpoon_terms or 3 local quick_binds = vim.g.harpoon_quick_binds or 5 M.keymaps = { - {"<leader>ss"}, - {"<leader>sa"}, + { "<leader>ss" }, + { "<leader>sa" }, } for i = 1, terms do - table.insert(M.keymaps, {string.format("<leader><leader>%s", i)}) + table.insert(M.keymaps, { string.format("<leader><leader>%s", i) }) end for i = 1, quick_binds do - table.insert(M.keymaps, {string.format("<leader>%s", i)}) + table.insert(M.keymaps, { string.format("<leader>%s", i) }) end |