Compare commits

..

3 commits

Author SHA1 Message Date
5f93ecba7c
lua: Format with stylua 2023-06-15 10:12:30 +02:00
e434c191c9
nvim: Switch away from depredcated nvim_exec function
Use nvim_exec2 instead, which is weirdly named.
2023-06-15 10:00:20 +02:00
2dbd94dda4
nvim: Remove copyright abbreviation
I never used it once.
2023-06-15 09:59:45 +02:00
34 changed files with 4063 additions and 3415 deletions

View file

@ -21,72 +21,110 @@ audio=yes
MAXENTRIES = 5000 MAXENTRIES = 5000
local msg = require 'mp.msg' local msg = require("mp.msg")
local options = require 'mp.options' local options = require("mp.options")
local utils = require 'mp.utils' local utils = require("mp.utils")
o = { o = {
disabled = false, disabled = false,
images = true, images = true,
videos = true, videos = true,
audio = true audio = true,
} }
options.read_options(o) options.read_options(o)
function Set (t) function Set(t)
local set = {} local set = {}
for _, v in pairs(t) do set[v] = true end for _, v in pairs(t) do
return set set[v] = true
end
return set
end end
function SetUnion (a,b) function SetUnion(a, b)
local res = {} local res = {}
for k in pairs(a) do res[k] = true end for k in pairs(a) do
for k in pairs(b) do res[k] = true end res[k] = true
return res end
for k in pairs(b) do
res[k] = true
end
return res
end end
EXTENSIONS_VIDEO = Set { EXTENSIONS_VIDEO = Set({
'mkv', 'avi', 'mp4', 'ogv', 'webm', 'rmvb', 'flv', 'wmv', 'mpeg', 'mpg', 'm4v', '3gp' "mkv",
} "avi",
"mp4",
"ogv",
"webm",
"rmvb",
"flv",
"wmv",
"mpeg",
"mpg",
"m4v",
"3gp",
})
EXTENSIONS_AUDIO = Set { EXTENSIONS_AUDIO = Set({
'mp3', 'wav', 'ogm', 'flac', 'm4a', 'wma', 'ogg', 'opus' "mp3",
} "wav",
"ogm",
"flac",
"m4a",
"wma",
"ogg",
"opus",
})
EXTENSIONS_IMAGES = Set { EXTENSIONS_IMAGES = Set({
'jpg', 'jpeg', 'png', 'tif', 'tiff', 'gif', 'webp', 'svg', 'bmp' "jpg",
} "jpeg",
"png",
"tif",
"tiff",
"gif",
"webp",
"svg",
"bmp",
})
EXTENSIONS = Set {} EXTENSIONS = Set({})
if o.videos then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO) end if o.videos then
if o.audio then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_AUDIO) end EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO)
if o.images then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_IMAGES) end end
if o.audio then
EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_AUDIO)
end
if o.images then
EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_IMAGES)
end
function add_files_at(index, files) function add_files_at(index, files)
index = index - 1 index = index - 1
local oldcount = mp.get_property_number("playlist-count", 1) local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do for i = 1, #files do
mp.commandv("loadfile", files[i], "append") mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist-move", oldcount + i - 1, index + i - 1) mp.commandv("playlist-move", oldcount + i - 1, index + i - 1)
end end
end end
function get_extension(path) function get_extension(path)
match = string.match(path, "%.([^%.]+)$" ) match = string.match(path, "%.([^%.]+)$")
if match == nil then if match == nil then
return "nomatch" return "nomatch"
else else
return match return match
end end
end end
table.filter = function(t, iter) table.filter = function(t, iter)
for i = #t, 1, -1 do for i = #t, 1, -1 do
if not iter(t[i]) then if not iter(t[i]) then
table.remove(t, i) table.remove(t, i)
end end
end end
end end
-- splitbynum and alnumcomp from alphanum.lua (C) Andre Bogus -- splitbynum and alnumcomp from alphanum.lua (C) Andre Bogus
@ -95,126 +133,136 @@ end
-- split a string into a table of number and string values -- split a string into a table of number and string values
function splitbynum(s) function splitbynum(s)
local result = {} local result = {}
for x, y in (s or ""):gmatch("(%d*)(%D*)") do for x, y in (s or ""):gmatch("(%d*)(%D*)") do
if x ~= "" then table.insert(result, tonumber(x)) end if x ~= "" then
if y ~= "" then table.insert(result, y) end table.insert(result, tonumber(x))
end end
return result if y ~= "" then
table.insert(result, y)
end
end
return result
end end
function clean_key(k) function clean_key(k)
k = (' '..k..' '):gsub("%s+", " "):sub(2, -2):lower() k = (" " .. k .. " "):gsub("%s+", " "):sub(2, -2):lower()
return splitbynum(k) return splitbynum(k)
end end
-- compare two strings -- compare two strings
function alnumcomp(x, y) function alnumcomp(x, y)
local xt, yt = clean_key(x), clean_key(y) local xt, yt = clean_key(x), clean_key(y)
for i = 1, math.min(#xt, #yt) do for i = 1, math.min(#xt, #yt) do
local xe, ye = xt[i], yt[i] local xe, ye = xt[i], yt[i]
if type(xe) == "string" then ye = tostring(ye) if type(xe) == "string" then
elseif type(ye) == "string" then xe = tostring(xe) end ye = tostring(ye)
if xe ~= ye then return xe < ye end elseif type(ye) == "string" then
end xe = tostring(xe)
return #xt < #yt end
if xe ~= ye then
return xe < ye
end
end
return #xt < #yt
end end
local autoloaded = nil local autoloaded = nil
function find_and_add_entries() function find_and_add_entries()
local path = mp.get_property("path", "") local path = mp.get_property("path", "")
local dir, filename = utils.split_path(path) local dir, filename = utils.split_path(path)
msg.trace(("dir: %s, filename: %s"):format(dir, filename)) msg.trace(("dir: %s, filename: %s"):format(dir, filename))
if o.disabled then if o.disabled then
msg.verbose("stopping: autoload disabled") msg.verbose("stopping: autoload disabled")
return return
elseif #dir == 0 then elseif #dir == 0 then
msg.verbose("stopping: not a local path") msg.verbose("stopping: not a local path")
return return
end end
local pl_count = mp.get_property_number("playlist-count", 1) local pl_count = mp.get_property_number("playlist-count", 1)
-- check if this is a manually made playlist -- check if this is a manually made playlist
if (pl_count > 1 and autoloaded == nil) or if
(pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil) then (pl_count > 1 and autoloaded == nil)
msg.verbose("stopping: manually made playlist") or (pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil)
return then
else msg.verbose("stopping: manually made playlist")
autoloaded = true return
end else
autoloaded = true
end
local pl = mp.get_property_native("playlist", {}) local pl = mp.get_property_native("playlist", {})
local pl_current = mp.get_property_number("playlist-pos-1", 1) local pl_current = mp.get_property_number("playlist-pos-1", 1)
msg.trace(("playlist-pos-1: %s, playlist: %s"):format(pl_current, msg.trace(("playlist-pos-1: %s, playlist: %s"):format(pl_current, utils.to_string(pl)))
utils.to_string(pl)))
local files = utils.readdir(dir, "files") local files = utils.readdir(dir, "files")
if files == nil then if files == nil then
msg.verbose("no other files in directory") msg.verbose("no other files in directory")
return return
end end
table.filter(files, function (v, k) table.filter(files, function(v, k)
if string.match(v, "^%.") then if string.match(v, "^%.") then
return false return false
end end
local ext = get_extension(v) local ext = get_extension(v)
if ext == nil then if ext == nil then
return false return false
end end
return EXTENSIONS[string.lower(ext)] return EXTENSIONS[string.lower(ext)]
end) end)
table.sort(files, alnumcomp) table.sort(files, alnumcomp)
if dir == "." then if dir == "." then
dir = "" dir = ""
end end
-- Find the current pl entry (dir+"/"+filename) in the sorted dir list -- Find the current pl entry (dir+"/"+filename) in the sorted dir list
local current local current
for i = 1, #files do for i = 1, #files do
if files[i] == filename then if files[i] == filename then
current = i current = i
break break
end end
end end
if current == nil then if current == nil then
return return
end end
msg.trace("current file position in files: "..current) msg.trace("current file position in files: " .. current)
local append = {[-1] = {}, [1] = {}} local append = { [-1] = {}, [1] = {} }
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1 for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do for i = 1, MAXENTRIES do
local file = files[current + i * direction] local file = files[current + i * direction]
local pl_e = pl[pl_current + i * direction] local pl_e = pl[pl_current + i * direction]
if file == nil or file[1] == "." then if file == nil or file[1] == "." then
break break
end end
local filepath = dir .. file local filepath = dir .. file
if pl_e then if pl_e then
-- If there's a playlist entry, and it's the same file, stop. -- If there's a playlist entry, and it's the same file, stop.
msg.trace(pl_e.filename.." == "..filepath.." ?") msg.trace(pl_e.filename .. " == " .. filepath .. " ?")
if pl_e.filename == filepath then if pl_e.filename == filepath then
break break
end end
end end
if direction == -1 then if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle if pl_current == 1 then -- never add additional entries in the middle
msg.info("Prepending " .. file) msg.info("Prepending " .. file)
table.insert(append[-1], 1, filepath) table.insert(append[-1], 1, filepath)
end end
else else
msg.info("Adding " .. file) msg.info("Adding " .. file)
table.insert(append[1], filepath) table.insert(append[1], filepath)
end end
end end
end end
add_files_at(pl_current + 1, append[1]) add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1]) add_files_at(pl_current, append[-1])
end end
mp.register_event("start-file", find_and_add_entries) mp.register_event("start-file", find_and_add_entries)

View file

@ -1,5 +1,5 @@
-- If the laptop is on battery, the profile 'lq' will be loaded; otherwise 'hq' is used -- If the laptop is on battery, the profile 'lq' will be loaded; otherwise 'hq' is used
local mp = require 'mp' local mp = require("mp")
local SHOULD_ADJUST = false local SHOULD_ADJUST = false
@ -7,27 +7,31 @@ local lqprofile = "lowquality"
local hqprofile = "highquality" local hqprofile = "highquality"
local function powerstate() local function powerstate()
local f = io.open("/sys/class/power_supply/AC/online") local f = io.open("/sys/class/power_supply/AC/online")
if f == nil then return end if f == nil then
local t = f:read("*n") return
f:close() end
return t local t = f:read("*n")
f:close()
return t
end end
local function adjust() local function adjust()
if not SHOULD_ADJUST then return end if not SHOULD_ADJUST then
return
end
local state = powerstate() local state = powerstate()
-- this actually overrides automatically applied profiles -- this actually overrides automatically applied profiles
-- like 'protocol.http' -- like 'protocol.http'
if state == 0 then if state == 0 then
mp.set_property("profile", lqprofile) mp.set_property("profile", lqprofile)
mp.msg.info("[quality] running battery, setting low-quality options.") mp.msg.info("[quality] running battery, setting low-quality options.")
mp.osd_message("[quality] LQ") mp.osd_message("[quality] LQ")
else else
mp.set_property("profile", hqprofile) mp.set_property("profile", hqprofile)
mp.msg.info("[quality] running ac, setting high-quality options.") mp.msg.info("[quality] running ac, setting high-quality options.")
mp.osd_message("[quality] HQ") mp.osd_message("[quality] HQ")
end end
end end
mp.add_hook("on_load", 1, adjust) mp.add_hook("on_load", 1, adjust)

View file

@ -1,5 +1,5 @@
local mp = require 'mp' local mp = require("mp")
require 'mp.msg' require("mp.msg")
-- Copy the current time of the video to clipboard. -- Copy the current time of the video to clipboard.
@ -8,73 +8,76 @@ UNIX = 3
KEY_BIND = "y" KEY_BIND = "y"
local function platform_type() local function platform_type()
local utils = require 'mp.utils' local utils = require("mp.utils")
local workdir = utils.to_string(mp.get_property_native("working-directory")) local workdir = utils.to_string(mp.get_property_native("working-directory"))
if string.find(workdir, "\\") then if string.find(workdir, "\\") then
return WINDOWS return WINDOWS
else else
return UNIX return UNIX
end end
end end
local function command_exists(cmd) local function command_exists(cmd)
local pipe = io.popen("type " .. cmd .. " > /dev/null 2> /dev/null; printf \"$?\"", "r") local pipe = io.popen("type " .. cmd .. ' > /dev/null 2> /dev/null; printf "$?"', "r")
if not pipe then return end if not pipe then
local exists = pipe:read() == "0" return
pipe:close() end
return exists local exists = pipe:read() == "0"
pipe:close()
return exists
end end
local function get_clipboard_cmd() local function get_clipboard_cmd()
if command_exists("xclip") then if command_exists("xclip") then
return "xclip -silent -in -selection clipboard" return "xclip -silent -in -selection clipboard"
elseif command_exists("wl-copy") then elseif command_exists("wl-copy") then
return "wl-copy" return "wl-copy"
elseif command_exists("pbcopy") then elseif command_exists("pbcopy") then
return "pbcopy" return "pbcopy"
else else
mp.msg.error("No supported clipboard command found") mp.msg.error("No supported clipboard command found")
return false return false
end end
end end
local function divmod(a, b) local function divmod(a, b)
return a / b, a % b return a / b, a % b
end end
local function set_clipboard(text) local function set_clipboard(text)
if platform == WINDOWS then if platform == WINDOWS then
mp.commandv("run", "powershell", "set-clipboard", text) mp.commandv("run", "powershell", "set-clipboard", text)
return true return true
elseif (platform == UNIX and clipboard_cmd) then elseif platform == UNIX and clipboard_cmd then
local pipe = io.popen(clipboard_cmd, "w") local pipe = io.popen(clipboard_cmd, "w")
if not pipe then return end if not pipe then
pipe:write(text) return
pipe:close() end
return true pipe:write(text)
else pipe:close()
mp.msg.error("Set_clipboard error") return true
return false else
end mp.msg.error("Set_clipboard error")
return false
end
end end
local function copyTime() local function copyTime()
local time_pos = mp.get_property_number("time-pos") local time_pos = mp.get_property_number("time-pos")
local minutes, remainder = divmod(time_pos, 60) local minutes, remainder = divmod(time_pos, 60)
local hours, minutes = divmod(minutes, 60) local hours, minutes = divmod(minutes, 60)
local seconds = math.floor(remainder) local seconds = math.floor(remainder)
local milliseconds = math.floor((remainder - seconds) * 1000) local milliseconds = math.floor((remainder - seconds) * 1000)
local time = string.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds) local time = string.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, milliseconds)
if set_clipboard(time) then if set_clipboard(time) then
mp.osd_message(string.format("[copytime] %s", time)) mp.osd_message(string.format("[copytime] %s", time))
else else
mp.osd_message("[copytime] failed") mp.osd_message("[copytime] failed")
end end
end end
platform = platform_type() platform = platform_type()
if platform == UNIX then if platform == UNIX then
clipboard_cmd = get_clipboard_cmd() clipboard_cmd = get_clipboard_cmd()
end end
mp.add_key_binding(KEY_BIND, "copyTime", copyTime) mp.add_key_binding(KEY_BIND, "copyTime", copyTime)

View file

@ -7,27 +7,27 @@
-- e.g. -- e.g.
-- `mpv gallery-dl://https://imgur.com/....` -- `mpv gallery-dl://https://imgur.com/....`
local mp = require 'mp' local mp = require("mp")
local utils = require 'mp.utils' local utils = require("mp.utils")
local msg = require 'mp.msg' local msg = require("mp.msg")
local function exec(args) local function exec(args)
local ret = utils.subprocess({ args = args }) local ret = utils.subprocess({ args = args })
return ret.status, ret.stdout, ret return ret.status, ret.stdout, ret
end end
mp.add_hook("on_load", 15, function() mp.add_hook("on_load", 15, function()
local fn = mp.get_property("stream-open-filename", "") local fn = mp.get_property("stream-open-filename", "")
if (fn:find("gdl://") ~= 1) then if fn:find("gdl://") ~= 1 then
msg.debug("not a gdl:// url: " .. fn) msg.debug("not a gdl:// url: " .. fn)
return return
end end
local url = string.gsub(url, "gdl://", "") local url = string.gsub(url, "gdl://", "")
local es, urls, result = exec({ "gallery-dl", "-g", url }) local es, urls, result = exec({ "gallery-dl", "-g", url })
if (es < 0) or (urls == nil) or (urls == "") then if (es < 0) or (urls == nil) or (urls == "") then
msg.error("failed to get album list.") msg.error("failed to get album list.")
end end
mp.commandv("loadlist", "memory://" .. urls) mp.commandv("loadlist", "memory://" .. urls)
end) end)

File diff suppressed because it is too large Load diff

View file

@ -5,90 +5,93 @@
-- --
-- original from https://codeberg.org/jouni/mpv_sponsorblock_minimal -- original from https://codeberg.org/jouni/mpv_sponsorblock_minimal
-- adapted for local playback skipping and some refactoring by me -- adapted for local playback skipping and some refactoring by me
local mp = require 'mp' local mp = require("mp")
local options = { local options = {
API = "https://sponsor.ajay.app/api/skipSegments", API = "https://sponsor.ajay.app/api/skipSegments",
-- Categories to fetch and skip -- Categories to fetch and skip
categories = '"sponsor","intro","outro","interaction","selfpromo"' categories = '"sponsor","intro","outro","interaction","selfpromo"',
} }
local function getranges() local function getranges()
local args = { local args = {
"curl", "-s", "-d", "videoID=" .. Youtube_id, "-d", "curl",
"categories=[" .. options.categories .. "]", "-G", options.API "-s",
} "-d",
local sponsors = mp.command_native({ "videoID=" .. Youtube_id,
name = "subprocess", "-d",
capture_stdout = true, "categories=[" .. options.categories .. "]",
playback_only = false, "-G",
args = args options.API,
}) }
local sponsors = mp.command_native({
name = "subprocess",
capture_stdout = true,
playback_only = false,
args = args,
})
if string.match(sponsors.stdout, "%[(.-)%]") then if string.match(sponsors.stdout, "%[(.-)%]") then
Ranges = {} Ranges = {}
for i in string.gmatch(string.sub(sponsors.stdout, 2, -2), "%[(.-)%]") do for i in string.gmatch(string.sub(sponsors.stdout, 2, -2), "%[(.-)%]") do
local k, v = string.match(i, "(%d+.?%d*),(%d+.?%d*)") local k, v = string.match(i, "(%d+.?%d*),(%d+.?%d*)")
Ranges[k] = v Ranges[k] = v
end end
end end
end end
local function skip_ads(_, pos) local function skip_ads(_, pos)
if pos ~= nil then if pos ~= nil then
for k, v in pairs(Ranges) do for k, v in pairs(Ranges) do
if tonumber(k) <= pos and tonumber(v) > pos then if tonumber(k) <= pos and tonumber(v) > pos then
-- this message may sometimes be wrong -- this message may sometimes be wrong
-- it only seems to be a visual thing though -- it only seems to be a visual thing though
mp.osd_message("[sponsorblock] skipping forward " .. mp.osd_message(
math.floor( "[sponsorblock] skipping forward " .. math.floor(tonumber(v) - mp.get_property("time-pos")) .. "s"
tonumber(v) - mp.get_property("time-pos")) .. )
"s") -- need to do the +0.01 otherwise mpv will start spamming skip sometimes
-- need to do the +0.01 otherwise mpv will start spamming skip sometimes -- example: https://www.youtube.com/watch?v=4ypMJzeNooo
-- example: https://www.youtube.com/watch?v=4ypMJzeNooo mp.set_property("time-pos", tonumber(v) + 0.01)
mp.set_property("time-pos", tonumber(v) + 0.01) return
return end
end end
end end
end
end end
local function file_loaded() local function file_loaded()
local video_path = mp.get_property("path") local video_path = mp.get_property("path")
local youtube_id1 = string.match(video_path, local youtube_id1 = string.match(video_path, "https?://youtu%.be/([%w-_]+).*")
"https?://youtu%.be/([%w-_]+).*") local youtube_id2 = string.match(video_path, "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*")
local youtube_id2 = string.match(video_path, local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*")
"https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*") local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*")
local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*") local localytfile = string.match(video_path, "-([%a%d%-_]+)%.[mw][kpe][v4b][m]?$")
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*") Youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or localytfile
local localytfile = string.match(video_path, if not Youtube_id or string.len(Youtube_id) < 11 then
"-([%a%d%-_]+)%.[mw][kpe][v4b][m]?$") return
Youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or end
localytfile Youtube_id = string.sub(Youtube_id, 1, 11)
if not Youtube_id or string.len(Youtube_id) < 11 then return end
Youtube_id = string.sub(Youtube_id, 1, 11)
getranges() getranges()
if Ranges then if Ranges then
ON = true ON = true
mp.add_key_binding("b", "sponsorblock", toggle) mp.add_key_binding("b", "sponsorblock", toggle)
mp.observe_property("time-pos", "native", skip_ads) mp.observe_property("time-pos", "native", skip_ads)
end end
return return
end end
local function toggle() local function toggle()
if ON then if ON then
mp.unobserve_property(skip_ads) mp.unobserve_property(skip_ads)
mp.osd_message("[sponsorblock] off") mp.osd_message("[sponsorblock] off")
ON = false ON = false
return return
end end
mp.observe_property("time-pos", "native", skip_ads) mp.observe_property("time-pos", "native", skip_ads)
mp.osd_message("[sponsorblock] on") mp.osd_message("[sponsorblock] on")
ON = true ON = true
return return
end end
mp.register_event("file-loaded", file_loaded) mp.register_event("file-loaded", file_loaded)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -11,5 +11,4 @@ iabbrev projcets projects
" Text expansion " Text expansion
iabbrev mo@ marty.oehme@gmail.com iabbrev mo@ marty.oehme@gmail.com
iabbrev mo.me@ <https://martyoeh.me/> iabbrev mome@ <https://martyoeh.me/>
iabbrev mcc@ Copyright 2020 Marty Oehme, all rights reserved.

View file

@ -1,5 +1,5 @@
local ns = vim.api.nvim_create_namespace('gitcommit') local ns = vim.api.nvim_create_namespace("gitcommit")
vim.api.nvim_set_hl(ns, 'ColorColumn', { bg = '#a33a3a', blend = 90 }) vim.api.nvim_set_hl(ns, "ColorColumn", { bg = "#a33a3a", blend = 90 })
vim.api.nvim_win_set_hl_ns(0, ns) vim.api.nvim_win_set_hl_ns(0, ns)
vim.bo.textwidth = 72 vim.bo.textwidth = 72
vim.wo.colorcolumn = '+0' vim.wo.colorcolumn = "+0"

View file

@ -1,90 +1,91 @@
-- Start quarto session -- Start quarto session
local startsession = function(file, args) local startsession = function(file, args)
file = file or "/tmp/jupyter-magma-session.json" file = file or "/tmp/jupyter-magma-session.json"
if args then file = args[0] end if args then
vim.fn.jobstart({ "jupyter", "console", "-f", file }, { file = args[0]
on_stdout = function(_) end
vim.cmd("MagmaInit " .. file) vim.fn.jobstart({ "jupyter", "console", "-f", file }, {
vim.cmd("JupyterAttach " .. file) on_stdout = function(_)
end, vim.cmd("MagmaInit " .. file)
on_exit = function(_) vim.cmd("JupyterAttach " .. file)
vim.notify(string.format("jupyter kernel stopped: %s", file), vim.log.levels.INFO) end,
end, on_exit = function(_)
stdin = nil vim.notify(string.format("jupyter kernel stopped: %s", file), vim.log.levels.INFO)
}) end,
stdin = nil,
})
end end
vim.api.nvim_create_user_command("JupyterStart", function() startsession() end, vim.api.nvim_create_user_command("JupyterStart", function()
{}) startsession()
end, {})
local map = vim.keymap.set local map = vim.keymap.set
-- filetype mappings -- filetype mappings
-- PLUGIN: magma-nvim -- PLUGIN: magma-nvim
-- Operate jupyter notebooks from within vim -- Operate jupyter notebooks from within vim
map('n', '<localleader>cc', ':MagmaEvaluateLine<cr>', { silent = true }) map("n", "<localleader>cc", ":MagmaEvaluateLine<cr>", { silent = true })
map('n', '<localleader>C', '?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>', map(
{ silent = true, desc = 'Evaluate current code cell' }) "n",
map('x', '<localleader>c', ':<C-u>MagmaEvaluateVisual<cr>', { silent = true }) "<localleader>C",
map('n', '<localleader>c', "nvim_exec('MagmaEvaluateOperator', v:true)", "?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>",
{ expr = true, silent = true, desc = '+code-evaluation' }) { silent = true, desc = "Evaluate current code cell" }
map('n', '<localleader>cr', ':MagmaReevaluateCell<cr>', { silent = true }) )
map('n', '<localleader>cu', ':MagmaShowOutput<cr>', { silent = true }) map("x", "<localleader>c", ":<C-u>MagmaEvaluateVisual<cr>", { silent = true })
map('n', '<localleader>cU', ':noautocmd :MagmaEnterOutput<cr>', map(
{ silent = true, desc = 'MagmaEnterOutput' }) "n",
map('n', '<localleader>cd', ':MagmaDelete<cr>', { silent = true }) "<localleader>c",
map('n', '<localleader>cs', ':MagmaInterrupt<cr>') "nvim_exec('MagmaEvaluateOperator', v:true)",
map('n', '<localleader>ci', ':MagmaInit ') { expr = true, silent = true, desc = "+code-evaluation" }
map('n', '<localleader>cD', ':MagmaDeinit<cr>') )
map('n', '<localleader>cR', ':MagmaRestart<cr>') map("n", "<localleader>cr", ":MagmaReevaluateCell<cr>", { silent = true })
map("n", "<localleader>cu", ":MagmaShowOutput<cr>", { silent = true })
map("n", "<localleader>cU", ":noautocmd :MagmaEnterOutput<cr>", { silent = true, desc = "MagmaEnterOutput" })
map("n", "<localleader>cd", ":MagmaDelete<cr>", { silent = true })
map("n", "<localleader>cs", ":MagmaInterrupt<cr>")
map("n", "<localleader>ci", ":MagmaInit ")
map("n", "<localleader>cD", ":MagmaDeinit<cr>")
map("n", "<localleader>cR", ":MagmaRestart<cr>")
-- jump to beginning of previous/ next cell code -- jump to beginning of previous/ next cell code
map('n', ']c', '/^```{<cr>}:nohl<cr>', { desc = 'Next quarto cell' }) map("n", "]c", "/^```{<cr>}:nohl<cr>", { desc = "Next quarto cell" })
map('n', '[c', '?^```<cr>n}:nohl<cr>', { desc = 'Previous quarto cell' }) map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
-- insert cell header above/below -- insert cell header above/below
map('n', '<localleader>co', 'o```{python}<cr><cr>```<esc>k', map("n", "<localleader>co", "o```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell below" })
{ desc = 'Insert quarto cell below' }) map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
map('n', '<localleader>cO', 'O```{python}<cr><cr>```<esc>k',
{ desc = 'Insert quarto cell above' })
local bufnr = 0 local bufnr = 0
map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>', map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
{ buffer = bufnr, desc = 'Previous diagnostic' }) map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>', map(
{ buffer = bufnr, desc = 'Next diagnostic' }) "n",
map('n', '[e', "[e",
'<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<cr>', "<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<cr>",
{ buffer = bufnr, desc = 'Previous error' }) { buffer = bufnr, desc = "Previous error" }
map('n', ']e', )
'<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<cr>', map(
{ buffer = bufnr, desc = 'Next error' }) "n",
"]e",
"<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<cr>",
{ buffer = bufnr, desc = "Next error" }
)
-- TODO find better way to enable lsp key mappings for quarto buffers -- TODO find better way to enable lsp key mappings for quarto buffers
local prefix = require('which-key').register local prefix = require("which-key").register
prefix({ ['<localleader>l'] = { name = "+lsp" } }) prefix({ ["<localleader>l"] = { name = "+lsp" } })
map('n', '<localleader>li', '<cmd>LspInfo<cr>', map("n", "<localleader>li", "<cmd>LspInfo<cr>", { buffer = bufnr, desc = "Lsp Info" })
{ buffer = bufnr, desc = 'Lsp Info' }) map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", { buffer = bufnr, desc = "Line diagnostics" })
map('n', '<localleader>ld', '<cmd>lua vim.diagnostic.open_float()<cr>', map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", { buffer = bufnr, desc = "Codeactions" })
{ buffer = bufnr, desc = 'Line diagnostics' }) map("n", "<localleader>ln", "<cmd>lua vim.lsp.buf.rename()<cr>", { buffer = bufnr, desc = "Rename element" })
map('n', '<localleader>la', '<cmd>lua vim.lsp.buf.code_action()<cr>', map("n", "<localleader>lr", "<cmd>lua vim.lsp.buf.references()<cr>", { buffer = bufnr, desc = "References" })
{ buffer = bufnr, desc = 'Codeactions' })
map('n', '<localleader>ln', '<cmd>lua vim.lsp.buf.rename()<cr>',
{ buffer = bufnr, desc = 'Rename element' })
map('n', '<localleader>lr', '<cmd>lua vim.lsp.buf.references()<cr>',
{ buffer = bufnr, desc = 'References' })
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", { buffer = bufnr, desc = "Hover definition" })
{ buffer = bufnr, desc = 'Hover definition' }) map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", { buffer = bufnr, desc = "Definition" })
map('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", { buffer = bufnr, desc = "Declaration" })
{ buffer = bufnr, desc = 'Definition' }) map("n", "gs", "<cmd>lua vim.lsp.buf.signature_help()<cr>", { buffer = bufnr, desc = "Signature help" })
map('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', map("n", "gI", "<cmd>lua vim.lsp.buf.implementation()<cr>", { buffer = bufnr, desc = "Implementation" })
{ buffer = bufnr, desc = 'Declaration' }) map("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<cr>", { buffer = bufnr, desc = "Type definition" })
map('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>',
{ buffer = bufnr, desc = 'Signature help' })
map('n', 'gI', '<cmd>lua vim.lsp.buf.implementation()<cr>',
{ buffer = bufnr, desc = 'Implementation' })
map('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<cr>',
{ buffer = bufnr, desc = 'Type definition' })
if vim.b['sessionfile'] == nil then if vim.b["sessionfile"] == nil then
vim.b['sessionfile'] = vim.fn.tempname() .. '.json' vim.b["sessionfile"] = vim.fn.tempname() .. ".json"
startsession(vim.b['sessionfile']) startsession(vim.b["sessionfile"])
end end

View file

