Compare commits
8 commits
fa48961f4a
...
d99c908ac3
Author | SHA1 | Date | |
---|---|---|---|
d99c908ac3 | |||
52c0260d6d | |||
444c378d89 | |||
851bf58b21 | |||
894b7ff175 | |||
e6497a2241 | |||
9ded34f73c | |||
7ff62840b7 |
9 changed files with 125 additions and 70 deletions
|
@ -1,26 +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",
|
|
||||||
})
|
|
43
nvim/.config/nvim/lua/core/commands.lua
Normal file
43
nvim/.config/nvim/lua/core/commands.lua
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
-- 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 })
|
|
@ -1,7 +1,7 @@
|
||||||
for _, source in ipairs({
|
for _, source in ipairs({
|
||||||
"core.settings",
|
"core.settings",
|
||||||
"core.lazy",
|
"core.lazy",
|
||||||
"core.autocmds",
|
"core.commands",
|
||||||
"core.mappings",
|
"core.mappings",
|
||||||
}) do
|
}) do
|
||||||
local status_ok, fault = pcall(require, source)
|
local status_ok, fault = pcall(require, source)
|
||||||
|
|
|
@ -127,10 +127,11 @@ 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", ":setlocal spell! spelllang=en_us,en_gb,de_de<cr>", { desc = "Toggle spellcheck" })
|
map("n", "<localleader>ZZ", "<cmd>SpellToggle en_us en_gb de_de<cr>", { desc = "Toggle spellcheck" })
|
||||||
map("n", "<localleader>ZE", ":setlocal spell! spelllang=en_us<cr>", { desc = "Toggle EN_US spellcheck" })
|
map("n", "<localleader>ZA", "<cmd>SpellToggle! en_us en_gb de_de<cr>", { desc = "Enable spellcheck" })
|
||||||
map("n", "<localleader>ZB", ":setlocal spell! spelllang=en_gb<cr>", { desc = "Toggle EN_GB spellcheck" })
|
map("n", "<localleader>ZE", "<cmd>SpellToggle en_us<cr>", { desc = "Toggle EN_US spellcheck" })
|
||||||
map("n", "<localleader>ZD", ":setlocal spell! spelllang=de_de<cr>", { desc = "Toggle DE_DE spellcheck" })
|
map("n", "<localleader>ZB", "<cmd>SpellToggle en_gb<cr>", { desc = "Toggle EN_GB 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" })
|
||||||
|
|
|
@ -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)
|
||||||
if cmp.visible() then
|
-- expand_or_jumpable() will always jump
|
||||||
cmp.select_next_item()
|
-- expand_or_locally_jumpable() only jumps when still inside snippet region
|
||||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
if luasnip.expand_or_locally_jumpable() then
|
||||||
-- they way you will only jump inside the snippet region
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
|
elseif cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
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 cmp.visible() then
|
if luasnip.jumpable(-1) then
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
|
elseif cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ local servers = {
|
||||||
eslint = {},
|
eslint = {},
|
||||||
gopls = {},
|
gopls = {},
|
||||||
julials = {},
|
julials = {},
|
||||||
ltex = {},
|
ltex = { autostart = false },
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
|
@ -35,9 +35,7 @@ local servers = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
marksman = {
|
marksman = {},
|
||||||
filetypes = { "markdown", "quarto" },
|
|
||||||
},
|
|
||||||
basedpyright = {},
|
basedpyright = {},
|
||||||
ruff = {},
|
ruff = {},
|
||||||
serve_d = {},
|
serve_d = {},
|
||||||
|
@ -157,6 +155,25 @@ 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({
|
||||||
|
@ -201,3 +218,23 @@ 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,
|
||||||
|
})
|
||||||
|
|
|
@ -133,7 +133,10 @@ 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>ZkNotes { sort = { 'modified' } }<cr>", desc = "note list" },
|
{ "<leader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", desc = "new note" },
|
||||||
|
{ "<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>",
|
||||||
|
@ -142,12 +145,9 @@ 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>ZkNotes { sort = { 'modified' } }<cr>", desc = "orphans list" },
|
{ "<leader>no", "<cmd>ZkOrphans { sort = { 'modified' } }<cr>", desc = "orphans list" },
|
||||||
{ "<leader>nl", "<cmd>ZkLinks<cr>", desc = "note links" },
|
{ "<localleader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" },
|
||||||
{ "<leader>nb", "<cmd>ZkBacklinks<cr>", desc = "note backlinks" },
|
{ "<localleader>nl", "<cmd>ZkLinks<cr>", desc = "note links" },
|
||||||
{ "<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,8 +182,6 @@ local prose_plugs = {
|
||||||
{
|
{
|
||||||
"barreiroleo/ltex_extra.nvim",
|
"barreiroleo/ltex_extra.nvim",
|
||||||
branch = "dev",
|
branch = "dev",
|
||||||
ft = writing_ft,
|
|
||||||
opts = {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
from typing import Any, Callable
|
from typing import Callable
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from qutebrowser.api import interceptor
|
from qutebrowser.api import interceptor
|
||||||
|
@ -29,7 +29,11 @@ def fixScribePath(url: QUrl):
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
|
||||||
redirects = {
|
type Service = dict[str, list[str]]
|
||||||
|
type Redirects = dict[str, Service]
|
||||||
|
|
||||||
|
|
||||||
|
redirects: Redirects = {
|
||||||
"youtube": {
|
"youtube": {
|
||||||
"source": ["youtube.com"],
|
"source": ["youtube.com"],
|
||||||
"farside": ["invidious"],
|
"farside": ["invidious"],
|
||||||
|
@ -163,11 +167,9 @@ 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()):
|
||||||
if "farside" in service:
|
url = _farside_redirect(
|
||||||
url = _farside_redirect(url, _pick_random(service["farside"]))
|
url, _pick_random(service["farside" if "farside" in service else "target"])
|
||||||
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:
|
||||||
|
@ -177,28 +179,24 @@ def rewrite(request: interceptor.Request) -> None:
|
||||||
url = service["postprocess"](url)
|
url = service["postprocess"](url)
|
||||||
|
|
||||||
|
|
||||||
def _farside_redirect(url: QUrl, service: str) -> QUrl:
|
def _farside_redirect(url: QUrl, service: str, use_fastside: bool = True) -> QUrl:
|
||||||
try:
|
try:
|
||||||
url.setHost("farside.link")
|
url.setHost("fastside.link" if use_fastside else "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 _target_redirect(url: QUrl, target: str) -> QUrl:
|
def _pick_random[T](choices: list[T]) -> T:
|
||||||
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(
|
||||||
host: str, redirects: dict = redirects
|
# TODO: Update to use typedefs/classes instead of this jumble
|
||||||
) -> dict[str, list] | None:
|
host: str,
|
||||||
|
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):
|
||||||
|
|
|
@ -25,6 +25,10 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue