diff --git a/nvim/.config/nvim/lua/core/autocmds.lua b/nvim/.config/nvim/lua/core/autocmds.lua new file mode 100644 index 0000000..cfd2303 --- /dev/null +++ b/nvim/.config/nvim/lua/core/autocmds.lua @@ -0,0 +1,26 @@ +-- Highlight whatever is being yanked +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', + desc = "Highlight yanked text whenevery yanking something", + group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }), +}) + +-- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to +vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { + pattern = { + "/dev/shm/gopass.*", + "/dev/shm/pass.?*/?*.txt", + "$TMPDIR/pass.?*/?*.txt", + "/tmp/pass.?*/?*.txt", + }, + command = "setlocal noswapfile nobackup noundofile nowritebackup viminfo=", + desc = "Don't leak any information when editing potential password files", + group = vim.api.nvim_create_augroup("passnoleak", { clear = true }), +}) + +-- remove line numbers from terminal buffers +vim.api.nvim_create_autocmd({ "TermOpen" }, { + desc = "Hide buffer numbers for terminals", + pattern = "*", + command = "setlocal nonumber norelativenumber", +}) diff --git a/nvim/.config/nvim/lua/core/commands.lua b/nvim/.config/nvim/lua/core/commands.lua deleted file mode 100644 index 289cd36..0000000 --- a/nvim/.config/nvim/lua/core/commands.lua +++ /dev/null @@ -1,43 +0,0 @@ --- Highlight whatever is being yanked -vim.api.nvim_create_autocmd({ "TextYankPost" }, { - command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', - desc = "Highlight yanked text whenevery yanking something", - group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }), -}) - --- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to -vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { - pattern = { - "/dev/shm/gopass.*", - "/dev/shm/pass.?*/?*.txt", - "$TMPDIR/pass.?*/?*.txt", - "/tmp/pass.?*/?*.txt", - }, - command = "setlocal noswapfile nobackup noundofile nowritebackup viminfo=", - desc = "Don't leak any information when editing potential password files", - group = vim.api.nvim_create_augroup("passnoleak", { clear = true }), -}) - --- remove line numbers from terminal buffers -vim.api.nvim_create_autocmd({ "TermOpen" }, { - desc = "Hide buffer numbers for terminals", - pattern = "*", - command = "setlocal nonumber norelativenumber", -}) - --- Custom spell enable which fires an event that other things can --- hook into. --- Toggles off and on by default, only turns on if called with bang. -vim.api.nvim_create_user_command("SpellToggle", function(opt) - vim.opt.spell = opt.bang or not vim.opt.spell:get() - if vim.opt.spell:get() then - if next(opt.fargs) ~= nil then - vim.opt.spelllang = opt.fargs - end - vim.api.nvim_exec_autocmds("User", { pattern = "SpellEnable" }) - vim.notify("Spellcheck enabled") - else - vim.api.nvim_exec_autocmds("User", { pattern = "SpellDisable" }) - vim.notify("Spellcheck disabled") - end -end, { nargs = "*", bang = true }) diff --git a/nvim/.config/nvim/lua/core/init.lua b/nvim/.config/nvim/lua/core/init.lua index 577c6e5..addb99f 100644 --- a/nvim/.config/nvim/lua/core/init.lua +++ b/nvim/.config/nvim/lua/core/init.lua @@ -1,7 +1,7 @@ for _, source in ipairs({ "core.settings", "core.lazy", - "core.commands", + "core.autocmds", "core.mappings", }) do local status_ok, fault = pcall(require, source) diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index 5f61ba8..a4d3028 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -127,11 +127,10 @@ map("n", "Q", "vapJgqap", { silent = true, desc = "Unformat then fo -- SPELL CHECKING -- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error or suggestion with [s ]s -map("n", "ZZ", "SpellToggle en_us en_gb de_de", { desc = "Toggle spellcheck" }) -map("n", "ZA", "SpellToggle! en_us en_gb de_de", { desc = "Enable spellcheck" }) -map("n", "ZE", "SpellToggle en_us", { desc = "Toggle EN_US spellcheck" }) -map("n", "ZB", "SpellToggle en_gb", { desc = "Toggle EN_GB spellcheck" }) -map("n", "ZD", "SpellToggle de_de", { desc = "Toggle DE_DE spellcheck" }) +map("n", "ZZ", ":setlocal spell! spelllang=en_us,en_gb,de_de", { desc = "Toggle spellcheck" }) +map("n", "ZE", ":setlocal spell! spelllang=en_us", { desc = "Toggle EN_US spellcheck" }) +map("n", "ZB", ":setlocal spell! spelllang=en_gb", { desc = "Toggle EN_GB spellcheck" }) +map("n", "ZD", ":setlocal spell! spelllang=de_de", { desc = "Toggle DE_DE spellcheck" }) -- undo last spelling mistake from insert and normal mode map("i", "", "ue[s1z=`]au") map("n", "z", "mse[s1z=`s", { desc = "Fix last spell error" }) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index a97c9bb..cb5a3fc 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -135,12 +135,12 @@ return { }), -- disable selection in cmd mode }), [""] = cmp.mapping(function(fallback) - -- expand_or_jumpable() will always jump - -- expand_or_locally_jumpable() only jumps when still inside snippet region - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif cmp.visible() then + if cmp.visible() then cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() else @@ -148,10 +148,10 @@ return { end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) - if luasnip.jumpable(-1) then - luasnip.jump(-1) - elseif cmp.visible() then + if cmp.visible() then cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index b4e3236..8650f74 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -20,7 +20,7 @@ local servers = { eslint = {}, gopls = {}, julials = {}, - ltex = { autostart = false }, + ltex = {}, lua_ls = { settings = { Lua = { @@ -35,7 +35,9 @@ local servers = { }, }, }, - marksman = {}, + marksman = { + filetypes = { "markdown", "quarto" }, + }, basedpyright = {}, ruff = {}, serve_d = {}, @@ -155,25 +157,6 @@ lsp.setup({ local lspconfig = require("lspconfig") lspconfig.nushell.setup({}) -lspconfig.marksman.setup({ - filetypes = { "markdown", "quarto" }, - on_attach = function(client, bufnr) - -- TODO: for some reason this is always true even though it shouldn't be - if client.config.in_zk_notebook then - vim.defer_fn(function() - vim.lsp.buf_detach_client(bufnr, client.id) - end, 1000) - end - end, - on_new_config = function(conf, new_root) - if require("lspconfig.util").root_pattern(".zk")(new_root) then - conf.in_zk_notebook = true - else - conf.in_zk_notebook = false - end - end, -}) - local python_path -- ensure python virtualenv is determined automatically on lsp start lspconfig.basedpyright.setup({ @@ -218,23 +201,3 @@ if require("core.util").is_available("arduino") then on_new_config = require("arduino").on_new_config, }) end - -vim.api.nvim_create_autocmd("User", { - pattern = "SpellEnable", - callback = function() - lspconfig.ltex.setup({ - on_attach = function(client, bufnr) - on_attach(client, bufnr) - if require("core.util").is_available("ltex_extra") then - require("ltex_extra").setup() - end - end, - settings = { - ltex = { - language = vim.opt.spelllang:get(), - }, - }, - }) - vim.cmd("LspStart ltex") - end, -}) diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 502fc34..b9ad789 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -133,10 +133,7 @@ local prose_plugs = { keys = { -- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua { "ni", "edit ~/documents/notes/index.md", desc = "open index", silent = true }, - { "nn", "ZkNew { title = vim.fn.input('Title: ') }", desc = "new note" }, - { "nn", ":'<,'>ZkNewFromTitleSelection", desc = "new note from selection", mode = "v" }, - { "nN", ":'<,'>ZkNewFromContentSelection", desc = "content from selection", mode = "v" }, - { "nl", "ZkNotes { sort = { 'modified' } }", desc = "note list" }, + { "nn", "ZkNotes { sort = { 'modified' } }", desc = "note list" }, { "nf", "ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }", @@ -145,9 +142,12 @@ local prose_plugs = { { "nf", "ZkMatch", desc = "find note from selection", mode = "v" }, { "nt", "ZkTags", desc = "note tags" }, { "nc", "ZkCd", desc = "notedir cd" }, - { "no", "ZkOrphans { sort = { 'modified' } }", desc = "orphans list" }, - { "nb", "ZkBacklinks", desc = "note backlinks" }, - { "nl", "ZkLinks", desc = "note links" }, + { "no", "ZkNotes { sort = { 'modified' } }", desc = "orphans list" }, + { "nl", "ZkLinks", desc = "note links" }, + { "nb", "ZkBacklinks", desc = "note backlinks" }, + { "nn", "ZkNew { title = vim.fn.input('Title: ') }", desc = "new note" }, + { "nn", ":'<,'>ZkNewFromTitleSelection", desc = "new note from selection", mode = "v" }, + { "nN", ":'<,'>ZkNewFromContentSelection", desc = "content from selection", mode = "v" }, }, }, @@ -182,6 +182,8 @@ local prose_plugs = { { "barreiroleo/ltex_extra.nvim", branch = "dev", + ft = writing_ft, + opts = {}, }, } diff --git a/qutebrowser/config/redirects.py b/qutebrowser/config/redirects.py index d6db906..0749fdd 100644 --- a/qutebrowser/config/redirects.py +++ b/qutebrowser/config/redirects.py @@ -1,6 +1,6 @@ import random import re -from typing import Callable +from typing import Any, Callable from urllib import parse from qutebrowser.api import interceptor @@ -29,11 +29,7 @@ def fixScribePath(url: QUrl): return url -type Service = dict[str, list[str]] -type Redirects = dict[str, Service] - - -redirects: Redirects = { +redirects = { "youtube": { "source": ["youtube.com"], "farside": ["invidious"], @@ -167,9 +163,11 @@ def rewrite(request: interceptor.Request) -> None: url = request.request_url if service := _should_be_redirected(url.host()): - url = _farside_redirect( - url, _pick_random(service["farside" if "farside" in service else "target"]) - ) + if "farside" in service: + url = _farside_redirect(url, _pick_random(service["farside"])) + else: + srv = _pick_random(service["target"]) + url = _target_redirect(url, srv) try: request.redirect(url) except RedirectException as e: @@ -179,24 +177,28 @@ def rewrite(request: interceptor.Request) -> None: url = service["postprocess"](url) -def _farside_redirect(url: QUrl, service: str, use_fastside: bool = True) -> QUrl: +def _farside_redirect(url: QUrl, service: str) -> QUrl: try: - url.setHost("fastside.link" if use_fastside else "farside.link") + url.setHost("farside.link") url.setPath(f"/{service}{url.path()}") except RedirectException as e: message.error(str(e)) return url -def _pick_random[T](choices: list[T]) -> T: +def _target_redirect(url: QUrl, target: str) -> QUrl: + if target is not None and url.setHost(target) is not False: + return url + return url + + +def _pick_random(choices: list) -> Any: return choices[random.randint(0, len(choices) - 1)] def _should_be_redirected( - # TODO: Update to use typedefs/classes instead of this jumble - host: str, - redirects: Redirects = redirects, -) -> Service | None: + host: str, redirects: dict = redirects +) -> dict[str, list] | None: for service in redirects.values(): for source in service["source"]: if re.search(source, host): diff --git a/scripts/.local/bin/lockscreen b/scripts/.local/bin/lockscreen index 6bf7cf4..c7f7435 100755 --- a/scripts/.local/bin/lockscreen +++ b/scripts/.local/bin/lockscreen @@ -25,10 +25,6 @@ pre_lock() { type mpc >/dev/null 2>&1 && mpc -q pause type playerctl >/dev/null 2>&1 && playerctl -s pause type amixer >/dev/null 2>&1 && amixer -q set Master mute - - # lock any pass coffins if we have them - type pass >/dev/null 2>&1 && pass close >/dev/null 2>&1 - return }