Remove lazy in favour of mini.deps

This commit is contained in:
2026-01-27 22:48:54 +01:00
parent 281589bf18
commit b7d4836f9f
14 changed files with 339 additions and 419 deletions

View File

@@ -1,4 +1,4 @@
require('config.opts') require('config.opts')
require('config.maps') require('config.maps')
require('config.autocmds') require('config.autocmds')
require('config.lazy') require('config.plug')

View File

@@ -1,24 +0,0 @@
-- bootstrap lazy
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' },
}, true, {})
return 1
end
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
change_detection = { enabled = false },
defaults = {
lazy = true,
},
spec = { { import = 'plugin' } },
})
Map('n', '<leader>L', '<cmd>Lazy<cr>', { desc = 'open Lazy' })

View File

@@ -0,0 +1,26 @@
-- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps'
local pkgpat = vim.fn.stdpath('data') .. '/site/'
local minipat = pkgpat .. 'pack/deps/start/mini.nvim'
if not vim.uv.fs_stat(minipat) then
vim.cmd('echo "Installing [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw')
local clone_cmd = {
'git', 'clone', '--filter=blob:none',
'https://github.com/nvim-mini/mini.nvim', minipat
}
vim.fn.system(clone_cmd)
vim.cmd('packadd mini.nvim | helptags ALL')
vim.cmd('echo "Installed [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw')
end
require('mini.deps').setup({ path = { package = pkgpat } })
require('plugin.auto-session')
require('plugin.blink-cmp')
require('plugin.conform')
require('plugin.gruvbox')
require('plugin.lazydev')
require('plugin.lspconfig')
require('plugin.luasnip')
require('plugin.mini')
require('plugin.nvim-lint')
require('plugin.nvim-treesitter')
require('plugin.toggleterm')

View File

@@ -1,44 +1,37 @@
---@type LazySpec MiniDeps.add({ source = 'https://github.com/rmagatti/auto-session' })
return {
"rmagatti/auto-session",
lazy = false,
priority = 100,
---@module "auto-session"
---@type AutoSession.Config
opts = {
enabled = true,
auto_save = true,
auto_create = true,
auto_restore = true,
auto_restore_last_session = false,
cwd_change_handling = true,
single_session_mode = false,
close_unsupported_windows = true,
suppressed_dirs = { '~/', '~/software/', '~/downloads/', '~/desktop/', '/etc/' },
close_filetypes_on_save = { 'checkhealth', 'man', 'oil' },
bypass_save_filetypes = { 'netrw', 'oil' },
auto_delete_empty_sessions = true, local path = vim.fn.argv(0)
purge_after_minutes = 14 * 24 * 60, if not path or type(path) ~= 'string' then return end
lazy_support = true, local realpath = vim.uv.fs_realpath(path)
legacy_cmds = false, if not realpath then return end
args_allow_single_directory = true,
args_allow_files_auto_save = false,
-- log_level = 'debug', if vim.fn.isdirectory(realpath) ~= 1 then return end
show_auto_restore_notif = true, vim.fn.chdir(realpath)
},
init = function()
local path = vim.fn.argv(0)
if not path or type(path) ~= 'string' then return end
local realpath = vim.uv.fs_realpath(path) vim.notify("loaded directory: '" .. realpath .. "'", vim.log.levels.INFO)
if not realpath then return end
if vim.fn.isdirectory(realpath) ~= 1 then return end require('auto-session').setup({
vim.fn.chdir(realpath) enabled = true,
auto_save = true,
auto_create = true,
auto_restore = true,
auto_restore_last_session = false,
cwd_change_handling = true,
single_session_mode = false,
close_unsupported_windows = true,
suppressed_dirs = { '~/', '~/software/', '~/downloads/', '~/desktop/', '/etc/' },
close_filetypes_on_save = { 'checkhealth', 'man', 'oil' },
bypass_save_filetypes = { 'netrw', 'oil' },
vim.notify("loaded directory: '" .. realpath .. "'", vim.log.levels.INFO) auto_delete_empty_sessions = true,
end, purge_after_minutes = 14 * 24 * 60,
}
lazy_support = true,
legacy_cmds = false,
args_allow_single_directory = true,
args_allow_files_auto_save = false,
-- log_level = 'debug',
show_auto_restore_notif = true,
})

View File

@@ -1,69 +1,70 @@
---@module 'lazy' local function build_blink(params)
---@type LazySpec vim.notify('Building blink.cmp', vim.log.levels.INFO)
return { { local obj = vim.system({ 'cargo', 'build', '--release' }, { cwd = params.path }):wait()
'saghen/blink.cmp', if obj.code == 0 then
event = 'InsertEnter', vim.notify('Building blink.cmp done', vim.log.levels.INFO)
version = '*', else
build = 'cargo build --release', vim.notify('Building blink.cmp failed', vim.log.levels.ERROR)
dependencies = { end
'saghen/blink.compat', end
MiniDeps.add({
source = 'https://github.com/saghen/blink.cmp',
hooks = {
post_install = build_blink,
post_checkout = build_blink,
}, },
---@module 'blink.cmp' })
---@type blink.cmp.Config
opts = { require('blink.cmp').setup({
keymap = { keymap = {
preset = 'none', preset = 'none',
['<tab>'] = { 'accept', 'fallback' }, -- accept the snippet ['<tab>'] = { 'accept', 'fallback' }, -- accept the snippet
['<c-space>'] = { 'show', 'show_documentation', 'hide_documentation' }, -- toggle auto-cmp manually ['<c-space>'] = { 'show', 'show_documentation', 'hide_documentation' }, -- toggle auto-cmp manually
['<c-k>'] = { 'show_signature', 'hide_signature', 'fallback' }, -- toggle signature ['<c-k>'] = { 'show_signature', 'hide_signature', 'fallback' }, -- toggle signature
['<c-n>'] = { 'select_next', 'fallback' }, -- next item ['<c-n>'] = { 'select_next', 'fallback' }, -- next item
['<c-p>'] = { 'select_prev', 'fallback' }, -- previous item ['<c-p>'] = { 'select_prev', 'fallback' }, -- previous item
['<c-f>'] = { 'scroll_documentation_down', 'fallback' }, -- forwards into the docs ['<c-f>'] = { 'scroll_documentation_down', 'fallback' }, -- forwards into the docs
['<c-b>'] = { 'scroll_documentation_up', 'fallback' }, -- backwards into the docs ['<c-b>'] = { 'scroll_documentation_up', 'fallback' }, -- backwards into the docs
['<c-e>'] = { 'cancel', 'fallback' }, -- keybind for cancelling completion ['<c-e>'] = { 'cancel', 'fallback' }, -- keybind for cancelling completion
}, },
snippets = { preset = 'luasnip' }, snippets = { preset = 'luasnip' },
sources = { sources = {
default = { 'lsp', 'path', 'snippets' }, default = { 'lsp', 'path', 'snippets' },
}, },
completion = { completion = {
menu = { menu = {
auto_show = true, -- whether to automatically show the window when new completion items are available auto_show = true, -- whether to automatically show the window when new completion items are available
border = 'rounded', border = 'rounded',
draw = { draw = {
columns = { { "kind_icon" }, { "label", "label_description", gap = 1 }, { 'kind' } }, columns = { { "kind_icon" }, { "label", "label_description", gap = 1 }, { 'kind' } },
treesitter = { 'lsp', 'snippets' }, treesitter = { 'lsp', 'snippets' },
},
}, },
documentation = {
auto_show = true, -- whether documentation is automatically shown when selecting a completion item
auto_show_delay_ms = 250,
treesitter_highlighting = true,
window = { border = "rounded" },
},
list = { selection = { preselect = true, auto_insert = true } },
trigger = {
show_on_insert_on_trigger_character = true,
show_on_accept_on_trigger_character = true,
show_in_snippet = false,
},
ghost_text = {
enabled = true,
show_with_selection = false, -- whether the ghost text is shown when an item is selected
show_without_selection = true, -- whether the ghost text is shown when no item is selected
show_with_menu = true, -- show ghost text when the menu is open
show_without_menu = true, -- show ghost text when the menu is closed
}
}, },
fuzzy = { documentation = {
use_proximity = true, auto_show = true, -- whether documentation is automatically shown when selecting a completion item
frecency = { enabled = true, }, auto_show_delay_ms = 250,
prebuilt_binaries = { treesitter_highlighting = true,
download = false, -- we are building from source window = { border = "rounded" },
} },
list = { selection = { preselect = true, auto_insert = true } },
trigger = {
show_on_insert_on_trigger_character = true,
show_on_accept_on_trigger_character = true,
show_in_snippet = false,
},
ghost_text = {
enabled = true,
show_with_selection = false, -- whether the ghost text is shown when an item is selected
show_without_selection = true, -- whether the ghost text is shown when no item is selected
show_with_menu = true, -- show ghost text when the menu is open
show_without_menu = true, -- show ghost text when the menu is closed
} }
}, },
config = function(_, opts) fuzzy = {
require("blink.cmp").setup(opts) use_proximity = true,
end frecency = { enabled = true, },
} } prebuilt_binaries = {
download = true, -- we are building from source
}
}
})

