Compare commits

...

20 Commits

Author SHA1 Message Date
4f2a74e546 less: Remap ^E to edit current screen in vim 2025-09-19 01:47:39 +02:00
cb1821ba33 less: Remap ^Y to copying the whole file 2025-09-19 01:44:23 +02:00
5128d15251 less: Strip all ANSI sequences, not just SGR
Kitty's shell integration uses OSC sequences to mark the prompt and
output in the scrollback buffer. When opening that in vim through less I
want these to be gone as well.
2025-09-19 01:36:54 +02:00
2b31632914 bin:no-ansi: Add a label to each pattern 2025-09-19 01:14:09 +02:00
27791acf50 bin:no-ansi: Correct allowed byte ranges
Correct the allowed byte ranges of the APC, DCS, OSC, PM & SOS
sequences. All but the SOS sequence allow additionally the bytes in the
range `0x8 - 0xD` and SOS may be followed by any sequence of bytes
except for SOS and ST (i.e. `\eX` & `\e\\`).

Link: https://www.ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf#page=27
2025-09-19 00:51:47 +02:00
8aa76b3ee6 bin:no-ansi: Don't just match CSI sequences
Try to match all ANSI escape sequences, not just CSI (i.e. `\e[`) - also
the ones that are followed by additional bytes (e.g. CSI, OSC).
2025-09-19 00:26:36 +02:00
6b866f5474 bin:no-ansi*: Use printf for escape byte
I dislike having the raw escape byte in these scripts. Unfortunately
`sed` does not support interpreting it via an escape sequence, so use
printf for that. To remain POSIX compatible use `\033` and not `\e` or
`\x1b` since I couldn't find these in the printf(1p) manpage.
Unfortunately this brings a second layer of escaping.
2025-09-19 00:13:28 +02:00
4f6929bcce less: Keep position when editing in vim via e/E 2025-09-18 23:19:07 +02:00
2495d835b4 kitty: Slightly decrease click_interval to 0.4
Kitty's source code makes me believe that this is always 0.5s on X11.
This decreases the delay when opening links.

Link: https://github.com/kovidgoyal/kitty/blob/3482d084aef1/glfw/x11_window.c#L2360-L2363
2025-09-18 12:56:10 +02:00
dda2ff640e kitty: Increase font size by one point to 12 2025-09-18 12:26:36 +02:00
87398bf712 vim:keys: Use getreginfo() instead of getregtype()
The result from getreginfo can be passed directly to setreg making this
a bit neater. Taken from the neovim defaults (ironically not from
v_star-default).

Link: https://github.com/neovim/neovim/blob/08847a9ea15a/runtime/lua/vim/_defaults.lua#L73-L79
2025-09-18 01:08:18 +02:00
0a5b6d0767 vim:keys: Only map v_* & v_# if they don't exist
I learned just now that neovim added mappings for these by default in
v0.8.0. But instead of checking for neovim, check for the existence of
mappings in case vim adds these in the future too.
2025-09-18 01:07:34 +02:00
5b8f54b0cb vim:keys: Fix newline and tab search for v_*
Multiline search didn't work previously when searching with v_* and tabs
were ignored when searching with v_<leader>*.
2025-09-17 23:01:11 +02:00
ef5b2911bf vim:coc: Select first item before confirming
I believe I had the problem in the past that the completion wouldn't
automatically select the first entry but simply display the menu. Thus
it would simply insert a new line when pressing return to accept it.

Unfortunately I didn't commit it back then and I can't reproduce it now.
But it doesn't not hurt so I commit it to be safe.
2025-09-17 21:55:00 +02:00
768cb4ed4a vim:keys: Add mapping for git-commit-last-msg 2025-09-17 21:46:43 +02:00
f2ce78b6b3 vim:fzf: Use location list instead of the quickfix
Since the quickfix is a global list I can't keep multiple ripgrep
searches open at once. The location list is window-local thus solving
this issue.
2025-09-17 21:44:46 +02:00
a3d2bf985c i3: Use back_and_forth instead of i3-msg+jq 2025-09-17 17:35:19 +02:00
e8c5ec93f1 i3: Re-add stacking and tabbed layout bindings
I removed these in 69d0290afd (i3: Remove bindings for stacked and
tabbed layout, 2023-04-20) since I never need them and I always forgot
how to switch back when I pressed these accidentally.

Bring these back as comments, since the comment above still mentions
these and since I can imagine a rare situation where I might want one
these and simply want to comment them in.
2025-09-17 17:30:51 +02:00
ae52ba20d2 vim: Disable 'cindent' in non-code filetypes 2025-09-17 16:49:34 +02:00
ea2867fc9f dircolors: Color pdfs like images and videos 2025-09-17 16:44:48 +02:00
13 changed files with 85 additions and 21 deletions

