diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cc5457a..0000000 --- a/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -tt.* -.tests -doc/tags -debug -.repro -foo.* -*.log -data diff --git a/init.lua b/init.lua index 55b8979..e8f08a6 100644 --- a/init.lua +++ b/init.lua @@ -1 +1,24 @@ -require("config.lazy") +-- Modules ===================================================================== +vim.loader.enable() +vim.opt.runtimepath:remove("/usr/share/nvim/site") +vim.opt.runtimepath:remove("/usr/share/nvim/site/after") +for _, m in ipairs({ "netrw", "netrwPlugin", "gzip", "tarPlugin", "zipPlugin", "tutor_mode_plugin" }) do + vim.g["loaded_" .. m] = 1 -- Block unused built-in modules +end + +-- Config Global =============================================================== +vim.pack.add({ "https://github.com/nvim-mini/mini.nvim" }) +local misc = require("mini.misc") +local gr = vim.api.nvim_create_augroup("custom-config", {}) + +_G.Config = { + now = function(f) misc.safely("now", f) end, + later = function(f) misc.safely("later", f) end, + on_event = function(ev, f) misc.safely("event:" .. ev, f) end, + on_filetype = function(ft, f) misc.safely("filetype:" .. ft, f) end, + autocmd = function(event, pattern, callback, desc, once) + vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once }) + end +} + +Config.now_if_args = vim.fn.argc(-1) > 0 and Config.now or Config.later diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 6abc9f2..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "LazyVim": { "branch": "main", "commit": "fca0af57cc3851b14f96a795a9c9bfafc5096dd1" }, - "blink.cmp": { "branch": "main", "commit": "451168851e8e2466bc97ee3e026c3dcb9141ce07" }, - "catppuccin": { "branch": "main", "commit": "c4d475e4b5684747cde9b3f849186af7837d4397" }, - "codecompanion.nvim": { "branch": "main", "commit": "d5551b1aac60e164fb569eba422ea9b65cd2d6f4" }, - "conform.nvim": { "branch": "master", "commit": "086a40dc7ed8242c03be9f47fbcee68699cc2395" }, - "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" }, - "laravel.nvim": { "branch": "main", "commit": "ef06a69137ed09a72addc0c6f967aaea7d891a63" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, - "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "a979821a975897b88493843301950c456a725982" }, - "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "mini.ai": { "branch": "main", "commit": "4b0a6207341d895b6cfe9bcb1e4d3e8607bfe4f4" }, - "mini.icons": { "branch": "main", "commit": "5b9076dae1bfbe47ba4a14bc8b967cde0ab5d77e" }, - "mini.pairs": { "branch": "main", "commit": "b7fde3719340946feb75017ef9d75edebdeb0566" }, - "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, - "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-lint": { "branch": "master", "commit": "606b823a57b027502a9ae00978ebf4f5d5158098" }, - "nvim-lspconfig": { "branch": "master", "commit": "841c6d4139aedb8a3f2baf30cef5327371385b93" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-treesitter": { "branch": "main", "commit": "e5f65e31a5ec0e8526b2311ff8c7aaea4a581c82" }, - "nvim-treesitter-textobjects": { "branch": "main", "commit": "93d60a475f0b08a8eceb99255863977d3a25f310" }, - "nvim-ts-autotag": { "branch": "main", "commit": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595" }, - "persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "rose-pine": { "branch": "main", "commit": "cf2a288696b03d0934da713d66c6d71557b5c997" }, - "snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" }, - "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, - "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, - "ts-comments.nvim": { "branch": "main", "commit": "123a9fb12e7229342f807ec9e6de478b1102b041" }, - "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } -} diff --git a/lazyvim.json b/lazyvim.json deleted file mode 100644 index d8bcaf6..0000000 --- a/lazyvim.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extras": [ - - ], - "install_version": 8, - "news": { - "NEWS.md": "11866" - }, - "version": 8 -} \ No newline at end of file diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua deleted file mode 100644 index ede6149..0000000 --- a/lua/config/lazy.lua +++ /dev/null @@ -1,43 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end -end -vim.opt.rtp:prepend(lazypath) - -require("lazy").setup({ - spec = { - { "LazyVim/LazyVim", import = "lazyvim.plugins" }, - { import = "plugins" }, - }, - defaults = { - lazy = false, - version = false, - }, - install = {}, - checker = { - enabled = true, - notify = true, - }, - performance = { - rtp = { - disabled_plugins = { - "gzip", - "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, - }, - }, -}) diff --git a/lua/config/options.lua b/lua/config/options.lua deleted file mode 100644 index 6d8fca0..0000000 --- a/lua/config/options.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.o.tw = 60 -vim.o.clipboard = "" -vim.g.snacks_animate = false -vim.g.lazyvim_php_lsp = "intelephense" diff --git a/lua/just.lua b/lua/just.lua new file mode 100644 index 0000000..0989601 --- /dev/null +++ b/lua/just.lua @@ -0,0 +1,41 @@ +local M = {} + +local function run_task(cmd) + vim.notify("󰑮 Running: " .. cmd) + vim.cmd("enew") + + local buf = vim.api.nvim_get_current_buf() + pcall(vim.api.nvim_buf_set_name, buf, "just://" .. cmd) + + vim.fn.termopen(cmd, { + on_exit = function(_, code) + if code == 0 then + vim.notify("󰄬 " .. cmd .. " success") + pcall(vim.cmd, "bdelete!") + else + vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", vim.log.levels.ERROR) + end + end, + }) +end + +--- Interactive picker for selecting and running tasks defined in a Justfile. +function M.pick_just_task() + local obj = vim.system({ "just", "--summary" }, { text = true }):wait() + if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then + return vim.notify("No recipes or justfile found", vim.log.levels.WARN) + end + + local recipes = vim.split(vim.trim(obj.stdout), "%s+") + require("mini.pick").start({ + source = { + items = recipes, + name = "󱁤 Just Tasks", + choose = function(choice) + run_task("just " .. choice) + end, + }, + }) +end + +return M diff --git a/lua/plugins/ai.lua b/lua/plugins/ai.lua deleted file mode 100644 index 166412d..0000000 --- a/lua/plugins/ai.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - { - "olimorris/codecompanion.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - }, - opts = {}, - keys = { - { "aa", "CodeCompanionChat", mode = { "n", "v" }, desc = "Toggle Chat" }, - { - "ap", - function() - local mode = vim.api.nvim_get_mode().mode - vim.ui.input({ prompt = "AI Prompt: " }, function(input) - if not input or input == "" then - return - end - - if mode:match("[vV]") then - vim.cmd("'<,'>CodeCompanion " .. input) - else - vim.cmd("CodeCompanion #{buffer} " .. input) - end - end) - end, - mode = { "n", "v" }, - desc = "AI Prompt", - }, - }, - }, -} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua deleted file mode 100644 index 4b17922..0000000 --- a/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - { "rose-pine/neovim", name = "rose-pine" }, - { - "LazyVim/LazyVim", - opts = { colorscheme = "rose-pine" }, - }, -} diff --git a/lua/plugins/disabled.lua b/lua/plugins/disabled.lua deleted file mode 100644 index 401608e..0000000 --- a/lua/plugins/disabled.lua +++ /dev/null @@ -1,25 +0,0 @@ -return { - { - "folke/snacks.nvim", - opts = { - dashboard = { enabled = false }, - explorer = { trash = false }, - }, - }, - { - "neovim/nvim-lspconfig", - opts = { - inlay_hints = { enabled = false }, - }, - }, - { "akinsho/bufferline.nvim", enabled = false }, - { "folke/flash.nvim", enabled = false }, - { "rafamadriz/friendly-snippets", enabled = false }, - - { "catppuccin/nvim", enabled = false }, - { "folke/tokyonight.nvim", enabled = false }, - - { "folke/todo-comments.nvim", enabled = false }, - { "folke/ts-comments.nvim", enabled = false }, - { "MagicDuck/grug-far.nvim", enabled = false }, -} diff --git a/lua/plugins/php.lua b/lua/plugins/php.lua deleted file mode 100644 index 6924904..0000000 --- a/lua/plugins/php.lua +++ /dev/null @@ -1,136 +0,0 @@ -return { - { - -- Set Laravel Pint as the default PHP formatter with PHP CS Fixer as a fall back. - "stevearc/conform.nvim", - optional = true, - opts = { - formatters_by_ft = { - php = { { "pint", "php_cs_fixer" } }, - }, - }, - }, - { - -- Remove phpcs linter. - "mfussenegger/nvim-lint", - optional = true, - opts = { - linters_by_ft = { - php = {}, - }, - }, - }, - { - "adalessa/laravel.nvim", - dependencies = { - "MunifTanjim/nui.nvim", - "nvim-lua/plenary.nvim", - "nvim-neotest/nvim-nio", - }, - ft = { "php", "blade" }, - event = { - "BufEnter composer.json", - }, - keys = { - { - "ll", - function() - Laravel.pickers.laravel() - end, - desc = "Laravel: Open Laravel Picker", - }, - { - "", - function() - Laravel.commands.run("view:finder") - end, - desc = "Laravel: Open View Finder", - }, - { - "la", - function() - Laravel.pickers.artisan() - end, - desc = "Laravel: Open Artisan Picker", - }, - { - "lt", - function() - Laravel.commands.run("actions") - end, - desc = "Laravel: Open Actions Picker", - }, - { - "lr", - function() - Laravel.pickers.routes() - end, - desc = "Laravel: Open Routes Picker", - }, - { - "lh", - function() - Laravel.run("artisan docs") - end, - desc = "Laravel: Open Documentation", - }, - { - "lm", - function() - Laravel.pickers.make() - end, - desc = "Laravel: Open Make Picker", - }, - { - "lc", - function() - Laravel.pickers.commands() - end, - desc = "Laravel: Open Commands Picker", - }, - { - "lo", - function() - Laravel.pickers.resources() - end, - desc = "Laravel: Open Resources Picker", - }, - { - "lp", - function() - Laravel.commands.run("command_center") - end, - desc = "Laravel: Open Command Center", - }, - { - "lu", - function() - Laravel.commands.run("hub") - end, - desc = "Laravel Artisan hub", - }, - { - "gf", - function() - local ok, res = pcall(function() - if Laravel.app("gf").cursorOnResource() then - return "lua Laravel.commands.run('gf')" - end - end) - if not ok or not res then - return "gf" - end - return res - end, - expr = true, - noremap = true, - }, - }, - opts = { - features = { - pickers = { - provider = "snacks", - }, - }, - }, - }, -} diff --git a/lua/terminal.lua b/lua/terminal.lua new file mode 100644 index 0000000..6ac792f --- /dev/null +++ b/lua/terminal.lua @@ -0,0 +1,13 @@ +local M = {} + +--- Opens a TUI application in a new scratch buffer and deletes the buffer on exit. +function M.open_terminal_app(cmd) + vim.cmd("enew") + vim.fn.termopen(cmd, { + on_exit = function() + pcall(vim.cmd, "bdelete!") + end, + }) +end + +return M diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..06936ae --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,72 @@ +{ + "plugins": { + "conform.nvim": { + "rev": "016802de402556da54c36bd7359b441266b01cdd", + "src": "https://github.com/stevearc/conform.nvim" + }, + "flutter-tools.nvim": { + "rev": "0867b346e9a60753080168188c8f1ee6be40b767", + "src": "https://github.com/nvim-flutter/flutter-tools.nvim" + }, + "kanagawa.nvim": { + "rev": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3", + "src": "https://github.com/rebelot/kanagawa.nvim" + }, + "kulala.nvim": { + "rev": "232a9939919fe9bc88d573bce92de50f2f160c60", + "src": "https://github.com/mistweaverco/kulala.nvim" + }, + "laravel.nvim": { + "rev": "6afb2a00530f67e7f49cf1c1ef9acc9e7c2ac72e", + "src": "https://github.com/adalessa/laravel.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "mini.nvim": { + "rev": "fb2bbae327f3c306f3c825031345b89dd176ce60", + "src": "https://github.com/nvim-mini/mini.nvim" + }, + "neovim": { + "rev": "ff483051a47e27d84bdef47703538df1ed9f4a47", + "src": "https://github.com/rose-pine/neovim" + }, + "nightfox.nvim": { + "rev": "4dacd3f0185a2227bdf3b6c0975a8f0bf87cac9a", + "src": "https://github.com/EdenEast/nightfox.nvim" + }, + "nui.nvim": { + "rev": "10fc361835c856ba4233ef5ea135b919bf3dce97", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, + "nvim": { + "rev": "edefef779ab08ce1a4a404713e3012b0d202bd35", + "src": "https://github.com/catppuccin/nvim" + }, + "nvim-dap": { + "rev": "9e848e09a697ee95302a3ef2dd43fd6eb709e570", + "src": "https://github.com/mfussenegger/nvim-dap" + }, + "nvim-lspconfig": { + "rev": "684cb45c2faa24ce463b4fe9aaf011bfe1e0fb26", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-nio": { + "rev": "edcc181a875301dd21840189aa2f2f9ad69fc172", + "src": "https://github.com/nvim-neotest/nvim-nio" + }, + "nvim-treesitter": { + "rev": "8b98b4470eb326f1c7b50dae79f8c963568e5720", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-treesitter-textobjects": { + "rev": "898ee307df58f854d11cd7edd06472574d48014e", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + } + } +} diff --git a/plugin/10_options.lua b/plugin/10_options.lua new file mode 100644 index 0000000..a278fb3 --- /dev/null +++ b/plugin/10_options.lua @@ -0,0 +1,58 @@ +-- General ===================================================================== +vim.g.mapleader = ' ' -- Use `` as key +vim.o.undofile = true -- Enable persistent undo + +-- UI ========================================================================== +vim.o.breakindent = true -- Indent wrapped lines to match line start +vim.o.breakindentopt = 'list:-1' -- Add padding for lists (if 'wrap' is set) +vim.o.cursorline = true -- Enable current line highlighting +vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set) +vim.o.list = true -- Show helpful text indicators +vim.o.number = true -- Show line numbers +vim.o.pumheight = 10 -- Make popup menu smaller +vim.o.pummaxwidth = 100 -- Make popup menu not too wide +vim.o.shortmess = 'CFOSWaco' -- Disable some built-in completion messages +vim.o.signcolumn = 'yes' -- Always show signcolumn (less flicker) +vim.o.splitbelow = true -- Horizontal splits will be below +vim.o.splitkeep = 'screen' -- Reduce scroll during window split +vim.o.splitright = true -- Vertical splits will be to the right +vim.o.wrap = false -- Don't visually wrap lines (toggle with \w) +vim.o.cmdheight = 0 -- Hide the command line when not in use +vim.cmd('syntax off') -- Disable legacy syntax highlighting + +-- Editing ===================================================================== +vim.o.expandtab = true -- Convert tabs to spaces +vim.o.formatoptions = 'rqnl1j' -- Improve comment editing +vim.o.ignorecase = true -- Ignore case during search +vim.o.infercase = true -- Infer case in built-in completion +vim.o.shiftwidth = 2 -- Use this number of spaces for indentation +vim.o.smartcase = true -- Respect case if search pattern has upper case +vim.o.spelloptions = 'camel' -- Treat camelCase word parts as separate words +vim.o.tabstop = 2 -- Show tab as this number of spaces +vim.o.virtualedit = 'block' -- Allow going past end of line in blockwise mode + +-- Pattern for a start of numbered list (used in `gw`). +vim.o.formatlistpat = [[^\s*[0-9\-\+\*]\+[\.\)]*\s\+]] + +-- Built-in completion +vim.o.complete = '.,w,b,kspell' -- Use less sources +vim.o.completeopt = 'menuone,noselect,fuzzy,nosort' -- Use custom behavior +vim.o.completetimeout = 100 -- Limit sources delay + +-- Autocommands ================================================================ +Config.autocmd('TextYankPost', '*', function() vim.hl.hl_op() end, 'Highlight yanked text') +Config.autocmd('TermOpen', '*', function() vim.cmd('startinsert') end, 'Start insert mode when terminal opens') + +-- Diagnostics ================================================================= +Config.later(function() + vim.diagnostic.config({ + signs = { priority = 9999, severity = { min = 'WARN', max = 'ERROR' } }, + underline = { severity = { min = 'HINT', max = 'ERROR' } }, + virtual_lines = false, + virtual_text = { + current_line = true, + severity = { min = 'ERROR', max = 'ERROR' }, + }, + update_in_insert = false, + }) +end) diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua new file mode 100644 index 0000000..546b581 --- /dev/null +++ b/plugin/20_keymaps.lua @@ -0,0 +1,125 @@ +-- Clues ======================================================================= +Config.leader_group_clues = { + { mode = "n", keys = "b", desc = "+Buffer" }, + { mode = "n", keys = "d", desc = "+Debug" }, + { mode = "n", keys = "e", desc = "+Explore" }, + { mode = "n", keys = "f", desc = "+Find" }, + { mode = "n", keys = "g", desc = "+Git" }, + { mode = "n", keys = "h", desc = "+Http" }, + { mode = "n", keys = "l", desc = "+Language" }, + { mode = "n", keys = "r", desc = "+Run" }, + { mode = "n", keys = "s", desc = "+Session" }, + { mode = "n", keys = "t", desc = "+Terminal" }, + { mode = "x", keys = "g", desc = "+Git" }, + { mode = "x", keys = "l", desc = "+Language" }, +} + +-- Helpers ===================================================================== +local function lazy_wrap(name, action) + return function() + if Config["setup_" .. name] then Config["setup_" .. name]() end + action() + end +end + +local nmap = function(lhs, rhs, desc, plugin) + local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs + vim.keymap.set("n", lhs, final_rhs, { desc = desc }) +end + +local nmap_leader = function(suffix, rhs, desc, plugin) + local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs + vim.keymap.set("n", "" .. suffix, final_rhs, { desc = desc }) +end + +local xmap_leader = function(suffix, rhs, desc, plugin) + local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs + vim.keymap.set("x", "" .. suffix, final_rhs, { desc = desc }) +end + +-- Buffers ===================================================================== +nmap_leader("bd", function() pcall(vim.cmd, "bdelete") end, "Delete") +nmap_leader("bD", function() pcall(vim.cmd, "bdelete!") end, "Delete!") +nmap_leader("bw", function() pcall(vim.cmd, "bwipeout") end, "Wipeout") +nmap_leader("bW", function() pcall(vim.cmd, "bwipeout!") end, "Wipeout!") +nmap_leader("bo", function() + local current = vim.api.nvim_get_current_buf() + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if buf ~= current and vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].buflisted then + pcall(vim.api.nvim_buf_delete, buf, { force = false }) + end + end +end, "Close all but current") + +-- Debug ======================================================================= +nmap_leader("db", function() require("dap").toggle_breakpoint() end, "Toggle Breakpoint", "dap") +nmap_leader("dc", function() require("dap").continue() end, "Run/Continue", "dap") +nmap_leader("dC", function() require("dap").run_to_cursor() end, "Run to Cursor", "dap") +nmap_leader("de", function() require("dap.ui.widgets").hover() end, "Inspect", "dap") +nmap_leader("dt", function() require("dap").terminate() end, "Terminate", "dap") + +-- Explore ===================================================================== +nmap_leader("ed", function() MiniFiles.open() end, "Directory") +nmap_leader("ef", + function() MiniFiles.open(vim.uv.fs_stat(vim.api.nvim_buf_get_name(0)) and vim.api.nvim_buf_get_name(0) or nil) end, + "File directory") +nmap_leader("en", function() MiniNotify.show_history() end, "Notifications") + +-- Find ======================================================================== +nmap_leader("f:", function() MiniExtra.pickers.history({ scope = ":" }) end, '":" history') +nmap_leader("fb", function() MiniPick.builtin.buffers() end, "Buffers") +nmap_leader("fc", function() MiniExtra.pickers.git_commits() end, "Commits (all)") +nmap_leader("fC", function() MiniExtra.pickers.git_commits({ path = "%" }) end, "Commits (buf)") +nmap_leader("fd", function() MiniExtra.pickers.diagnostic({ scope = "all" }) end, "Diagnostic workspace") +nmap_leader("fD", function() MiniExtra.pickers.diagnostic({ scope = "current" }) end, "Diagnostic buffer") +nmap_leader("ff", function() MiniPick.builtin.files() end, "Files") +nmap_leader("fg", function() MiniPick.builtin.grep_live() end, "Grep live") +nmap_leader("fG", function() MiniPick.builtin.grep({ pattern = vim.fn.expand("") }) end, "Grep current word") +nmap_leader("fh", function() MiniPick.builtin.help() end, "Help tags") +nmap_leader("fl", function() MiniPick.builtin.buf_lines({ scope = "all" }) end, "Lines (all)") +nmap_leader("fL", function() MiniPick.builtin.buf_lines({ scope = "current" }) end, "Lines (buf)") +nmap_leader("fr", function() MiniPick.builtin.resume() end, "Resume") +nmap_leader("fs", function() MiniExtra.pickers.lsp({ scope = "workspace_symbol_live" }) end, "Symbols workspace (live)") +nmap_leader("fS", function() MiniExtra.pickers.lsp({ scope = "document_symbol" }) end, "Symbols document") +nmap_leader("f:", function() MiniExtra.pickers.history({ scope = ":" }) end, '":" history') +nmap_leader("f;", function() MiniExtra.pickers.history({ scope = ":" }) end, "Command history") + +-- Git ========================================================================= +nmap_leader("go", function() MiniDiff.toggle_overlay() end, "Toggle overlay") +nmap_leader("gs", function() MiniGit.show_at_cursor() end, "Show at cursor") +xmap_leader("gs", function() MiniGit.show_at_cursor() end, "Show at selection") + +-- HTTP ======================================================================== +nmap_leader("hr", function() require("kulala").run() end, "Send HTTP request", "kulala") + +-- Language ==================================================================== +nmap_leader("la", function() vim.lsp.buf.code_action() end, "Actions") +nmap_leader("ld", function() vim.diagnostic.open_float() end, "Diagnostic popup") +nmap_leader("lf", function() require("conform").format({ async = true }) end, "Format") +nmap_leader("li", function() vim.lsp.buf.implementation() end, "Implementation") +nmap_leader("lh", function() vim.lsp.buf.hover() end, "Hover") +nmap_leader("ll", function() vim.lsp.codelens.run() end, "Lens") +nmap_leader("lr", function() vim.lsp.buf.rename() end, "Rename") +nmap_leader("lR", function() vim.lsp.buf.references() end, "References") +nmap_leader("ls", function() vim.lsp.buf.definition() end, "Source definition") +nmap_leader("lt", function() vim.lsp.buf.type_definition() end, "Type definition") +xmap_leader("lf", function() require("conform").format({ async = true }) end, "Format selection") + +-- Run ========================================================================= +nmap_leader("r", function() require("just").pick_just_task() end, "Run Just Task") + +-- Session ===================================================================== +nmap_leader("sd", function() MiniSessions.select("delete") end, "Delete") +nmap_leader("sn", function() vim.ui.input({ prompt = "Session name: " }, MiniSessions.write) end, "New") +nmap_leader("sr", function() MiniSessions.select("read") end, "Read") +nmap_leader("sR", function() MiniSessions.restart() end, "Restart") +nmap_leader("sw", function() MiniSessions.write() end, "Write current") + +-- Terminal ==================================================================== +nmap_leader("tT", function() vim.cmd("horizontal term") end, "Terminal (horizontal)") +nmap_leader("tt", function() vim.cmd("vertical term") end, "Terminal (vertical)") +nmap_leader("tg", function() require("terminal").open_terminal_app("lazygit") end, "LazyGit") +nmap_leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL") + +-- Overwrites ================================================================== +nmap("", function() vim.cmd("nohlsearch") end, "Clear search highlights") diff --git a/plugin/30_mini.lua b/plugin/30_mini.lua new file mode 100644 index 0000000..86e0f47 --- /dev/null +++ b/plugin/30_mini.lua @@ -0,0 +1,125 @@ +-- UI ========================================================================== +Config.now(function() + -- Global icon provider. + require('mini.icons').setup() + Config.later(MiniIcons.tweak_lsp_kind) + + -- Notifications. + require('mini.notify').setup() + + -- Start screen. + require('mini.starter').setup() + + -- Statusline. + require('mini.statusline').setup() + + -- Statuscolumn. + require('mini.statuscolumn').setup() + + -- Session management. + require('mini.sessions').setup() +end) + +Config.later(function() + -- Git diff indicators. + require('mini.diff').setup() + require('mini.git').setup() + + -- Keymap hints. + local miniclue = require('mini.clue') + miniclue.setup({ + clues = { + Config.leader_group_clues, + miniclue.gen_clues.builtin_completion(), + miniclue.gen_clues.g(), + miniclue.gen_clues.marks(), + miniclue.gen_clues.registers(), + miniclue.gen_clues.square_brackets(), + miniclue.gen_clues.windows({ submode_resize = true }), + miniclue.gen_clues.z(), + }, + triggers = { + { mode = { 'n', 'x' }, keys = '' }, -- Leader triggers + { mode = 'n', keys = '\\' }, -- mini.basics + { mode = { 'n', 'x' }, keys = '[' }, -- mini.bracketed + { mode = { 'n', 'x' }, keys = ']' }, + { mode = 'i', keys = '' }, -- Built-in completion + { mode = { 'n', 'x' }, keys = 'g' }, -- `g` key + { mode = { 'n', 'x' }, keys = "'" }, -- Marks + { mode = { 'n', 'x' }, keys = '`' }, + { mode = { 'n', 'x' }, keys = '"' }, -- Registers + { mode = { 'i', 'c' }, keys = '' }, + { mode = 'n', keys = '' }, -- Window commands + { mode = { 'n', 'x' }, keys = 's' }, -- `s` key (mini.surround, etc.) + { mode = { 'n', 'x' }, keys = 'z' }, -- `z` key + }, + }) +end) + +-- Editing ===================================================================== +Config.later(function() + -- Enhanced text objects (a/i). + require('mini.ai').setup() + + -- Auto-close brackets and quotes. + require('mini.pairs').setup() + + -- Surround functionality (add/delete/replace). + require('mini.surround').setup() +end) + +-- Navigation ================================================================== +Config.now_if_args(function() + -- File system explorer. + require('mini.files').setup() + local add_marks = function() + MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' }) + MiniFiles.set_bookmark('d', vim.fn.expand('~/Documents'), { desc = 'Documents' }) + MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' }) + end + Config.autocmd('User', 'MiniFilesExplorerOpen', add_marks, 'Add default marks') +end) + +Config.later(function() + -- Fuzzy picker. + require('mini.pick').setup() + + -- Square bracket navigation. + require('mini.bracketed').setup() +end) + +-- Completion ================================================================== +Config.now_if_args(function() + -- Autocompletion and signature help. + require('mini.completion').setup({ + lsp_completion = { + source_func = 'omnifunc', + auto_setup = false, + process_items = function(items, base) + return MiniCompletion.default_process_items(items, base, { kind_priority = { Text = -1 } }) + end, + }, + }) + + -- Set 'omnifunc' for LSP completion only when needed. + local on_attach = function(ev) + vim.bo[ev.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp' + end + Config.autocmd('LspAttach', nil, on_attach, "Set 'omnifunc'") + + -- Advertise to servers that Neovim supports certain set of completion features. + vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() }) +end) + +-- Utilities =================================================================== +Config.now_if_args(function() + -- Miscellaneous utility functions. + require('mini.misc').setup() + MiniMisc.setup_auto_root() + MiniMisc.setup_restore_cursor() +end) + +Config.later(function() + -- Extra functionality (pickers, clues). + require('mini.extra').setup() +end) diff --git a/plugin/40_plugins.lua b/plugin/40_plugins.lua new file mode 100644 index 0000000..0cbb551 --- /dev/null +++ b/plugin/40_plugins.lua @@ -0,0 +1,132 @@ +-- Colortheme ================================================================== +Config.now(function() + vim.pack.add({ "https://github.com/rose-pine/neovim" }) + require("rose-pine").setup({ + enable = { + legacy_highlights = false, + migrations = false, + }, + }) + vim.cmd("colorscheme rose-pine") +end) + +-- Treesitter ================================================================== +Config.now_if_args(function() + vim.pack.add({ + 'https://github.com/nvim-treesitter/nvim-treesitter', + 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects', + }) + + vim.treesitter.language.register('tsx', { 'typescriptreact' }) + + local filetypes = { + 'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript', + 'typescript', 'typescriptreact', 'dockerfile', 'yaml', 'markdown', 'dart', + 'json', 'xml', 'toml', 'bash', 'gitcommit', 'diff', 'regex', 'zsh' + } + + Config.autocmd('FileType', filetypes, function(ev) + if pcall(vim.treesitter.start, ev.buf) then + if vim.bo[ev.buf].filetype == 'php' then + -- fixes broken indentation on `o` in php buffers + vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end + end, 'Start tree-sitter') + + Config.later(function() + require('nvim-treesitter').install(vim.tbl_map(function(ft) + return vim.treesitter.language.get_lang(ft) or ft + end, filetypes)) + end) +end) + +-- Mason ======================================================================= +Config.now_if_args(function() + vim.pack.add({ "https://github.com/mason-org/mason.nvim" }) + require("mason").setup() +end) + +-- LSP ========================================================================= +Config.now_if_args(function() + vim.pack.add({ "https://github.com/neovim/nvim-lspconfig" }) + + vim.lsp.enable({ + "ansiblels", + "gopls", + "intelephense", + "lua_ls", + "tailwindcss", + "tsc", + "dartls" + }) +end) + +-- Formatting ================================================================== +Config.now_if_args(function() + vim.pack.add({ "https://github.com/stevearc/conform.nvim" }) + + require("conform").setup({ + default_format_opts = { lsp_format = "fallback" }, + format_on_save = { + lsp_format = "fallback", + timeout_ms = 1000, + }, + formatters_by_ft = { + go = { "gofumpt", "goimports" }, + php = { "php_cs_fixer" }, + }, + }) +end) + +-- DAP ========================================================================= +function Config.setup_dap() + Config.setup_dap = nil + vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" }) + + local dap = require("dap") + dap.adapters.php = { + type = "executable", + command = "node", + args = { vim.fn.stdpath("data") .. "/mason/packages/php-debug-adapter/extension/out/phpDebug.js" }, + } + dap.adapters.go = { + type = "server", + host = "127.0.0.1", + port = "${port}", + } +end + +-- Kulala ====================================================================== +function Config.setup_kulala() + Config.setup_kulala = nil + vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" }) + require("kulala").setup({ default_env = "dev" }) +end + +-- Laravel ===================================================================== +function Config.setup_laravel() + Config.setup_laravel = nil + vim.pack.add({ + "https://github.com/MunifTanjim/nui.nvim", + "https://github.com/nvim-lua/plenary.nvim", + "https://github.com/nvim-neotest/nvim-nio", + "https://github.com/adalessa/laravel.nvim", + }) + + require("laravel").setup({}) +end + +-- Flutter ===================================================================== +function Config.setup_flutter() + Config.setup_flutter = nil + vim.pack.add({ + "https://github.com/nvim-lua/plenary.nvim", + "https://github.com/nvim-flutter/flutter-tools.nvim", + }) + + require("flutter-tools").setup({ lsp = { color_capabilities = true } }) +end + +Config.autocmd('FileType', 'php', Config.setup_laravel, "Setup laravel", true) +Config.autocmd('FileType', 'dart', Config.setup_flutter, "Setup flutter", true)