View File

@@ -1,38 +1,23 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/stevearc/conform.nvim' })
---@type LazySpec require('conform').setup({
return { { notify_on_error = true,
'stevearc/conform.nvim', -- allows you to format a buffer formatters_by_ft = {
event = { 'BufWritePre' }, c = { 'clang-format' },
cmd = { 'ConformInfo' }, h = { 'clang-format' },
keys = { cpp = { 'clang-format' },
{ hpp = { 'clang-format' },
'<leader>f', glsl = { 'clang-format', lsp_format = "first" },
function() typescript = { 'clang-format', lsp_format = "first" },
require('conform').format { async = true, lsp_format = 'fallback' } -- execute the formatter css = { 'clang-format' },
-- vim.cmd [[keepjumps keeppatterns %s/\s\+$//e]] -- removes trailing whitespace rust = { 'rustfmt' },
end, sh = { 'shfmt' },
mode = 'n', python = { 'isort' },
desc = '[f]ormat buffer', -- json = { 'jq' },
}, -- yaml = { 'yq' },
toml = { 'yq' },
xml = { 'yq' },
}, },
---@type conform.setupOpts })
opts = { Map('n', '<leader>f', function()
notify_on_error = true, require('conform').format({ async = true, lsp_format = 'fallback' })
formatters_by_ft = { end, { desc = 'Format Buffer' })
c = { 'clang-format' },
h = { 'clang-format' },
cpp = { 'clang-format' },
hpp = { 'clang-format' },
glsl = { 'clang-format', lsp_format = "first" },
typescript = { 'clang-format', lsp_format = "first" },
css = { 'clang-format' },
rust = { 'rustfmt' },
sh = { 'shfmt' },
python = { 'isort' },
-- json = { 'jq' },
-- yaml = { 'yq' },
toml = { 'yq' },
xml = { 'yq' },
},
}
} }

View File

@@ -1,32 +1,20 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/ellisonleao/gruvbox.nvim' })
---@type LazySpec local colour = require('gruvbox')
return { { colour.setup({
'ellisonleao/gruvbox.nvim', styles = {
lazy = false, comments = { italic = true }
priority = 1000, }
---@module 'gruvbox' })
---@type GruvboxConfig vim.cmd.colorscheme('gruvbox')
opts = { _G.userdat.palette = colour.palette
styles = {
comments = { italic = true }
}
},
config = function(_, opts)
local colour = require('gruvbox')
colour.setup(opts)
vim.cmd.colorscheme('gruvbox')
_G.userdat.palette = colour.palette
-- non-essential configuration should be put in here -- non-essential configuration should be put in here
Autocmd('VimEnter', { Autocmd('VimEnter', {
callback = callback = function()
function() -- spell highlight must be grey
-- spell highlight must be grey for _, spell in pairs { 'SpellBad', 'SpellCap', 'SpellRare', 'SpellLocal' } do
for _, spell in pairs { 'SpellBad', 'SpellCap', 'SpellRare', 'SpellLocal' } do vim.api.nvim_set_hl(0, spell,
vim.api.nvim_set_hl(0, spell, { fg = nil, bg = nil, sp = _G.userdat.palette.gray, undercurl = true })
{ fg = nil, bg = nil, sp = _G.userdat.palette.gray, undercurl = true }) end
end
end
})
end end
} } })

View File

@@ -1,12 +1,2 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/folke/lazydev.nvim' })
---@type LazySpec require('lazydev').setup()
return { {
'folke/lazydev.nvim', -- provides the lua LSP for the neovim config.
event = 'VeryLazy',
ft = 'lua',
opts = {
library = {
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } }, -- load luvit types when the `vim.uv` word is found
},
},
}, }

