Merge branch 'trunk' of github.com:bugabinga/dotfiles into trunk
d4fde2a12c211cf6e35dc36f2fa531127caaa20c
Oliver Krylow <o.krylow@isp-insoft.de> ·
unsigned
- Parent 1: f7518152b7fe · Showing diff
- Parent 2: 6bf371a10cfc · Diff against parent 2
bugabingas dorkfiles
d4fde2a12c211cf6e35dc36f2fa531127caaa20c
Oliver Krylow <o.krylow@isp-insoft.de> ·
unsigned
+57 / −468 text lines
+0 / −9 text lines
+12 / −20 text lines
A-up = [ "extend_to_line_bounds", "delete_selection", "move_line_up", "paste_before",]A-k = [ "extend_to_line_bounds", "delete_selection", "move_line_up", "paste_before",]A-k = [ "extend_to_line_bounds", "delete_selection", "move_line_up", "paste_before", ]A-down = ["extend_to_line_bounds", "delete_selection", "paste_after"]"A-=" = ":format"+7 / −11 text lines
+3 / −0 text lines
deleted file mode 100644+0 / −132 text lines
local vim = _G['vim'] or error 'where is my vim'local co = coroutinelocal function current_non_main_co() local data = { coroutine.running(), } if select( '#', unpack( data ) ) == 2 then local co, is_main = unpack( data ) if is_main then return nil end return co end return unpack( data )endlocal function wrap( func, argc, opts ) opts = vim.tbl_extend( 'keep', opts or {}, { strict = true, } ) vim.validate { func = { func, 'function', }, argc = { argc, 'number', }, } local protected = function ( ... ) local args = { ..., } local cb = args[argc] args[argc] = function ( ... ) cb( true, ... ) end xpcall( func, function ( err ) cb( false, err, debug.traceback() ) end, unpack( args, 1, argc ) ) end return function ( ... ) if not current_non_main_co() then if opts.strict then error 'Cannot call async function from non-async context' end return func( ... ) end local ret = { coroutine.yield( argc, protected, ... ), } local success = ret[1] if not success then error( ('Wrapped function failed: %s\n%s'):format( ret[2], ret[3] ) ) end return unpack( ret, 2, table.maxn( ret ) ) endendlocal dbg = function ( fmt, ... ) vim.print( string.format( fmt, ... ) )endlocal load_version = function ( prg, callback ) vim.validate { prg = { prg, 'string', }, callback = { callback, 'function', }, } return co.create( function () local current_thread = co.running() local stdin = nil; local stdout = vim.uv.new_pipe(); local stderr = vim.uv.new_pipe(); local process_result = {} local process_error = {} local handle, pid = vim.uv.spawn( prg, { stdio = { stdin, stdout, stderr, }, args = { '--version', }, hide = true, }, function ( code, signal ) dbg( 'process done with code: %d, signal: %s', code, signal ) callback( process_error, process_result, code, signal ) co.resume( current_thread ) end ) if not handle then error( string.format( 'program %s could not be spawned', prg ) ) end -- dbg( 'process open with handle: %s and pid %d', handle, pid ) vim.uv.read_start( stdout, function ( err, data ) if err then dbg( err ) elseif data then -- dbg( 'chunk of stdout: %s', data ) table.insert( process_result, data ) else -- dbg 'stdout done' end end ) vim.uv.read_start( stderr, function ( err, data ) if err then dbg( err ) elseif data then -- dbg( 'chunk of stderr: %s', data ) table.insert( process_error, data ) else -- dbg 'stderr done' end end ) co.yield() end )endlocal java = load_version( 'java', function ( err, result, code, signal ) if #err ~= 0 then dbg( 'err: %s, code: %s, signal: %s', table.concat( err ), code, signal ) else dbg( 'java version is: %s', table.concat( result ) ) endend )local cargo = load_version( 'cargo', function ( err, result ) dbg( 'cargo version is: %s', table.concat( result ) )end )local nvim = load_version( 'nvim', function ( err, result ) dbg( 'nvim version is: %s', table.concat( result ) )end )-- vim.uv.run()-- vim.uv.run 'once'-- vim.wait( 300, function ()-- dbg '---'-- end, 300 )deleted file mode 100644+0 / −22 text lines
local puck = require 'puck'local gh = puck.plugin_types.github.typelocal cb = puck.plugin_types.codeberg.typelocal srht = puck.plugin_types.sourcehut.typelocal dev = puck.plugin_types.development.type-- TODO move this outside-- testing the pucklocal plugins = { { dev, 'bugabinga/venn.nvim', }, { gh, 'nyoom-engineering/oxocarbon.nvim', 'c5846d10cbe4131cc5e32c6d00beaf59cb60f6a2', }, { srht, '~adigitoleo/haunt.nvim', 'e3e3c8f45663fed8225ba5efb0af00a2df14a736', }, { cb, 'jthvai/lavender.nvim', 'a5187e6f4afe4b1f2fbcd0fe0bad34c40002ba48', }, { dev, 'bugabinga/auto-dark-mode.nvim', },}puck.setup { plugins = plugins, -- TODO change Workspace on win32 workspace = '~/Workspace',}+10 / −3 text lines
"colorizer.nvim": { "branch": "master", "commit": "c1602ff3f11566bb7f16f90985b0c59d3d7db0ef" }, "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, "conform.nvim": { "branch": "master", "commit": "936f2413e6c57185cd873623a29a0685bce4b423" }, "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, "indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" }, "nvim-lsp-file-operations": { "branch": "master", "commit": "92a673de7ecaa157dd230d0128def10beb56d103" }, "nvim-neoclip.lua": { "branch": "main", "commit": "32e05f2d23dc5b6a284a688c0535a83d1bfc633f" }, "nvim-treesitter": { "branch": "master", "commit": "c436d45eeeeb78e5482cb28b59de1d7a77c93d86" }, "nvim-treesitter-context": { "branch": "master", "commit": "e6cc783b74606d97ca9eff6494e3f5c2ca603a50" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, "nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" }, "oil.nvim": { "branch": "master", "commit": "1fe476daf0b3c108cb8ee1fc1226cc282fa2c9c1" }, "qf_helper.nvim": { "branch": "master", "commit": "fa3c2f3f2706e2c9984409c9c14b5993302ddfa7" }, "telescope-zoxide": { "branch": "main", "commit": "54bfe630bad08dc9891ec78c7cf8db38dd725c97" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "tint.nvim": { "branch": "master", "commit": "02bd0527a315a80e4e25bb2dd7b6994fb0daae01" }, "todo-comments.nvim": { "branch": "main", "commit": "313b04e5b02d29ab9275c9295ff5e2b73921b0eb" }, "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" }, "vim-vscode-snippets": { "branch": "master", "commit": "c34e9edee6a00cf3d0b8edb515e08e3df450bcfa" },+5 / −1 text lines
+1 / −11 text lines
local table = require 'std.table'local map = require 'std.map'+4 / −2 text lines
+1 / −1 text lines
+0 / −1 text lines
deleted file mode 100644+0 / −246 text lines
-- [x] Install tarballs into data dir-- [x] Put local plugins on runtimepath-- Generate helptags ALL-- project local plugin settings ?-- make this module async --> emit PuckDone event?-- Install treesitter parser into data dir-- Build parsers and put them where?-- vim.validate all input in functions---- [x] Cache lua byte code? not necessary anymore thanks to vim.loader-- TODO export some kind of structure--local dev = 'plugin_under_development'local gh = 'plugin_from_github'local srht = 'plugin_from_srht'local cb = 'plugin_from_codeberg'local gh_format = 'https://github.com/%s/archive/%s.tar.gz'local cb_format = 'https://codeberg.org/%s/archive/%s.tar.gz'local srht_format = 'https://git.sr.ht/%s/archive/%s.tar.gz'local plugins = {}local as_name = function ( plugin_coords ) return vim.fs.basename(plugin_coords):gsub( '(%w+)%.?%w*', '%1' )endlocal configure_plugin = function( plugin_name ) local config = 'config.' .. plugin_name vim.schedule( function() local ok = pcall(require, config) if not ok then vim.notify(string.format('unable to load configuration for %s at %s', plugin_name, config), vim.log.levels.WARN) end end)endlocal download_plugin_into = function ( puck_root, plugin_name, plugin_tarball_url, plugin_install_path) vim.validate { puck_root = { puck_root, 'string' }, plugin_name = { plugin_name, 'string'}, plugin_tarball_url = { plugin_tarball_url, 'string' }, plugin_install_path = { plugin_install_path, 'string'}, } assert(vim.fn.executable 'curl', 'curl not found') assert(vim.fn.executable 'tar', 'tar not found') -- local tmp_dir = vim.uv.fs_mkdtemp(vim.fs.joinpath(vim.uv.os_tmpdir(),'puck_tmp_install_path_XXXXXX')) -- vim.fn.mkdir( plugin_install_path, 'p' ) local tarball_data_stream = vim.uv.new_pipe(true) local curl_handle, curl_pid = vim.uv.spawn( 'curl', { args = { '--silent', '--location', plugin_tarball_url }, cwd = puck_root, stdio = {nil, tarball_data_stream, nil}, hide = true, }, function(code, signal) if code ~= 0 then error('curl', code, signal) end end ) local tar_handle, tar_pid = vim.uv.spawn( 'tar', { args = { '--extract','--gzip', '--file', '-' }, cwd = puck_root, stdio = { tarball_data_stream, nil, nil}, hide = true, }, function(code, signal) if code ~= 0 then error('tar done', code, signal) end local contains_name = function(name, path) return name:find(plugin_name,0,true) end local extracted_dir = vim.fs.find( contains_name, { path = puck_root, type = 'directory', limit = 1 }) assert(#extracted_dir ~= 0, 'No directory was found in tarball') assert(#extracted_dir == 1, 'Too many directories were found in tarball. Expected one!') -- FIXME: filter out files and folders, that are unnecessary for neovim plugins local ok = vim.uv.fs_rename(extracted_dir[1], plugin_install_path) assert(ok, string.format('Failed to move extracted plugin from %s to %s.', extracted_dir[1], plugin_install_path)) configure_plugin(plugin_name) end ) vim.uv.shutdown(tarball_data_stream, function() vim.uv.close(curl_handle) vim.uv.close(tar_handle) end)endlocal delete_directory_recursive = function ( path ) local stat = vim.uv.fs_stat( path ) if stat and stat.type == 'directory' then local dir = vim.uv.fs_scandir( path ) if dir then while true do local name, type = vim.uv.fs_scandir_next( dir ) if not name then break end local full_path = vim.fs.joinpath( path, name ) if type == 'directory' then return delete_directory_recursive( full_path ) else return vim.uv.fs_unlink( full_path ) end end end return vim.uv.fs_rmdir( path ) else return false end return trueendlocal as_url_format = function(plugin_type) assert(plugin_type ~= dev, 'local plugins need not have an url format!') if plugin_type == gh then return gh_format end if plugin_type == cb then return cb_format end if plugin_type == srht then return srht_format end error('unknown plugin type '..plugin_type..' given.')endlocal install_plugin = function ( puck_root, plugin_type, plugin_coords, plugin_rev) local plugin_name = as_name( plugin_coords ) local plugin_install_path = vim.fs.normalize( vim.fs.joinpath( puck_root, plugin_name ) ) local plugin_install_path_stat = vim.uv.fs_stat( plugin_install_path ) local plugin_already_exists = plugin_install_path_stat and plugin_install_path_stat.type == 'directory' local plugin_install_rev_path = vim.fs.normalize( vim.fs.joinpath(puck_root, plugin_name .. '.rev' )) -- either do nothing or update/fresh install if (vim.uv.fs_access( plugin_install_rev_path, 'R' )) then local plugin_install_rev_file = io.open( plugin_install_rev_path, 'r' ) if not plugin_install_rev_file then vim.notify('Unable to read rev file ' .. plugin_install_rev_path, vim.log.levels.ERROR) end local current_rev = plugin_install_rev_file:read() plugin_install_rev_file:close() if current_rev == plugin_rev then configure_plugin(plugin_name) return end end -- rev is different, must be update (we don`t care if up or down) or fresh install local removed = delete_directory_recursive( plugin_install_path ) local url_format = as_url_format(plugin_type) local plugin_tarball_url = url_format:format( plugin_coords, plugin_rev ) download_plugin_into(puck_root, plugin_name, plugin_tarball_url, plugin_install_path, callback ) local mode = vim.uv.fs_access(plugin_install_rev_path, 'W') and 'w+' or 'w' local plugin_install_rev_file = io.open( plugin_install_rev_path, mode) if not plugin_install_rev_file then vim.notify('Unable to write rev file ' .. plugin_install_rev_path, vim.log.levels.ERROR) end plugin_install_rev_file:write( plugin_rev ) plugin_install_rev_file:close() if removed then vim.notify( 'Plugin ' .. plugin_coords .. '@' .. plugin_rev .. ' updated!', vim.log.levels.INFO ) else vim.notify( 'Plugin ' .. plugin_coords .. '@' .. plugin_rev .. ' installed!', vim.log.levels.INFO ) endendlocal delete_unused_plugins = function ( puck_root ) endlocal register_local_plugin = function ( workspace, plugin_coords ) local plugin_path = vim.fs.normalize( vim.fs.joinpath(workspace, vim.fs.basename(plugin_coords) ) ) local plugin_path_stat = vim.uv.fs_stat( plugin_path ) if (plugin_path_stat and plugin_path_stat.type == 'directory') then vim.opt.runtimepath:prepend( plugin_path ) else vim.notify( 'Failed to load local plugin ' .. plugin_path .. '!', vim.log.levels.ERROR ) endendlocal load_local_plugin = function ( plugin_coords ) local plugin_name = as_name( plugin_coords ) local plugin_init = {} vim.tbl_extend( 'keep', plugin_init, vim.api.nvim_get_runtime_file( 'plugin/' .. plugin_name .. '.vim', false ) ) vim.tbl_extend( 'keep', plugin_init, vim.api.nvim_get_runtime_file( 'plugin/' .. plugin_name .. '.lua', false ) ) for _, init in pairs( plugin_init ) do vim.cmd.source( init ) endendlocal load_registered_plugin = function ( plugin_name ) vim.cmd.packadd(plugin_name) -- vim.cmd.helptags(plugin_name) return require(plugin_name)endlocal setup = function ( options ) options = options or {} vim.validate { ['options.workspace'] = { options.workspace, 'string'}, } options.plugins = options.plugins or {} plugins = options.plugins -- take control of loading plugins. -- that means we have to take care of builtin plugins later vim.opt.loadplugins = false local puck_root = vim.fs.normalize( vim.fn.stdpath 'data' .. '/site/pack/puck/opt' ) vim.fn.mkdir( puck_root, 'p' ) for _, plugin in pairs( plugins ) do local plugin_type = plugin[1] local plugin_coords = plugin[2] local plugin_rev = plugin[3] if plugin_type == dev then register_local_plugin(options.workspace, plugin_coords ) -- TODO def v plugins need configure too -- configure_plugin(plugin_name) else install_plugin( puck_root, plugin_type, plugin_coords, plugin_rev) end end delete_unused_plugins( puck_root ) -- manually load builtin plugins, that we disabled earlier -- loads only a subset of builtins, that i find useful. load_local_plugin 'plugin/shada.vim' load_local_plugin 'plugin/tutor.vim' load_local_plugin 'plugin/spellfile.vim' load_local_plugin 'plugin/osc52.lua' -- can this be useful on win32? -- load_local_plugin 'plugin/man.lua' load_local_plugin 'plugin/editorconfig.lua'endreturn { -- FIXME: load needs to handle registerd and local plugin loading load = load_registered_plugin, setup = setup, plugin_types = { github = { type = gh, format = gh_format }, codeberg = { type = cb, format = cb_format }, sourcehut = { type = srht, format = srht_format }, development = { type = dev, format = nil }, },}+1 / −1 text lines
+1 / −1 text lines
+4 / −1 text lines
+7 / −6 text lines
+1 / −0 text lines