View File

@@ -185,3 +185,6 @@ EXEC 01;92
*.opus 00;36
*.spx 00;36
*.xspf 00;36
## Others
*.pdf 01;95

View File

@@ -79,6 +79,8 @@ bindsym $mod+Shift+v split horizontal
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
#bindsym $mod+s layout stacking
#bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
@@ -104,9 +106,7 @@ bindsym $mod+0 exec ~/.config/i3/multi-monitor-workspaces.sh -s 0
# switch back to the previous workspace
workspace_auto_back_and_forth yes
bindsym $mod+Tab exec i3-msg workspace "$( \
i3-msg -t get_workspaces | \
jq -r '.[] | select(.focused).name')"
bindsym $mod+Tab workspace back_and_forth
# Switch visible workspaces (e.g. multi monitor setup)
bindsym $mod+Shift+Tab exec i3-msg workspace "$( \

View File

@@ -20,7 +20,7 @@
#: <https://sw.kovidgoyal.net/kitty/kittens/choose-fonts/#font-spec-
#: syntax>.
# font_size 11.0
font_size 12.0
#: Font size (in pts).
@@ -630,7 +630,7 @@ mouse_hide_wait -1
#: If empty (default) select_by_word_characters will be used for both
#: directions.
# click_interval -1.0
click_interval 0.4
#: The interval between successive clicks to detect double/triple
#: clicks (in seconds). Negative numbers will use the system default

View File

@@ -6,11 +6,17 @@
# NOTE: the current file can be edited with `v` already, but this doesn't work
# when reading from stdin
# NOTE: ^P omits the "done" message
# NOTE: '' jumps back to the previous position
#
# edit in vim without any ANSI SGR sequences (e.g. color)
e noaction g|$no-ansi-sgr | nvim -\n
# edit in vim without any ANSI escape sequences (e.g. color)
e noaction g|$no-ansi | nvim -\n''
# edit in vim while keeping them
E noaction g|$nvim -\n
E noaction g|$nvim -\n''
# edit current screen in vim
^E noaction |.no-ansi | nvim -\n
# copy whole file
^Y noaction g|$xclip -selection clipboard\n''
#env
# NOTE: Lines need a trailing space when concatenating

View File

@@ -3,6 +3,9 @@ setlocal colorcolumn+=51
setlocal textwidth=72
" Spell checking always enabled
setlocal spell spelllang=en
" Disable C-indentation as it messes up formatting of paragraphs containing
" parentheses
setlocal nocindent
" Disable gutentags as it seems to regenerate the entire tags file when editing
" git-commits...

View File

@@ -1,5 +1,8 @@
" Turn on line-wrapping
setlocal wrap
" Disable C-indentation as it messes up formatting of paragraphs containing
" parentheses
setlocal nocindent
" Fold by sections
function! MdSectionFold()

View File

@@ -1,5 +1,8 @@
" Turn on line-wrapping
setlocal wrap
" Disable C-indentation as it messes up formatting of paragraphs containing
" parentheses
setlocal nocindent
" Close the quickfix window after a cursor movement
let g:vimtex_quickfix_autoclose_after_keystrokes = 1

View File

@@ -1,3 +1,7 @@
" Disable C-indentation as it messes up formatting of paragraphs containing
" parentheses
setlocal nocindent
" Don't highlight Unicode table separator (e.g. vertical box drawing character).
" See vimrc.d/looks.vim for w:ignore_non_ascii_chars
if vimwiki#vars#get_syntaxlocal('rxTableSep') !~ '[\d0-\d127]'

View File