View File

@@ -1,51 +1,41 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/neovim/nvim-lspconfig' })
---@type LazySpec local opts = {
return { { ['clangd'] = false,
'neovim/nvim-lspconfig', ['ccls'] = true,
event = { "BufReadPre", "BufNewFile" }, ['glsl_analyzer'] = true,
dependencies = { 'saghen/blink.cmp' }, ['rust_analyzer'] = true,
---@type table<string, boolean|vim.lsp.Config> ['omnisharp'] = false,
opts = { ['lua_ls'] = true,
['clangd'] = false,
['ccls'] = true,
['glsl_analyzer'] = true,
['rust_analyzer'] = true,
['omnisharp'] = false,
['lua_ls'] = true,
['html'] = true, ['html'] = true,
['cssls'] = true, ['cssls'] = true,
['ts_ls'] = true, ['ts_ls'] = true,
['jsonls'] = true, ['jsonls'] = true,
['yamlls'] = { ['yamlls'] = {
settings = { settings = {
yaml = { yaml = {
schemas = { schemas = {
["https://json.schemastore.org/github-workflow.json"] = ["https://json.schemastore.org/github-workflow.json"] =
"/.github/workflows/*", "/.github/workflows/*",
["https://json.schemastore.org/clang-format"] = ".clang-format", ["https://json.schemastore.org/clang-format"] = ".clang-format",
["https://json.schemastore.org/clang-tidy"] = ".clang-tidy", ["https://json.schemastore.org/clang-tidy"] = ".clang-tidy",
},
}, },
}, },
}, },
}, },
---@param opts table<string,boolean|vim.lsp.Config> }
config = function(_, opts) -- store the default capabilities
-- store the default capabilities local capabilities = require('blink.cmp').get_lsp_capabilities()
local capabilities = require('blink.cmp').get_lsp_capabilities()
-- enable the LSP -- enable the LSP
for server, config in pairs(opts) do for server, config in pairs(opts) do
if type(config) == 'boolean' then if type(config) == 'boolean' then
vim.lsp.enable(server, config) vim.lsp.enable(server, config)
else else
vim.lsp.enable(server, true) vim.lsp.enable(server, true)
vim.lsp.config[server] = vim.tbl_deep_extend('force', {}, vim.lsp.config[server], vim.lsp.config[server] = vim.tbl_deep_extend('force', {}, vim.lsp.config[server],
config or {}) config or {})
end
vim.lsp.config[server].capabilities = capabilities
end
end end
} } vim.lsp.config[server].capabilities = capabilities
end

View File

@@ -1,5 +1,16 @@
return { { local function compile(params)
'L3MON4D3/LuaSnip', local obj = vim.system({ 'make', 'install_jsregexp' }, { cwd = params.path }):wait()
build = 'make install_jsregexp', if obj.code == 0 then
version = "v2.*", vim.notify('Building lacmp done', vim.log.levels.INFO)
} } else
vim.notify('Building blink.cmp failed', vim.log.levels.ERROR)
end
end
MiniDeps.add({
source = 'https://github.com/L3MON4D3/LuaSnip',
hooks = {
post_install = compile,
post_checkout = compile,
}
})

View File

