diff options
Diffstat (limited to 'firefox')
-rw-r--r-- | firefox/.config/firefox/.config/userscipts/rustdoc-condensed.js | 72 | ||||
-rw-r--r-- | firefox/.config/tridactyl/tridactylrc | 41 |
2 files changed, 86 insertions, 27 deletions
diff --git a/firefox/.config/firefox/.config/userscipts/rustdoc-condensed.js b/firefox/.config/firefox/.config/userscipts/rustdoc-condensed.js new file mode 100644 index 0000000..40d6a5a --- /dev/null +++ b/firefox/.config/firefox/.config/userscipts/rustdoc-condensed.js @@ -0,0 +1,72 @@ +// Copied from from BurntSushi's dotfiles +// Ref: https://raw.githubusercontent.com/BurntSushi/dotfiles/214aab9fdc45e7a507d41b564a1136eea9b298c9/.config/tridactyl/rustdoc-condensed.js + +(function() { + // This function forces rustdoc to collapse documentation for all items, + // except for the methods defined in an impl block and the primary type's + // declaration. This is the most natural view IMO, since it provides the + // primary type along with an easy to scan overview of available methods. + // + // rustdoc does seemingly have user settings that purport to make this the + // default, but I could never cause them to work in a reliably consistent + // way. This is especially useful when writing documents, where you commonly + // want to refresh and look at the docs for the specific item you're working + // on. This mini-script will automatically scroll to and expand the currently + // selected method. + // + // I used the tridactyl Firefox extension to bind this script to `,z` with + // the following in my tridactylrc: + // + // bind ,z composite jsb tri.native.run('cat path/to/rustdoc-condensed.js') | js -p eval(JS_ARG.content) + + // get the currently selected doc item from URL's hash fragment + // e.g., in `struct.BStr.html#method.words`, this returns `method.words`. + function getPageId() { + var id = document.location.href.split("#")[1]; + if (id) { + return id.split("?")[0].split("&")[0]; + } + return null; + } + + // collapse everything, with an extra click in case things are partially + // collapased already + const toggleAll = document.getElementById("toggle-all-docs"); + if (toggleAll.className.indexOf("will-expand") > -1) { + toggleAll.click(); + } + toggleAll.click(); + + // re-expand primary impls + const impls = document.getElementsByClassName("impl"); + for (let i = 0; i < impls.length; i++) { + // but don't expand every impl, just the ones on this type + if (!/^impl(-\d+)?$/.test(impls[i].id)) { + continue; + } + + const toggles = impls[i].getElementsByClassName("collapse-toggle"); + for (let j = 0; j < toggles.length; j++) { + // If it's already expanded, then let it be. In newer versions of + // rustdoc, collapsing everything doesn't collapse the methods, so we + // don't need to do anything. + if (toggles[j].innerText == "[−]") { + continue; + } + toggles[j].click(); + } + } + + // expand type declaration docs + const main = document.getElementById("main"); + const wrapper = document.getElementsByClassName("toggle-wrapper")[0]; + wrapper.getElementsByTagName("a")[0].click(); + + // re-expand specific method declaration, and scroll to it + const pageId = getPageId(); + if (pageId !== null) { + const method = document.getElementById(pageId); + method.getElementsByClassName("collapse-toggle")[0].click(); + method.scrollIntoView(); + } +})(); diff --git a/firefox/.config/tridactyl/tridactylrc b/firefox/.config/tridactyl/tridactylrc index 3a5f64e..70c2d02 100644 --- a/firefox/.config/tridactyl/tridactylrc +++ b/firefox/.config/tridactyl/tridactylrc @@ -1,53 +1,40 @@ " vim: filetype=vim -" Most of this config was taken from two places -" glacambre: https://github.com/glacambre/.dotfiles/blob/master/default/.config/tridactyl/tridactylrc -" BurntSushi: https://gist.github.com/BurntSushi/393546a65db38d57cedcfd72c6d89bf3 +" tridactyl config +" Ref: https://raw.githubusercontent.com/glacambre/.dotfiles/master/default/.config/tridactyl/tridactylrc +" Ref: https://raw.githubusercontent.com/BurntSushi/dotfiles/master/.config/tridactyl/tridactylrc -" This wipes all existing settings. This means that if a setting in this file -" is removed, then it will return to default. In other words, this file serves -" as an enforced single point of truth for Tridactyl's configuration. sanitize tridactyllocal tridactylsync -" Just use a blank page for new tab. It would be nicer to use the standard -" Firefox homepage, but Tridactyl doesn't support this yet. -set newtab about:blank +alias save_rss jsb -p tri.native.run("r2e add '" + JS_ARG + "'") set rsscmd save_rss %u +alias gitclone jsb -p tri.native.run("git clone --depth=1 '" + JS_ARG + "' /home/tobyv/src/" + JS_ARG.split("/").slice(-1)) -" Use vim in tmux for editor. -" set editorcmd alacritty -e tmux new -As tridactylrc nvim -S $XDG_DATA_HOME/nvim/session/tridactylrc.vim -" set editorcmd alacritty -e wsl --cd ~ --shell-type login -- tmux new -As tridactylrc -- nvim -S /home/tobyv/.local/share/nvim/session/tridactylrc.vim -" js tri.browserBg.runtime.getPlatformInfo().then(os=>{const editorcmd = os.os=="linux" ? "st vim" : "auto"; tri.config.set("editorcmd", editorcmd)}) +set findcase sensitive +set smoothscroll true +set editorcmd alacritty -e tmux new -As tridactylrc nvim -S $XDG_DATA_HOME/nvim/session/tridactylrc.vim unbind <C-f> bind / fillcmdline find bind ? fillcmdline find -? bind n findnext bind N findnext -? - -" Remove search highlighting. bind ,<Space> nohlsearch -" Use sensitive case. Smart case would be nice here, but it doesn't work. -set findcase sensitive - -" Smooth scrolling, yes please. This is still a bit janky in Tridactyl. -set smoothscroll true - -" The default jump of 10 is a bit much. bind j scrollline 5 bind k scrollline -5 - -" K and J should move between tabs. x should close them. bind J tabprev bind K tabnext bind x tabclose +bind zv composite js document.location.href | exclaim_quiet mpv --loop +bind zz composite jsb tri.native.run('cat /home/tobyv/.config/firefox/userscripts/rustdoc-condensed.js') | js -p eval(JS_ARG.content) -" Disabled sites autocmd DocStart mail.google.com mode ignore +autocmd DocStart discordapp.com mode ignore -" Native messenger stuff fixamo_quiet + guiset_quiet hoverlink right guiset_quiet tabs count + setpref accessibility.typeaheadfind.autostart false setpref accessibility.typeaheadfind.flashBar 0 setpref app.normandy.api_url "" @@ -65,7 +52,7 @@ setpref browser.download.folderList 2 setpref browser.download.manager.addToRecentDocs false setpref browser.download.useDownloadDir false setpref browser.eme.ui.enabled false -setpref browser.feeds.handler.default "client" +" setpref browser.feeds.handler.default "client" " setpref browser.feeds.handlers.application "/home/me/bin/add_rss_feed" setpref browser.formfill.enable false setpref browser.helperApps.deleteTempFileOnExit true |