@ -2,15 +2,18 @@
-- https://github.com/elianiva/dotfiles/ - with much gratitude -- https://github.com/elianiva/dotfiles/ - with much gratitude
local api = vim.api local api = vim.api
api.nvim_exec('runtime abbrev.vim', false) api.nvim_exec2("runtime abbrev.vim", {})
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
"git", "clone", "--filter=blob:none", "git",
"https://github.com/folke/lazy.nvim.git", "--branch=stable", -- latest stable release "clone",
lazypath "--filter=blob:none",
}) "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
@ -18,14 +21,14 @@ vim.opt.rtp:prepend(lazypath)
-- needs to be set before lazy.nvim is loaded -- needs to be set before lazy.nvim is loaded
vim.g.mapleader = " " vim.g.mapleader = " "
require('settings') require("settings")
require('autocmds') require("autocmds")
require("lazy").setup("plugins", { require("lazy").setup("plugins", {
defaults = { version = "*" }, defaults = { version = "*" },
performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } } performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } },
}) })
require('look') require("look")
require('maps') require("maps")
-- to include e.g. the spell dictionaries for vim -- to include e.g. the spell dictionaries for vim
vim.opt.rtp:append(vim.fn.stdpath("data") .. "/site") vim.opt.rtp:append(vim.fn.stdpath("data") .. "/site")

View file

@ -1,33 +1,37 @@
-- Highlight whatever is being yanked -- Highlight whatever is being yanked
vim.api.nvim_create_autocmd({ "TextYankPost" }, { vim.api.nvim_create_autocmd({ "TextYankPost" }, {
command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', command = 'silent! lua require"vim.highlight".on_yank{timeout=500}',
desc = "Highlight yanked text whenevery yanking something", desc = "Highlight yanked text whenevery yanking something",
group = vim.api.nvim_create_augroup('highlightyanks', { clear = true }) 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 -- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
pattern = { pattern = {
"/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt", "/dev/shm/gopass.*",
"$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt" "/dev/shm/pass.?*/?*.txt",
}, "$TMPDIR/pass.?*/?*.txt",
command = 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=', "/tmp/pass.?*/?*.txt",
desc = "Don't leak any information when editing potential password files", },
group = vim.api.nvim_create_augroup('passnoleak', { clear = true }) 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 }),
}) })
-- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330) -- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330)
vim.api.nvim_create_autocmd({ "VimEnter" }, { vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function() callback = function()
local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH
vim.defer_fn(function() vim.loop.kill(pid, WINCH) end, 20) vim.defer_fn(function()
end, vim.loop.kill(pid, WINCH)
desc = "Fix neovim sizing issues if opening same time as alacritty", end, 20)
group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true }) end,
desc = "Fix neovim sizing issues if opening same time as alacritty",
group = vim.api.nvim_create_augroup("alacritty_fixsize", { clear = true }),
}) })
-- remove line numbers from terminal buffers -- remove line numbers from terminal buffers
vim.api.nvim_create_autocmd({ "TermOpen" }, { vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = '*', pattern = "*",
command = 'setlocal nonumber norelativenumber' command = "setlocal nonumber norelativenumber",
}) })

View file

@ -1,15 +1,17 @@
local colorsfile = vim.fn.stdpath('state') .. '/colorscheme.lua' local colorsfile = vim.fn.stdpath("state") .. "/colorscheme.lua"
local function source_colors() local function source_colors()
if vim.fn.filereadable(colorsfile) == 1 then if vim.fn.filereadable(colorsfile) == 1 then
vim.cmd("source " .. colorsfile) vim.cmd("source " .. colorsfile)
end end
end end
-- set on startup -- set on startup
source_colors() source_colors()
-- continuously watch colors file for changes -- continuously watch colors file for changes
local fwatch = require('fwatch') local fwatch = require("fwatch")
fwatch.watch(colorsfile, { fwatch.watch(colorsfile, {
on_event = vim.schedule_wrap(function() source_colors() end) on_event = vim.schedule_wrap(function()
source_colors()
end),
}) })

View file

@ -1,5 +1,5 @@
local map = vim.keymap.set local map = vim.keymap.set
local prefix = require('which-key').register local prefix = require("which-key").register
-- The general ideas behind these mappings: -- The general ideas behind these mappings:
-- --
@ -10,73 +10,77 @@ local prefix = require('which-key').register
-- In other words mostly filetype specific mappings -- In other words mostly filetype specific mappings
-- backspace to switch to alternate (last) buffer -- backspace to switch to alternate (last) buffer
map('n', '<BS>', '<C-^>') map("n", "<BS>", "<C-^>")
-- since u undoes, would it not make sense that U redoes? -- since u undoes, would it not make sense that U redoes?
map('n', 'U', '<C-r>') map("n", "U", "<C-r>")
-- d-motion puts the last 'deleted' thing into the default register to paste; -- d-motion puts the last 'deleted' thing into the default register to paste;
-- use D-motion to truly delete something into nothingness and keep whatever -- use D-motion to truly delete something into nothingness and keep whatever
-- you want in your register, ready to paste -- you want in your register, ready to paste
map('n', 'D', '"_d') map("n", "D", '"_d')
-- I don't particularly need ex mode (at least, yet) but faster macro access is nice -- I don't particularly need ex mode (at least, yet) but faster macro access is nice
map('n', 'Q', '@') map("n", "Q", "@")
-- stronger versions of left,right - move all the way to beginning/end of line -- stronger versions of left,right - move all the way to beginning/end of line
map('n', 'H', '^') map("n", "H", "^")
map('n', 'L', '$') map("n", "L", "$")
-- when in softwrapped files, allow moving through the visible lines with j/k -- when in softwrapped files, allow moving through the visible lines with j/k
-- but when prepending a number jump *exactly* as many lines, wrapped or not -- but when prepending a number jump *exactly* as many lines, wrapped or not
-- This makes relative linenumbers much more useful in prose docs since they -- This makes relative linenumbers much more useful in prose docs since they
-- are always exactly correct -- are always exactly correct
local function wrap_up() local function wrap_up()
if vim.v.count == 0 then return 'gk' end if vim.v.count == 0 then
return 'k' return "gk"
end
return "k"
end end
local function wrap_down() local function wrap_down()
if vim.v.count == 0 then return 'gj' end if vim.v.count == 0 then
return 'j' return "gj"
end
return "j"
end end
map('n', 'k', wrap_up, { expr = true }) map("n", "k", wrap_up, { expr = true })
map('n', 'j', wrap_down, { expr = true }) map("n", "j", wrap_down, { expr = true })
-- move around between matching brackets with tab -- move around between matching brackets with tab
map('n', '<Tab>', '%') map("n", "<Tab>", "%")
-- when in insertion mode, C-u uppercases the current word, C-l lowercases it, -- when in insertion mode, C-u uppercases the current word, C-l lowercases it,
map('i', '<C-u>', '<esc>gUiw`]a') map("i", "<C-u>", "<esc>gUiw`]a")
map('i', '<C-y>', '<esc>guiw`]a') map("i", "<C-y>", "<esc>guiw`]a")
-- Add undo break-points at punctuations for plaintext editing -- Add undo break-points at punctuations for plaintext editing
for _, char in pairs({ ",", ".", ";", "?", "!" }) do for _, char in pairs({ ",", ".", ";", "?", "!" }) do
map("i", char, string.format("%s<c-g>u", char)) map("i", char, string.format("%s<c-g>u", char))
end end
-- yank current filename/filepath to f buffer -- yank current filename/filepath to f buffer
map('n', 'yp', ':let @p = expand("%")<Cr>', { desc = 'yank filename' }) map("n", "yp", ':let @p = expand("%")<Cr>', { desc = "yank filename" })
map('n', 'yP', ':let @p = expand("%:p")<Cr>', { desc = 'yank filepath' }) map("n", "yP", ':let @p = expand("%:p")<Cr>', { desc = "yank filepath" })
-- repeat the last substitute command with all its flags preserved -- repeat the last substitute command with all its flags preserved
map('n', '&', ':&&<cr>') map("n", "&", ":&&<cr>")
-- bracket pairings to go to the next/previous of: -- bracket pairings to go to the next/previous of:
-- (works with count prefixes) -- (works with count prefixes)
-- Argument list -- Argument list
map('n', '[a', ':previous<cr>') map("n", "[a", ":previous<cr>")
map('n', ']a', ':next<cr>') map("n", "]a", ":next<cr>")
-- Buffers -- Buffers
map('n', '[b', ':bprevious<cr>') map("n", "[b", ":bprevious<cr>")
map('n', ']b', ':bnext<cr>') map("n", "]b", ":bnext<cr>")
-- Quickfix list -- Quickfix list
map('n', '[q', ':cprevious<cr>') map("n", "[q", ":cprevious<cr>")
map('n', ']q', ':cnext<cr>') map("n", "]q", ":cnext<cr>")
-- Location list -- Location list
map('n', '[l', ':lprevious<cr>') map("n", "[l", ":lprevious<cr>")
map('n', ']l', ':lnext<cr>') map("n", "]l", ":lnext<cr>")
-- maps the leader for buffer local mappings -- maps the leader for buffer local mappings
-- since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does -- since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does
@ -86,198 +90,193 @@ vim.g.maplocalleader = ","
-- If we mapped localleader to comma, we can still get to its original function -- If we mapped localleader to comma, we can still get to its original function
-- by douple-tapping it. -- by douple-tapping it.
-- FIXME does this work still (and is it necessary)? -- FIXME does this work still (and is it necessary)?
if vim.g.maplocalleader == ',' then if vim.g.maplocalleader == "," then
map('', ',,', ',') map("", ",,", ",")
vim.keymap.del('', ',,', { silent = true }) vim.keymap.del("", ",,", { silent = true })
end end
-- remove search highlights by pressing space+/ -- remove search highlights by pressing space+/
map('n', '<leader>/', ':noh<cr>', { desc = 'remove highlights' }) map("n", "<leader>/", ":noh<cr>", { desc = "remove highlights" })
-- split buffers vertically/horizontally with the leader \ or - (mirrors my -- split buffers vertically/horizontally with the leader \ or - (mirrors my
-- tmux setup) -- tmux setup)
map('n', '<leader>-', ':sp<cr>', { desc = 'open horiz split' }) map("n", "<leader>-", ":sp<cr>", { desc = "open horiz split" })
map('n', '<leader>\\', ':vsp<cr>', { desc = 'open vert split' }) map("n", "<leader>\\", ":vsp<cr>", { desc = "open vert split" })
-- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it)
map('n', '<leader>t', ':vsp | Vifm<cr>', { desc = 'open buffer' }) map("n", "<leader>t", ":vsp | Vifm<cr>", { desc = "open buffer" })
-- open actual new tab with leader-T -- open actual new tab with leader-T
map('n', '<leader>T', ':tabedit | Vifm<cr>', { desc = 'open tab' }) map("n", "<leader>T", ":tabedit | Vifm<cr>", { desc = "open tab" })
-- select the whole buffer with <leader>-a -- select the whole buffer with <leader>-a
map('n', '<leader>a', 'ggVG', { desc = 'select all' }) map("n", "<leader>a", "ggVG", { desc = "select all" })
-- PLUGIN: Navigator.nvim -- PLUGIN: Navigator.nvim
map('n', '<c-w>h', '<CMD>lua require("Navigator").left()<cr>', { silent = true }) map("n", "<c-w>h", '<CMD>lua require("Navigator").left()<cr>', { silent = true })
map('n', '<c-w>k', '<CMD>lua require("Navigator").up()<cr>', { silent = true }) map("n", "<c-w>k", '<CMD>lua require("Navigator").up()<cr>', { silent = true })
map('n', '<c-w>l', '<CMD>lua require("Navigator").right()<cr>', { silent = true }) map("n", "<c-w>l", '<CMD>lua require("Navigator").right()<cr>', { silent = true })
map('n', '<c-w>j', '<CMD>lua require("Navigator").down()<cr>', { silent = true }) map("n", "<c-w>j", '<CMD>lua require("Navigator").down()<cr>', { silent = true })
map('n', '<c-w>p', '<CMD>lua require("Navigator").previous()<cr>', map("n", "<c-w>p", '<CMD>lua require("Navigator").previous()<cr>', { silent = true })
{ silent = true })
-- PLUGIN: Vifm.vim -- PLUGIN: Vifm.vim
-- open/close file tree with leader-e -- open/close file tree with leader-e
map('n', '<leader>e', ':Vifm<cr>', { desc = 'browse files' }) map("n", "<leader>e", ":Vifm<cr>", { desc = "browse files" })
-- open current file tree with current file directory -- open current file tree with current file directory
map('n', '<leader>E', ':Vifm getcwd()<cr>', { desc = 'browse project' }) map("n", "<leader>E", ":Vifm getcwd()<cr>", { desc = "browse project" })
-- set 'v'im-related options -- set 'v'im-related options
prefix({ ['<leader>v'] = { name = "+vim" } }) prefix({ ["<leader>v"] = { name = "+vim" } })
map('n', '<leader>vc', ':Vifm ' .. vim.fn.stdpath('config') .. '/lua<cr>', map("n", "<leader>vc", ":Vifm " .. vim.fn.stdpath("config") .. "/lua<cr>", { desc = "open config" })
{ desc = 'open config' }) map("n", "<leader>vh", ":lua require 'telescope.builtin'.help_tags()<cr>", { desc = "help tags" })
map('n', '<leader>vh', ":lua require 'telescope.builtin'.help_tags()<cr>", map("n", "<leader>vH", ":lua require 'telescope.builtin'.man_pages()<cr>", { desc = "man pages" })
{ desc = 'help tags' }) map(
map('n', '<leader>vH', ":lua require 'telescope.builtin'.man_pages()<cr>", "n",
{ desc = 'man pages' }) "<leader>vC",
map('n', '<leader>vC', ":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>",
":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>", { desc = "colorschemes" }
{ desc = 'colorschemes' }) )
map('n', '<leader>vl', ":Lazy<cr>", { desc = 'Lazy' }) map("n", "<leader>vl", ":Lazy<cr>", { desc = "Lazy" })
map('n', '<leader>vm', ":Mason<cr>", { desc = 'Mason' }) map("n", "<leader>vm", ":Mason<cr>", { desc = "Mason" })
-- Set vim to distraction free prose mode with F11 -- Set vim to distraction free prose mode with F11
map('n', '<leader>vz', ':ZenMode<cr>', { silent = true }) map("n", "<leader>vz", ":ZenMode<cr>", { silent = true })
-- PLUGIN: Telescope GLOBAL FUZZY FINDING -- PLUGIN: Telescope GLOBAL FUZZY FINDING
-- buffers and files in current workdir -- buffers and files in current workdir
prefix({ ['<leader>f'] = { name = '+find' } }) prefix({ ["<leader>f"] = { name = "+find" } })
map('n', '<leader>fb', map(
":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>", "n",
{ desc = 'list buffers' }) "<leader>fb",
":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>",
{ desc = "list buffers" }
)
-- most recently used / MRU, bound to S since it is essentially a larger -- most recently used / MRU, bound to S since it is essentially a larger
-- go-back intention than just buffers -- go-back intention than just buffers
map('n', '<leader>fo', map(
":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>", "n",
{ desc = 'list old files' }) "<leader>fo",
":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>",
{ desc = "list old files" }
)
-- fuzzy find files in cwd -- fuzzy find files in cwd
map('n', '<leader>ff', ":lua require 'telescope.builtin'.find_files()<cr>", map("n", "<leader>ff", ":lua require 'telescope.builtin'.find_files()<cr>", { desc = "find files" })
{ desc = 'find files' })
-- fuzzy find hidden files in cwd -- fuzzy find hidden files in cwd
map('n', '<leader>fh', map("n", "<leader>fh", ":lua require 'telescope.builtin'.find_files({hidden=true})<cr>", { desc = "find hidden files" })
":lua require 'telescope.builtin'.find_files({hidden=true})<cr>",
{ desc = 'find hidden files' })
-- general full-text search in cwd with rg -- general full-text search in cwd with rg
map('n', '<leader>fw', ":lua require 'telescope.builtin'.live_grep()<cr>", map("n", "<leader>fw", ":lua require 'telescope.builtin'.live_grep()<cr>", { desc = "grep search" })
{ desc = 'grep search' })
-- git status -- git status
map('n', '<leader>fg', ":lua require 'telescope.builtin'.git_status()<cr>", map("n", "<leader>fg", ":lua require 'telescope.builtin'.git_status()<cr>", { desc = "git status" })
{ desc = 'git status' })
-- git buffercommits -- git buffercommits
map('n', '<leader>fc', ":lua require 'telescope.builtin'.git_bcommits()<cr>", map("n", "<leader>fc", ":lua require 'telescope.builtin'.git_bcommits()<cr>", { desc = "git buffer commits" })
{ desc = 'git buffer commits' })
-- git commitlog -- git commitlog
map('n', '<leader>fl', ":lua require 'telescope.builtin'.git_commits()<cr>", map("n", "<leader>fl", ":lua require 'telescope.builtin'.git_commits()<cr>", { desc = "git commit log" })
{ desc = 'git commit log' })
-- spell suggestions -- spell suggestions
map('n', 'z=', map("n", "z=", ":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>")
":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>")
-- Format current Paragraph (esp useful in prose writing) -- Format current Paragraph (esp useful in prose writing)
map('n', '<localleader>q', 'gqap', map("n", "<localleader>q", "gqap", { silent = true, desc = "Format current paragraph" })
{ silent = true, desc = 'Format current paragraph' }) map("x", "<localleader>q", "gq", { silent = true, desc = "Format {motion}" })
map('x', '<localleader>q', 'gq', { silent = true, desc = 'Format {motion}' }) map("n", "<localleader>Q", "vapJgqap", { silent = true, desc = "Unformat then format paragraph" })
map('n', '<localleader>Q', 'vapJgqap',
{ silent = true, desc = 'Unformat then format paragraph' })
map('n', '<localleader>mp', '<Plug>MarkdownPreviewToggle', map("n", "<localleader>mp", "<Plug>MarkdownPreviewToggle", { desc = "Toggle md preview" })
{ desc = 'Toggle md preview' })
-- FORMAT code with -- FORMAT code with
-- PLUGIN: formatter.nvim -- PLUGIN: formatter.nvim
map('n', '<localleader>f', ':FormatLock<cr>') map("n", "<localleader>f", ":FormatLock<cr>")
map('n', '<localleader>F', ':FormatWriteLock<cr>') map("n", "<localleader>F", ":FormatWriteLock<cr>")
-- 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
prefix({ ['<localleader>Z'] = { name = '+Spelling' } }) prefix({ ["<localleader>Z"] = { name = "+Spelling" } })
map('n', '<localleader>ZZ', ':setlocal spell! spelllang=en_us,de_de<cr>', map("n", "<localleader>ZZ", ":setlocal spell! spelllang=en_us,de_de<cr>", { desc = "Toggle spellcheck" })
{ desc = 'Toggle spellcheck' }) map("n", "<localleader>ZE", ":setlocal spell! spelllang=en_us<cr>", { desc = "Toggle EN spellcheck" })
map('n', '<localleader>ZE', ':setlocal spell! spelllang=en_us<cr>', map("n", "<localleader>ZG", ":setlocal spell! spelllang=de_de<cr>", { desc = "Toggle DE spellcheck" })
{ desc = 'Toggle EN spellcheck' })
map('n', '<localleader>ZG', ':setlocal spell! spelllang=de_de<cr>',
{ desc = 'Toggle 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>[s1z=`]a<C-G>u') map("i", "<c-z>", "<C-G>u<Esc>[s1z=`]a<C-G>u")
map('n', '<localleader>z', 'ms[s1z=`s', { desc = 'Fix last spell error' }) map("n", "<localleader>z", "ms[s1z=`s", { desc = "Fix last spell error" })
-- PLUGIN: mini.nvim -- PLUGIN: mini.nvim
prefix({ ['<leader>s'] = { name = '+show' } }) prefix({ ["<leader>s"] = { name = "+show" } })
map('n', '<leader>sm', ':lua MiniMap.toggle()<cr>', map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "toggle minimap" })
{ silent = true, desc = 'toggle minimap' }) map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "show startpage" })
map('n', '<leader>ss', ":lua MiniStarter.open()<cr>", { desc = 'show startpage' })
-- PLUGIN: symbols-outline.nvim -- PLUGIN: symbols-outline.nvim
map('n', '<leader>so', '<cmd>SymbolsOutline<cr>', map("n", "<leader>so", "<cmd>SymbolsOutline<cr>", { silent = true, desc = "toggle symbol outline" })
{ silent = true, desc = 'toggle symbol outline' })
-- PLUGIN: nvim-tree -- PLUGIN: nvim-tree
map('n', '<leader>se', '<cmd>NvimTreeToggle<cr>', map("n", "<leader>se", "<cmd>NvimTreeToggle<cr>", { silent = true, desc = "toggle filetree" })
{ silent = true, desc = 'toggle filetree' })
-- PLUGIN: easy-align -- PLUGIN: easy-align
-- Start interactive EasyAlign in visual mode (e.g. vipga) -- Start interactive EasyAlign in visual mode (e.g. vipga)
map('x', 'ga', '<Plug>(EasyAlign)') map("x", "ga", "<Plug>(EasyAlign)")
-- Start interactive EasyAlign for a motion/text object (e.g. gaip) -- Start interactive EasyAlign for a motion/text object (e.g. gaip)
map('n', 'ga', '<Plug>(EasyAlign)') map("n", "ga", "<Plug>(EasyAlign)")
-- trim trailing whitespaces with mini.nvim trailspace -- trim trailing whitespaces with mini.nvim trailspace
map("n", "<localleader>w", function() require("mini.trailspace").trim() end, map("n", "<localleader>w", function()
{ noremap = true }) require("mini.trailspace").trim()
end, { noremap = true })
-- PLUGIN: dial-increment -- PLUGIN: dial-increment
map("n", "<C-a>", '<Plug>(dial-increment)') map("n", "<C-a>", "<Plug>(dial-increment)")
map("n", "<C-x>", '<Plug>(dial-decrement)') map("n", "<C-x>", "<Plug>(dial-decrement)")
map("v", "<C-a>", '<Plug>(dial-increment)') map("v", "<C-a>", "<Plug>(dial-increment)")
map("v", "<C-x>", '<Plug>(dial-increment)') map("v", "<C-x>", "<Plug>(dial-increment)")
map("v", "g<C-a>", 'g<Plug>(dial-increment)') map("v", "g<C-a>", "g<Plug>(dial-increment)")
map("v", "g<C-x>", 'g<Plug>(dial-increment)') map("v", "g<C-x>", "g<Plug>(dial-increment)")
-- PLUGIN: zettelkasten.nvim -- PLUGIN: zettelkasten.nvim
map('n', '<cr>', [[:silent lua require 'zettelkasten'.link_follow()<cr>]]) map("n", "<cr>", [[:silent lua require 'zettelkasten'.link_follow()<cr>]])
map('v', '<cr>', [[:lua require 'zettelkasten'.link_follow(true)<cr>]]) map("v", "<cr>", [[:lua require 'zettelkasten'.link_follow(true)<cr>]])
prefix({ ['<leader>n'] = { name = '+notes' } }) prefix({ ["<leader>n"] = { name = "+notes" } })
map('n', '<leader>ni', [[:lua require 'zettelkasten'.index_open()<cr> ]], map("n", "<leader>ni", [[:lua require 'zettelkasten'.index_open()<cr> ]], { desc = "index page" })
{ desc = "index page" })
-- PLUGIN: zk -- PLUGIN: zk
map('n', '<leader>nn', "<cmd>ZkNotes { sort = { 'modified' } }<cr>", map("n", "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", { desc = "note list" })
{ desc = "note list" }) map(
map("n", "<leader>nf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", "n",
{ desc = "note search" }) "<leader>nf",
map('n', '<leader>nt', "<cmd>ZkTags<cr>", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>",
{ desc = "note tags" }) { desc = "note search" }
map('n', '<leader>nc', "<cmd>ZkCd<cr>", )
{ desc = "notes directory" }) map("n", "<leader>nt", "<cmd>ZkTags<cr>", { desc = "note tags" })
prefix({ ['<localleader>n'] = { name = '+note' } }) map("n", "<leader>nc", "<cmd>ZkCd<cr>", { desc = "notes directory" })
map('n', '<localleader>nl', "<cmd>ZkLinks<cr>", prefix({ ["<localleader>n"] = { name = "+note" } })
{ desc = "note links" }) map("n", "<localleader>nl", "<cmd>ZkLinks<cr>", { desc = "note links" })
map('n', '<localleader>nb', "<cmd>ZkLinks<cr>", map("n", "<localleader>nb", "<cmd>ZkLinks<cr>", { desc = "note backlinks" })
{ desc = "note backlinks" }) map("n", "<localleader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", { desc = "new note" })
map('n', '<localleader>nn', "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", prefix({ ["<localleader>n"] = { name = "+note", mode = "v" } })
{ desc = "new note" }) map("v", "<localleader>nn", ":ZkNewFromTitleSelection<cr>", { desc = "title from selection" })
prefix({ ['<localleader>n'] = { name = '+note', mode = "v" } }) map("v", "<localleader>nN", ":ZkNewFromContentSelection<cr>", { desc = "content from selection" })
map('v', '<localleader>nn', ":ZkNewFromTitleSelection<cr>", map("v", "<localleader>nf", ":ZkMatch<cr>", { desc = "find note from selection" })
{ desc = "title from selection" })
map('v', '<localleader>nN', ":ZkNewFromContentSelection<cr>",
{ desc = "content from selection" })
map('v', '<localleader>nf', ":ZkMatch<cr>",
{ desc = "find note from selection" })
-- PLUGIN: toggleterm.nvim -- PLUGIN: toggleterm.nvim
-- create a lazygit window, set up in toggleterm settings -- create a lazygit window, set up in toggleterm settings
map('n', '<leader>G', ':Lazygit<cr>') map("n", "<leader>G", ":Lazygit<cr>")
prefix({ ['<localleader>s'] = { name = '+set' } }) prefix({ ["<localleader>s"] = { name = "+set" } })
-- PLUGIN: wrapping.nvim -- PLUGIN: wrapping.nvim
map('n', '<localleader>sw', [[:lua require('wrapping').toggle_wrap_mode()<cr> ]], map(
{ silent = true, desc = 'toggle wrap mode' }) "n",
"<localleader>sw",
[[:lua require('wrapping').toggle_wrap_mode()<cr> ]],
{ silent = true, desc = "toggle wrap mode" }
)
-- PLUGIN: easyread.nvim -- PLUGIN: easyread.nvim
map('n', '<localleader>ss', ':EasyreadToggle<cr>', { silent = true, desc = 'toggle speedreading' }) map("n", "<localleader>ss", ":EasyreadToggle<cr>", { silent = true, desc = "toggle speedreading" })
-- PLUGIN: nabla.nvim -- PLUGIN: nabla.nvim
map('n', '<localleader>sv', '<cmd>lua require("nabla").popup()<cr>', { silent = true, desc = 'latex formula popup' }) map("n", "<localleader>sv", '<cmd>lua require("nabla").popup()<cr>', { silent = true, desc = "latex formula popup" })
map('n', '<localleader>sV', '<cmd>lua require("nabla").toggle_virt({autogen = true, silent = true})<cr>', map(
{ silent = true, desc = 'toggle formula notation' }) "n",
"<localleader>sV",
'<cmd>lua require("nabla").toggle_virt({autogen = true, silent = true})<cr>',
{ silent = true, desc = "toggle formula notation" }
)
-- PLUGIN: nvim-colorizer -- PLUGIN: nvim-colorizer
map('n', '<localleader>sc', '<cmd>ColorizerToggle<cr>', { silent = true, desc = 'toggle colorizer' }) map("n", "<localleader>sc", "<cmd>ColorizerToggle<cr>", { silent = true, desc = "toggle colorizer" })
map('n', '<localleader>sC', '<cmd>lua require("colorizer").attach_to_buffer(0, {mode = "background"} )<cr>', map(
{ silent = true, desc = 'colorize background' }) "n",
"<localleader>sC",
'<cmd>lua require("colorizer").attach_to_buffer(0, {mode = "background"} )<cr>',
{ silent = true, desc = "colorize background" }
)

