diff --git a/init.lua b/init.lua index 27990f9..82dc745 100644 --- a/init.lua +++ b/init.lua @@ -1,10 +1,10 @@ --- Modules ===================================================================== +-- Modules vim.opt.runtimepath:remove("/usr/share/nvim/site") 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 =============================================================== +-- 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", {}) @@ -12,10 +12,8 @@ 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 }) + autocmd = function(event, pattern, callback, desc) + vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc }) end } diff --git a/lua/just.lua b/lua/just.lua index 8db5ba5..b32d0ef 100644 --- a/lua/just.lua +++ b/lua/just.lua @@ -1,21 +1,5 @@ local M = {} ---- 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 - - require("mini.pick").start({ - source = { - items = vim.split(vim.trim(obj.stdout), "%s+"), - name = "󱁤 Just Tasks", - choose = function(choice) run_task("just " .. choice) end, - }, - }) -end - local function run_task(cmd) vim.notify("󰑮 Running: " .. cmd) @@ -36,4 +20,20 @@ local function run_task(cmd) end) end +-- Interactive picker for standard Justfile targets +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 + + require("mini.pick").start({ + source = { + items = vim.split(vim.trim(obj.stdout), "%s+"), + name = "󱁤 Just Tasks", + choose = function(choice) run_task("just " .. choice) end, + }, + }) +end + return M diff --git a/lua/terminal.lua b/lua/terminal.lua index 62052e5..d64cb3d 100644 --- a/lua/terminal.lua +++ b/lua/terminal.lua @@ -1,15 +1,18 @@ local M = {} ---- Opens a TUI application in a simple centered floating window. +-- Open a command in a simple centered floating window function M.open_terminal_app(cmd) local buf = vim.api.nvim_create_buf(false, true) - local w, h = math.floor(vim.o.columns * 0.95), math.floor(vim.o.lines * 0.95) + + local lines = vim.o.lines - vim.o.cmdheight - (vim.o.laststatus > 0 and 1 or 0) + local w = math.floor(vim.o.columns * 0.95) + local h = math.floor(lines * 0.92) local win = vim.api.nvim_open_win(buf, true, { relative = "editor", width = w, height = h, - row = math.floor((vim.o.lines - h) / 2), + row = math.floor((lines - h) / 2), col = math.floor((vim.o.columns - w) / 2), border = "rounded", }) diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index 14ffebe..e033005 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -8,8 +8,12 @@ "rev": "9d01f392b33fb2ba36fbc87fc0bf4453e63ffb0a", "src": "https://github.com/nvim-mini/mini.nvim" }, + "nvim-dap": { + "rev": "c9a0738e45f1bd41d792a126941348dce661cf9b", + "src": "https://github.com/mfussenegger/nvim-dap" + }, "nvim-lspconfig": { - "rev": "ee1e369181a9e64904cdd7b739e98c70778cfc71", + "rev": "85e732c62ac59ab7c12df71ddd020baa87948390", "src": "https://github.com/neovim/nvim-lspconfig" }, "nvim-treesitter": { diff --git a/plugin/10_options.lua b/plugin/10_options.lua index fe65c1f..e5ef7a8 100644 --- a/plugin/10_options.lua +++ b/plugin/10_options.lua @@ -1,9 +1,9 @@ --- General ===================================================================== -vim.g.mapleader = ' ' -- Use `` as key -vim.o.undofile = true -- Enable persistent undo -vim.o.shada = "'100,<50,s10,:1000,/100,@100,h" -- Limit ShaDa file (for startup) +-- General +vim.g.mapleader = ' ' -- Use `` as key +vim.o.undofile = true -- Enable persistent undo +vim.o.shada = "'100,<50,s10,:1000,/100,@100,h" -- Limit ShaDa file (for startup) --- UI ========================================================================== +-- 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 @@ -26,33 +26,32 @@ require("vim._core.ui2").enable({ -- Enable new ui (requires nightly) msg = { targets = "msg" } }) --- 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 -vim.opt.autoread = true -- Do not prompt to reread files on update +-- 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 +vim.opt.autoread = true -- Do not prompt to reread files on update --- 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 ================================================================ +-- 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 ================================================================= +-- Diagnostics Config.later(function() vim.diagnostic.config({ signs = { priority = 9999, - severity = { min = 'WARN', max = 'ERROR' }, + severity = { min = vim.diagnostic.severity.WARN, max = vim.diagnostic.severity.ERROR }, text = { [vim.diagnostic.severity.ERROR] = '', [vim.diagnostic.severity.WARN] = '', @@ -60,11 +59,11 @@ Config.later(function() [vim.diagnostic.severity.HINT] = '', }, }, - underline = { severity = { min = 'HINT', max = 'ERROR' } }, + underline = { severity = { min = vim.diagnostic.severity.HINT, max = vim.diagnostic.severity.ERROR } }, virtual_lines = false, virtual_text = { current_line = true, - severity = { min = 'ERROR', max = 'ERROR' }, + severity = { min = vim.diagnostic.severity.ERROR, max = vim.diagnostic.severity.ERROR }, }, update_in_insert = false, }) diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua index 0e03817..6f62098 100644 --- a/plugin/20_keymaps.lua +++ b/plugin/20_keymaps.lua @@ -1,4 +1,4 @@ --- Clues ======================================================================= +-- Clues Config.leader_group_clues = { { mode = "n", keys = "b", desc = "+Buffer" }, { mode = "n", keys = "d", desc = "+Debug" }, @@ -13,105 +13,96 @@ Config.leader_group_clues = { { mode = "x", keys = "l", desc = "+Language" }, } --- Helpers ===================================================================== -local function map(mode, lhs, rhs, desc, plugin) - local final_rhs = plugin and function() - if Config["setup_" .. plugin] then Config["setup_" .. plugin]() end - rhs() - end or rhs - vim.keymap.set(mode, lhs, final_rhs, { desc = desc }) +-- Keymap Helpers +local function map(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, { desc = desc, silent = true }) end -local nmap = function(lhs, rhs, desc, plugin) map("n", lhs, rhs, desc, plugin) end -local tmap = function(lhs, rhs, desc, plugin) map("t", lhs, rhs, desc, plugin) end -local nmap_leader = function(suffix, rhs, desc, plugin) map("n", "" .. suffix, rhs, desc, plugin) end -local xmap_leader = function(suffix, rhs, desc, plugin) map("x", "" .. suffix, rhs, desc, plugin) end +local function leader(suffix, rhs, desc, mode) + map(mode or "n", "" .. suffix, rhs, 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() +-- Buffers +leader("bd", "bdelete", "Delete") +leader("bD", "bdelete!", "Delete!") +leader("bw", "bwipeout", "Wipeout") +leader("bW", "bwipeout!", "Wipeout!") +leader("bo", function() local visible = vim.iter(vim.api.nvim_list_wins()):map(vim.api.nvim_win_get_buf):totable() + vim.iter(vim.api.nvim_list_bufs()) + :filter(function(buf) return not vim.list_contains(visible, buf) end) + :each(function(buf) pcall(vim.api.nvim_buf_delete, buf, { force = false }) end) +end, "Close invisible buffers") - for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if not vim.list_contains(visible, buf) then - pcall(vim.api.nvim_buf_delete, buf, { force = false }) - end - end -end, "Close all invisible buffers") +-- Debug +leader("db", function() require("dap").toggle_breakpoint() end, "Toggle Breakpoint") +leader("dl", function() require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point: ")) end, "Log point") +leader("dc", function() require("dap").continue() end, "Run/Continue") +leader("dC", function() require("dap").run_to_cursor() end, "Run to Cursor") +leader("de", function() require("dap.ui.widgets").hover() end, "Inspect") +leader("dr", function() require("dap").repl.open() end, "Open REPL") +leader("dt", function() require("dap").terminate() end, "Terminate") --- Debug ======================================================================= -nmap_leader("db", function() require("dap").toggle_breakpoint() end, "Toggle Breakpoint", "dap") -nmap_leader("dl", function() require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) end, - "log point", "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("dr", function() require("dap").repl.open() end, "Open repl", "dap") -nmap_leader("dt", function() require("dap").terminate() end, "Terminate", "dap") +-- Explore +leader("ed", function() MiniFiles.open() end, "Directory") +leader("ef", function() + local file = vim.api.nvim_buf_get_name(0) + MiniFiles.open(vim.uv.fs_stat(file) and file or nil) +end, "File directory") --- 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") +-- Find +leader("fb", function() MiniPick.builtin.buffers() end, "Buffers") +leader("fc", function() MiniExtra.pickers.git_commits() end, "Commits (all)") +leader("fC", function() MiniExtra.pickers.git_commits({ path = "%" }) end, "Commits (buf)") +leader("fd", function() MiniExtra.pickers.diagnostic({ scope = "all" }) end, "Diagnostic workspace") +leader("fD", function() MiniExtra.pickers.diagnostic({ scope = "current" }) end, "Diagnostic buffer") +leader("ff", function() MiniPick.builtin.files() end, "Files") +leader("fg", function() MiniPick.builtin.grep_live() end, "Grep live") +leader("fG", function() MiniPick.builtin.grep({ pattern = vim.fn.expand("") }) end, "Grep word") +leader("fh", function() MiniPick.builtin.help() end, "Help tags") +leader("fl", function() MiniPick.builtin.buf_lines({ scope = "all" }) end, "Lines (all)") +leader("fL", function() MiniPick.builtin.buf_lines({ scope = "current" }) end, "Lines (buf)") +leader("fr", function() MiniPick.builtin.resume() end, "Resume") +leader("fs", function() MiniExtra.pickers.lsp({ scope = "workspace_symbol_live" }) end, "Symbols workspace") +leader("fS", function() MiniExtra.pickers.lsp({ scope = "document_symbol" }) end, "Symbols document") +leader("f:", function() MiniExtra.pickers.history({ scope = ":" }) end, "Command history") --- Find ======================================================================== -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 +leader("go", function() MiniDiff.toggle_overlay() end, "Toggle overlay") +leader("gs", function() MiniGit.show_at_cursor() end, "Show at cursor") +leader("gs", function() MiniGit.show_at_cursor() end, "Show selection", "x") --- 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") +-- Language +leader("la", vim.lsp.buf.code_action, "Actions") +leader("ld", vim.diagnostic.open_float, "Diagnostic popup") +leader("lf", function() require("conform").format({ async = true }) end, "Format") +leader("lf", function() require("conform").format({ async = true }) end, "Format selection", "x") +leader("li", vim.lsp.buf.implementation, "Implementation") +leader("lh", vim.lsp.buf.hover, "Hover") +leader("ll", vim.lsp.codelens.run, "Lens") +leader("lr", vim.lsp.buf.rename, "Rename") +leader("lR", vim.lsp.buf.references, "References") +leader("ls", vim.lsp.buf.definition, "Source definition") +leader("lt", vim.lsp.buf.type_definition, "Type definition") --- 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 +leader("rj", function() require("just").pick_just_task() end, "Run Just Task") +leader("rh", function() require("kulala").run() end, "Send HTTP request") --- Run ========================================================================= -nmap_leader("rj", function() require("just").pick_just_task() end, "Run Just Task") -nmap_leader("rh", function() require("kulala").run() end, "Send HTTP request", "kulala") +-- Session +leader("sd", function() MiniSessions.select("delete") end, "Delete") +leader("sn", function() vim.ui.input({ prompt = "Session name: " }, MiniSessions.write) end, "New") +leader("sr", function() MiniSessions.select("read") end, "Read") +leader("sR", function() MiniSessions.restart() end, "Restart") +leader("sw", function() MiniSessions.write() end, "Write current") --- 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 +leader("tT", "horizontal term", "Terminal (horizontal)") +leader("tt", "vertical term", "Terminal (vertical)") +leader("tc", "vertical term claude", "Claude") +leader("tg", function() require("terminal").open_terminal_app("lazygit") end, "LazyGit") +leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL") --- 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("tc", function() vim.cmd("vertical term claude") end, "Claude") -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") -tmap("", "", "Terminal window navigation") +-- Overwrites +map("n", "", "nohlsearch", "Clear highlights") +map("t", "", "", "Terminal window navigation") diff --git a/plugin/30_mini.lua b/plugin/30_mini.lua index b6f3d45..a993fe0 100644 --- a/plugin/30_mini.lua +++ b/plugin/30_mini.lua @@ -1,25 +1,21 @@ --- UI ========================================================================== +-- UI Config.now(function() - -- Global icon provider. + -- Global icon provider require('mini.icons').setup() Config.later(MiniIcons.tweak_lsp_kind) - -- Start screen. + -- Start screen, statusline, and session management require('mini.starter').setup() - - -- Statusline. require('mini.statusline').setup() - - -- Session management. require('mini.sessions').setup() end) Config.later(function() - -- Git diff indicators. + -- Git diff indicators require('mini.diff').setup() require('mini.git').setup() - -- Keymap hints. + -- Keymap hints local miniclue = require('mini.clue') miniclue.setup({ clues = { @@ -33,54 +29,43 @@ Config.later(function() miniclue.gen_clues.z(), }, triggers = { - { mode = { 'n', 'x' }, keys = '' }, -- Leader triggers - { mode = { 'n', 'x' }, keys = '[' }, -- mini.bracketed + { mode = { 'n', 'x' }, keys = '' }, + { mode = { 'n', 'x' }, keys = '[' }, { mode = { 'n', 'x' }, keys = ']' }, - { mode = 'i', keys = '' }, -- Built-in completion - { mode = { 'n', 'x' }, keys = 'g' }, -- `g` key - { mode = { 'n', 'x' }, keys = "'" }, -- Marks + { mode = 'i', keys = '' }, + { mode = { 'n', 'x' }, keys = 'g' }, + { mode = { 'n', 'x' }, keys = "'" }, { mode = { 'n', 'x' }, keys = '`' }, - { mode = { 'n', 'x' }, keys = '"' }, -- Registers + { mode = { 'n', 'x' }, keys = '"' }, { 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 + { mode = 'n', keys = '' }, + { mode = { 'n', 'x' }, keys = 's' }, + { mode = { 'n', 'x' }, keys = 'z' }, }, }) end) --- Editing ===================================================================== +-- Editing & Navigation Config.later(function() - -- Enhanced text objects (a/i). require('mini.ai').setup() - - -- Surround functionality (add/delete/replace). require('mini.surround').setup() + require('mini.pick').setup() + require('mini.bracketed').setup() + require('mini.extra').setup() end) --- Navigation ================================================================== +-- File Explorer Config.now_if_args(function() - -- File system explorer. require('mini.files').setup() - local add_marks = function() + Config.autocmd('User', 'MiniFilesExplorerOpen', 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, 'Add default marks') end) +-- Completion Config.later(function() - -- Fuzzy picker. - require('mini.pick').setup() - - -- Square bracket navigation. - require('mini.bracketed').setup() -end) - --- Completion ================================================================== -Config.later(function() - -- Autocompletion and signature help. require('mini.completion').setup({ lsp_completion = { source_func = 'omnifunc', @@ -91,24 +76,15 @@ Config.later(function() }, }) - -- Set 'omnifunc' for LSP completion only when needed. - local on_attach = function(ev) + Config.autocmd('LspAttach', nil, function(ev) vim.bo[ev.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp' - end - Config.autocmd('LspAttach', nil, on_attach, "Set 'omnifunc'") + end, "Set 'omnifunc'") - -- Advertise to servers that Neovim supports certain set of completion features. vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() }) end) --- Utilities =================================================================== +-- Utilities Config.now_if_args(function() - -- Miscellaneous utility functions. require('mini.misc').setup() MiniMisc.setup_auto_root() 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 index 7ad4fd8..e1ced1b 100644 --- a/plugin/40_plugins.lua +++ b/plugin/40_plugins.lua @@ -1,20 +1,15 @@ --- Colortheme ================================================================== +-- Colortheme Config.now(function() vim.pack.add({ { src = "https://github.com/rose-pine/neovim", name = "rose-pine" } }) require("rose-pine").setup({ - enable = { - terminal = false, - legacy_highlights = false, - migrations = false, - }, + enable = { terminal = false, legacy_highlights = false, migrations = false }, }) vim.cmd("colorscheme rose-pine") end) --- Treesitter ================================================================== +-- Treesitter Config.now_if_args(function() vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' }) - vim.treesitter.language.register('tsx', { 'typescriptreact' }) local filetypes = { @@ -24,11 +19,8 @@ Config.now_if_args(function() } 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 + if pcall(vim.treesitter.start, ev.buf) and vim.bo[ev.buf].filetype == 'php' then + vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end end, 'Start tree-sitter') @@ -39,32 +31,18 @@ Config.now_if_args(function() end) end) --- LSP ========================================================================= +-- LSP Config.later(function() vim.pack.add({ "https://github.com/neovim/nvim-lspconfig" }) - - vim.lsp.enable({ - "ansiblels", - "gopls", - "intelephense", - "lua_ls", - "svelte", - "tailwindcss", - "tsc", - "dartls" - }) + vim.lsp.enable({ "ansiblels", "gopls", "intelephense", "lua_ls", "svelte", "tailwindcss", "tsc", "dartls" }) end) --- Formatting ================================================================== +-- Formatting Config.later(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, - }, + format_on_save = { lsp_format = "fallback", timeout_ms = 1000 }, formatters_by_ft = { go = { "gofumpt", "goimports" }, php = { "php_cs_fixer" }, @@ -78,9 +56,8 @@ Config.later(function() }) end) --- DAP ========================================================================= -function Config.setup_dap() - Config.setup_dap = nil +-- DAP +Config.later(function() vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" }) local dap_signs = { @@ -94,26 +71,19 @@ function Config.setup_dap() vim.fn.sign_define(name, sign) end - local dap = require("dap") - dap.adapters.go = { type = "server", host = "127.0.0.1", port = "${port}" } -end + require("dap").adapters.go = { type = "server", host = "127.0.0.1", port = "${port}" } +end) --- Kulala ====================================================================== -function Config.setup_kulala() - Config.setup_kulala = nil +-- Kulala & Flutter +Config.autocmd('FileType', { 'http' }, function() vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" }) require("kulala").setup({ default_env = "dev" }) -end +end, "Setup Kulala", true) --- Flutter ===================================================================== -function Config.setup_flutter() - Config.setup_flutter = nil +Config.autocmd('FileType', 'dart', function() 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', 'dart', Config.setup_flutter, "Setup flutter", true) +end, "Setup Flutter", true)