dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search neovim: new function std.prequire d97451d00a4d754237c71226cb06841fd854a3a6
Oliver Jan Krylow <oliver@bugabinga.net > · 25 Mar 2024
unsigned
Browse files Compare with HEAD
stolen from stevearc's dotfiles.
it is a better version of my previous `std.want` function, which had the same purpose.
thanks to the clever use of a metatable, `prequire` can be used with the same pattern as `require`, even when the modules fails to load.
Changed files (14) deleted file mode 100644 3 - $env.WIN32 = (
$nu.os-info.name =~
"windows" )
4 - $env.NURC_DIR = (
$nu.config-path | path expand | path dirname )
5 - $env.DOTFILES = (
$env.NURC_DIR | path join
".." | path expand )
6 - $env.WORKSPACE =
if $env.WIN32 {
"W:/" }
else {
"~/Workspace" | path expand }
7 - $env.NOTES =
if $env.WIN32 {
"N:/" }
else {
"~/Notes" | path expand }
9 - if (
$env | get -i TERM_PROGRAM) == WezTerm {
10 - $env.TERM =
"wezterm" 12 - $env.TERMCAP = ~./termcap/w/wezterm
17 - $env.LS_COLORS = (try { vivid generate alabaster_dark | into string } catch {
"" })
23 - $env.ENV_CONVERSIONS = {
25 - from_string: { |s|
$s | split row (char esep) }
26 - to_string: { |v|
$v | str join (char esep) }
29 - from_string: { |s|
$s | split row (char esep) }
30 - to_string: { |v|
$v | str join (char esep) }
36 - (
$nu.config-path | path dirname | path join
'modules' ),
37 - (
$nu.config-path | path dirname | path join
'completions' )
43 - $env.Path = (
$env.Path | prepend
'' )
45 - $env.CARGO_HOME = (
'~/.cargo' | path expand )
46 - $env.PATH = (
$env.PATH | prepend (
$env.CARGO_HOME | path join
'bin' ) )
47 - $env.PATH = (
$env.PATH | prepend (
'~/.local/bin' | path expand ) )
12 11 : standard lib. can only depend on itself and neovim apis.
15 13 : config modules. in aggregation, defines all of the config. can depend on itself, std and plugins.
17 14 lua/bugabinga/plugins
18 15 : third party plugins and their config glue integrating it into the config.
24 19 : file type specific config
14 14 vim.cmd.colorscheme
'nugu' 17 + prequire
= require 'std.prequire' 25 28 ok, loaded
= pcall (
require ,
'bugabinga.editorconfig' )
27 - vim.print(
'error while loading editorconfg extensions' , loaded )
30 + vim.print(
'error while loading editorconfig extensions' , loaded )
49 52 ok, loaded
= pcall (
require ,
'bugabinga.mark' )
51 - vim.print(
'error while loading mark' , loaded )
54 + vim.print(
'error while loading mark' , loaded )
neovim/lua/bugabinga/lazy.lua Modified neovim/lua/bugabinga/lsp/clients/lua.lua Modified 12 12 addonManager = {
enable =
false , },
13 13 completion = {
callSnippet =
'Replace' , },
14 - diagnostics = {
globals = {
'vim' , },
workspaceRate =
50 , },
14 + diagnostics = {
globals = {
'vim' ,
'prequire' , },
workspaceRate =
50 , },
15 15 hint = {
enable =
true ,
setType =
true , },
16 16 telemetry = {
enable =
false , },
17 17 window = {
progressBar =
true ,
statusBar =
true , },
neovim/lua/bugabinga/options/ui.lua Modified 9 9 command = function () vim.highlight.on_yank()
end ,
12 11 auto
'disable_columns_in_special_buffers' {
13 12 description =
'Hide columns in buffers, that do not show source code.' ,
14 13 events = {
'FileType' , },
25 24 vim.opt.list
= true 26 25 vim.opt.listchars
= {
29 28 tab = icon.tab
.. icon.middle_ellipsis,
30 29 trail = icon.trail,
31 30 extends = icon.extends,
37 36 vim.cmd
[[ language mes en_US.utf8 ]] 46 45 vim.opt.signcolumn
= 'yes:1' 78 77 vim.opt.shortmess:append
't' 81 80 vim.opt.cmdheight
= 1 84 83 vim.opt.conceallevel
= 0 105 104 vim.opt.showmode
= false 108 107 vim.opt.showtabline
= 2 110 109 local is_tty
= os .
getenv 'XDG_SESSION_TYPE' == 'tty' and os .
getenv 'SSH_TTY' == '' 122 121 vim.opt.smoothscroll
= true 124 + vim.opt.guicursor
= 'n-v-c-sm:block-Cursor,i-ci-ve:ver25-blinkon250,r-cr:hor20,o:hor50' 128 127 vim.opt.guifont
= 'Cousine,Symbols Nerd Font Mono:#e-subpixelantialias:#h-full' neovim/lua/bugabinga/plugins/format.lua Modified 26 26 formatters_by_ft = {
28 + markdown = {
'mdslw' , },
30 30 toml = {
'taplo' , },
43 - prepend_args = {
'--end-markers' ,
'?!.' , },
46 46 log_level
= debug .get()
and vim.log.levels.TRACE
or vim.log.levels.INFO,
neovim/lua/bugabinga/plugins/sessions.lua Modified 12 12 if vim.fn.argc(
- 1 )
== 0 then 14 - require 'resession' .load( vim.fn.getcwd(), {
dir =
'autosession' ,
silence_errors =
true , } )
14 + prequire
'resession' .load( vim.fn.getcwd(), {
dir =
'autosession' ,
silence_errors =
true , } )
19 19 events =
'VimLeavePre' ,
20 20 description =
'Automatically save sessions for the CWD (tab)' ,
21 - command =
function ()
require 'resession' .save_tab( vim.fn.getcwd(), {
dir =
'autosession' ,
notify =
false , } )
end ,
21 + command =
function () prequire
'resession' .save_tab( vim.fn.getcwd(), {
dir =
'autosession' ,
notify =
false , } )
end ,
24 24 events =
'VimLeavePre' ,
25 25 description =
'Automatically save last session (all tabs)' ,
26 - command =
function ()
require 'resession' .save( LAST_SESSION )
end ,
26 + command =
function () prequire
'resession' .save( LAST_SESSION )
end ,
31 31 description
= 'Restore last session' ,
32 32 category
= 'history' ,
33 33 keys
= '<leader>sl' ,
34 - command = function ()
require 'resession' .load( LAST_SESSION )
end ,
34 + command = function () prequire
'resession' .load( LAST_SESSION )
end ,
38 38 description =
'Restore a session' ,
39 39 category =
'history' ,
40 40 keys =
'<leader>sL' ,
41 - command =
function ()
require 'resession' .load()
end ,
41 + command =
function () prequire
'resession' .load()
end ,
45 45 description =
'Delete session' ,
46 46 category =
'history' ,
47 47 keys =
'<leader>sd' ,
48 - command =
function ()
require 'resession' .delete()
end ,
48 + command =
function () prequire
'resession' .delete()
end ,
52 52 description =
'Save session (tab)' ,
53 53 category =
'history' ,
54 54 keys =
'<leader>ss' ,
55 - command =
function ()
require 'resession' .save_tab()
end ,
55 + command =
function () prequire
'resession' .save_tab()
end ,
59 59 description =
'Save session (all tabs)' ,
60 60 category =
'history' ,
61 61 keys =
'<leader>sS' ,
62 - command =
function ()
require 'resession' .save()
end ,
62 + command =
function () prequire
'resession' .save()
end ,
neovim/lua/bugabinga/ui.lua Modified 1 - local NuiPopup
= require 'nui.popup' 2 - local NuiText
= require 'nui.text' 3 - local NuiLine
= require 'nui.line' 1 + local NuiPopup
= prequire
'nui.popup' 2 + local NuiText
= prequire
'nui.text' 3 + local NuiLine
= prequire
'nui.line' 5 5 local get_nui_popup = function ()
6 6 local popup
= NuiPopup {
neovim/lua/std/prequire.lua Added new file mode 100644 16 + local args
= {
... }
19 + for _, arg
in ipairs (args)
do 20 + if type (arg)
== "function" then 24 + local ok, mod
= pcall (
require , arg)
26 + if not first_mod
then 29 + table .
insert (mods, mod)
31 + vim.notify_once(
string .
format (
"Missing module: %s" , arg), vim.log.levels.WARN)
35 + setmetatable (proxy, {
39 + __index =
function ()
neovim/neovim.yml Modified neovim/spell/nerd.utf-8.add Modified neovim/spell/nerd.utf-8.add.spl Modified Previous version contains binary or non-UTF-8 data.
Current version contains binary or non-UTF-8 data.