View file

@ -1,12 +1,11 @@
local M = {} local M = {}
function M.getCompletionItems(prefix) function M.getCompletionItems(prefix)
-- define your total completion items -- define your total completion items
local items = vim.api.nvim_call_function('pandoc#completion#Complete', local items = vim.api.nvim_call_function("pandoc#completion#Complete", { 0, prefix })
{0, prefix}) return items
return items
end end
M.complete_item = {item = M.getCompletionItems} M.complete_item = { item = M.getCompletionItems }
return M return M

View file

@ -9,34 +9,41 @@ window, otherwise opens a new split.
The buffer, by default is set to the pandoc filetype. The buffer, by default is set to the pandoc filetype.
This can be changed by setting the `g:scratchpad_ft` variable or the `b:scratchpad_ft` This can be changed by setting the `g:scratchpad_ft` variable or the `b:scratchpad_ft`
variable to the intended filetype. variable to the intended filetype.
]] -- ]]
--
local api = vim.api local api = vim.api
local M = {} local M = {}
local function isempty(s) return s == nil or s == '' end local function isempty(s)
return s == nil or s == ""
end
function M.create(split, ft) function M.create(split, ft)
-- should we create a new split or switch out the current buffer? -- should we create a new split or switch out the current buffer?
if isempty(split) then if isempty(split) then
split = false split = false
else else
split = true split = true
end end
-- which filetype to set for the scratchpad, defaults to pandoc -- which filetype to set for the scratchpad, defaults to pandoc
if isempty(ft) then if isempty(ft) then
ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "pandoc" ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "pandoc"
end end
local buf = api.nvim_create_buf(false, true) local buf = api.nvim_create_buf(false, true)
if buf == 0 then print("Error opening scratch buffer.") end if buf == 0 then
api.nvim_buf_set_option(buf, "bufhidden", "hide") print("Error opening scratch buffer.")
api.nvim_buf_set_option(buf, "buftype", "nofile") end
api.nvim_buf_set_option(buf, "swapfile", false) api.nvim_buf_set_option(buf, "bufhidden", "hide")
api.nvim_buf_set_option(buf, "filetype", ft) api.nvim_buf_set_option(buf, "buftype", "nofile")
api.nvim_buf_set_option(buf, "swapfile", false)
api.nvim_buf_set_option(buf, "filetype", ft)
if split then api.nvim_command('vsplit new') end -- i think this is the only way to interact with the buffers creating a new split if split then
-- switch to scratchpad api.nvim_command("vsplit new")
api.nvim_win_set_buf(0, buf) end -- i think this is the only way to interact with the buffers creating a new split
-- switch to scratchpad
api.nvim_win_set_buf(0, buf)
end end
return M return M

View file

@ -1,44 +1,56 @@
require('gitsigns').setup { require("gitsigns").setup({
numhl = true, numhl = true,
signcolumn = false, signcolumn = false,
on_attach = function(bufnr) on_attach = function(bufnr)
local gs = package.loaded.gitsigns local gs = package.loaded.gitsigns
local function map(mode, l, r, opts) local function map(mode, l, r, opts)
opts = opts or {} opts = opts or {}
opts.buffer = bufnr opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts) vim.keymap.set(mode, l, r, opts)
end end
-- Navigation -- Navigation
map('n', ']h', function() map("n", "]h", function()
if vim.wo.diff then return ']h' end if vim.wo.diff then
vim.schedule(function() gs.next_hunk() end) return "]h"
return '<Ignore>' end
end, { expr = true }) vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map('n', '[h', function() map("n", "[h", function()
if vim.wo.diff then return '[h' end if vim.wo.diff then
vim.schedule(function() gs.prev_hunk() end) return "[h"
return '<Ignore>' end
end, { expr = true }) vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
-- Actions -- Actions
require('which-key').register({ ['<localleader>h'] = { name = '+git' } }) require("which-key").register({ ["<localleader>h"] = { name = "+git" } })
map({ 'n', 'v' }, '<localleader>hs', ':Gitsigns stage_hunk<CR>', { desc = 'stage hunk' }) map({ "n", "v" }, "<localleader>hs", ":Gitsigns stage_hunk<CR>", { desc = "stage hunk" })
map({ 'n', 'v' }, '<localleader>hr', ':Gitsigns reset_hunk<CR>', { desc = 'reset hunk' }) map({ "n", "v" }, "<localleader>hr", ":Gitsigns reset_hunk<CR>", { desc = "reset hunk" })
map('n', '<localleader>hS', gs.stage_buffer, { desc = 'stage buffer' }) map("n", "<localleader>hS", gs.stage_buffer, { desc = "stage buffer" })
map('n', '<localleader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) map("n", "<localleader>hu", gs.undo_stage_hunk, { desc = "undo stage hunk" })
map('n', '<localleader>hR', gs.reset_buffer, { desc = 'reset buffer' }) map("n", "<localleader>hR", gs.reset_buffer, { desc = "reset buffer" })
map('n', '<localleader>hp', gs.preview_hunk, { desc = 'preview hunk' }) map("n", "<localleader>hp", gs.preview_hunk, { desc = "preview hunk" })
map('n', '<localleader>hb', function() gs.blame_line { full = true } end, { desc = 'blame line' }) map("n", "<localleader>hb", function()
map('n', '<localleader>hB', gs.toggle_current_line_blame, { desc = 'toggle blame' }) gs.blame_line({ full = true })
map('n', '<localleader>hd', gs.diffthis, { desc = 'diffthis' }) end, { desc = "blame line" })
map('n', '<localleader>hD', function() gs.diffthis('~') end, { desc = 'diffbase' }) map("n", "<localleader>hB", gs.toggle_current_line_blame, { desc = "toggle blame" })
map('n', '<localleader>ht', gs.toggle_deleted, { desc = 'toggle deleted' }) map("n", "<localleader>hd", gs.diffthis, { desc = "diffthis" })
map("n", "<localleader>hD", function()
gs.diffthis("~")
end, { desc = "diffbase" })
map("n", "<localleader>ht", gs.toggle_deleted, { desc = "toggle deleted" })
-- Text object -- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>') map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
map({ 'o', 'x' }, 'ah', ':<C-U>Gitsigns select_hunk<CR>') map({ "o", "x" }, "ah", ":<C-U>Gitsigns select_hunk<CR>")
end end,
} })

View file

@ -1,28 +1,28 @@
require('lualine').setup { require("lualine").setup({
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = 'auto', theme = "auto",
component_separators = {left = '', right = ''}, component_separators = { left = "", right = "" },
section_separators = {left = '', right = ''}, section_separators = { left = "", right = "" },
disabled_filetypes = {}, disabled_filetypes = {},
always_divide_middle = true always_divide_middle = true,
}, },
sections = { sections = {
lualine_a = {'mode'}, lualine_a = { "mode" },
lualine_b = {'branch', 'diff', 'diagnostics'}, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = {'filename'}, lualine_c = { "filename" },
lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = {'progress', 'location'}, lualine_y = { "progress", "location" },
lualine_z = {'hostname'} lualine_z = { "hostname" },
}, },
inactive_sections = { inactive_sections = {
lualine_a = {}, lualine_a = {},
lualine_b = {'branch', 'diff'}, lualine_b = { "branch", "diff" },
lualine_c = {'filename'}, lualine_c = { "filename" },
lualine_x = {}, lualine_x = {},
lualine_y = {'location'}, lualine_y = { "location" },
lualine_z = {} lualine_z = {},
}, },
tabline = {}, tabline = {},
extensions = {'quickfix', 'toggleterm'} extensions = { "quickfix", "toggleterm" },
} })

View file

@ -1,38 +1,38 @@
require('mini.ai').setup() require("mini.ai").setup()
require('mini.comment').setup({ require("mini.comment").setup({
hooks = { hooks = {
pre = function() pre = function()
require('ts_context_commentstring.internal').update_commentstring() require("ts_context_commentstring.internal").update_commentstring()
end end,
} },
}) })
require('mini.cursorword').setup({ delay = 500 }) require("mini.cursorword").setup({ delay = 500 })
require('mini.fuzzy').setup() require("mini.fuzzy").setup()
require('mini.indentscope').setup({ require("mini.indentscope").setup({
symbol = "", symbol = "",
draw = { animation = require('mini.indentscope').gen_animation.none() }, draw = { animation = require("mini.indentscope").gen_animation.none() },
options = { indent_at_cursor = false } options = { indent_at_cursor = false },
}) })
require('mini.map').setup() require("mini.map").setup()
-- require('mini.move').setup() -- has not hit stable yet -- require('mini.move').setup() -- has not hit stable yet
require('mini.pairs').setup() require("mini.pairs").setup()
require('mini.trailspace').setup() require("mini.trailspace").setup()
local starter = require('mini.starter') local starter = require("mini.starter")
starter.setup({ starter.setup({
evaluate_single = true, evaluate_single = true,
items = { items = {
starter.sections.builtin_actions(), starter.sections.builtin_actions(),
starter.sections.recent_files(10, false), starter.sections.recent_files(10, false),
starter.sections.recent_files(10, true), starter.sections.recent_files(10, true),
-- Use this if you set up 'mini.sessions' -- Use this if you set up 'mini.sessions'
starter.sections.telescope() starter.sections.telescope(),
}, },
content_hooks = { content_hooks = {
starter.gen_hook.adding_bullet(), starter.gen_hook.adding_bullet(),
starter.gen_hook.padding(3, 2), starter.gen_hook.padding(3, 2),
starter.gen_hook.aligning('center', 'center') starter.gen_hook.aligning("center", "center"),
} },
}) })
vim.api.nvim_set_hl(0, 'MiniCursorword', { bold = true }) vim.api.nvim_set_hl(0, "MiniCursorword", { bold = true })

View file

@ -4,40 +4,61 @@
-- rg (ripgrep) for in-text searches -- rg (ripgrep) for in-text searches
-- fd for quicker directory structure searches -- fd for quicker directory structure searches
-- lsp for a variety of lsp queries -- lsp for a variety of lsp queries
require("telescope").setup { require("telescope").setup({
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
'rg', '--ignore-vcs', '--hidden', '--color=never', '--no-heading', "rg",
'--with-filename', '--line-number', '--column', '--smart-case' "--ignore-vcs",
}, "--hidden",
generic_sorter = require('mini.fuzzy').get_telescope_sorter "--color=never",
}, "--no-heading",
defaults = { "--with-filename",
-- Appearance "--line-number",
prompt_prefix = '', "--column",
selection_caret = '󰳟 ', "--smart-case",
color_devicons = true },
}, generic_sorter = require("mini.fuzzy").get_telescope_sorter,
pickers = { },
buffers = {theme = "ivy"}, defaults = {
oldfiles = {theme = "ivy"}, -- Appearance
find_files = { prompt_prefix = "",
theme = "dropdown", selection_caret = "󰳟 ",
-- nice minimal picker design color_devicons = true,
borderchars = { },
{'', '', '', '', '', '', '', ''}, pickers = {
prompt = {"", "", " ", "", '', '', "", ""}, buffers = { theme = "ivy" },
results = { oldfiles = { theme = "ivy" },
"", "", "", "", "", "", "", "" find_files = {
}, theme = "dropdown",
preview = { -- nice minimal picker design
'', '', '', '', '', '', '', '' borderchars = {
} { "", "", "", "", "", "", "", "" },
}, prompt = { "", "", " ", "", "", "", "", "" },
width = 0.8, results = {
previewer = false, "",
prompt_title = false "",
} "",
} "",
} "",
"",
"",
"",
},
preview = {
"",
"",
"",
"",
"",
"",
"",
"",
},
},
width = 0.8,
previewer = false,
prompt_title = false,
},
},
})
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")

View file

@ -1,16 +1,18 @@
require("toggleterm").setup { require("toggleterm").setup({
open_mapping = [[<leader>=]], open_mapping = [[<leader>=]],
insert_mappings = false -- don't map the key in insert mode insert_mappings = false, -- don't map the key in insert mode
} })
local Terminal = require('toggleterm.terminal').Terminal local Terminal = require("toggleterm.terminal").Terminal
-- create a lazygit window with the lazygit command -- create a lazygit window with the lazygit command
local lazygit = Terminal:new({ local lazygit = Terminal:new({
cmd = "lazygit", cmd = "lazygit",
hidden = true, hidden = true,
direction = 'float', direction = "float",
float_opts = { border = "curved" } float_opts = { border = "curved" },
}) })
function _Lazygit_toggle() lazygit:toggle() end function _Lazygit_toggle()
lazygit:toggle()
end
vim.cmd([[command! Lazygit :lua _Lazygit_toggle()<cr>]]) vim.cmd([[command! Lazygit :lua _Lazygit_toggle()<cr>]])

View file

@ -1,21 +1,21 @@
local rainbow = require('ts-rainbow') local rainbow = require("ts-rainbow")
require 'nvim-treesitter.configs'.setup { require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all", ensure_installed = "all",
highlight = { enable = true }, highlight = { enable = true },
incremental_selection = { enable = true }, incremental_selection = { enable = true },
textobjects = { enable = true }, textobjects = { enable = true },
indent = { enable = true }, indent = { enable = true },
-- enable rainbow brackets, needs p00f/nvim-ts-rainbow -- enable rainbow brackets, needs p00f/nvim-ts-rainbow
rainbow = { rainbow = {
enable = true, enable = true,
strategy = { rainbow.strategy.global } strategy = { rainbow.strategy.global },
}, },
-- for improved commentstrings, needs corresponding plugin -- for improved commentstrings, needs corresponding plugin
context_commentstring = { context_commentstring = {
enable = true, enable = true,
enable_autocmd = false -- since we run it as a hook from the mini.comment plugin enable_autocmd = false, -- since we run it as a hook from the mini.comment plugin
} },
} })

View file

