Attempting to fix firefox video meetings, further busted kakoune

This commit is contained in:
Nathan Anderson 2024-02-15 11:22:47 -07:00
parent 55618f4f1a
commit ba4e1700e9
7 changed files with 341 additions and 87 deletions

View File

@ -259,7 +259,7 @@ command = "lua-language-server"
# diagnostics.enable = true
[language.markdown]
filetype = ["md", "markdown"]
filetypes = ["md", "markdown"]
roots = [".git", ".hg"]
command = "vscode-markdown-language-server"
args = ["--stdio"]

View File

@ -0,0 +1,185 @@
# Auto-pairing of characters
# Heavily based on Visual Studio Code.
# https://code.visualstudio.com
#
# Public commands: ["enable-auto-pairs", "disable-auto-pairs"]
# Public options: ["auto_pairs"]
#
# Usage:
#
# enable-auto-pairs
#
# Configuration:
#
# set-option global auto_pairs ( ) { } [ ] '"' '"' "'" "'" ` ` “ ” « »
#
# How does it work?
#
# The script installs insert hooks on opening pair characters, such as brackets and quotes.
# When auto-closing has been triggered, it activates the following functionalities:
#
# {closing-pair} ⇒ Insert closing pair or move right in pair
# Enter ⇒ Insert a new indented line in pair (only for the next key)
# Control+Enter ⇒ Prompt a count for new indented lines in pair (only for the next key)
#
# When moving or leaving insert mode, the functionalities deactivate.
#
# Technical details:
#
# Insert hooks are added on opening pair characters from %opt{auto_pairs} option.
# Evaluates %opt{auto_close_trigger} option to activate auto-pairing.
# Provides %opt{opening_pair} expansion in expressions.
# Uses %opt{inserted_pairs} count to keep track of inserted pairs for inserting or moving in pair.
# Uses the same implementation for nestable (such as brackets) and non-nestable (such as quotes) pairs.
# Since insert hooks are added on opening pair characters (for auto-pairing) and mappings on closing pair characters (for moving in pair),
# we can distinguish same pair characters once auto-pairing has been activated.
# Configuration ────────────────────────────────────────────────────────────────
# List of surrounding pairs
declare-option -docstring 'list of surrounding pairs' str-list auto_pairs ( ) { } [ ] '"' '"' "'" "'" ` ` “ ” « »
# Auto-pairing of characters activates only when this expression does not fail.
# By default, it avoids non-nestable pairs (such as quotes), escaped pairs and word characters.
declare-option -docstring 'auto-pairing of characters activates only when this expression does not fail' str auto_close_trigger '<a-h><a-K>(\w["''`]|""|''''|``).\z<ret><a-k>[^\\]?\Q%opt{opening_pair}<a-!>\E\W\z<ret>'
# Internal variables ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
# Retain inserted pairs
declare-option -hidden str opening_pair
declare-option -hidden int inserted_pairs
# Commands ─────────────────────────────────────────────────────────────────────
define-command -override enable-auto-pairs -docstring 'enable auto-pairs' %{
remove-hooks global auto-pairs
evaluate-commands %sh{
set -- ${kak_opt_auto_pairs}
while [ "$2" ]
do
printf 'auto-close-pair %%<%s> %%<%s>\n' "$1" "$2"
shift 2
done
}
}
define-command -override disable-auto-pairs -docstring 'disable auto-pairs' %{
remove-hooks global auto-pairs
}
# Internal commands ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
define-command -override -hidden auto-close-pair -params 2 %{
hook -group auto-pairs global InsertChar "\Q%arg{1}" "handle-inserted-opening-pair %%<%arg{1}> %%<%arg{2}>"
hook -group auto-pairs global InsertDelete "\Q%arg{1}" "handle-deleted-opening-pair %%<%arg{1}> %%<%arg{2}>"
}
# Internal hooks ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
define-command -override -hidden handle-inserted-opening-pair -params 2 %{
try %{
# Test whether the commands contained in the option pass.
# If not, it will throw an exception and execution will jump to
# the “catch” block below.
set-option window opening_pair %arg{1}
execute-keys -draft %opt{auto_close_trigger}
# Action: Close pair
execute-keys %arg{2}
# Keep the track of inserted pairs
increment-inserted-pairs-count
# Move back in pair (preserve selected text):
try %{
execute-keys -draft '<a-k>..<ret>'
execute-keys '<a-;>H'
} catch %{
execute-keys '<a-;>h'
}
# Add insert mappings
map -docstring 'insert closing pair or move right in pair' window insert %arg{2} "<a-;>:insert-closing-pair-or-move-right-in-pair %%🐈%arg{2}🐈<ret>"
map -docstring 'insert a new indented line in pair' window insert <ret> '<a-;>:insert-new-line-in-pair<ret>'
map -docstring 'prompt a count for new indented lines in pair' window insert <c-ret> '<a-;>:prompt-insert-new-line-in-pair<ret>'
# Enter is only available on next key.
hook -group auto-pairs -once window InsertChar '.*' %{
unmap window insert <ret>
unmap window insert <c-ret>
}
# Clean insert mappings and remove hooks
hook -group auto-pairs -once window WinSetOption 'inserted_pairs=0' "
unmap window insert %%🐈%arg{2}🐈
unmap window insert <ret>
unmap window insert <c-ret>
remove-hooks window auto-pairs
"
# Clean state when moving or leaving insert mode
hook -group auto-pairs -once window InsertMove '.*' %{
reset-inserted-pairs-count
}
hook -always -once window ModeChange 'pop:insert:normal' %{
reset-inserted-pairs-count
}
}
}
# Backspace ⇒ Erases the whole bracket
define-command -override -hidden handle-deleted-opening-pair -params 2 %{
try %{
execute-keys -draft "<space>;<a-k>\Q%arg{2}<ret>"
execute-keys '<del>'
decrement-inserted-pairs-count
}
}
# Internal mappings ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
# {closing-pair} ⇒ Insert closing pair or move right in pair
define-command -override -hidden insert-closing-pair-or-move-right-in-pair -params 1 %{
try %{
execute-keys -draft "<space>;<a-k>\Q%arg{1}<ret>"
# Move right in pair
execute-keys '<a-;>l'
decrement-inserted-pairs-count
} catch %{
# Insert character with hooks
execute-keys -with-hooks %arg{1}
}
}
# Enter ⇒ Insert a new indented line in pair (only for the next key)
define-command -override -hidden insert-new-line-in-pair %{
execute-keys '<a-;>;<ret><ret><esc>KK<a-&>j<a-gt>'
execute-keys -with-hooks A
reset-inserted-pairs-count
}
# Control+Enter ⇒ Prompt a count for new indented lines in pair (only for the next key)
define-command -override -hidden prompt-insert-new-line-in-pair %{
prompt count: %{
execute-keys '<a-;>;<ret><ret><esc>KK<a-&>j<a-gt>'
execute-keys "xHyx<a-d>%val{text}O<c-r>""<esc>"
execute-keys -with-hooks A
reset-inserted-pairs-count
}
}
# ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
# Increment and decrement inserted pairs count
define-command -override -hidden increment-inserted-pairs-count %{
set-option -add window inserted_pairs 1
}
define-command -override -hidden decrement-inserted-pairs-count %{
set-option -remove window inserted_pairs 1
}
define-command -override -hidden reset-inserted-pairs-count %{
set-option window inserted_pairs 0
}

View File

@ -0,0 +1,84 @@
provide-module phantom-selection %{
set-face global PhantomSelection black,green+F
declare-option -hidden str-list phantom_selections
declare-option -hidden range-specs phantom_selections_ranges
add-highlighter global/ ranges phantom_selections_ranges
define-command -hidden phantom-selection-store-and-highlight %{
set window phantom_selections %reg{^}
set window phantom_selections_ranges %val{timestamp}
eval -no-hooks -draft -itersel %{
set -add window phantom_selections_ranges "%val{selection_desc}|PhantomSelection"
}
}
define-command -hidden phantom-selection-iterate-impl -params 1 %{
eval -save-regs ^ %{
reg ^ %opt{phantom_selections}
try %{
exec z
exec %arg{1}
# keep the main selection and put all the other in the mark
# a recent change to Kakoune swaps <space> with "," (and
# <a-space> with <a-,>). Try both to make sure we clear selections
# both with and without this breaking change. Pad them with <esc>
# to cancel out the key with the other behavior.
exec -save-regs '' 'Z'
phantom-selection-store-and-highlight
exec '<space><esc><,><esc>'
} catch %{
fail 'No phantom selections'
}
}
}
define-command phantom-selection-iterate-next -docstring "
Turn secondary selections into phantoms and select the next phantom
" %{
phantom-selection-iterate-impl ')'
}
define-command phantom-selection-iterate-prev -docstring "
Turn secondary selections into phantoms and select the previous phantom
" %{
phantom-selection-iterate-impl '('
}
define-command phantom-selection-clear -docstring "
Remove all phantom selections
" %{
unset window phantom_selections
unset window phantom_selections_ranges
}
define-command phantom-selection-select-all -docstring "
Select all phantom selections
" %{
eval -save-regs ^ %{
reg ^ %opt{phantom_selections}
try %{
exec z
echo ""
} catch %{
fail 'No phantom selections'
}
}
}
define-command phantom-selection-add-selection -docstring "
Create phantoms out of the current selections
" %{
eval -draft -save-regs ^ %{
reg ^ %opt{phantom_selections}
try %{ exec "<a-z>a" }
exec -save-regs '' "Z"
phantom-selection-store-and-highlight
}
}
}
require-module phantom-selection

View File

@ -1,23 +1,3 @@
# ------------------
# Plugin Setup
# ------------------
# IMORTANT NOTE:
# I needed to open kakoune and type ':plug-install' to actually
# install the plugins listed in this file. I did not see this
# mentioned in wikis or anything, so make sure to do this to
# avoid searching github wikis and reddit needlessly.
# Creates the /plugins folder if it doesnt exist each startup
evaluate-commands %sh{
plugins="$kak_config/plugins"
mkdir -p "$plugins"
[ ! -e "$plugins/plug.kak" ] && \
git clone -q https://github.com/andreyorst/plug.kak.git "$plugins/plug.kak"
printf "%s\n" "source '$plugins/plug.kak/rc/plug.kak'"
}
plug "andreyorst/plug.kak" noload
# ------------------
# Editor Settings
# ------------------
@ -28,14 +8,13 @@ set-option global startup_info_version 30000000
set-option global tabstop 4
set-option global indentwidth 4
set-option global scrolloff 5,3
declare-option str kakrc_path "~/.config/kak/kakrc"
declare-option str sway_conf_path "~/.config/sway/config.d/default"
declare-option str shell_config "~/.zshrc"
# plug "catppuccin/kakoune" theme config %{
# colorscheme catppuccin_macchiato
# }
declare-option str kakrc_path "~/system/nate/dotfiles/kak/kakrc"
declare-option str sway_conf_path "~/system/nate/dotfiles/sway/config.d/default"
declare-option str shell_config "~/system/nate/dotfiles/.zshrc"
colorscheme catppuccin_macchiato
# relative line numbers
hook global BufCreate .* %{
add-highlighter buffer/ number-lines -hlcursor
@ -153,7 +132,9 @@ map global normal <a-K> <c-N> -docstring 'prev result add selection'
map global insert <down> <c-n> -docstring 'next completion'
map global insert <up> <c-p> -docstring 'prev completion'
# User Mode Bindings
# ------------------
# User mode Bindings
# ------------------
# Accessed with <space>
declare-user-mode git
map global user g ': enter-user-mode git<ret>' -docstring "Git mode"
@ -173,21 +154,17 @@ map global git d '<esc>:git show-diff<ret>' -docstring "Show diff"
# LSP Configuration
# -----------------
plug "kak-lsp/kak-lsp" do %{
cargo install --locked --force --path .
mkdir -p ~/.config/kak-lsp
cp -n kak-lsp.toml ~/.config/kak-lsp/
} config %{
# plug "kak-lsp/kak-lsp" do %{
# cargo install --locked --force --path .
# mkdir -p ~/.config/kak-lsp
# cp -n kak-lsp.toml ~/.config/kak-lsp/
# } config %{
# enable inlay hints
lsp-inlay-hints-enable global
lsp-inlay-diagnostics-enable global
# set global lsp_diagnostic_line_error_sign '║'
# set global lsp_diagnostic_line_warning_sign '┊'
define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start }
map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
@ -196,57 +173,42 @@ plug "kak-lsp/kak-lsp" do %{
map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
# load lsp for supported filetypes
set-option global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"
hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp|zig|dart|ruby) %{
eval %sh{kak-lsp --kakoune -s $kak_session} # Not needed if you load it with plug.kak.
hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp|dart|zig|nix|ocaml) %{
lsp-enable-window
# lsp-auto-hover-enable
map global user l ': enter-user-mode lsp<ret>' -docstring 'lsp mode'
map global user h ': enter-user-mode lsp<ret>h' -docstring 'lsp help'
map global user a ': enter-user-mode lsp<ret>a' -docstring 'lsp code action'
set-option global lsp_hover_anchor false
set-option global lsp_hover_anchor true
lsp-inlay-hints-enable global
lsp-inlay-diagnostics-enable global
}
hook global KakEnd .* lsp-exit
}
# load lsp for supported filetypes
# set-option global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"
# hook global WinSetOption filetype=(rust|python|go|javascript|typescript|c|cpp|zig|dart|ruby) %{
# lsp-enable-window
# # lsp-auto-hover-enable
# map global user l ': enter-user-mode lsp<ret>' -docstring 'lsp mode'
# map global user h ': enter-user-mode lsp<ret>h' -docstring 'lsp help'
# map global user a ': enter-user-mode lsp<ret>a' -docstring 'lsp code action'
# set-option global lsp_hover_anchor false
# }
# }
# -----------------
# Other Plugins
# -----------------
# fzf file picker
map global goto f '<esc>:prompt -shell-script-candidates %{ fd --type f --hidden } file: %{ edit %val{text} }<ret>' -docstring "file"
map global goto b '<esc>:prompt -buffer-completion buffer: %{ buffer %val{text} }<ret>' -docstring "buffer"
# Fzf Plugin
plug "andreyorst/fzf.kak" config %{
# map global user f ':fzf-mode<ret>v' -docstring 'fzf file in project'
map global user b ':fzf-mode<ret>b' -docstring 'fzf current buffers'
map global user / ':fzf-mode<ret>g' -docstring 'fzf search in project'
# def fzf_file %{
# evaluate-commands %sh{
# printf "%s\n" ":fzf-mode<ret><esc>:fzf -items-cmd fd<ret>"
# }
# }
# Change FZF colors
# FZF_DEFAULT_OPTS=" \
# --color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
# --color=fg:#cdd6f4,header:#f38ba8,info:#cba6f7,pointer:#f5e0dc \
# --color=marker:#f5e0dc,fg+:#cdd6f4,prompt:#cba6f7,hl+:#f38ba8"
}
plug "alexherbo2/auto-pairs.kak" %{
enable-auto-pairs
}
plug "https://github.com/h-youhei/kakoune-surround"
map global normal <c-m> ':surround<ret>'
# Custom scripts
source "~/.config/kak/rc/fzf_git.kak"

View File

@ -12,7 +12,13 @@ in
};
config = lib.mkIf cfg.enable {
programs.firefox = {
# Add pipewire support
package = (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {});
enable = true;
# Use system file picker
preferences = {
"widget.use-xdg-desktop-portal.file-picker" = 1;
};
profiles = {
default = {
id = 0;
@ -33,6 +39,17 @@ in
template = "https://www.startpage.com/sp/search?query={searchTerms}";
}];
};
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{ name = "type"; value = "packages"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
};
};
settings = {
@ -54,7 +71,7 @@ in
"signon.rememberSignon" = false;
"extensions.formautofill.creditCards.enabled" = false;
"extensions.formautofill.addresses.enabled" = false;
# "browser.bookmarks.showMobileBookmarks" = true;
"browser.toolbars.bookmarks.visibility" = "always";
# "browser.newtabpage.pinned" = [{
# title = "NixOS";
# url = "https://nixos.org";

View File

@ -30,7 +30,7 @@
home.packages = with pkgs; [
# nur.repos.crazazy.js.eslint
# inputs.nixpkgs-stable.legacyPackages.x86_64-linux.corectrl
chromium
#
# Dev Tools
#
@ -40,10 +40,12 @@
flutter316
docker
docker-compose
jq
python310
nodejs_21
zig
### LSP's
kak-lsp
rnix-lsp # Nix LSP
openscad-lsp
nodePackages.typescript-language-server
@ -61,6 +63,7 @@
# Gaming
#
amdgpu_top
mangohud
wine-wayland
webcord
@ -75,6 +78,8 @@
ripgrep
tre-command
gtop
htop
neofetch
# Normies
unzip

View File

@ -103,6 +103,7 @@
programs.zsh.enable = true;
programs.steam.enable = config.swaywm.installGaming;
programs.gamemode.enable = true;
programs.adb.enable = true;
# kdeconnect setup