diff --git a/lua/core/keymap.lua b/lua/core/keymap.lua index 2b4da97..af95de9 100644 --- a/lua/core/keymap.lua +++ b/lua/core/keymap.lua @@ -25,10 +25,10 @@ K.SESSIONS = { description = 'Create Session', }, MENU = { - mode = "n", + mode = 'n', shortcut = 'sm', - description = "Open Session Menu" - } + description = 'Open Session Menu', + }, } --[[ Git ]] diff --git a/lua/core/package_manager.lua b/lua/core/package_manager.lua index 5eaab0c..9d0e66a 100644 --- a/lua/core/package_manager.lua +++ b/lua/core/package_manager.lua @@ -15,5 +15,5 @@ local plugins = require('toolchain').get_plugins() table.insert(plugins, 1, { import = 'editor' }) require('lazy').setup({ - spec = plugins + spec = plugins, }) diff --git a/lua/editor/auto_brackets.lua b/lua/editor/auto_brackets.lua index 2799654..9d9491f 100644 --- a/lua/editor/auto_brackets.lua +++ b/lua/editor/auto_brackets.lua @@ -1,4 +1,6 @@ return { 'm4xshen/autoclose.nvim', - config = function() require('autoclose').setup() end, + config = function() + require('autoclose').setup() + end, } diff --git a/lua/editor/dashboard.lua b/lua/editor/dashboard.lua index cb072da..d336557 100644 --- a/lua/editor/dashboard.lua +++ b/lua/editor/dashboard.lua @@ -42,10 +42,9 @@ return { local session_utils = require('session_manager.utils') local sessions = session_utils.get_sessions() - table.sort( - sessions, - function(a, b) return a.dir.filename < b.dir.filename end - ) + table.sort(sessions, function(a, b) + return a.dir.filename < b.dir.filename + end) local line_len = 0 for i = 1, #sessions, 1 do diff --git a/lua/editor/debugging.lua b/lua/editor/debugging.lua index 92236fa..0c55444 100644 --- a/lua/editor/debugging.lua +++ b/lua/editor/debugging.lua @@ -1,4 +1,5 @@ local K = require('core.keymap') +local T = require('toolchain') return { 'mfussenegger/nvim-dap', @@ -10,6 +11,8 @@ return { -- Setup Debugging -- local dap = require('dap') + T.setup_debuggers(dap.adapters, dap.configurations) + -- Open UI on Debugging -- local dapui = require('dapui') dapui.setup({ @@ -32,8 +35,12 @@ return { }, }, }) - dap.listeners.before.attach.dapui_config = function() dapui.open() end - dap.listeners.before.launch.dapui_config = function() dapui.open() end + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.open() + end -- Keybinding -- vim.keymap.set( diff --git a/lua/editor/language_server.lua b/lua/editor/language_server.lua index fc9326a..75ee123 100644 --- a/lua/editor/language_server.lua +++ b/lua/editor/language_server.lua @@ -5,7 +5,9 @@ return { { 'williamboman/mason.nvim', lazy = false, - config = function() require('mason').setup() end, + config = function() + require('mason').setup() + end, }, { 'williamboman/mason-lspconfig.nvim', diff --git a/lua/editor/search.lua b/lua/editor/search.lua index 327ff8c..9af3b92 100644 --- a/lua/editor/search.lua +++ b/lua/editor/search.lua @@ -18,11 +18,7 @@ return { require('telescope').load_extension('ui-select') -- Keybinding -- - local function setTelescopeBinding( - mapping, - method, - search_global - ) + local function setTelescopeBinding(mapping, method, search_global) local function binding() local path = search_global and '~' or require('neo-tree.sources.manager').get_state( @@ -30,21 +26,18 @@ return { ).path method({ search_dirs = { path } }) end - vim.keymap.set(mapping.mode, mapping.shortcut, binding, { desc = mapping.description }) + vim.keymap.set( + mapping.mode, + mapping.shortcut, + binding, + { desc = mapping.description } + ) end local telescope = require('telescope.builtin') - setTelescopeBinding( - K.SEARCH.FIND_FILE, - telescope.find_files, - false - ) - setTelescopeBinding( - K.SEARCH.FUZZY_FIND, - telescope.live_grep, - false - ) + setTelescopeBinding(K.SEARCH.FIND_FILE, telescope.find_files, false) + setTelescopeBinding(K.SEARCH.FUZZY_FIND, telescope.live_grep, false) setTelescopeBinding( K.SEARCH.GLOBAL_FIND_FILE, telescope.find_files, diff --git a/lua/editor/snippets.lua b/lua/editor/snippets.lua index fdee73b..7e1188a 100644 --- a/lua/editor/snippets.lua +++ b/lua/editor/snippets.lua @@ -49,7 +49,9 @@ return { vim.keymap.set( K.SNIPPETS.JUMP_BACKWARDS.mode, K.SNIPPETS.JUMP_BACKWARDS.shortcut, - function() luasnip.jump(-1) end, + function() + luasnip.jump(-1) + end, { silent = true } ) @@ -64,7 +66,9 @@ return { -- Setup -- cmp.setup({ snippet = { - expand = function(args) luasnip.lsp_expand(args.body) end, + expand = function(args) + luasnip.lsp_expand(args.body) + end, }, window = { completion = cmp.config.window.bordered(), diff --git a/lua/editor/status_bar.lua b/lua/editor/status_bar.lua index 9a710b2..5ead74a 100644 --- a/lua/editor/status_bar.lua +++ b/lua/editor/status_bar.lua @@ -42,7 +42,9 @@ return { sections = { lualine_a = { 'mode' }, lualine_b = { - function() return require('lsp-progress').progress() end, + function() + return require('lsp-progress').progress() + end, }, lualine_c = { 'diagnostics' }, lualine_d = { lspsaga_breadcrumbs }, @@ -77,6 +79,8 @@ return { 'lewis6991/gitsigns.nvim', 'nvim-tree/nvim-web-devicons', }, - config = function() require('barbar').setup() end, + config = function() + require('barbar').setup() + end, }, } diff --git a/lua/editor/theme.lua b/lua/editor/theme.lua index 9495097..8d8796e 100644 --- a/lua/editor/theme.lua +++ b/lua/editor/theme.lua @@ -20,5 +20,5 @@ return { brightness_down = K.FOCUS_SHADE.DOWN.shortcut, }, }, - },]]-- + },]] -- } diff --git a/lua/toolchain/config.lua b/lua/toolchain/config.lua index a740216..5360b20 100644 --- a/lua/toolchain/config.lua +++ b/lua/toolchain/config.lua @@ -2,7 +2,7 @@ local T = require('toolchain') local M = {} function M.setup() - T.add_highlighter_autoinstalls( 'json', 'xml', 'yaml', 'toml' ) + T.add_highlighter_autoinstalls('json', 'xml', 'yaml', 'toml') T.add_null_ls_module(function(null_ls) return { @@ -19,22 +19,19 @@ function M.setup() lspconfig.taplo.setup(config) end) - T.add_plugins( - { - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = {}, - }, + T.add_plugins({ + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = {}, }, - { - "folke/neoconf.nvim", - priority = 100, - config = function() - require('neoconf').setup() - end - } - ) + }, { + 'folke/neoconf.nvim', + priority = 100, + config = function() + require('neoconf').setup() + end, + }) end return M diff --git a/lua/toolchain/git.lua b/lua/toolchain/git.lua index cd0006e..f5c6797 100644 --- a/lua/toolchain/git.lua +++ b/lua/toolchain/git.lua @@ -3,46 +3,48 @@ local K = require('core.keymap') local M = {} function M.setup() - T.add_highlighter_autoinstalls('gitcommit', 'gitignore', 'gitattributes', 'git_rebase', 'git_config') - - T.add_plugins( - { - 'tpope/vim-fugitive', - }, - { - 'lewis6991/gitsigns.nvim', - config = function() - -- Setup -- - require('gitsigns').setup() - - -- Keybinding -- - vim.keymap.set( - K.GIT.HUNK.mode, - K.GIT.HUNK.shortcut, - ':Gitsigns preview_hunk_inline', - { desc = K.GIT.HUNK.description } - ) - vim.keymap.set( - K.GIT.BLAME.mode, - K.GIT.BLAME.shortcut, - ':Gitsigns toggle_current_line_blame', - { desc = K.GIT.BLAME.description } - ) - vim.keymap.set( - K.GIT.OPEN.mode, - K.GIT.OPEN.shortcut, - ':Git ', - { desc = K.GIT.OPEN.description } - ) - end, - }, - { - 'moyiz/git-dev.nvim', - lazy = true, - cmd = { 'GitDevOpen', 'GitDevCleanAll' }, - opts = {}, - } + T.add_highlighter_autoinstalls( + 'gitcommit', + 'gitignore', + 'gitattributes', + 'git_rebase', + 'git_config' ) + + T.add_plugins({ + 'tpope/vim-fugitive', + }, { + 'lewis6991/gitsigns.nvim', + config = function() + -- Setup -- + require('gitsigns').setup() + + -- Keybinding -- + vim.keymap.set( + K.GIT.HUNK.mode, + K.GIT.HUNK.shortcut, + ':Gitsigns preview_hunk_inline', + { desc = K.GIT.HUNK.description } + ) + vim.keymap.set( + K.GIT.BLAME.mode, + K.GIT.BLAME.shortcut, + ':Gitsigns toggle_current_line_blame', + { desc = K.GIT.BLAME.description } + ) + vim.keymap.set( + K.GIT.OPEN.mode, + K.GIT.OPEN.shortcut, + ':Git ', + { desc = K.GIT.OPEN.description } + ) + end, + }, { + 'moyiz/git-dev.nvim', + lazy = true, + cmd = { 'GitDevOpen', 'GitDevCleanAll' }, + opts = {}, + }) end return M diff --git a/lua/toolchain/go.lua b/lua/toolchain/go.lua index 919bf2e..61ec58a 100644 --- a/lua/toolchain/go.lua +++ b/lua/toolchain/go.lua @@ -27,14 +27,17 @@ function M.setup() config = function() local args = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_ARGS) if args ~= nil then - args = vim.split(args, "") + args = vim.split(args, '') end require('dap-go').setup({ delve = { cwd = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_DIR), - build_flags = CONFIG.get(C.CONFIG_DAP_MODULE, C.CONFIG_DAP_KEY_BUILD_FLAGS), - args = args - } + build_flags = CONFIG.get( + C.CONFIG_DAP_MODULE, + C.CONFIG_DAP_KEY_BUILD_FLAGS + ), + args = args, + }, }) end, }) diff --git a/lua/toolchain/init.lua b/lua/toolchain/init.lua index 65197b5..cdcf652 100644 --- a/lua/toolchain/init.lua +++ b/lua/toolchain/init.lua @@ -8,7 +8,7 @@ local plugins = {} --- @param ... LazySpec function TOOLCHAINS.add_plugins(...) - for _, spec in ipairs({...}) do + for _, spec in ipairs({ ... }) do table.insert(plugins, spec) end end @@ -16,6 +16,7 @@ end function TOOLCHAINS.get_plugins() return plugins end + --------- -- LSPs - --------- @@ -24,7 +25,7 @@ local lsp_setups = {} --- @param ... string function TOOLCHAINS.add_lsp_autoinstalls(...) - for _, lsp in ipairs({...}) do + for _, lsp in ipairs({ ... }) do table.insert(lsp_autoinstalls, lsp) end end @@ -57,7 +58,6 @@ function TOOLCHAINS.add_null_ls_module(setup) table.insert(null_ls_setups, setup) end - function TOOLCHAINS.get_null_ls_source(null_ls) local null_ls_sources = {} for _, setup_function in ipairs(null_ls_setups) do @@ -79,7 +79,7 @@ local highlighter_autoinstalls = {} --- @param ... string function TOOLCHAINS.add_highlighter_autoinstalls(...) - for _, highlighter in ipairs({...}) do + for _, highlighter in ipairs({ ... }) do table.insert(highlighter_autoinstalls, highlighter) end end @@ -88,9 +88,39 @@ function TOOLCHAINS.get_highlighter_autoinstalls() return highlighter_autoinstalls end ----------------- +-------------- +-- Debugging - +-------------- + +local debug_adapters = {} +local debug_configs = {} + +---@param name string +---@param adapter dap.Adapter +function TOOLCHAINS.add_debug_adapter(name, adapter) + debug_adapters[name] = adapter +end + +---@param name string +---@param config dap.Configuration +function TOOLCHAINS.add_debug_config(name, config) + debug_configs[name] = config +end + +---@param adapters table +---@param configs table +function TOOLCHAINS.setup_debuggers(adapters, configs) + for name, adapter in pairs(debug_adapters) do + adapters[name] = adapter + end + for name, config in pairs(debug_configs) do + configs[name] = config + end +end + +--------- -- Init - ----------------- +--------- function TOOLCHAINS.init() require('toolchain.config').setup() require('toolchain.database').setup() @@ -106,6 +136,7 @@ function TOOLCHAINS.init() require('toolchain.web').setup() require('toolchain.angular').setup() end + return TOOLCHAINS --------------------- diff --git a/lua/toolchain/lua.lua b/lua/toolchain/lua.lua index 49a3c01..87ac299 100644 --- a/lua/toolchain/lua.lua +++ b/lua/toolchain/lua.lua @@ -2,7 +2,7 @@ local T = require('toolchain') local M = {} function M.setup() - T.add_highlighter_autoinstalls('lua','luadoc') + T.add_highlighter_autoinstalls('lua', 'luadoc') T.add_null_ls_module(function(null_ls) return { diff --git a/lua/toolchain/php.lua b/lua/toolchain/php.lua index 155375b..5a0d469 100644 --- a/lua/toolchain/php.lua +++ b/lua/toolchain/php.lua @@ -27,6 +27,23 @@ function M.setup() lspconfig.phpactor.setup(config) lspconfig.stimulus_ls.setup(config) end) + + T.add_debug_adapter('php', { + type = 'executable', + command = 'node', + args = { + vim.loop.os_homedir() + .. '/.local/share/nvim/mason/packages/php-debug-adapter/extension/out/phpDebug.js', + }, + }) + T.add_debug_config('php', { + { + type = 'php', + request = 'launch', + name = 'Listen for Xdebug', + port = 9003, + }, + }) end return M diff --git a/lua/toolchain/rust.lua b/lua/toolchain/rust.lua index 66b212c..d997b6f 100644 --- a/lua/toolchain/rust.lua +++ b/lua/toolchain/rust.lua @@ -3,43 +3,39 @@ local M = {} function M.setup() T.add_highlighter_autoinstalls('rust') - T.add_null_ls_module( - function(null_ls) - return { - { - name = 'clippy', - method = null_ls.methods.FORMATTING, - filetypes = { 'rust' }, - generator = require('null-ls.helpers').formatter_factory({ - command = 'rustfmt', - to_stdin = true, - input = '$TEXT', - }), - }, - } - end - ) + T.add_null_ls_module(function(null_ls) + return { + { + name = 'clippy', + method = null_ls.methods.FORMATTING, + filetypes = { 'rust' }, + generator = require('null-ls.helpers').formatter_factory({ + command = 'rustfmt', + to_stdin = true, + input = '$TEXT', + }), + }, + } + end) T.add_lsp_autoinstalls('rust_analyzer') - T.add_lsps( - function(lspconfig, capabilities) - lspconfig.rust_analyzer.setup({ - cmd = { 'ra-multiplex' }, - settings = { - ['rust-analyzer'] = { - check = { - overrideCommand = { - 'cargo', - 'clippy', - '--message-format=json-diagnostic-rendered-ansi', - '--fix', - '--allow-dirty', - }, + T.add_lsps(function(lspconfig, capabilities) + lspconfig.rust_analyzer.setup({ + cmd = { 'ra-multiplex' }, + settings = { + ['rust-analyzer'] = { + check = { + overrideCommand = { + 'cargo', + 'clippy', + '--message-format=json-diagnostic-rendered-ansi', + '--fix', + '--allow-dirty', }, }, }, - }) - end - ) + }, + }) + end) end --[[T.add_plugins({ diff --git a/lua/util/config.lua b/lua/util/config.lua index 293d72a..6b2b68c 100644 --- a/lua/util/config.lua +++ b/lua/util/config.lua @@ -3,18 +3,18 @@ local F = require('util.finder') local CONFIG = {} -CONFIG.config_dir = F.project_dir .. "/" .. C.CONFIG_DIR +CONFIG.config_dir = F.project_dir .. '/' .. C.CONFIG_DIR function CONFIG.get(module, name) - local config_file_path = CONFIG.config_dir .. module .. ".json" + local config_file_path = CONFIG.config_dir .. module .. '.json' if vim.fn.filereadable(config_file_path) == 0 then return nil end - local config_file = vim.fn.readfile(config_file_path, "") + local config_file = vim.fn.readfile(config_file_path, '') local succes, data = pcall(function() - return vim.json.decode(table.concat(config_file, "")) + return vim.json.decode(table.concat(config_file, '')) end) if not succes or data then @@ -22,9 +22,9 @@ function CONFIG.get(module, name) end return table.concat( - vim.split(data[name], C.PROJECT_DIR_PLACEHOLDER, { plain = true}), + vim.split(data[name], C.PROJECT_DIR_PLACEHOLDER, { plain = true }), F.project_dir ) end -return CONFIG \ No newline at end of file +return CONFIG diff --git a/lua/util/const.lua b/lua/util/const.lua index 62ae3a6..3110ed9 100644 --- a/lua/util/const.lua +++ b/lua/util/const.lua @@ -1,9 +1,9 @@ local CONST = {} -CONST.PROJECT_DIR_PLACEHOLDER = "$PROJECT_DIR" -CONST.CONFIG_DIR = ".nvim" -CONST.CONFIG_DAP_MODULE = "debugging" -CONST.CONFIG_DAP_KEY_DIR = "dir" -CONST.CONFIG_DAP_KEY_ARGS = "args" -CONST.CONFIG_DAP_KEY_BUILD_FLAGS = "build_flags" -return CONST \ No newline at end of file +CONST.PROJECT_DIR_PLACEHOLDER = '$PROJECT_DIR' +CONST.CONFIG_DIR = '.nvim' +CONST.CONFIG_DAP_MODULE = 'debugging' +CONST.CONFIG_DAP_KEY_DIR = 'dir' +CONST.CONFIG_DAP_KEY_ARGS = 'args' +CONST.CONFIG_DAP_KEY_BUILD_FLAGS = 'build_flags' +return CONST diff --git a/lua/util/finder.lua b/lua/util/finder.lua index 875221f..30530a2 100644 --- a/lua/util/finder.lua +++ b/lua/util/finder.lua @@ -5,4 +5,4 @@ if FINDER.project_dir == '' then FINDER.project_dir = vim.fn.getcwd() end -return FINDER \ No newline at end of file +return FINDER diff --git a/stylua.toml b/stylua.toml index 197d5e3..b19b346 100644 --- a/stylua.toml +++ b/stylua.toml @@ -4,4 +4,4 @@ indent_type = "Spaces" indent_width = 4 quote_style = "AutoPreferSingle" call_parentheses = "Always" -collapse_simple_statement = "FunctionOnly" +collapse_simple_statement = "Never"