@@ -1,21 +1,9 @@
-- Clone 'mini.nvim' manually in a way that it gets managed by 'mini.deps' MiniDeps.add({ source = 'https://github.com/nvim-mini/mini.nvim' })
local path_package = vim.fn.stdpath('data') .. '/site/'
local mini_path = path_package .. 'pack/deps/start/mini.nvim'
if not (vim.uv or vim.loop).fs_stat(mini_path) then
vim.cmd('echo "Installing [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw')
local clone_cmd = {
'git', 'clone', '--filter=blob:none',
'https://github.com/nvim-mini/mini.nvim', mini_path
}
vim.fn.system(clone_cmd)
vim.cmd('packadd mini.nvim | helptags ALL')
vim.cmd('echo "Installed [`mini.nvim`](../doc/mini-nvim.qmd#mini.nvim)" | redraw')
end
require('mini.deps').setup({ path = { package = path_package } })
require('mini.ai').setup() -- enhances the use of a/i textobjects require('mini.ai').setup() -- enhances the use of a/i textobjects
require('mini.align').setup() -- utility to align text in various ways require('mini.align').setup() -- utility to align text in various ways
require('mini.comment').setup() -- for toggling comments inline require('mini.comment').setup() -- for toggling comments inline
-- TODO: mini.completion to replace blink?
require('mini.move').setup() -- moving lines require('mini.move').setup() -- moving lines
require('mini.operators').setup() -- duplicating lines and evaluating equations inline require('mini.operators').setup() -- duplicating lines and evaluating equations inline
require('mini.pairs').setup() -- automatic closing pairs require('mini.pairs').setup() -- automatic closing pairs
@@ -65,9 +53,7 @@ require('mini.clue').setup({ -- shows available keybinds when performing ke
}, },
}) })
require('mini.diff').setup({ -- shows git diffs in the file require('mini.diff').setup({ -- shows git diffs in the file
view = { view = { style = 'sign' }
style = 'sign',
}
}) })
require('mini.files').setup({ -- file browser require('mini.files').setup({ -- file browser
content = { content = {
@@ -104,12 +90,14 @@ require('mini.files').setup({ -- file browser
Map('n', '<leader>o', MiniFiles.open, { desc = "Open mini file browser" }) Map('n', '<leader>o', MiniFiles.open, { desc = "Open mini file browser" })
require('mini.jump').setup() -- extends f,F,t,T to work across multiple lines require('mini.jump').setup() -- extends f,F,t,T to work across multiple lines
require('mini.pick').setup() require('mini.pick').setup()
require('mini.extra').setup()
Map('n', '<c-s>', MiniPick.builtin.resume, { desc = "Resume Previous Search" })
Map('n', '<c-p>', MiniPick.builtin.files, { desc = "File Picker" }) Map('n', '<c-p>', MiniPick.builtin.files, { desc = "File Picker" })
Map('n', '<c-g>', MiniPick.builtin.live_grep, { desc = "Live Grep" }) Map('n', '<c-g>', MiniPick.builtin.grep_live, { desc = "Live Grep" })
Map('n', '<leader>p', MiniPick.builtin.files, { desc = "File Picker" }) Map('n', '<leader>p', MiniPick.builtin.files, { desc = "File Picker" })
Map('n', '<leader>sg', MiniPick.builtin.grep_live, { desc = "Search Live Grep" }) Map('n', '<leader>sg', MiniPick.builtin.grep_live, { desc = "Search Live Grep" })
Map('n', '<leader>sd', MiniExtra.pickers.diagnositc, { desc = "Search Diagnostics" }) Map('n', '<leader>sd', MiniExtra.pickers.diagnostic, { desc = "Search Diagnostics" })
-- TODO: Use mini.sessions?
require('mini.cursorword').setup() -- highlight words beneath the cursor require('mini.cursorword').setup() -- highlight words beneath the cursor
require('mini.hipatterns').setup({ require('mini.hipatterns').setup({
highlighters = { highlighters = {
@@ -193,7 +181,3 @@ require('mini.statusline').setup({
}) })
require('mini.tabline').setup() -- shows buffers that are open require('mini.tabline').setup() -- shows buffers that are open
require('mini.trailspace').setup() -- trailing space indication and removal. require('mini.trailspace').setup() -- trailing space indication and removal.
---@module 'lazy'
---@type LazySpec
return {}

View File

@@ -1,57 +1,50 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/mfussenegger/nvim-lint' })
---@type LazySpec local lint = require('lint')
return { {
'mfussenegger/nvim-lint',
event = { 'BufWritePost', 'BufReadPost', 'TextChanged' },
---@module 'lint'
opts = {
---@type table<string, string[]>
linters_by_ft = {
sh = { 'shellcheck' },
glsl = { 'glslang' },
},
linters = {
glslang = {
cmd = 'glslangValidator',
stdin = false,
args = { '-C' },
ignore_exitcode = true,
parser = function(output)
local diags = {}
for _, line in ipairs(vim.split(output, '\n')) do
local f, lnum, sev, msg = line:match(
'^([^:]+):(%d+):%s+([^:]+):%s+(.+)$') -- file:line: severity: message
if not f then sev, f, lnum, msg = line:match(
'^(%w+):%s+([^:]+):(%d+):%s+(.+)$') end -- severity: file:line: message
if lnum then local linters = {
local s = sev:lower() == 'error' glslang = {
and vim.diagnostic.severity.ERROR cmd = 'glslangValidator',
or vim.diagnostic.severity.WARN stdin = false,
table.insert(diags, { args = { '-C' },
lnum = tonumber(lnum) - 1, ignore_exitcode = true,
col = 0, parser = function(output)
message = msg, local diags = {}
source = 'glslang', for _, line in ipairs(vim.split(output, '\n')) do
severity = s local f, lnum, sev, msg = line:match(
}) '^([^:]+):(%d+):%s+([^:]+):%s+(.+)$') -- file:line: severity: message
end if not f then
end sev, f, lnum, msg = line:match(
return diags '^(%w+):%s+([^:]+):(%d+):%s+(.+)$')
end -- severity: file:line: message
if lnum then
local s = sev:lower() == 'error'
and vim.diagnostic.severity.ERROR
or vim.diagnostic.severity.WARN
table.insert(diags, {
lnum = tonumber(lnum) - 1,
col = 0,
message = msg,
source = 'glslang',
severity = s
})
end end
} end
} return diags
},
config = function(_, opts)
local lint = require('lint')
lint.linters_by_ft = opts.linters_by_ft
for name, linter in pairs(opts.linters) do
lint.linters[name] = linter
end end
}
}
-- autocommand for linting
Autocmd({ 'BufWritePost', 'BufWinEnter', 'TextChanged' }, lint.linters_by_ft = {
{ callback = function() lint.try_lint() end }); sh = { 'shellcheck' },
end glsl = { 'glslang' },
} } }
for name, linter in pairs(linters) do
lint.linters[name] = linter
end
-- autocommand for linting
Autocmd({ 'BufWritePost', 'BufWinEnter', 'TextChanged' },
{ callback = function() lint.try_lint() end });

View File

@@ -1,39 +1,32 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/nvim-treesitter/nvim-treesitter' })
---@type LazySpec
return { {
'nvim-treesitter/nvim-treesitter', -- highlight, edit, and navigate code
build = ':TSUpdate',
lazy = false,
config = function()
-- Pre-install a few languages we're (very) likely going to use
local ts = require('nvim-treesitter')
ts.setup({ install_dir = vim.fn.stdpath('cache') .. '/tree-sitter' })
ts.install({
'c', 'make',
'bash', 'gitignore', 'editorconfig',
'ini', 'json', 'yaml',
'markdown', 'markdown_inline',
})
-- Define aliases for entries that lack an entry, but should have one. -- Pre-install a few languages we're (very) likely going to use
local alias = { local ts = require('nvim-treesitter')
{ 'sh', 'bash' }, ts.setup({ install_dir = vim.fn.stdpath('cache') .. '/tree-sitter' })
} ts.install({
'c', 'make',
'bash', 'gitignore', 'editorconfig',
'ini', 'json', 'yaml',
'markdown', 'markdown_inline',
})
local pat = vim.iter(alias):map(function(a) return a[1] end):totable() -- Define aliases for entries that lack an entry, but should have one.
vim.list_extend(pat, ts.get_available()) local alias = {
Autocmd('FileType', { { 'sh', 'bash' },
pattern = pat, }
callback = function(arg)
local a = vim.iter(alias) local pat = vim.iter(alias):map(function(a) return a[1] end):totable()
:find(function(a) return arg.match == a[1] end) vim.list_extend(pat, ts.get_available())
if not a then -- Ensure we only install if an alias was found Autocmd('FileType', {
require('nvim-treesitter').install(vim.bo.ft) pattern = pat,
pcall(vim.treesitter.start) callback = function(arg)
return local a = vim.iter(alias)
end :find(function(a) return arg.match == a[1] end)
vim.bo.ft = a[2] -- Retriggers function if not a then -- Ensure we only install if an alias was found
end require('nvim-treesitter').install(vim.bo.ft)
}) pcall(vim.treesitter.start)
end, return
} } end
vim.bo.ft = a[2] -- Retriggers function
end
})

View File

@@ -1,56 +1,46 @@
---@module 'lazy' MiniDeps.add({ source = 'https://github.com/akinsho/toggleterm.nvim' })
---@type LazySpec local tt = require('toggleterm')
return { { local term = require('toggleterm.terminal')
'akinsho/toggleterm.nvim', -- allows to toggle the terminal rather than open one in a separate window tt.setup({
event = 'VeryLazy', direction = 'float',
---@type ToggleTermConfig open_mapping = [[<C-\>]]
---@diagnostic disable-next-line: missing-fields })
opts = {
direction = "float",
open_mapping = [[<C-\>]]
},
config = function(_, opts)
local tt = require('toggleterm')
local term = require('toggleterm.terminal')
tt.setup(opts)
local term_lazygit = term.Terminal:new({ cmd = "lazygit", hidden = true, direction = 'float' }) local term_lazygit = term.Terminal:new({ cmd = "lazygit", hidden = true, direction = 'float' })
-- Set mappings to toggle the above -- Set mappings to toggle the above
Map({ 'n' }, '<leader>gg', function() term_lazygit:toggle() end) Map({ 'n' }, '<leader>gg', function() term_lazygit:toggle() end)
-- Add a keymap for executing makefiles, or launch scripts -- Add a keymap for executing makefiles, or launch scripts
Map({ 'n', 't', 'v' }, '<c-b>', function() Map({ 'n', 't', 'v' }, '<c-b>', function()
local cwd = vim.fn.getcwd() local cwd = vim.fn.getcwd()
local cmd = nil local cmd = nil
local launchcfg = cwd .. '/.launch.sh' local launchcfg = cwd .. '/.launch.sh'
-- If the path is readable, the attached command is executed and no more is checked. -- If the path is readable, the attached command is executed and no more is checked.
for _, obj in ipairs({ for _, obj in ipairs({
{ launchcfg, launchcfg }, { launchcfg, launchcfg },
{ cwd .. '/Makefile', 'make -C ' .. cwd }, { cwd .. '/Makefile', 'make -C ' .. cwd },
{ cwd .. '/makefile', 'make -C ' .. cwd }, { cwd .. '/makefile', 'make -C ' .. cwd },
}) do }) do
local pat = obj[1] local pat = obj[1]
local exec = obj[2] local exec = obj[2]
if (vim.fn.filereadable(pat) == 1) then if (vim.fn.filereadable(pat) == 1) then
cmd = '\r' .. exec -- use \r to override text if it's present cmd = '\r' .. exec -- use \r to override text if it's present
break break
end end
end
-- If cmd still hasn't been set; edit the file
if (not cmd) then
local buf = vim.api.nvim_create_buf(true, false) -- listed, not scratch
vim.api.nvim_set_current_buf(buf)
vim.api.nvim_buf_set_name(buf, launchcfg)
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, { '#!/usr/bin/env sh', 'exec ' })
vim.bo.ft = 'sh'
return
end
-- Execute the command in terminal 1
tt.exec(cmd, 1, nil, nil, nil, nil, false, true)
end, { desc = 'compile the program using .buildcofig placed in PWD' })
end end
} }
-- If cmd still hasn't been set; edit the file
if (not cmd) then
local buf = vim.api.nvim_create_buf(true, false) -- listed, not scratch
vim.api.nvim_set_current_buf(buf)
vim.api.nvim_buf_set_name(buf, launchcfg)
vim.api.nvim_buf_set_text(0, 0, 0, 0, 0, { '#!/usr/bin/env sh', 'exec ' })
vim.bo.ft = 'sh'
return
end
-- Execute the command in terminal 1
tt.exec(cmd, 1, nil, nil, nil, nil, false, true)
end, { desc = 'compile the program using .buildcofig placed in PWD' })