Skip to content

Instantly share code, notes, and snippets.

@cdnspix
Created December 26, 2025 17:11
Show Gist options
  • Select an option

  • Save cdnspix/8eef4cced6ec82377d3c0e5cbd464844 to your computer and use it in GitHub Desktop.

Select an option

Save cdnspix/8eef4cced6ec82377d3c0e5cbd464844 to your computer and use it in GitHub Desktop.
vim.iter {
'config',
'state',
'cache',
'data',
}:each(function(d)
vim.system {
'mkdir',
'-p',
vim.fn.stdpath(d)
}:wait()
end)
vim.iter {
'lua',
'lsp',
'plugin',
'ftplugin',
'after',
'after/plugin',
}:each(function(d)
vim.system {
'mkdir',
'-p',
vim.fn.stdpath('config') .. '/' .. d
}:wait()
end)
vim.system { 'mkdir', '-p', vim.fn.stdpath('data') .. '/site/pack/packages/start' }
local write_to_file = function(filename, text)
local f = assert(vim.uv.fs_open(filename, 'w', tonumber('644', 8)))
vim.uv.fs_write(f, vim.trim(text) .. '\n')
vim.uv.fs_close(f)
end
local write_config = function(filename, text)
return write_to_file(vim.fn.stdpath('config') .. '/' .. filename, text)
end
write_config('/plugin/opts.lua',
'local o = vim.opt_global\n'
.. vim.iter(
vim.api.nvim_get_all_options_info()
):map(function(k,v)
return '-- o.' .. k .. ' = ' .. string.gsub(vim.inspect(vim.opt[k]:get()), '\n', ' ')
end):join '\n'
)
write_config('/plugin/lsp.lua', [=[
vim.lsp.enable 'lua_ls'
vim.lsp.enable 'clangd'
]=])
write_config('/plugin/opts_default.lua', [=[
vim.cmd.colorscheme 'delek'
local o = vim.opt_global
o.shiftwidth = 4
o.tabstop = 4
o.expandtab = true
]=])
write_config('/plugin/config.lua', [=[
if vim.fn.argc() == 0 then
vim.schedule(function()
vim.cmd.cd(vim.fn.stdpath 'config')
vim.cmd.edit '.'
end)
end
]=])
write_config('/plugin/package-install.lua', [=[
local gh = 'https://github.com/'
vim.g.install_package = function(url)
vim.system({
'git', 'clone', url
}, {
text = true,
stdout = true,
stderr = true,
cwd = vim.fn.stdpath('data') .. '/site/pack/packages/start',
}):wait()
end
vim.g.install_package_gh = function(r)
return vim.g.install_package(gh .. r)
end
]=])
vim.cmd 'qa!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment