refactor: small fixes

This commit is contained in:
Job Jobse
2026-08-29 13:03:23 +02:00
parent 1bb7c08186
commit 9f74d7a7a1
8 changed files with 206 additions and 143 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ _G.Config = {
later = function(f) misc.safely("later", f) end, later = function(f) misc.safely("later", f) end,
on_event = function(ev, f) misc.safely("event:" .. ev, f) end, on_event = function(ev, f) misc.safely("event:" .. ev, f) end,
on_filetype = function(ft, f) misc.safely("filetype:" .. ft, f) end, on_filetype = function(ft, f) misc.safely("filetype:" .. ft, f) end,
autocmd = function(event, pattern, callback, desc) autocmd = function(event, pattern, callback, desc, once)
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc }) vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once })
end end
} }
+16 -14
View File
@@ -1,29 +1,29 @@
local function run_task(cmd) local M = {}
local buf = vim.api.nvim_create_buf(true, true)
vim.api.nvim_buf_set_name(buf, "just://" .. cmd)
vim.notify("󰑮 Running: " .. cmd)
vim.api.nvim_buf_call(buf, function() local function run_task(cmd)
vim.fn.jobstart(cmd, { vim.notify("󰑮 Running: " .. cmd)
term = true, 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) on_exit = function(_, code)
if code == 0 then if code == 0 then
vim.notify("󰄬 " .. cmd .. " success") vim.notify("󰄬 " .. cmd .. " success")
vim.schedule(function() pcall(vim.cmd, "bdelete!")
pcall(vim.api.nvim_buf_delete, buf, { force = true })
end)
else else
vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", 4) vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", vim.log.levels.ERROR)
end end
end, end,
}) })
end)
end end
function pick_just_task() --- 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() local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
return vim.notify("No recipes or justfile found", 3) return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
end end
local recipes = vim.split(vim.trim(obj.stdout), "%s+") local recipes = vim.split(vim.trim(obj.stdout), "%s+")
@@ -37,3 +37,5 @@ function pick_just_task()
}, },
}) })
end end
return M
+1 -1
View File
@@ -5,7 +5,7 @@ function M.open_terminal_app(cmd)
vim.cmd("enew") vim.cmd("enew")
vim.fn.termopen(cmd, { vim.fn.termopen(cmd, {
on_exit = function() on_exit = function()
vim.cmd("bdelete!") pcall(vim.cmd, "bdelete!")
end, end,
}) })
end end
+29 -5
View File
@@ -4,12 +4,20 @@
"rev": "016802de402556da54c36bd7359b441266b01cdd", "rev": "016802de402556da54c36bd7359b441266b01cdd",
"src": "https://github.com/stevearc/conform.nvim" "src": "https://github.com/stevearc/conform.nvim"
}, },
"flutter-tools.nvim": {
"rev": "0867b346e9a60753080168188c8f1ee6be40b767",
"src": "https://github.com/nvim-flutter/flutter-tools.nvim"
},
"kanagawa.nvim": { "kanagawa.nvim": {
"rev": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3", "rev": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3",
"src": "https://github.com/rebelot/kanagawa.nvim" "src": "https://github.com/rebelot/kanagawa.nvim"
}, },
"kulala.nvim": {
"rev": "232a9939919fe9bc88d573bce92de50f2f160c60",
"src": "https://github.com/mistweaverco/kulala.nvim"
},
"laravel.nvim": { "laravel.nvim": {
"rev": "c0b171c8f9f0b5914f12b197711b93aa2c4047d3", "rev": "6afb2a00530f67e7f49cf1c1ef9acc9e7c2ac72e",
"src": "https://github.com/adalessa/laravel.nvim" "src": "https://github.com/adalessa/laravel.nvim"
}, },
"mason.nvim": { "mason.nvim": {
@@ -17,15 +25,31 @@
"src": "https://github.com/mason-org/mason.nvim" "src": "https://github.com/mason-org/mason.nvim"
}, },
"mini.nvim": { "mini.nvim": {
"rev": "e58ad4b0c9e9376096b9704f98fc00d4c9448870", "rev": "fb2bbae327f3c306f3c825031345b89dd176ce60",
"src": "https://github.com/nvim-mini/mini.nvim" "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": { "nui.nvim": {
"rev": "a25dd472316d806eb38a5dd667c2e40da5570c75", "rev": "10fc361835c856ba4233ef5ea135b919bf3dce97",
"src": "https://github.com/MunifTanjim/nui.nvim" "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": { "nvim-lspconfig": {
"rev": "0662886bc0a4e0c199dec65cee23a4319dd79f55", "rev": "684cb45c2faa24ce463b4fe9aaf011bfe1e0fb26",
"src": "https://github.com/neovim/nvim-lspconfig" "src": "https://github.com/neovim/nvim-lspconfig"
}, },
"nvim-nio": { "nvim-nio": {
@@ -33,7 +57,7 @@
"src": "https://github.com/nvim-neotest/nvim-nio" "src": "https://github.com/nvim-neotest/nvim-nio"
}, },
"nvim-treesitter": { "nvim-treesitter": {
"rev": "074aa4422bf029908338e855d0c0f71470a971bb", "rev": "8b98b4470eb326f1c7b50dae79f8c963568e5720",
"src": "https://github.com/nvim-treesitter/nvim-treesitter" "src": "https://github.com/nvim-treesitter/nvim-treesitter"
}, },
"nvim-treesitter-textobjects": { "nvim-treesitter-textobjects": {
+2 -1
View File
@@ -17,7 +17,8 @@ vim.o.splitbelow = true -- Horizontal splits will be below
vim.o.splitkeep = 'screen' -- Reduce scroll during window split vim.o.splitkeep = 'screen' -- Reduce scroll during window split
vim.o.splitright = true -- Vertical splits will be to the right 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.wrap = false -- Don't visually wrap lines (toggle with \w)
vim.o.cmdheight = 0 -- Hide the command line when not in use. vim.o.cmdheight = 0 -- Hide the command line when not in use
vim.cmd('syntax off') -- Disable legacy syntax highlighting
-- Editing ===================================================================== -- Editing =====================================================================
vim.o.expandtab = true -- Convert tabs to spaces vim.o.expandtab = true -- Convert tabs to spaces
+69 -49
View File
@@ -1,6 +1,5 @@
-- Clues ======================================================================= -- Clues =======================================================================
Config.leader_group_clues = { Config.leader_group_clues = {
{ mode = "n", keys = "<Leader>a", desc = "+AI" },
{ mode = "n", keys = "<Leader>b", desc = "+Buffer" }, { mode = "n", keys = "<Leader>b", desc = "+Buffer" },
{ mode = "n", keys = "<Leader>d", desc = "+Debug" }, { mode = "n", keys = "<Leader>d", desc = "+Debug" },
{ mode = "n", keys = "<Leader>e", desc = "+Explore" }, { mode = "n", keys = "<Leader>e", desc = "+Explore" },
@@ -16,46 +15,63 @@ Config.leader_group_clues = {
} }
-- Helpers ===================================================================== -- Helpers =====================================================================
local nmap = function(lhs, rhs, desc) vim.keymap.set("n", lhs, rhs, { desc = desc }) end local function lazy_wrap(name, action)
local nmap_leader = function(suffix, rhs, desc) vim.keymap.set("n", "<Leader>" .. suffix, rhs, { desc = desc }) end
local xmap_leader = function(suffix, rhs, desc) vim.keymap.set("x", "<Leader>" .. suffix, rhs, { desc = desc }) end
local function lazy_setup(name, action)
return function() return function()
if Config and type(Config["setup_" .. name]) == "function" then if Config["setup_" .. name] then Config["setup_" .. name]() end
Config["setup_" .. name]()
end
action() action()
end end
end end
-- Buffers ===================================================================== local nmap = function(lhs, rhs, desc, plugin)
nmap_leader("bd", function() vim.cmd("bd") end, "Delete") local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
nmap_leader("bD", function() vim.cmd("bd!") end, "Delete!") vim.keymap.set("n", lhs, final_rhs, { desc = desc })
nmap_leader("bw", function() vim.cmd("bw") end, "Wipeout") end
nmap_leader("bW", function() vim.cmd("bw!") end, "Wipeout!")
nmap_leader("bo", function() vim.cmd("%bd|e#") end, "Close all but current")
-- Debug ===================================================================== local nmap_leader = function(suffix, rhs, desc, plugin)
nmap_leader("db", lazy_setup("dap", function() require("dap").toggle_breakpoint() end), "Toggle Breakpoint") local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
nmap_leader("dc", lazy_setup("dap", function() require("dap").continue() end), "Run/Continue") vim.keymap.set("n", "<Leader>" .. suffix, final_rhs, { desc = desc })
nmap_leader("dC", lazy_setup("dap", function() require("dap").run_to_cursor() end), "Run to Cursor") end
nmap_leader("de", lazy_setup("dap", function() require("dap.ui.widgets").hover() end), "Inspect")
nmap_leader("dt", lazy_setup("dap", function() require("dap").terminate() end), "Terminate") local xmap_leader = function(suffix, rhs, desc, plugin)
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
vim.keymap.set("x", "<Leader>" .. 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 ===================================================================== -- Explore =====================================================================
nmap_leader("ed", function() MiniFiles.open() end, "Directory") nmap_leader("ed", function() MiniFiles.open() end, "Directory")
nmap_leader("ef", function() MiniFiles.open(vim.api.nvim_buf_get_name(0)) end, "File 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") nmap_leader("en", function() MiniNotify.show_history() end, "Notifications")
-- Find ===================================================================== -- Find ========================================================================
nmap_leader("f/", function() MiniPick.builtin.history({ scope = "/" }) end, '"/" history') nmap_leader("f:", function() MiniExtra.pickers.history({ scope = ":" }) end, '":" history')
nmap_leader("f:", function() MiniPick.builtin.history({ scope = ":" }) end, '":" history')
nmap_leader("fb", function() MiniPick.builtin.buffers() end, "Buffers") nmap_leader("fb", function() MiniPick.builtin.buffers() end, "Buffers")
nmap_leader("fc", function() MiniPick.builtin.git_commits() end, "Commits (all)") nmap_leader("fc", function() MiniExtra.pickers.git_commits() end, "Commits (all)")
nmap_leader("fC", function() MiniPick.builtin.git_commits({ path = "%" }) end, "Commits (buf)") nmap_leader("fC", function() MiniExtra.pickers.git_commits({ path = "%" }) end, "Commits (buf)")
nmap_leader("fd", function() MiniPick.builtin.diagnostic({ scope = "all" }) end, "Diagnostic workspace") nmap_leader("fd", function() MiniExtra.pickers.diagnostic({ scope = "all" }) end, "Diagnostic workspace")
nmap_leader("fD", function() MiniPick.builtin.diagnostic({ scope = "current" }) end, "Diagnostic buffer") nmap_leader("fD", function() MiniExtra.pickers.diagnostic({ scope = "current" }) end, "Diagnostic buffer")
nmap_leader("ff", function() MiniPick.builtin.files() end, "Files") 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_live() end, "Grep live")
nmap_leader("fG", function() MiniPick.builtin.grep({ pattern = vim.fn.expand("<cword>") }) end, "Grep current word") nmap_leader("fG", function() MiniPick.builtin.grep({ pattern = vim.fn.expand("<cword>") }) end, "Grep current word")
@@ -63,29 +79,33 @@ 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 = "all" }) end, "Lines (all)")
nmap_leader("fL", function() MiniPick.builtin.buf_lines({ scope = "current" }) end, "Lines (buf)") nmap_leader("fL", function() MiniPick.builtin.buf_lines({ scope = "current" }) end, "Lines (buf)")
nmap_leader("fr", function() MiniPick.builtin.resume() end, "Resume") nmap_leader("fr", function() MiniPick.builtin.resume() end, "Resume")
nmap_leader("fs", function() MiniPick.builtin.lsp({ scope = "workspace_symbol_live" }) end, "Symbols workspace (live)") nmap_leader("fs", function() MiniExtra.pickers.lsp({ scope = "workspace_symbol_live" }) end, "Symbols workspace (live)")
nmap_leader("fS", function() MiniPick.builtin.lsp({ scope = "document_symbol" }) end, "Symbols document") 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 ===================================================================== -- Git =========================================================================
nmap_leader("go", function() MiniDiff.toggle_overlay() end, "Toggle overlay") 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 ===================================================================== -- HTTP ========================================================================
nmap_leader("hr", lazy_setup("kulala", function() require("kulala").run() end), "Send HTTP request") nmap_leader("hr", function() require("kulala").run() end, "Send HTTP request", "kulala")
-- Language ===================================================================== -- Language ====================================================================
nmap_leader("la", vim.lsp.buf.code_action, "Actions") nmap_leader("la", function() vim.lsp.buf.code_action() end, "Actions")
nmap_leader("ld", vim.diagnostic.open_float, "Diagnostic popup") nmap_leader("ld", function() vim.diagnostic.open_float() end, "Diagnostic popup")
nmap_leader("lf", function() require("conform").format() end, "Format") nmap_leader("lf", function() require("conform").format({ async = true }) end, "Format")
nmap_leader("li", vim.lsp.buf.implementation, "Implementation") nmap_leader("li", function() vim.lsp.buf.implementation() end, "Implementation")
nmap_leader("lh", vim.lsp.buf.hover, "Hover") nmap_leader("lh", function() vim.lsp.buf.hover() end, "Hover")
nmap_leader("ll", vim.lsp.codelens.run, "Lens") nmap_leader("ll", function() vim.lsp.codelens.run() end, "Lens")
nmap_leader("lr", vim.lsp.buf.rename, "Rename") nmap_leader("lr", function() vim.lsp.buf.rename() end, "Rename")
nmap_leader("lR", vim.lsp.buf.references, "References") nmap_leader("lR", function() vim.lsp.buf.references() end, "References")
nmap_leader("ls", vim.lsp.buf.definition, "Source definition") nmap_leader("ls", function() vim.lsp.buf.definition() end, "Source definition")
nmap_leader("lt", vim.lsp.buf.type_definition, "Type definition") nmap_leader("lt", function() vim.lsp.buf.type_definition() end, "Type definition")
xmap_leader("lf", function() require("conform").format() end, "Format selection") xmap_leader("lf", function() require("conform").format({ async = true }) end, "Format selection")
-- Run ===================================================================== -- Run =========================================================================
nmap_leader("r", function() require("just").pick_just_task() end, "Run Just Task") nmap_leader("r", function() require("just").pick_just_task() end, "Run Just Task")
-- Session ===================================================================== -- Session =====================================================================
@@ -95,11 +115,11 @@ nmap_leader("sr", function() MiniSessions.select("read") end, "Read")
nmap_leader("sR", function() MiniSessions.restart() end, "Restart") nmap_leader("sR", function() MiniSessions.restart() end, "Restart")
nmap_leader("sw", function() MiniSessions.write() end, "Write current") nmap_leader("sw", function() MiniSessions.write() end, "Write current")
-- Terminal ===================================================================== -- Terminal ====================================================================
nmap_leader("tT", function() vim.cmd("horizontal term") end, "Terminal (horizontal)") nmap_leader("tT", function() vim.cmd("horizontal term") end, "Terminal (horizontal)")
nmap_leader("tt", function() vim.cmd("vertical term") end, "Terminal (vertical)") 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("tg", function() require("terminal").open_terminal_app("lazygit") end, "LazyGit")
nmap_leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL") nmap_leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL")
-- Overwrites ===================================================================== -- Overwrites ==================================================================
nmap("<Esc>", function() vim.cmd("nohlsearch") end, "Clear search highlights") nmap("<Esc>", function() vim.cmd("nohlsearch") end, "Clear search highlights")
+6 -6
View File
@@ -12,11 +12,15 @@ Config.now(function()
-- Statusline. -- Statusline.
require('mini.statusline').setup() require('mini.statusline').setup()
-- Session management.
require('mini.sessions').setup()
end) end)
Config.later(function() Config.later(function()
-- Git diff indicators. -- Git diff indicators.
require('mini.diff').setup() require('mini.diff').setup()
require('mini.git').setup()
-- Keymap hints. -- Keymap hints.
local miniclue = require('mini.clue') local miniclue = require('mini.clue')
@@ -67,6 +71,7 @@ Config.now_if_args(function()
require('mini.files').setup() require('mini.files').setup()
local add_marks = function() local add_marks = function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' }) 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' }) MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end end
Config.autocmd('User', 'MiniFilesExplorerOpen', add_marks, 'Add default marks') Config.autocmd('User', 'MiniFilesExplorerOpen', add_marks, 'Add default marks')
@@ -103,12 +108,7 @@ Config.now_if_args(function()
vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() }) vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() })
end) end)
-- Workspace & Utilities ======================================================= -- Utilities ===================================================================
Config.now(function()
-- Session management.
require('mini.sessions').setup()
end)
Config.now_if_args(function() Config.now_if_args(function()
-- Miscellaneous utility functions. -- Miscellaneous utility functions.
require('mini.misc').setup() require('mini.misc').setup()
+58 -42
View File
@@ -1,14 +1,13 @@
-- Colortheme ================================================================== -- Colortheme ==================================================================
Config.now(function() Config.now(function()
vim.pack.add({ "https://github.com/rebelot/kanagawa.nvim" }) vim.pack.add({ "https://github.com/rose-pine/neovim" })
require("kanagawa").setup({ compile = true }) require("rose-pine").setup({
vim.cmd("colo kanagawa") enable = {
end) legacy_highlights = false,
migrations = false,
-- Mason ==================================================================== },
Config.now_if_args(function() })
vim.pack.add({ "https://github.com/mason-org/mason.nvim" }) vim.cmd("colorscheme rose-pine")
require("mason").setup()
end) end)
-- Treesitter ================================================================== -- Treesitter ==================================================================
@@ -18,25 +17,34 @@ Config.now_if_args(function()
'https://github.com/nvim-treesitter/nvim-treesitter-textobjects', 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects',
}) })
local languages = { vim.treesitter.language.register('tsx', { 'typescriptreact' })
'lua',
'go',
'php',
'sql',
'javascript',
'typescript',
'tsx',
'dockerfile',
'yaml',
'markdown',
}
local isnt_installed = function(lang)
return #vim.api.nvim_get_runtime_file('parser/' .. lang .. '.*', false) == 0
end
local to_install = vim.tbl_filter(isnt_installed, languages)
if #to_install > 0 then require('nvim-treesitter').install(to_install) end
Config.autocmd('FileType', languages, function(ev) vim.treesitter.start(ev.buf) end, 'Start tree-sitter') 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) end)
-- LSP ========================================================================= -- LSP =========================================================================
@@ -49,11 +57,12 @@ Config.now_if_args(function()
"intelephense", "intelephense",
"lua_ls", "lua_ls",
"tailwindcss", "tailwindcss",
"vtsls", "tsc",
"dartls"
}) })
end) end)
-- Conform ===================================================================== -- Formatting ==================================================================
Config.now_if_args(function() Config.now_if_args(function()
vim.pack.add({ "https://github.com/stevearc/conform.nvim" }) vim.pack.add({ "https://github.com/stevearc/conform.nvim" })
@@ -61,7 +70,7 @@ Config.now_if_args(function()
default_format_opts = { lsp_format = "fallback" }, default_format_opts = { lsp_format = "fallback" },
format_on_save = { format_on_save = {
lsp_format = "fallback", lsp_format = "fallback",
timeout_ms = 500, timeout_ms = 1000,
}, },
formatters_by_ft = { formatters_by_ft = {
go = { "gofumpt", "goimports" }, go = { "gofumpt", "goimports" },
@@ -72,20 +81,15 @@ end)
-- DAP ========================================================================= -- DAP =========================================================================
function Config.setup_dap() function Config.setup_dap()
if package.loaded["dap"] then Config.setup_dap = nil
return
end
vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" }) vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" })
local dap = require("dap") local dap = require("dap")
dap.adapters.php = { dap.adapters.php = {
type = "executable", type = "executable",
command = "node", command = "node",
args = { vim.fn.stdpath("data") .. "/mason/packages/php-debug-adapter/extension/out/phpDebug.js" }, args = { vim.fn.stdpath("data") .. "/mason/packages/php-debug-adapter/extension/out/phpDebug.js" },
} }
dap.adapters.go = { dap.adapters.go = {
type = "server", type = "server",
host = "127.0.0.1", host = "127.0.0.1",
@@ -95,16 +99,14 @@ end
-- Kulala ====================================================================== -- Kulala ======================================================================
function Config.setup_kulala() function Config.setup_kulala()
if package.loaded["kulala"] then Config.setup_kulala = nil
return
end
vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" }) vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" })
require("kulala").setup({ default_env = "dev" }) require("kulala").setup({ default_env = "dev" })
end end
-- Laravel ===================================================================== -- Laravel =====================================================================
Config.now_if_args(function() function Config.setup_laravel()
Config.setup_laravel = nil
vim.pack.add({ vim.pack.add({
"https://github.com/MunifTanjim/nui.nvim", "https://github.com/MunifTanjim/nui.nvim",
"https://github.com/nvim-lua/plenary.nvim", "https://github.com/nvim-lua/plenary.nvim",
@@ -113,4 +115,18 @@ Config.now_if_args(function()
}) })
require("laravel").setup({}) require("laravel").setup({})
end) 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)