@ -1,261 +1,321 @@
local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" } local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" }
return { return {
-- essential -- essential
{ 'numToStr/Navigator.nvim', branch = "master", config = true }, -- allow seamless navigation between vim buffers and tmux/wezterm splits { "numToStr/Navigator.nvim", branch = "master", config = true }, -- allow seamless navigation between vim buffers and tmux/wezterm splits
{ 'jeffkreeftmeijer/vim-numbertoggle', event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative { "jeffkreeftmeijer/vim-numbertoggle", event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative
{ 'ojroques/vim-oscyank', event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank { "ojroques/vim-oscyank", event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank
{ 'ggandor/lightspeed.nvim', event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak { "ggandor/lightspeed.nvim", event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak
{ {
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter "lewis6991/gitsigns.nvim", -- show vcs changes on left-hand gutter
config = function() require('plug._gitsigns') end, config = function()
event = "BufRead" require("plug._gitsigns")
}, { "m4xshen/smartcolumn.nvim", config = true }, -- auto-hiding colorcolumn end,
-- files event = "BufRead",
{ 'vifm/vifm.vim' }, -- integrate file manager },
{ { "m4xshen/smartcolumn.nvim", config = true }, -- auto-hiding colorcolumn
'nvim-tree/nvim-tree.lua', -- integrate file tree -- files
config = true, { "vifm/vifm.vim" }, -- integrate file manager
dependencies = { 'nvim-tree/nvim-web-devicons', config = true }, {
cmd = "NvimTreeToggle" "nvim-tree/nvim-tree.lua", -- integrate file tree
}, -- colors config = true,
{ dependencies = { "nvim-tree/nvim-web-devicons", config = true },
'RRethy/nvim-base16', cmd = "NvimTreeToggle",
event = "BufWinEnter", }, -- colors
dependencies = { 'rktjmp/fwatch.nvim' } {
}, { "RRethy/nvim-base16",
'NvChad/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme event = "BufWinEnter",
config = function() dependencies = { "rktjmp/fwatch.nvim" },
require('colorizer').setup({ },
user_default_options = { mode = 'virtualtext' } {
}) "NvChad/nvim-colorizer.lua", -- color hex, named colors in the correct preview scheme
end, config = function()
event = "VeryLazy" require("colorizer").setup({
}, -- editing user_default_options = { mode = "virtualtext" },
{ 'kylechui/nvim-surround', version = '*', config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds })
{ end,
'monaqa/dial.nvim', -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers event = "VeryLazy",
config = function() }, -- editing
local augend = require("dial.augend") { "kylechui/nvim-surround", version = "*", config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds
require("dial.config").augends:register_group { {
-- default augends used when no group name is specified "monaqa/dial.nvim", -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers
default = { config = function()
augend.integer.alias.decimal, augend.integer.alias.hex, local augend = require("dial.augend")
augend.date.alias["%Y/%m/%d"], require("dial.config").augends:register_group({
augend.date.alias["%Y-%m-%d"], augend.date.alias["%m/%d"], -- default augends used when no group name is specified
augend.date.alias["%H:%M:%S"], augend.date.alias["%H:%M"], default = {
augend.constant.alias.de_weekday_full, augend.integer.alias.decimal,
augend.constant.alias.de_weekday, augend.integer.alias.hex,
augend.constant.alias.bool, augend.semver.alias.semver, augend.date.alias["%Y/%m/%d"],
augend.constant.alias.Alpha, augend.constant.alias.alpha, augend.date.alias["%Y-%m-%d"],
augend.hexcolor.new { case = "lower" }, augend.constant.new { augend.date.alias["%m/%d"],
elements = { "and", "or" }, augend.date.alias["%H:%M:%S"],
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. augend.date.alias["%H:%M"],
cyclic = true -- "or" is incremented into "and". augend.constant.alias.de_weekday_full,
}, augend.constant.alias.de_weekday,
augend.constant augend.constant.alias.bool,
.new { augend.semver.alias.semver,
elements = { "&&", "||" }, augend.constant.alias.Alpha,
word = false, augend.constant.alias.alpha,
cyclic = true augend.hexcolor.new({ case = "lower" }),
} augend.constant.new({
} elements = { "and", "or" },
} word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
end, cyclic = true, -- "or" is incremented into "and".
event = "VeryLazy" }),
}, { augend.constant.new({
'tommcdo/vim-exchange', -- adds exchange operator with cx. common use: cxiw . on 2 words to switch elements = { "&&", "||" },
event = "VeryLazy" word = false,
}, { cyclic = true,
'junegunn/vim-easy-align', -- Align tables and other alignable things }),
event = "VeryLazy" },
}, { 'edKotinsky/Arduino.nvim', ft = 'arduino', config = true }, -- statusline })
{ end,
'nvim-lualine/lualine.nvim', event = "VeryLazy",
requires = { 'nvim-tree/nvim-web-devicons', config = true }, },
config = function() require('plug._lualine') end {
}, -- writing "tommcdo/vim-exchange", -- adds exchange operator with cx. common use: cxiw . on 2 words to switch
{ 'vim-pandoc/vim-criticmarkup', ft = writing_ft }, { event = "VeryLazy",
'jbyuki/nabla.nvim', },
ft = writing_ft, {
config = function() "junegunn/vim-easy-align", -- Align tables and other alignable things
require('nabla').enable_virt({ autogen = true, silent = true }) event = "VeryLazy",
end },
}, { { "edKotinsky/Arduino.nvim", ft = "arduino", config = true }, -- statusline
'mickael-menu/zk-nvim', {
config = function() require('zk').setup({ picker = "telescope" }) end "nvim-lualine/lualine.nvim",
}, { requires = { "nvim-tree/nvim-web-devicons", config = true },
'andrewferrier/wrapping.nvim', config = function()
config = function() require("plug._lualine")
require('wrapping').setup({ end,
create_keymappings = false, }, -- writing
notify_on_switch = false { "vim-pandoc/vim-criticmarkup", ft = writing_ft },
}) {
end "jbyuki/nabla.nvim",
}, { ft = writing_ft,
'quarto-dev/quarto-nvim', config = function()
dependencies = { require("nabla").enable_virt({ autogen = true, silent = true })
'jmbuhr/otter.nvim', 'neovim/nvim-lspconfig', end,
'vim-pandoc/vim-pandoc-syntax', 'hrsh7th/nvim-cmp', },
'nvim-treesitter/nvim-treesitter' {
}, "mickael-menu/zk-nvim",
config = function() config = function()
require 'quarto'.setup { require("zk").setup({ picker = "telescope" })
lspFeatures = { end,
enabled = true, },
languages = { 'r', 'python', 'julia' }, {
diagnostics = { enabled = true, triggers = { "BufWrite" } }, "andrewferrier/wrapping.nvim",
completion = { enabled = true } config = function()
} require("wrapping").setup({
} create_keymappings = false,
end, notify_on_switch = false,
ft = "quarto" })
}, { end,
"lkhphuc/jupyter-kernel.nvim", },
config = true, {
cmd = "JupyterAttach", "quarto-dev/quarto-nvim",
build = ":UpdateRemotePlugins", dependencies = {
keys = { "jmbuhr/otter.nvim",
{ "neovim/nvim-lspconfig",
"<localleader>ck", "vim-pandoc/vim-pandoc-syntax",
"<Cmd>JupyterInspect<CR>", "hrsh7th/nvim-cmp",
desc = "Inspect object in kernel" "nvim-treesitter/nvim-treesitter",
} },
} config = function()
}, { 'micarmst/vim-spellsync', event = "VeryLazy" }, -- personal dict improvements for git sync require("quarto").setup({
{ 'folke/zen-mode.nvim', config = true, event = "VeryLazy" }, -- provide distraction free writing lspFeatures = {
{ 'folke/twilight.nvim', event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs) enabled = true,
{ languages = { "r", "python", "julia" },
'JellyApple102/easyread.nvim', diagnostics = { enabled = true, triggers = { "BufWrite" } },
config = true, completion = { enabled = true },
ft = writing_ft, },
cmd = 'EasyreadToggle' })
}, -- enable 'speed-reading' mode (bionic reading) end,
{ 'marty-oehme/zettelkasten.nvim', ft = writing_ft, event = "VeryLazy" }, -- simple static markdown linking ft = "quarto",
{ },
"iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files {
build = function() vim.fn["mkdp#util#install"]() end, "lkhphuc/jupyter-kernel.nvim",
ft = writing_ft config = true,
}, -- languages cmd = "JupyterAttach",
{ 'euclidianAce/BetterLua.vim', ft = 'lua' }, -- better syntax highlighting for lua build = ":UpdateRemotePlugins",
{ 'aliou/bats.vim', ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library keys = {
{
"<localleader>ck",
"<Cmd>JupyterInspect<CR>",
desc = "Inspect object in kernel",
},
},
},
{ "micarmst/vim-spellsync", event = "VeryLazy" }, -- personal dict improvements for git sync
{ "folke/zen-mode.nvim", config = true, event = "VeryLazy" }, -- provide distraction free writing
{ "folke/twilight.nvim", event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs)
{
"JellyApple102/easyread.nvim",
config = true,
ft = writing_ft,
cmd = "EasyreadToggle",
}, -- enable 'speed-reading' mode (bionic reading)
{ "marty-oehme/zettelkasten.nvim", ft = writing_ft, event = "VeryLazy" }, -- simple static markdown linking
{
"iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files
build = function()
vim.fn["mkdp#util#install"]()
end,
ft = writing_ft,
}, -- languages
{ "euclidianAce/BetterLua.vim", ft = "lua" }, -- better syntax highlighting for lua
{ "aliou/bats.vim", ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library
-- REPL work -- REPL work
{ {
'WhiteBlackGoose/magma-nvim-goose', "WhiteBlackGoose/magma-nvim-goose",
build = ":UpdateRemotePlugins", build = ":UpdateRemotePlugins",
config = function() config = function()
vim.g.magma_image_provider = "kitty" vim.g.magma_image_provider = "kitty"
vim.g.magma_automatically_open_output = false vim.g.magma_automatically_open_output = false
end end,
}, { },
'echasnovski/mini.nvim', {
version = '*', "echasnovski/mini.nvim",
config = function() require('plug._mini') end version = "*",
}, { config = function()
"akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim require("plug._mini")
config = function() require('plug._toggleterm') end end,
}, },
{ {
"folke/which-key.nvim", "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim
config = function() require("which-key").setup {} end config = function()
}, -- fuzzy matching require("plug._toggleterm")
{ "nvim-telescope/telescope-fzf-native.nvim", build = 'make' }, { end,
"nvim-telescope/telescope.nvim", },
dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" }, {
config = function() require('plug._telescope') end "folke/which-key.nvim",
}, { config = function()
"dense-analysis/neural", require("which-key").setup({})
dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" }, end,
config = function() }, -- fuzzy matching
require('neural').setup({ { "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
source = { openai = { api_key = vim.env.OPENAI_API_KEY } } {
}) "nvim-telescope/telescope.nvim",
end dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" },
}, -- treesitter config = function()
{ require("plug._telescope")
'nvim-treesitter/nvim-treesitter', end,
build = ':TSUpdate', },
config = function() require('plug._treesitter') end, {
event = "BufReadPre", "dense-analysis/neural",
-- rainbow brackets using treesitter dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" },
-- show current cursor context at top of buffer config = function()
-- improves commenting plugin above by using ts require("neural").setup({
dependencies = { source = { openai = { api_key = vim.env.OPENAI_API_KEY } },
'https://gitlab.com/HiPhish/nvim-ts-rainbow2.git', })
{ 'romgrk/nvim-treesitter-context', config = true }, end,
'JoosepAlviste/nvim-ts-context-commentstring' }, -- treesitter
} {
}, { 'nvim-treesitter/playground', cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree "nvim-treesitter/nvim-treesitter",
{ build = ":TSUpdate",
'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches config = function()
config = function() require("plug._treesitter")
require 'nvim-treesitter.configs'.setup { end,
textsubjects = { event = "BufReadPre",
enable = true, -- rainbow brackets using treesitter
keymaps = { -- show current cursor context at top of buffer
['.'] = 'textsubjects-smart', -- improves commenting plugin above by using ts
[';'] = 'textsubjects-container-outer' dependencies = {
} "https://gitlab.com/HiPhish/nvim-ts-rainbow2.git",
} { "romgrk/nvim-treesitter-context", config = true },
} "JoosepAlviste/nvim-ts-context-commentstring",
end, },
event = "BufReadPre" },
}, { { "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree
-- lsp {
"VonHeikemen/lsp-zero.nvim", "RRethy/nvim-treesitter-textsubjects", -- allows using . and ; to target treesitter branches
dependencies = { config = function()
{ "neovim/nvim-lspconfig", branch = "master" }, require("nvim-treesitter.configs").setup({
"williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", { textsubjects = {
"hrsh7th/nvim-cmp", enable = true,
branch = "main", keymaps = {
dependencies = { ["."] = "textsubjects-smart",
"andersevenrud/cmp-tmux", "cbarrete/completion-vcard", [";"] = "textsubjects-container-outer",
"f3fora/cmp-spell", "hrsh7th/cmp-nvim-lsp", },
"hrsh7th/cmp-path", "hrsh7th/cmp-buffer", },
"hrsh7th/cmp-calc", "hrsh7th/cmp-cmdline", })
"hrsh7th/cmp-nvim-lua", "dmitmel/cmp-digraphs", end,
"jc-doyle/cmp-pandoc-references", event = "BufReadPre",
"kdheepak/cmp-latex-symbols", "lukas-reineke/cmp-rg", },
"crispgm/cmp-beancount", "ray-x/cmp-treesitter", {
"saadparwaiz1/cmp_luasnip" -- lsp
} "VonHeikemen/lsp-zero.nvim",
}, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets", dependencies = {
-- { "lukas-reineke/lsp-format.nvim", config = true }, { "neovim/nvim-lspconfig", branch = "master" },
{ "j-hui/fidget.nvim", config = true }, -- loading animations for some LSP "williamboman/mason.nvim",
{ "williamboman/mason-lspconfig.nvim",
"jay-babu/mason-null-ls.nvim", {
event = { "BufReadPre", "BufNewFile" }, "hrsh7th/nvim-cmp",
dependencies = { branch = "main",
"williamboman/mason.nvim", "jose-elias-alvarez/null-ls.nvim" dependencies = {
}, "andersevenrud/cmp-tmux",
} "cbarrete/completion-vcard",
}, "f3fora/cmp-spell",
config = function() require('plug._lsp') end, "hrsh7th/cmp-nvim-lsp",
branch = "v2.x" "hrsh7th/cmp-path",
}, { 'simrat39/symbols-outline.nvim', config = true, event = "VeryLazy" }, -- vista-like outline view for code "hrsh7th/cmp-buffer",
{ 'ray-x/lsp_signature.nvim', config = true }, -- UI improvements "hrsh7th/cmp-calc",
{ 'stevearc/dressing.nvim', config = true }, { "hrsh7th/cmp-cmdline",
'rcarriga/nvim-notify', "hrsh7th/cmp-nvim-lua",
config = function() vim.notify = require("notify") end "dmitmel/cmp-digraphs",
} "jc-doyle/cmp-pandoc-references",
-- { -- REQUIRES custom `yay -S --asdeps lua51-lyaml invocation` AND is suuper slow "kdheepak/cmp-latex-symbols",
-- "jghauser/papis.nvim", "lukas-reineke/cmp-rg",
-- after = { "telescope.nvim", "nvim-cmp" }, "crispgm/cmp-beancount",
-- dependencies = { "ray-x/cmp-treesitter",
-- "kkharji/sqlite.lua", "nvim-lua/plenary.nvim", "saadparwaiz1/cmp_luasnip",
-- "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter" },
-- }, },
-- ft = writing_ft, "L3MON4D3/LuaSnip",
-- rocks = { "lyaml" }, "rafamadriz/friendly-snippets",
-- config = function() -- { "lukas-reineke/lsp-format.nvim", config = true },
-- require('papis').setup({ { "j-hui/fidget.nvim", config = true }, -- loading animations for some LSP
-- papis_python = { {
-- dir = "/home/marty/documents/library/academia", "jay-babu/mason-null-ls.nvim",
-- info_name = "info.yaml", event = { "BufReadPre", "BufNewFile" },
-- notes_name = [[notes.qmd]] dependencies = {
-- } "williamboman/mason.nvim",
-- }) "jose-elias-alvarez/null-ls.nvim",
-- end },
-- } },
},
config = function()
require("plug._lsp")
end,
branch = "v2.x",
},
{ "simrat39/symbols-outline.nvim", config = true, event = "VeryLazy" }, -- vista-like outline view for code
{ "ray-x/lsp_signature.nvim", config = true }, -- UI improvements
{ "stevearc/dressing.nvim", config = true },
{
"rcarriga/nvim-notify",
config = function()
vim.notify = require("notify")
end,
},
-- { -- REQUIRES custom `yay -S --asdeps lua51-lyaml invocation` AND is suuper slow
-- "jghauser/papis.nvim",
-- after = { "telescope.nvim", "nvim-cmp" },
-- dependencies = {
-- "kkharji/sqlite.lua", "nvim-lua/plenary.nvim",
-- "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter"
-- },
-- ft = writing_ft,
-- rocks = { "lyaml" },
-- config = function()
-- require('papis').setup({
-- papis_python = {
-- dir = "/home/marty/documents/library/academia",
-- info_name = "info.yaml",
-- notes_name = [[notes.qmd]]
-- }
-- })
-- end
-- }
} }

View file

@ -1,68 +1,70 @@
local default_builtins_disabled = { "netrw", "netrwPlugin" } local default_builtins_disabled = { "netrw", "netrwPlugin" }
local disable_builtins = function(builtins) local disable_builtins = function(builtins)
for _, plugin in pairs(builtins) do vim.g["loaded_" .. plugin] = 1 end for _, plugin in pairs(builtins) do
vim.g["loaded_" .. plugin] = 1
end
end end
local o = { local o = {
termguicolors = true, termguicolors = true,
-- sets tabs to be 2 characters, expanded into spaces, but still removable with -- sets tabs to be 2 characters, expanded into spaces, but still removable with
-- one press of backspace. -- one press of backspace.
-- great explanation: http://vimcasts.org/transcripts/2/en/ -- great explanation: http://vimcasts.org/transcripts/2/en/
tabstop = 4, tabstop = 4,
shiftwidth = 4, shiftwidth = 4,
softtabstop = 4, softtabstop = 4,
expandtab = true, expandtab = true,
-- make jumplist behave more like browser, when jumping back -- make jumplist behave more like browser, when jumping back
-- and then adding a new jump discards all the previous -- and then adding a new jump discards all the previous
-- 'future-jump' tree, making more sense for wiki-like movement -- 'future-jump' tree, making more sense for wiki-like movement
jumpoptions = 'stack', jumpoptions = "stack",
-- set cursor line highlighting, esp useful when using with bracket -- set cursor line highlighting, esp useful when using with bracket
-- highlighting and you don't know which side of the brace the cursor is on -- highlighting and you don't know which side of the brace the cursor is on
cursorline = true, cursorline = true,
-- shows linenumbers relative to the one you are on, for easy movement and -- shows linenumbers relative to the one you are on, for easy movement and
-- dNUMBERd deletions -- dNUMBERd deletions
number = true, number = true,
relativenumber = true, relativenumber = true,
-- puts the numbers into the signcolumn so when git/lsp show signs there's no jump -- puts the numbers into the signcolumn so when git/lsp show signs there's no jump
signcolumn = 'number', signcolumn = "number",
-- keeps an undofile next to files so that you can even undo if vim is closed -- keeps an undofile next to files so that you can even undo if vim is closed
-- in between -- in between
undofile = true, undofile = true,
-- TODO o.undodir = '~/.cache/nvim/undodir' -- TODO o.undodir = '~/.cache/nvim/undodir'
-- ignores case by default but will use case when search is specifically not -- ignores case by default but will use case when search is specifically not
-- all lowercased -- all lowercased
ignorecase = true, ignorecase = true,
smartcase = true, smartcase = true,
-- shows previews of what substitute command will do (and a couple others) -- shows previews of what substitute command will do (and a couple others)
inccommand = 'split', inccommand = "split",
-- disables showing us the current mode in the command line since airline takes -- disables showing us the current mode in the command line since airline takes
-- care of it -- care of it
showmode = false, showmode = false,
-- turn off modeline, to ensure security observation -- turn off modeline, to ensure security observation
modeline = false, modeline = false,
-- i feel foldlevel 2 is generally pretty usable, for headlines and similar -- i feel foldlevel 2 is generally pretty usable, for headlines and similar
-- set to use treesitter in treesitter config -- set to use treesitter in treesitter config
foldlevel = 2, foldlevel = 2,
conceallevel = 2, conceallevel = 2,
-- enable mouse, doesn't bug me and might come in useful at some point -- enable mouse, doesn't bug me and might come in useful at some point
mouse = 'a', mouse = "a",
-- pump all clippings into the system clipboard -- pump all clippings into the system clipboard
clipboard = 'unnamedplus', clipboard = "unnamedplus",
-- turn of automatic resizing of individual splits -- turn of automatic resizing of individual splits
equalalways = false, equalalways = false,
-- make sure there's always *some* context below cursor -- make sure there's always *some* context below cursor
scrolloff = 4, scrolloff = 4,
-- open new buffers bottomright -- open new buffers bottomright
splitright = true, splitright = true,
splitbelow = true, splitbelow = true,
-- remove command line if no command is currently present -- remove command line if no command is currently present
cmdheight = 0, cmdheight = 0,
} }
for k, v in pairs(o) do for k, v in pairs(o) do
vim.opt[k] = v vim.opt[k] = v
end end
vim.api.nvim_set_var('tex_flavor', 'latex') vim.api.nvim_set_var("tex_flavor", "latex")
disable_builtins(default_builtins_disabled) disable_builtins(default_builtins_disabled)

View file

@ -3,15 +3,15 @@
-- usage example - italicize comments: -- usage example - italicize comments:
-- set_hl("Comment", { gui = "italic" }) -- set_hl("Comment", { gui = "italic" })
return function(group, options) return function(group, options)
local bg = options.bg == nil and "" or "guibg=" .. options.bg local bg = options.bg == nil and "" or "guibg=" .. options.bg
local fg = options.fg == nil and "" or "guifg=" .. options.fg local fg = options.fg == nil and "" or "guifg=" .. options.fg
local gui = options.gui == nil and "" or "gui=" .. options.gui local gui = options.gui == nil and "" or "gui=" .. options.gui
local link = options.link or false local link = options.link or false
local target = options.target local target = options.target
if not link then if not link then
vim.cmd(string.format("hi %s %s %s %s", group, bg, fg, gui)) vim.cmd(string.format("hi %s %s %s %s", group, bg, fg, gui))
else else
vim.cmd(string.format("hi! link", group, target)) vim.cmd(string.format("hi! link", group, target))
end end
end end

View file

@ -1,45 +1,42 @@
local util = require('lspconfig/util') local util = require("lspconfig/util")
local path = util.path local path = util.path
local T = {} local T = {}
local exepath = vim.fn.exepath local exepath = vim.fn.exepath
local path_sep = function() local path_sep = function()
local is_win = vim.loop.os_uname().sysname:find('Windows') local is_win = vim.loop.os_uname().sysname:find("Windows")
if is_win then if is_win then
return '\\' return "\\"
else else
return '/' return "/"
end end
end end
-- from https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677 -- from https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677
T.get_path = function(workspace) T.get_path = function(workspace)
-- Use activated virtualenv. -- Use activated virtualenv.
if vim.env.VIRTUAL_ENV then if vim.env.VIRTUAL_ENV then
return path.join(vim.env.VIRTUAL_ENV, 'bin', 'python'), 'virtual env' return path.join(vim.env.VIRTUAL_ENV, "bin", "python"), "virtual env"
end end
-- Find and use virtualenv in workspace directory. -- Find and use virtualenv in workspace directory.
for _, pattern in ipairs({ '*', '.*' }) do for _, pattern in ipairs({ "*", ".*" }) do
local match = vim.fn.glob(path.join(workspace, pattern, 'pyvenv.cfg')) local match = vim.fn.glob(path.join(workspace, pattern, "pyvenv.cfg"))
local sep = path_sep() local sep = path_sep()
local py = 'bin' .. sep .. 'python' local py = "bin" .. sep .. "python"
if match ~= '' then if match ~= "" then
match = string.gsub(match, 'pyvenv.cfg', py) match = string.gsub(match, "pyvenv.cfg", py)
return match, string.format('venv base folder: %s', match) return match, string.format("venv base folder: %s", match)
end end
match = vim.fn.glob(path.join(workspace, pattern, 'poetry.lock')) match = vim.fn.glob(path.join(workspace, pattern, "poetry.lock"))
if match ~= '' then if match ~= "" then
local venv_base_folder = vim.fn.trim(vim.fn.system( local venv_base_folder = vim.fn.trim(vim.fn.system("poetry env info -p"))
'poetry env info -p')) return path.join(venv_base_folder, "bin", "python"), string.format("venv base folder: %s", venv_base_folder)
return path.join(venv_base_folder, 'bin', 'python'), end
string.format('venv base folder: %s', venv_base_folder) end
end
end
-- Fallback to system Python. -- Fallback to system Python.
return exepath('python3') or exepath('python') or 'python', return exepath("python3") or exepath("python") or "python", "fallback to system python path"
'fallback to system python path'
end end
return T return T

View file

@ -1,15 +1,13 @@
local accounts = {} local accounts = {}
local _, gmailuser = pipe_from( local _, gmailuser = pipe_from("pass show misc/gmail-app-password | grep username | cut -d: -f2")
'pass show misc/gmail-app-password | grep username | cut -d: -f2') local _, gmailpass = pipe_from("pass show misc/gmail-app-password | head -n1")
local _, gmailpass = pipe_from(
'pass show misc/gmail-app-password | head -n1')
-- Setup an imap account called gmail -- Setup an imap account called gmail
accounts.gmail = IMAP { accounts.gmail = IMAP({
server = "imap.gmail.com", server = "imap.gmail.com",
username = gmailuser, username = gmailuser,
password = gmailpass, password = gmailpass,
ssl = "auto" ssl = "auto",
} })
return accounts return accounts

View file

@ -20,67 +20,64 @@ CONTINUOUS = false
UPDATE_TIME = 120 UPDATE_TIME = 120
-- implement simple wait function in case server does not support IDLE mode -- implement simple wait function in case server does not support IDLE mode
function sleep(n) os.execute("sleep " .. tonumber(n)) end function sleep(n)
os.execute("sleep " .. tonumber(n))
end
-- will set filters to be grabbed from XDG-compliant filter directory -- will set filters to be grabbed from XDG-compliant filter directory
-- can be overridden with env var IMAPFILTER_FILTERDIR -- can be overridden with env var IMAPFILTER_FILTERDIR
function getConfigDir() function getConfigDir()
-- -- set directory for imapfilter files -- -- set directory for imapfilter files
local configdir local configdir
if os.getenv("IMAPFILTER_CONFIGDIR") then if os.getenv("IMAPFILTER_CONFIGDIR") then
configdir = os.getenv("IMAPFILTER_CONFIGDIR") configdir = os.getenv("IMAPFILTER_CONFIGDIR")
elseif os.getenv("XDG_CONFIG_HOME") then elseif os.getenv("XDG_CONFIG_HOME") then
configdir = os.getenv("XDG_CONFIG_HOME") .. "/imapfilter" configdir = os.getenv("XDG_CONFIG_HOME") .. "/imapfilter"
else else
configdir = os.getenv("HOME") .. "/.config/imapfilter" configdir = os.getenv("HOME") .. "/.config/imapfilter"
end end
return configdir return configdir
end end
-- will set filters to be grabbed from XDG-compliant filter directory -- will set filters to be grabbed from XDG-compliant filter directory
-- can be overridden with env var IMAPFILTER_FILTERDIR -- can be overridden with env var IMAPFILTER_FILTERDIR
function getFilterDir() function getFilterDir()
-- -- set directory for imapfilter files -- -- set directory for imapfilter files
local imapfilterdir local imapfilterdir
if os.getenv("IMAPFILTER_FILTERDIR") then if os.getenv("IMAPFILTER_FILTERDIR") then
imapfilterdir = os.getenv("IMAPFILTER_FILTERDIR") imapfilterdir = os.getenv("IMAPFILTER_FILTERDIR")
else else
imapfilterdir = configDir .. "/filters" imapfilterdir = configDir .. "/filters"
end end
return imapfilterdir return imapfilterdir
end end
-- dirlist, from https://stackoverflow.com/a/25266573 -- dirlist, from https://stackoverflow.com/a/25266573
function applyFilters(dir) function applyFilters(dir)
local p = io.popen('find "' .. dir .. '" -type f -name "*.lua"') -- Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files. local p = io.popen('find "' .. dir .. '" -type f -name "*.lua"') -- Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files.
for file in p:lines() do -- Loop through all files for file in p:lines() do -- Loop through all files
loadfile(file)() loadfile(file)()
end end
end end
-- create global variable containing the configuration files -- create global variable containing the configuration files
configDir = getConfigDir() configDir = getConfigDir()
assert(configDir, assert(configDir, "No configuration directory found. Ensure " .. os.getenv("HOME") .. "/.config/imapfilter exists.")
"No configuration directory found. Ensure " .. os.getenv("HOME") ..
"/.config/imapfilter exists.")
-- create global variable containing account access -- create global variable containing account access
accounts = loadfile(configDir .. "/accounts.lua")() accounts = loadfile(configDir .. "/accounts.lua")()
assert(accounts, assert(accounts, "No accounts configured. Ensure accounts.lua exists and returns a table of accounts.")
"No accounts configured. Ensure accounts.lua exists and returns a table of accounts.")
-- immediately act on the filters once -- immediately act on the filters once
applyFilters(getFilterDir()) applyFilters(getFilterDir())
-- continuously watch for mail if needed -- continuously watch for mail if needed
while CONTINUOUS == true do while CONTINUOUS == true do
local has_idle = accounts.gmail['Inbox']:enter_idle() local has_idle = accounts.gmail["Inbox"]:enter_idle()
applyFilters(getFilterDir()) applyFilters(getFilterDir())
if has_idle == false then if has_idle == false then
print( print("Server does not support idle, application will be polling again in " .. UPDATE_TIME .. "minutes.")
"Server does not support idle, application will be polling again in " .. sleep(UPDATE_TIME)
UPDATE_TIME .. "minutes.") end
sleep(UPDATE_TIME)
end
end end

View file

@ -1,40 +1,39 @@
function sendToFolder(folderFrom, folderTo, senders) function sendToFolder(folderFrom, folderTo, senders)
local messages = folderFrom:select_all() local messages = folderFrom:select_all()
for _, sender in pairs(senders) do for _, sender in pairs(senders) do
local filtered = messages:contain_from(sender) local filtered = messages:contain_from(sender)
filtered:mark_seen() filtered:mark_seen()
filtered:move_messages(folderTo) filtered:move_messages(folderTo)
end end
end end
-- will set filters to be grabbed from XDG-compliant filter directory -- will set filters to be grabbed from XDG-compliant filter directory
-- can be overridden with env var IMAPFILTER_ROLLUPFILE -- can be overridden with env var IMAPFILTER_ROLLUPFILE
function getRollupFile(fname) function getRollupFile(fname)
local f local f
local fname = fname or "rollup.txt" local fname = fname or "rollup.txt"
if os.getenv("IMAPFILTER_ROLLUPFILE") then if os.getenv("IMAPFILTER_ROLLUPFILE") then
f = os.getenv("IMAPFILTER_ROLLUPFILE") f = os.getenv("IMAPFILTER_ROLLUPFILE")
elseif os.getenv("XDG_DATA_HOME") then elseif os.getenv("XDG_DATA_HOME") then
f = os.getenv("XDG_DATA_HOME") .. "/imapfilter/" .. fname f = os.getenv("XDG_DATA_HOME") .. "/imapfilter/" .. fname
else else
f = os.getenv("HOME") .. "/.local/share/imapfilter/" .. fname f = os.getenv("HOME") .. "/.local/share/imapfilter/" .. fname
end end
return f return f
end end
function getSenderList(rollupfile) function getSenderList(rollupfile)
local rollupSenders = {} local rollupSenders = {}
local file = io.open(rollupfile) local file = io.open(rollupfile)
if file then if file then
for line in file:lines() do table.insert(rollupSenders, line) end for line in file:lines() do
else table.insert(rollupSenders, line)
print( end
"rollup did not find rollup.txt file containing mail addresses at " .. else
rollupfile or ". Skipping.") print("rollup did not find rollup.txt file containing mail addresses at " .. rollupfile or ". Skipping.")
end end
return rollupSenders return rollupSenders
end end
sendToFolder(accounts.gmail["Inbox"], accounts.gmail["Dump"], sendToFolder(accounts.gmail["Inbox"], accounts.gmail["Dump"], getSenderList(getRollupFile()))
getSenderList(getRollupFile()))

View file

@ -1,75 +1,81 @@
local wezterm = require 'wezterm' local wezterm = require("wezterm")
local io = require 'io' local io = require("io")
local os = require 'os' local os = require("os")
local act = wezterm.action local act = wezterm.action
local function setup() local function setup()
local function isViProcess(pane) local function isViProcess(pane)
return pane:get_foreground_process_name():find('n?vim') ~= nil return pane:get_foreground_process_name():find("n?vim") ~= nil
end end
local function conditionalActivatePane(window, pane, pane_direction, local function conditionalActivatePane(window, pane, pane_direction, vim_direction)
vim_direction) if isViProcess(pane) then
if (isViProcess(pane)) then window:perform_action(
window:perform_action(act.Multiple { act.Multiple({
act.SendKey { key = 'w', mods = 'CTRL' }, act.SendKey({ key = "w", mods = "CTRL" }),
act.SendKey { key = vim_direction } act.SendKey({ key = vim_direction }),
}, pane) }),
else pane
window:perform_action(act.ActivatePaneDirection(pane_direction), )
pane) else
end window:perform_action(act.ActivatePaneDirection(pane_direction), pane)
end end
end
wezterm.on('ActivatePaneDirection-right', function(window, pane) wezterm.on("ActivatePaneDirection-right", function(window, pane)
conditionalActivatePane(window, pane, 'Right', 'l') conditionalActivatePane(window, pane, "Right", "l")
end) end)
wezterm.on('ActivatePaneDirection-left', function(window, pane) wezterm.on("ActivatePaneDirection-left", function(window, pane)
conditionalActivatePane(window, pane, 'Left', 'h') conditionalActivatePane(window, pane, "Left", "h")
end) end)
wezterm.on('ActivatePaneDirection-up', function(window, pane) wezterm.on("ActivatePaneDirection-up", function(window, pane)
conditionalActivatePane(window, pane, 'Up', 'k') conditionalActivatePane(window, pane, "Up", "k")
end) end)
wezterm.on('ActivatePaneDirection-down', function(window, pane) wezterm.on("ActivatePaneDirection-down", function(window, pane)
conditionalActivatePane(window, pane, 'Down', 'j') conditionalActivatePane(window, pane, "Down", "j")
end) end)
-- Retrieve the current scrollback text and send to editor -- Retrieve the current scrollback text and send to editor
wezterm.on('edit-scrollback', function(window, pane) wezterm.on("edit-scrollback", function(window, pane)
local viewport_text = pane:get_lines_as_text(10000) local viewport_text = pane:get_lines_as_text(10000)
-- Create a temporary file to pass to vim -- Create a temporary file to pass to vim
local name = os.tmpname() local name = os.tmpname()
local f = io.open(name, 'w+') local f = io.open(name, "w+")
if f == nil then return false end if f == nil then
f:write(viewport_text) return false
f:flush() end
f:close() f:write(viewport_text)
f:flush()
f:close()
-- Open a new window running vim and tell it to open the file -- Open a new window running vim and tell it to open the file
window:perform_action(act.SpawnCommandInNewTab { window:perform_action(
args = { (os.getenv('EDITOR') or 'vi'), name } act.SpawnCommandInNewTab({
}, pane) args = { (os.getenv("EDITOR") or "vi"), name },
}),
pane
)
-- Wait time for vim to read the file before we remove it. -- Wait time for vim to read the file before we remove it.
wezterm.sleep_ms(1000) wezterm.sleep_ms(1000)
os.remove(name) os.remove(name)
end) end)
wezterm.on("toggle-leader", function(window, pane) wezterm.on("toggle-leader", function(window, pane)
wezterm.log_info("toggling the leader") wezterm.log_info("toggling the leader")
local overrides = window:get_config_overrides() or {} local overrides = window:get_config_overrides() or {}
if not overrides.leader then if not overrides.leader then
wezterm.log_info("leader wasn't set") wezterm.log_info("leader wasn't set")
overrides.leader = { key = "s", mods = "SUPER" }; overrides.leader = { key = "s", mods = "SUPER" }
else else
wezterm.log_info("leader was set") wezterm.log_info("leader was set")
overrides.leader = nil overrides.leader = nil
end end
window:set_config_overrides(overrides) window:set_config_overrides(overrides)
end) end)
end end
return { setup = setup } return { setup = setup }

View file

@ -1,127 +1,137 @@
local wezterm = require('wezterm') local wezterm = require("wezterm")
local act = wezterm.action local act = wezterm.action
local keys = { local keys = {
{ key = 'O', mods = 'CTRL', action = act.ShowDebugOverlay }, { key = "O", mods = "CTRL", action = act.ShowDebugOverlay },
{ key = '[', mods = 'CTRL', action = act.ScrollToPrompt(-1) },
{ key = ']', mods = 'CTRL', action = act.ScrollToPrompt(1) },
{ -- vertical pane
key = '\\',
mods = 'LEADER',
action = act.SplitHorizontal { domain = 'CurrentPaneDomain' }
}, { -- horizontal pane
key = '-',
mods = 'LEADER',
action = act.SplitVertical { domain = 'CurrentPaneDomain' }
}, -- pane movement keys
{
key = 'h',
mods = 'CTRL',
action = act.EmitEvent 'ActivatePaneDirection-left'
},
{
key = 'j',
mods = 'CTRL',
action = act.EmitEvent 'ActivatePaneDirection-down'
},
{
key = 'k',
mods = 'CTRL',
action = act.EmitEvent 'ActivatePaneDirection-up'
}, {
key = 'l',
mods = 'CTRL',
action = act.EmitEvent 'ActivatePaneDirection-right'
}, { key = 'z', mods = 'LEADER', action = act.TogglePaneZoomState },
{ key = ' ', mods = 'LEADER', action = act.RotatePanes 'Clockwise' },
{ key = 'q', mods = 'LEADER', action = act.PaneSelect { mode = 'Activate' } },
{
key = 'Q',
mods = 'LEADER',
action = act.PaneSelect { mode = 'SwapWithActive' }
}, { key = 'c', mods = 'LEADER', action = act.SpawnTab 'CurrentPaneDomain' },
{ key = ',', mods = 'LEADER', action = act.MoveTabRelative(-1) },
{ key = '.', mods = 'LEADER', action = act.MoveTabRelative(1) }, -- workspace selection
{
key = 's',
mods = 'LEADER',
action = act.ShowLauncherArgs { flags = 'FUZZY|WORKSPACES' }
}, { key = 't', mods = 'LEADER', action = act.ShowTabNavigator },
{ key = '[', mods = 'LEADER', action = act.ActivateCopyMode }, {
key = 'r',
mods = 'LEADER',
action = act.ActivateKeyTable {
name = 'resize_pane',
one_shot = false,
timeout_milliseconds = 2000,
replace_current = true
}
}, { key = 'f', mods = 'LEADER', action = act.QuickSelect }, {
key = 'F',
mods = 'LEADER',
action = wezterm.action.QuickSelectArgs {
patterns = { "https?://\\S+" },
action = wezterm.action_callback(
function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info("opening: " .. url)
wezterm.open_with(url)
end)
}
}, {
key = '/',
mods = 'LEADER',
action = act.Search('CurrentSelectionOrEmptyString')
}, {
key = 'b',
mods = 'LEADER',
action = act.ActivateKeyTable {
name = 'scroll_mode',
one_shot = false,
replace_current = true,
timeout_milliseconds = 15000
}
}, { key = 'e', mods = 'LEADER', action = act.EmitEvent 'edit-scrollback' },
{
key = 'l',
mods = 'LEADER',
action = act.EmitEvent 'ActivatePaneDirection-Right'
}, { key = 'a', mods = 'CTRL|ALT', action = act.EmitEvent 'toggle-leader' }
{ key = "[", mods = "CTRL", action = act.ScrollToPrompt(-1) },
{ key = "]", mods = "CTRL", action = act.ScrollToPrompt(1) },
{ -- vertical pane
key = "\\",
mods = "LEADER",
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
},
{ -- horizontal pane
key = "-",
mods = "LEADER",
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
}, -- pane movement keys
{
key = "h",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-left"),
},
{
key = "j",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-down"),
},
{
key = "k",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-up"),
},
{
key = "l",
mods = "CTRL",
action = act.EmitEvent("ActivatePaneDirection-right"),
},
{ key = "z", mods = "LEADER", action = act.TogglePaneZoomState },
{ key = " ", mods = "LEADER", action = act.RotatePanes("Clockwise") },
{ key = "q", mods = "LEADER", action = act.PaneSelect({ mode = "Activate" }) },
{
key = "Q",
mods = "LEADER",
action = act.PaneSelect({ mode = "SwapWithActive" }),
},
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
{ key = ",", mods = "LEADER", action = act.MoveTabRelative(-1) },
{ key = ".", mods = "LEADER", action = act.MoveTabRelative(1) }, -- workspace selection
{
key = "s",
mods = "LEADER",
action = act.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }),
},
{ key = "t", mods = "LEADER", action = act.ShowTabNavigator },
{ key = "[", mods = "LEADER", action = act.ActivateCopyMode },
{
key = "r",
mods = "LEADER",
action = act.ActivateKeyTable({
name = "resize_pane",
one_shot = false,
timeout_milliseconds = 2000,
replace_current = true,
}),
},
{ key = "f", mods = "LEADER", action = act.QuickSelect },
{
key = "F",
mods = "LEADER",
action = wezterm.action.QuickSelectArgs({
patterns = { "https?://\\S+" },
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info("opening: " .. url)
wezterm.open_with(url)
end),
}),
},
{
key = "/",
mods = "LEADER",
action = act.Search("CurrentSelectionOrEmptyString"),
},
{
key = "b",
mods = "LEADER",
action = act.ActivateKeyTable({
name = "scroll_mode",
one_shot = false,
replace_current = true,
timeout_milliseconds = 15000,
}),
},
{ key = "e", mods = "LEADER", action = act.EmitEvent("edit-scrollback") },
{
key = "l",
mods = "LEADER",
action = act.EmitEvent("ActivatePaneDirection-Right"),
},
{ key = "a", mods = "CTRL|ALT", action = act.EmitEvent("toggle-leader") },
} }
-- Leader + number to activate that tab -- Leader + number to activate that tab
for i = 1, 8 do for i = 1, 8 do
table.insert(keys, { table.insert(keys, {
key = tostring(i), key = tostring(i),
mods = 'LEADER', mods = "LEADER",
action = act.ActivateTab(i - 1) action = act.ActivateTab(i - 1),
}) })
end end
-- key table sub modes -- key table sub modes
local key_tables = { local key_tables = {
-- mode to change size of any panes -- mode to change size of any panes
resize_pane = { resize_pane = {
{ key = 'h', action = act.AdjustPaneSize { 'Left', 1 } }, { key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = 'l', action = act.AdjustPaneSize { 'Right', 1 } }, { key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = 'k', action = act.AdjustPaneSize { 'Up', 1 } }, { key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = 'j', action = act.AdjustPaneSize { 'Down', 1 } }, { key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = 'H', action = act.AdjustPaneSize { 'Left', 10 } }, { key = "H", action = act.AdjustPaneSize({ "Left", 10 }) },
{ key = 'L', action = act.AdjustPaneSize { 'Right', 10 } }, { key = "L", action = act.AdjustPaneSize({ "Right", 10 }) },
{ key = 'K', action = act.AdjustPaneSize { 'Up', 10 } }, { key = "K", action = act.AdjustPaneSize({ "Up", 10 }) },
{ key = 'J', action = act.AdjustPaneSize { 'Down', 10 } }, { key = "J", action = act.AdjustPaneSize({ "Down", 10 }) },
{ key = 'Escape', action = 'PopKeyTable' } { key = "Escape", action = "PopKeyTable" },
}, },
scroll_mode = { scroll_mode = {
{ key = 'y', mods = 'CTRL', action = act.ScrollByLine(-1) }, { key = "y", mods = "CTRL", action = act.ScrollByLine(-1) },
{ key = 'e', mods = 'CTRL', action = act.ScrollByLine(1) }, { key = "e", mods = "CTRL", action = act.ScrollByLine(1) },
{ key = 'f', mods = 'CTRL', action = act.ScrollByPage(1) }, { key = "f", mods = "CTRL", action = act.ScrollByPage(1) },
{ key = 'b', mods = 'CTRL', action = act.ScrollByPage(-1) }, { key = "b", mods = "CTRL", action = act.ScrollByPage(-1) },
{ key = 'd', mods = 'CTRL', action = act.ScrollByPage(0.5) }, { key = "d", mods = "CTRL", action = act.ScrollByPage(0.5) },
{ key = 'u', mods = 'CTRL', action = act.ScrollByPage(-0.5) }, { key = "u", mods = "CTRL", action = act.ScrollByPage(-0.5) },
{ key = 'g', mods = 'CTRL', action = act.ScrollToTop }, { key = "g", mods = "CTRL", action = act.ScrollToTop },
{ key = 'G', mods = 'CTRL', action = act.ScrollToBottom }, { key = "G", mods = "CTRL", action = act.ScrollToBottom },
{ key = 'Escape', action = 'PopKeyTable' } { key = "Escape", action = "PopKeyTable" },
} },
} }
return { keys = keys, key_tables = key_tables } return { keys = keys, key_tables = key_tables }

View file

@ -1,46 +1,47 @@
local wezterm = require 'wezterm' local wezterm = require("wezterm")
local function basename(s) return string.gsub(s or '', '(.*[/\\])(.*)', '%2') end local function basename(s)
return string.gsub(s or "", "(.*[/\\])(.*)", "%2")
end
local SEPARATOR = ' | ' local SEPARATOR = " | "
local function setup() local function setup()
-- STATUSBAR -- STATUSBAR
-- show currently active key table in lower right status bar -- show currently active key table in lower right status bar
-- mimicing Vim modes -- mimicing Vim modes
wezterm.on('update-status', function(window, pane) wezterm.on("update-status", function(window, pane)
local displayed = { left = {}, right = {} } local displayed = { left = {}, right = {} }
local keytable = window:active_key_table() local keytable = window:active_key_table()
if keytable then if keytable then
displayed.left[#displayed.left + 1] = 'MODE: ' .. keytable displayed.left[#displayed.left + 1] = "MODE: " .. keytable
end end
local workspace = window:active_workspace() local workspace = window:active_workspace()
if workspace and workspace ~= 'default' then if workspace and workspace ~= "default" then
displayed.left[#displayed.left + 1] = 'WORKSPACE: ' .. workspace displayed.left[#displayed.left + 1] = "WORKSPACE: " .. workspace
end end
local bat = '' local bat = ""
for _, b in ipairs(wezterm.battery_info()) do for _, b in ipairs(wezterm.battery_info()) do
bat = '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) .. bat = "🔋 " .. string.format("%.0f%%", b.state_of_charge * 100) .. " " .. b.state
' ' .. b.state end
end displayed.right[#displayed.right + 1] = bat
displayed.right[#displayed.right + 1] = bat
local currentprogram = pane:get_foreground_process_name() local currentprogram = pane:get_foreground_process_name()
displayed.right[#displayed.right + 1] = basename(currentprogram) displayed.right[#displayed.right + 1] = basename(currentprogram)
local statusleft = '' local statusleft = ""
for _, v in ipairs(displayed.left) do for _, v in ipairs(displayed.left) do
statusleft = statusleft .. v .. SEPARATOR statusleft = statusleft .. v .. SEPARATOR
end end
local statusright = '' local statusright = ""
for _, v in ipairs(displayed.right) do for _, v in ipairs(displayed.right) do
statusright = statusright .. v .. SEPARATOR statusright = statusright .. v .. SEPARATOR
end end
window:set_left_status(statusleft or '') window:set_left_status(statusleft or "")
window:set_right_status(statusright or '') window:set_right_status(statusright or "")
end) end)
end end
return { setup = setup } return { setup = setup }

View file

@ -1,82 +1,78 @@
local wezterm = require 'wezterm' local wezterm = require("wezterm")
local maps = require 'maps' local maps = require("maps")
require 'statusbar'.setup() require("statusbar").setup()
require 'events'.setup() require("events").setup()
local function file_exists(name) local function file_exists(name)
local f = io.open(name, "r") local f = io.open(name, "r")
if f ~= nil then if f ~= nil then
io.close(f) io.close(f)
return true return true
else else
return false return false
end end
end end
-- automatically reload colors file -- automatically reload colors file
local colorsfile = (os.getenv('XDG_STATE_HOME') or local colorsfile = (os.getenv("XDG_STATE_HOME") or (os.getenv("HOME") .. "/.local/state")) .. "/wezterm/colors.toml"
(os.getenv('HOME') .. '/.local/state')) ..
'/wezterm/colors.toml'
local colors = {} local colors = {}
if file_exists(colorsfile) == true then if file_exists(colorsfile) == true then
wezterm.add_to_config_reload_watch_list(colorsfile) wezterm.add_to_config_reload_watch_list(colorsfile)
colors = wezterm.color.load_scheme(colorsfile) colors = wezterm.color.load_scheme(colorsfile)
end end
local settings = { local settings = {
enable_wayland = true, enable_wayland = true,
hide_tab_bar_if_only_one_tab = true, hide_tab_bar_if_only_one_tab = true,
use_fancy_tab_bar = false, use_fancy_tab_bar = false,
tab_bar_at_bottom = true, tab_bar_at_bottom = true,
window_padding = { left = 0, right = 0, top = 0, bottom = 0 }, window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
colors = colors, colors = colors,
color_scheme = "Nord (base16)", -- will be overwritten by colors color_scheme = "Nord (base16)", -- will be overwritten by colors
-- default_prog = {"nu"}, -- default_prog = {"nu"},
scrollback_lines = 10000, scrollback_lines = 10000,
font = wezterm.font('Iosevka Nerd Font'), font = wezterm.font("Iosevka Nerd Font"),
-- add cursive italic font from Victor font for all weights -- add cursive italic font from Victor font for all weights
font_rules = { font_rules = {
{ {
intensity = 'Bold', intensity = "Bold",
italic = true, italic = true,
font = wezterm.font { font = wezterm.font({
family = 'VictorMono Nerd Font', family = "VictorMono Nerd Font",
weight = 'Bold', weight = "Bold",
style = 'Italic', style = "Italic",
}, }),
}, },
{ {
italic = true, italic = true,
intensity = 'Half', intensity = "Half",
font = wezterm.font { font = wezterm.font({
family = 'VictorMono Nerd Font', family = "VictorMono Nerd Font",
weight = 'DemiBold', weight = "DemiBold",
style = 'Italic', style = "Italic",
}, }),
}, },
{ {
italic = true, italic = true,
intensity = 'Normal', intensity = "Normal",
font = wezterm.font { font = wezterm.font({
family = 'VictorMono Nerd Font', family = "VictorMono Nerd Font",
style = 'Italic', style = "Italic",
}, }),
}, },
}, },
line_height = 1.0, line_height = 1.0,
leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 }, leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1500 },
keys = maps.keys, keys = maps.keys,
key_tables = maps.key_tables, key_tables = maps.key_tables,
mouse_bindings = { mouse_bindings = {
{ {
event = { Up = { streak = 1, button = 'Left' } }, event = { Up = { streak = 1, button = "Left" } },
mods = 'NONE', mods = "NONE",
action = wezterm.action action = wezterm.action.CompleteSelectionOrOpenLinkAtMouseCursor("ClipboardAndPrimarySelection"),
.CompleteSelectionOrOpenLinkAtMouseCursor },
'ClipboardAndPrimarySelection' },
}
}
} }
return settings return settings