@@ -38,6 +38,12 @@ if (exists("g:loaded_tmux_navigator"))
let g:tmux_navigator_disable_when_zoomed = 1
endif
if (get(g:, 'loaded_fzf_vim'))
let g:fzf_vim = {}
" Use location list instead of quickfix list
let g:fzf_vim.listproc = { list -> fzf#vim#listproc#location(list) }
endif
if (get(g:, 'loaded_vimwiki'))
" Use vertical box drawing character as table separator
call vimwiki#vars#set_syntaxlocal('rxTableSep', '│')

View File

@@ -64,7 +64,7 @@ endif
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u starts a new undo break, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics

View File

@@ -108,26 +108,39 @@ if (get(g:, 'loaded_fzf'))
endif
" Search for selected text.
" Modified from https://vim.fandom.com/wiki/Search_for_visually_selected_text
function! GetVisualSelection()
let l:old_reg = getreg('"')
let l:old_regtype = getregtype('"')
" Modified version of:
" https://vim.fandom.com/wiki/Search_for_visually_selected_text
" and https://github.com/neovim/neovim/blob/08847a9ea15a/runtime/lua/vim/_defaults.lua#L73-L79
function! GetVisualSelection(escape = "", byteescape = 'n')
let l:save_reg = getreginfo('"')
norm gvy
let l:sel = getreg('"')
call setreg('"', l:old_reg, l:old_regtype)
call setreg('"', l:save_reg)
let l:sel = l:sel->escape(a:escape)
for l:char in a:byteescape
let l:sel = l:sel->substitute('\'..l:char, '\\'..l:char, 'g')
endfor
return l:sel
endfunction
vmap * /\V<C-R>=escape(GetVisualSelection(),'/\')<CR><CR>
vmap # ?\V<C-R>=escape(GetVisualSelection(),'?\')<CR><CR>
" In case these do not exist already (At the time of writing only Neovim adds
" mappings for these)
if maparg('*', 'v', 0, 1) == {}
vmap * /\V<C-R>=GetVisualSelection('/\')<CR><CR>
vmap # ?\V<C-R>=GetVisualSelection('?\')<CR><CR>
endif
" Extended `*`. Starts vim search (without jump) and ripgrep
nmap <leader>* :let @/ = '\<' . expand('<cword>') . '\>' <bar>
\ set hlsearch <bar>
\ Rg \b<C-R>=expand('<cword>')<CR>\b<CR>
vmap <leader>* :<C-U>let @/ = "\\V<C-R>=escape(escape(GetVisualSelection(), '\'), '"\')<CR>" <bar>
" TODO: pass --multiline to rg when multiple lines selected
" TODO: Use ^ and $ anchors in visual-line mode
vmap <leader>* :<C-U>let @/ = "\\V<C-R>=escape(GetVisualSelection('\'), '"\')<CR>" <bar>
\ set hlsearch <bar>
\ Rg <C-R>=escape(GetVisualSelection(), '.\[]<bar>*+?{}^$()')<CR><CR>
\ Rg <C-R>=GetVisualSelection('.\[]<bar>*+?{}^$()', 'nt')<CR><CR>
nmap <leader>g* :let @/ = expand('<cword>') <bar>
\ set hlsearch <bar>
\ Rg <C-R>=expand('<cword>')<CR><CR>
@@ -168,6 +181,8 @@ if exists('g:loaded_fugitive')
nmap <leader>gcc <Cmd>G commit<CR>
" Amend the current commit and open the message in a split
nmap <leader>gca <Cmd>G commit --amend<CR>
" Commit with the last commit message as template
nmap <leader>gclm <Cmd>G commit-last-msg<CR>
" Move to root of directory
nmap <leader>gcd <Cmd>Gcd<CR>
" git blame in scroll bound vertical split (only the commit hashes, see
@@ -437,7 +452,7 @@ vnoremap <leader><C-L> gu
" `ExpandVisualSelection(1)` which results in a block selection that spans over
" all other TODOs as well.
function! ExpandVisualSelection(direction)
let l:sel = escape(GetVisualSelection(), '\')
let l:sel = GetVisualSelection('\')
normal gv
" Move the cursor onto the side of the selection that points in the

View File

@@ -3,5 +3,26 @@
# Copyright (c) 2025 Julian Prein
#
# Remove ANSI escape sequences.
#
# Additionally to the general form `\e[ -/]*[0-~]` this also tries to cover
# sequences that are followed by additional bytes (e.g. CSI, OSC). This script
# covers no C1 sequences.
#
# The patterns cover the following escape sequences (from top to bottom):
# - CSI
# - OSC, DCS, PM & APC
# - SOS
# - All remaining sequences
#
# See:
# - https://en.wikipedia.org/wiki/ANSI_escape_code
# - https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
# - https://www.ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf
env LC_ALL=C sed 's/\[[0-?]*[ -/]*[@-~]//g'
env LC_ALL=C sed -E "$(printf "%b" \
's/' \
'\033\\[[0-?]*[ -/]*[@-~]' '|' \
'\033[]P^_][\010-\015 -~]*\033\\\\' '|' \
'\033X([^\033]|\033+[^\033X\\])*\033+\\\\' '|' \
'\033[ -/]*[0-~]' \
'//g')"

View File

@@ -5,4 +5,4 @@
# Remove ANSI SGR (Select Graphic Rendition) escape sequences, e.g. setting
# color or bold font.
env LC_ALL=C sed 's/\[[0-?]*[ -/]*m//g'
env LC_ALL=C sed "$(printf 's/\033\\[[0-?]*[ -/]*m//g')"