Compare commits

..

No commits in common. "d99c908ac31d911b2c4c0061ed08c5658cd81624" and "fa48961f4a90c82f8380417dd7f711cb93669432" have entirely different histories.

9 changed files with 70 additions and 125 deletions

View file

@ -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",
})

View file

@ -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 })

View file

@ -1,7 +1,7 @@
for _, source in ipairs({ for _, source in ipairs({
"core.settings", "core.settings",
"core.lazy", "core.lazy",
"core.commands", "core.autocmds",
"core.mappings", "core.mappings",
}) do }) do
local status_ok, fault = pcall(require, source) local status_ok, fault = pcall(require, source)

View file

@ -127,11 +127,10 @@ map("n", "<localleader>Q", "vapJgqap", { silent = true, desc = "Unformat then fo
-- SPELL CHECKING -- SPELL CHECKING
-- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error with [S ]S
-- Move to the prev/next spelling error or suggestion with [s ]s -- Move to the prev/next spelling error or suggestion with [s ]s
map("n", "<localleader>ZZ", "<cmd>SpellToggle en_us en_gb de_de<cr>", { desc = "Toggle spellcheck" }) map("n", "<localleader>ZZ", ":setlocal spell! spelllang=en_us,en_gb,de_de<cr>", { desc = "Toggle spellcheck" })
map("n", "<localleader>ZA", "<cmd>SpellToggle! en_us en_gb de_de<cr>", { desc = "Enable spellcheck" }) map("n", "<localleader>ZE", ":setlocal spell! spelllang=en_us<cr>", { desc = "Toggle EN_US spellcheck" })
map("n", "<localleader>ZE", "<cmd>SpellToggle en_us<cr>", { desc = "Toggle EN_US spellcheck" }) map("n", "<localleader>ZB", ":setlocal spell! spelllang=en_gb<cr>", { desc = "Toggle EN_GB spellcheck" })
map("n", "<localleader>ZB", "<cmd>SpellToggle en_gb<cr>", { desc = "Toggle EN_GB spellcheck" }) map("n", "<localleader>ZD", ":setlocal spell! spelllang=de_de<cr>", { desc = "Toggle DE_DE spellcheck" })
map("n", "<localleader>ZD", "<cmd>SpellToggle de_de<cr>", { desc = "Toggle DE_DE spellcheck" })
-- undo last spelling mistake from insert and normal mode -- undo last spelling mistake from insert and normal mode
map("i", "<c-z>", "<C-G>u<Esc>e[s1z=`]a<C-G>u") map("i", "<c-z>", "<C-G>u<Esc>e[s1z=`]a<C-G>u")
map("n", "<localleader>z", "mse[s1z=`s", { desc = "Fix last spell error" }) map("n", "<localleader>z", "mse[s1z=`s", { desc = "Fix last spell error" })

View file

@ -135,12 +135,12 @@ return {
}), -- disable selection in cmd mode }), -- disable selection in cmd mode
}), }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
-- expand_or_jumpable() will always jump if cmp.visible() then
-- 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
cmp.select_next_item() 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 elseif has_words_before() then
cmp.complete() cmp.complete()
else else
@ -148,10 +148,10 @@ return {
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then if cmp.visible() then
luasnip.jump(-1)
elseif cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else else
fallback() fallback()
end end

View file

@ -20,7 +20,7 @@ local servers = {
eslint = {}, eslint = {},
gopls = {}, gopls = {},
julials = {}, julials = {},
ltex = { autostart = false }, ltex = {},
lua_ls = { lua_ls = {
settings = { settings = {
Lua = { Lua = {
@ -35,7 +35,9 @@ local servers = {
}, },
}, },
}, },
marksman = {}, marksman = {
filetypes = { "markdown", "quarto" },
},
basedpyright = {}, basedpyright = {},
ruff = {}, ruff = {},
serve_d = {}, serve_d = {},
@ -155,25 +157,6 @@ lsp.setup({
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
lspconfig.nushell.setup({}) 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 local python_path
-- ensure python virtualenv is determined automatically on lsp start -- ensure python virtualenv is determined automatically on lsp start
lspconfig.basedpyright.setup({ lspconfig.basedpyright.setup({
@ -218,23 +201,3 @@ if require("core.util").is_available("arduino") then
on_new_config = require("arduino").on_new_config, on_new_config = require("arduino").on_new_config,
}) })
end 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,
})

View file

@ -133,10 +133,7 @@ local prose_plugs = {
keys = { keys = {
-- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua -- additional key instpirations https://github.com/al1-ce/MonolithVim/blob/master/after/ftplugin/markdown.lua
{ "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true }, { "<leader>ni", "<cmd>edit ~/documents/notes/index.md<cr>", desc = "open index", silent = true },
{ "<leader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", desc = "new note" }, { "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{ "<leader>nn", ":'<,'>ZkNewFromTitleSelection<cr>", desc = "new note from selection", mode = "v" },
{ "<leader>nN", ":'<,'>ZkNewFromContentSelection<cr>", desc = "content from selection", mode = "v" },
{ "<leader>nl", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
{ {
"<leader>nf", "<leader>nf",
"<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>",
@ -145,9 +142,12 @@ local prose_plugs = {
{ "<leader>nf", "<cmd>ZkMatch<cr>", desc = "find note from selection", mode = "v" }, { "<leader>nf", "<cmd>ZkMatch<cr>", desc = "find note from selection", mode = "v" },
{ "<leader>nt", "<cmd>ZkTags<cr>", desc = "note tags" }, { "<leader>nt", "<cmd>ZkTags<cr>", desc = "note tags" },
{ "<leader>nc", "<cmd>ZkCd<cr>", desc = "notedir cd" }, { "<leader>nc", "<cmd>ZkCd<cr>", desc = "notedir cd" },
{ "<leader>no", "<cmd>ZkOrphans { sort = { 'modified' } }<cr>", desc = "orphans list" }, { "<leader>no", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", desc = "orphans list" },
{ "<localleader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" }, { "<leader>nl", "<cmd>ZkLinks<cr>", desc = "note links" },
{ "<localleader>nl", "<cmd>ZkLinks<cr>", desc = "note links" }, { "<leader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" },
{ "<localleader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", desc = "new note" },
{ "<localleader>nn", ":'<,'>ZkNewFromTitleSelection<cr>", desc = "new note from selection", mode = "v" },
{ "<localleader>nN", ":'<,'>ZkNewFromContentSelection<cr>", desc = "content from selection", mode = "v" },
}, },
}, },
@ -182,6 +182,8 @@ local prose_plugs = {
{ {
"barreiroleo/ltex_extra.nvim", "barreiroleo/ltex_extra.nvim",
branch = "dev", branch = "dev",
ft = writing_ft,
opts = {},
}, },
} }

View file

@ -1,6 +1,6 @@
import random import random
import re import re
from typing import Callable from typing import Any, Callable
from urllib import parse from urllib import parse
from qutebrowser.api import interceptor from qutebrowser.api import interceptor
@ -29,11 +29,7 @@ def fixScribePath(url: QUrl):
return url return url
type Service = dict[str, list[str]] redirects = {
type Redirects = dict[str, Service]
redirects: Redirects = {
"youtube": { "youtube": {
"source": ["youtube.com"], "source": ["youtube.com"],
"farside": ["invidious"], "farside": ["invidious"],
@ -167,9 +163,11 @@ def rewrite(request: interceptor.Request) -> None:
url = request.request_url url = request.request_url
if service := _should_be_redirected(url.host()): if service := _should_be_redirected(url.host()):
url = _farside_redirect( if "farside" in service:
url, _pick_random(service["farside" if "farside" in service else "target"]) url = _farside_redirect(url, _pick_random(service["farside"]))
) else:
srv = _pick_random(service["target"])
url = _target_redirect(url, srv)
try: try:
request.redirect(url) request.redirect(url)
except RedirectException as e: except RedirectException as e:
@ -179,24 +177,28 @@ def rewrite(request: interceptor.Request) -> None:
url = service["postprocess"](url) 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: try:
url.setHost("fastside.link" if use_fastside else "farside.link") url.setHost("farside.link")
url.setPath(f"/{service}{url.path()}") url.setPath(f"/{service}{url.path()}")
except RedirectException as e: except RedirectException as e:
message.error(str(e)) message.error(str(e))
return url 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)] return choices[random.randint(0, len(choices) - 1)]
def _should_be_redirected( def _should_be_redirected(
# TODO: Update to use typedefs/classes instead of this jumble host: str, redirects: dict = redirects
host: str, ) -> dict[str, list] | None:
redirects: Redirects = redirects,
) -> Service | None:
for service in redirects.values(): for service in redirects.values():
for source in service["source"]: for source in service["source"]:
if re.search(source, host): if re.search(source, host):

View file

@ -25,10 +25,6 @@ pre_lock() {
type mpc >/dev/null 2>&1 && mpc -q pause type mpc >/dev/null 2>&1 && mpc -q pause
type playerctl >/dev/null 2>&1 && playerctl -s pause type playerctl >/dev/null 2>&1 && playerctl -s pause
type amixer >/dev/null 2>&1 && amixer -q set Master mute 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 return
} }