Compare commits

...

3 Commits

Author SHA1 Message Date
32727866bd
nvim: add typescript support 2023-05-07 10:36:01 -04:00
f9d5bc7764
fish: add git add abbreviation 2023-05-06 17:32:20 -04:00
2aa28fb2be
qutebrowser: add code block copying 2023-05-06 17:31:46 -04:00
5 changed files with 71 additions and 3 deletions

View File

@ -19,7 +19,7 @@ gimp
blender
audacity
pulsemixer
ffmppeg
ffmpeg
mpv
netcat
nmap
@ -31,6 +31,8 @@ scrot
pynvim
python-lsp-server
python-lsp-black
typescript
typescript-language-server
bear
xsel
xwallpaper

View File

@ -45,6 +45,7 @@ end
abbr -a -- gs git status
abbr -a -- gl git log
abbr -a -- gc git commit -S
abbr -a -- ga git add
abbr -a -- gca git commit -aS
abbr -a -- gp git push
abbr -a --position anywhere -- gh "&& git push gh"

View File

@ -1,6 +1,6 @@
-- Syntax highlighting
require'nvim-treesitter.configs'.setup {
ensure_installed = { "c", "cpp", "javascript", "python", "vim", "latex", "fish", "bash" },
ensure_installed = { "c", "cpp", "javascript", "typescript", "python", "vim", "fish", "bash" },
sync_install = false,
auto_install = false,
highlight = {
@ -65,6 +65,7 @@ local servers = {
}
},
clangd = {},
tsserver = {},
}
local nvim_lsp = require('lspconfig')

View File

@ -83,7 +83,7 @@ c.content.headers.custom = {"accept": "text/html,application/xhtml+xml,applicati
# Sending a Do Not Track header makes your fingerprint more unique according to Panopticlick,
# and I don't trust sites to respect it, so I think it's better to not include it at all.
# (True: send DNT, False: Send DNT header set to 0, None: Don't send DNT)
c.content.headers.do_not_track = None;
c.content.headers.do_not_track = None
# Block certain trackers
c.content.canvas_reading = False
@ -95,3 +95,10 @@ config.bind("#", "set-cmd-text -s :scroll-to-anchor ")
config.bind(";I", "hint images yank")
# This overrides pP because I don't use primary clip
config.bind("p", "open -t {clipboard}")
# code block copying
c.hints.selectors["code"] = [
":not(pre) > code",
"pre"
]
config.bind("cc", "hint code userscript code_select.py")

View File

@ -0,0 +1,57 @@
#!/usr/bin/env python3
import os
import html
import re
import sys
import xml.etree.ElementTree as ET
try:
import pyperclip
except ImportError:
try:
import pyclip as pyperclip
except ImportError:
PYPERCLIP = False
else:
PYPERCLIP = True
else:
PYPERCLIP = True
def parse_text_content(element):
root = ET.fromstring(element)
text = ET.tostring(root, encoding="unicode", method="text")
text = html.unescape(text)
return text
def send_command_to_qute(command):
with open(os.environ.get("QUTE_FIFO"), "w") as f:
f.write(command)
def main():
delimiter = sys.argv[1] if len(sys.argv) > 1 else ";"
# For info on qute environment vairables, see
# https://github.com/qutebrowser/qutebrowser/blob/master/doc/userscripts.asciidoc
element = os.environ.get("QUTE_SELECTED_HTML")
code_text = parse_text_content(element)
if PYPERCLIP:
pyperclip.copy(code_text)
send_command_to_qute(
"message-info 'copied to clipboard: {info}{suffix}'".format(
info=code_text.splitlines()[0],
suffix="..." if len(code_text.splitlines()) > 1 else ""
)
)
else:
# Qute's yank command won't copy accross multiple lines so we
# compromise by placing lines on a single line seperated by the
# specified delimiter
code_text = re.sub("(\n)+", delimiter, code_text)
code_text = code_text.replace("'", "\"")
send_command_to_qute("yank inline '{code}'\n".format(code=code_text))
if __name__ == "__main__":
main()