lua: Format with stylua

This commit is contained in:
Marty Oehme 2023-06-15 10:12:30 +02:00
parent e434c191c9
commit 5f93ecba7c
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
33 changed files with 4062 additions and 3413 deletions

View file

@ -21,72 +21,110 @@ audio=yes
MAXENTRIES = 5000
local msg = require 'mp.msg'
local options = require 'mp.options'
local utils = require 'mp.utils'
local msg = require("mp.msg")
local options = require("mp.options")
local utils = require("mp.utils")
o = {
disabled = false,
images = true,
videos = true,
audio = true
disabled = false,
images = true,
videos = true,
audio = true,
}
options.read_options(o)
function Set (t)
local set = {}
for _, v in pairs(t) do set[v] = true end
return set
function Set(t)
local set = {}
for _, v in pairs(t) do
set[v] = true
end
return set
end
function SetUnion (a,b)
local res = {}
for k in pairs(a) do res[k] = true end
for k in pairs(b) do res[k] = true end
return res
function SetUnion(a, b)
local res = {}
for k in pairs(a) do
res[k] = true
end
for k in pairs(b) do
res[k] = true
end
return res
end
EXTENSIONS_VIDEO = Set {
'mkv', 'avi', 'mp4', 'ogv', 'webm', 'rmvb', 'flv', 'wmv', 'mpeg', 'mpg', 'm4v', '3gp'
}
EXTENSIONS_VIDEO = Set({
"mkv",
"avi",
"mp4",
"ogv",
"webm",
"rmvb",
"flv",
"wmv",
"mpeg",
"mpg",
"m4v",
"3gp",
})
EXTENSIONS_AUDIO = Set {
'mp3', 'wav', 'ogm', 'flac', 'm4a', 'wma', 'ogg', 'opus'
}
EXTENSIONS_AUDIO = Set({
"mp3",
"wav",
"ogm",
"flac",
"m4a",
"wma",
"ogg",
"opus",
})
EXTENSIONS_IMAGES = Set {
'jpg', 'jpeg', 'png', 'tif', 'tiff', 'gif', 'webp', 'svg', 'bmp'
}
EXTENSIONS_IMAGES = Set({
"jpg",
"jpeg",
"png",
"tif",
"tiff",
"gif",
"webp",
"svg",
"bmp",
})
EXTENSIONS = Set {}
if o.videos then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO) end
if o.audio then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_AUDIO) end
if o.images then EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_IMAGES) end
EXTENSIONS = Set({})
if o.videos then
EXTENSIONS = SetUnion(EXTENSIONS, EXTENSIONS_VIDEO)
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)
index = index - 1
local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do
mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist-move", oldcount + i - 1, index + i - 1)
end
index = index - 1
local oldcount = mp.get_property_number("playlist-count", 1)
for i = 1, #files do
mp.commandv("loadfile", files[i], "append")
mp.commandv("playlist-move", oldcount + i - 1, index + i - 1)
end
end
function get_extension(path)
match = string.match(path, "%.([^%.]+)$" )
if match == nil then
return "nomatch"
else
return match
end
match = string.match(path, "%.([^%.]+)$")
if match == nil then
return "nomatch"
else
return match
end
end
table.filter = function(t, iter)
for i = #t, 1, -1 do
if not iter(t[i]) then
table.remove(t, i)
end
end
for i = #t, 1, -1 do
if not iter(t[i]) then
table.remove(t, i)
end
end
end
-- 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
function splitbynum(s)
local result = {}
for x, y in (s or ""):gmatch("(%d*)(%D*)") do
if x ~= "" then table.insert(result, tonumber(x)) end
if y ~= "" then table.insert(result, y) end
end
return result
local result = {}
for x, y in (s or ""):gmatch("(%d*)(%D*)") do
if x ~= "" then
table.insert(result, tonumber(x))
end
if y ~= "" then
table.insert(result, y)
end
end
return result
end
function clean_key(k)
k = (' '..k..' '):gsub("%s+", " "):sub(2, -2):lower()
return splitbynum(k)
k = (" " .. k .. " "):gsub("%s+", " "):sub(2, -2):lower()
return splitbynum(k)
end
-- compare two strings
function alnumcomp(x, y)
local xt, yt = clean_key(x), clean_key(y)
for i = 1, math.min(#xt, #yt) do
local xe, ye = xt[i], yt[i]
if type(xe) == "string" then ye = tostring(ye)
elseif type(ye) == "string" then xe = tostring(xe) end
if xe ~= ye then return xe < ye end
end
return #xt < #yt
local xt, yt = clean_key(x), clean_key(y)
for i = 1, math.min(#xt, #yt) do
local xe, ye = xt[i], yt[i]
if type(xe) == "string" then
ye = tostring(ye)
elseif type(ye) == "string" then
xe = tostring(xe)
end
if xe ~= ye then
return xe < ye
end
end
return #xt < #yt
end
local autoloaded = nil
function find_and_add_entries()
local path = mp.get_property("path", "")
local dir, filename = utils.split_path(path)
msg.trace(("dir: %s, filename: %s"):format(dir, filename))
if o.disabled then
msg.verbose("stopping: autoload disabled")
return
elseif #dir == 0 then
msg.verbose("stopping: not a local path")
return
end
local path = mp.get_property("path", "")
local dir, filename = utils.split_path(path)
msg.trace(("dir: %s, filename: %s"):format(dir, filename))
if o.disabled then
msg.verbose("stopping: autoload disabled")
return
elseif #dir == 0 then
msg.verbose("stopping: not a local path")
return
end
local pl_count = mp.get_property_number("playlist-count", 1)
-- check if this is a manually made playlist
if (pl_count > 1 and autoloaded == nil) or
(pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil) then
msg.verbose("stopping: manually made playlist")
return
else
autoloaded = true
end
local pl_count = mp.get_property_number("playlist-count", 1)
-- check if this is a manually made playlist
if
(pl_count > 1 and autoloaded == nil)
or (pl_count == 1 and EXTENSIONS[string.lower(get_extension(filename))] == nil)
then
msg.verbose("stopping: manually made playlist")
return
else
autoloaded = true
end
local pl = mp.get_property_native("playlist", {})
local pl_current = mp.get_property_number("playlist-pos-1", 1)
msg.trace(("playlist-pos-1: %s, playlist: %s"):format(pl_current,
utils.to_string(pl)))
local pl = mp.get_property_native("playlist", {})
local pl_current = mp.get_property_number("playlist-pos-1", 1)
msg.trace(("playlist-pos-1: %s, playlist: %s"):format(pl_current, utils.to_string(pl)))
local files = utils.readdir(dir, "files")
if files == nil then
msg.verbose("no other files in directory")
return
end
table.filter(files, function (v, k)
if string.match(v, "^%.") then
return false
end
local ext = get_extension(v)
if ext == nil then
return false
end
return EXTENSIONS[string.lower(ext)]
end)
table.sort(files, alnumcomp)
local files = utils.readdir(dir, "files")
if files == nil then
msg.verbose("no other files in directory")
return
end
table.filter(files, function(v, k)
if string.match(v, "^%.") then
return false
end
local ext = get_extension(v)
if ext == nil then
return false
end
return EXTENSIONS[string.lower(ext)]
end)
table.sort(files, alnumcomp)
if dir == "." then
dir = ""
end
if dir == "." then
dir = ""
end
-- Find the current pl entry (dir+"/"+filename) in the sorted dir list
local current
for i = 1, #files do
if files[i] == filename then
current = i
break
end
end
if current == nil then
return
end
msg.trace("current file position in files: "..current)
-- Find the current pl entry (dir+"/"+filename) in the sorted dir list
local current
for i = 1, #files do
if files[i] == filename then
current = i
break
end
end
if current == nil then
return
end
msg.trace("current file position in files: " .. current)
local append = {[-1] = {}, [1] = {}}
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * direction]
local pl_e = pl[pl_current + i * direction]
if file == nil or file[1] == "." then
break
end
local append = { [-1] = {}, [1] = {} }
for direction = -1, 1, 2 do -- 2 iterations, with direction = -1 and +1
for i = 1, MAXENTRIES do
local file = files[current + i * direction]
local pl_e = pl[pl_current + i * direction]
if file == nil or file[1] == "." then
break
end
local filepath = dir .. file
if pl_e then
-- If there's a playlist entry, and it's the same file, stop.
msg.trace(pl_e.filename.." == "..filepath.." ?")
if pl_e.filename == filepath then
break
end
end
local filepath = dir .. file
if pl_e then
-- If there's a playlist entry, and it's the same file, stop.
msg.trace(pl_e.filename .. " == " .. filepath .. " ?")
if pl_e.filename == filepath then
break
end
end
if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle
msg.info("Prepending " .. file)
table.insert(append[-1], 1, filepath)
end
else
msg.info("Adding " .. file)
table.insert(append[1], filepath)
end
end
end
if direction == -1 then
if pl_current == 1 then -- never add additional entries in the middle
msg.info("Prepending " .. file)
table.insert(append[-1], 1, filepath)
end
else
msg.info("Adding " .. file)
table.insert(append[1], filepath)
end
end
end
add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1])
add_files_at(pl_current + 1, append[1])
add_files_at(pl_current, append[-1])
end
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
local mp = require 'mp'
local mp = require("mp")
local SHOULD_ADJUST = false
@ -7,27 +7,31 @@ local lqprofile = "lowquality"
local hqprofile = "highquality"
local function powerstate()
local f = io.open("/sys/class/power_supply/AC/online")
if f == nil then return end
local t = f:read("*n")
f:close()
return t
local f = io.open("/sys/class/power_supply/AC/online")
if f == nil then
return
end
local t = f:read("*n")
f:close()
return t
end
local function adjust()
if not SHOULD_ADJUST then return end
if not SHOULD_ADJUST then
return
end
local state = powerstate()
-- this actually overrides automatically applied profiles
-- like 'protocol.http'
if state == 0 then
mp.set_property("profile", lqprofile)
mp.msg.info("[quality] running battery, setting low-quality options.")
mp.osd_message("[quality] LQ")
else
mp.set_property("profile", hqprofile)
mp.msg.info("[quality] running ac, setting high-quality options.")
mp.osd_message("[quality] HQ")
end
local state = powerstate()
-- this actually overrides automatically applied profiles
-- like 'protocol.http'
if state == 0 then
mp.set_property("profile", lqprofile)
mp.msg.info("[quality] running battery, setting low-quality options.")
mp.osd_message("[quality] LQ")
else
mp.set_property("profile", hqprofile)
mp.msg.info("[quality] running ac, setting high-quality options.")
mp.osd_message("[quality] HQ")
end
end
mp.add_hook("on_load", 1, adjust)

View file

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

View file

@ -7,27 +7,27 @@
-- e.g.
-- `mpv gallery-dl://https://imgur.com/....`
local mp = require 'mp'
local utils = require 'mp.utils'
local msg = require 'mp.msg'
local mp = require("mp")
local utils = require("mp.utils")
local msg = require("mp.msg")
local function exec(args)
local ret = utils.subprocess({ args = args })
return ret.status, ret.stdout, ret
local ret = utils.subprocess({ args = args })
return ret.status, ret.stdout, ret
end
mp.add_hook("on_load", 15, function()
local fn = mp.get_property("stream-open-filename", "")
if (fn:find("gdl://") ~= 1) then
msg.debug("not a gdl:// url: " .. fn)
return
end
local url = string.gsub(url, "gdl://", "")
local fn = mp.get_property("stream-open-filename", "")
if fn:find("gdl://") ~= 1 then
msg.debug("not a gdl:// url: " .. fn)
return
end
local url = string.gsub(url, "gdl://", "")
local es, urls, result = exec({ "gallery-dl", "-g", url })
if (es < 0) or (urls == nil) or (urls == "") then
msg.error("failed to get album list.")
end
local es, urls, result = exec({ "gallery-dl", "-g", url })
if (es < 0) or (urls == nil) or (urls == "") then
msg.error("failed to get album list.")
end
mp.commandv("loadlist", "memory://" .. urls)
mp.commandv("loadlist", "memory://" .. urls)
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
-- adapted for local playback skipping and some refactoring by me
local mp = require 'mp'
local mp = require("mp")
local options = {
API = "https://sponsor.ajay.app/api/skipSegments",
API = "https://sponsor.ajay.app/api/skipSegments",
-- Categories to fetch and skip
categories = '"sponsor","intro","outro","interaction","selfpromo"'
-- Categories to fetch and skip
categories = '"sponsor","intro","outro","interaction","selfpromo"',
}
local function getranges()
local args = {
"curl", "-s", "-d", "videoID=" .. Youtube_id, "-d",
"categories=[" .. options.categories .. "]", "-G", options.API
}
local sponsors = mp.command_native({
name = "subprocess",
capture_stdout = true,
playback_only = false,
args = args
})
local args = {
"curl",
"-s",
"-d",
"videoID=" .. Youtube_id,
"-d",
"categories=[" .. options.categories .. "]",
"-G",
options.API,
}
local sponsors = mp.command_native({
name = "subprocess",
capture_stdout = true,
playback_only = false,
args = args,
})
if string.match(sponsors.stdout, "%[(.-)%]") then
Ranges = {}
for i in string.gmatch(string.sub(sponsors.stdout, 2, -2), "%[(.-)%]") do
local k, v = string.match(i, "(%d+.?%d*),(%d+.?%d*)")
Ranges[k] = v
end
end
if string.match(sponsors.stdout, "%[(.-)%]") then
Ranges = {}
for i in string.gmatch(string.sub(sponsors.stdout, 2, -2), "%[(.-)%]") do
local k, v = string.match(i, "(%d+.?%d*),(%d+.?%d*)")
Ranges[k] = v
end
end
end
local function skip_ads(_, pos)
if pos ~= nil then
for k, v in pairs(Ranges) do
if tonumber(k) <= pos and tonumber(v) > pos then
-- this message may sometimes be wrong
-- it only seems to be a visual thing though
mp.osd_message("[sponsorblock] skipping forward " ..
math.floor(
tonumber(v) - mp.get_property("time-pos")) ..
"s")
-- need to do the +0.01 otherwise mpv will start spamming skip sometimes
-- example: https://www.youtube.com/watch?v=4ypMJzeNooo
mp.set_property("time-pos", tonumber(v) + 0.01)
return
end
end
end
if pos ~= nil then
for k, v in pairs(Ranges) do
if tonumber(k) <= pos and tonumber(v) > pos then
-- this message may sometimes be wrong
-- it only seems to be a visual thing though
mp.osd_message(
"[sponsorblock] skipping forward " .. math.floor(tonumber(v) - mp.get_property("time-pos")) .. "s"
)
-- need to do the +0.01 otherwise mpv will start spamming skip sometimes
-- example: https://www.youtube.com/watch?v=4ypMJzeNooo
mp.set_property("time-pos", tonumber(v) + 0.01)
return
end
end
end
end
local function file_loaded()
local video_path = mp.get_property("path")
local youtube_id1 = string.match(video_path,
"https?://youtu%.be/([%w-_]+).*")
local youtube_id2 = string.match(video_path,
"https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*")
local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*")
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*")
local localytfile = string.match(video_path,
"-([%a%d%-_]+)%.[mw][kpe][v4b][m]?$")
Youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or
localytfile
if not Youtube_id or string.len(Youtube_id) < 11 then return end
Youtube_id = string.sub(Youtube_id, 1, 11)
local video_path = mp.get_property("path")
local youtube_id1 = string.match(video_path, "https?://youtu%.be/([%w-_]+).*")
local youtube_id2 = string.match(video_path, "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*")
local youtube_id3 = string.match(video_path, "/watch.*[?&]v=([%w-_]+).*")
local youtube_id4 = string.match(video_path, "/embed/([%w-_]+).*")
local localytfile = string.match(video_path, "-([%a%d%-_]+)%.[mw][kpe][v4b][m]?$")
Youtube_id = youtube_id1 or youtube_id2 or youtube_id3 or youtube_id4 or localytfile
if not Youtube_id or string.len(Youtube_id) < 11 then
return
end
Youtube_id = string.sub(Youtube_id, 1, 11)
getranges()
if Ranges then
ON = true
mp.add_key_binding("b", "sponsorblock", toggle)
mp.observe_property("time-pos", "native", skip_ads)
end
return
getranges()
if Ranges then
ON = true
mp.add_key_binding("b", "sponsorblock", toggle)
mp.observe_property("time-pos", "native", skip_ads)
end
return
end
local function toggle()
if ON then
mp.unobserve_property(skip_ads)
mp.osd_message("[sponsorblock] off")
ON = false
return
end
mp.observe_property("time-pos", "native", skip_ads)
mp.osd_message("[sponsorblock] on")
ON = true
return
if ON then
mp.unobserve_property(skip_ads)
mp.osd_message("[sponsorblock] off")
ON = false
return
end
mp.observe_property("time-pos", "native", skip_ads)
mp.osd_message("[sponsorblock] on")
ON = true
return
end
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

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

View file

@ -1,90 +1,91 @@
-- Start quarto session
local startsession = function(file, args)
file = file or "/tmp/jupyter-magma-session.json"
if args then file = args[0] end
vim.fn.jobstart({ "jupyter", "console", "-f", file }, {
on_stdout = function(_)
vim.cmd("MagmaInit " .. file)
vim.cmd("JupyterAttach " .. file)
end,
on_exit = function(_)
vim.notify(string.format("jupyter kernel stopped: %s", file), vim.log.levels.INFO)
end,
stdin = nil
})
file = file or "/tmp/jupyter-magma-session.json"
if args then
file = args[0]
end
vim.fn.jobstart({ "jupyter", "console", "-f", file }, {
on_stdout = function(_)
vim.cmd("MagmaInit " .. file)
vim.cmd("JupyterAttach " .. file)
end,
on_exit = function(_)
vim.notify(string.format("jupyter kernel stopped: %s", file), vim.log.levels.INFO)
end,
stdin = nil,
})
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
-- filetype mappings
-- PLUGIN: magma-nvim
-- Operate jupyter notebooks from within vim
map('n', '<localleader>cc', ':MagmaEvaluateLine<cr>', { silent = true })
map('n', '<localleader>C', '?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>',
{ silent = true, desc = 'Evaluate current code cell' })
map('x', '<localleader>c', ':<C-u>MagmaEvaluateVisual<cr>', { silent = true })
map('n', '<localleader>c', "nvim_exec('MagmaEvaluateOperator', v:true)",
{ expr = true, silent = true, desc = '+code-evaluation' })
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>')
map("n", "<localleader>cc", ":MagmaEvaluateLine<cr>", { silent = true })
map(
"n",
"<localleader>C",
"?^```{<cr>jV/```<cr>k:<C-u>MagmaEvaluateVisual<cr>",
{ silent = true, desc = "Evaluate current code cell" }
)
map("x", "<localleader>c", ":<C-u>MagmaEvaluateVisual<cr>", { silent = true })
map(
"n",
"<localleader>c",
"nvim_exec('MagmaEvaluateOperator', v:true)",
{ expr = true, silent = true, desc = "+code-evaluation" }
)
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
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>}:nohl<cr>", { desc = "Next quarto cell" })
map("n", "[c", "?^```<cr>n}:nohl<cr>", { desc = "Previous quarto cell" })
-- insert cell header above/below
map('n', '<localleader>co', 'o```{python}<cr><cr>```<esc>k',
{ 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 below" })
map("n", "<localleader>cO", "O```{python}<cr><cr>```<esc>k", { desc = "Insert quarto cell above" })
local bufnr = 0
map('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>',
{ buffer = bufnr, desc = 'Previous diagnostic' })
map('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>',
{ buffer = bufnr, desc = 'Next diagnostic' })
map('n', '[e',
'<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<cr>',
{ buffer = bufnr, desc = 'Previous error' })
map('n', ']e',
'<cmd>lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})<cr>',
{ buffer = bufnr, desc = 'Next error' })
map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<cr>", { buffer = bufnr, desc = "Previous diagnostic" })
map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<cr>", { buffer = bufnr, desc = "Next diagnostic" })
map(
"n",
"[e",
"<cmd>lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})<cr>",
{ buffer = bufnr, desc = "Previous error" }
)
map(
"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
local prefix = require('which-key').register
prefix({ ['<localleader>l'] = { name = "+lsp" } })
map('n', '<localleader>li', '<cmd>LspInfo<cr>',
{ buffer = bufnr, desc = 'Lsp Info' })
map('n', '<localleader>ld', '<cmd>lua vim.diagnostic.open_float()<cr>',
{ buffer = bufnr, desc = 'Line diagnostics' })
map('n', '<localleader>la', '<cmd>lua vim.lsp.buf.code_action()<cr>',
{ 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' })
local prefix = require("which-key").register
prefix({ ["<localleader>l"] = { name = "+lsp" } })
map("n", "<localleader>li", "<cmd>LspInfo<cr>", { buffer = bufnr, desc = "Lsp Info" })
map("n", "<localleader>ld", "<cmd>lua vim.diagnostic.open_float()<cr>", { buffer = bufnr, desc = "Line diagnostics" })
map("n", "<localleader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", { 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>',
{ 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.declaration()<cr>',
{ buffer = bufnr, desc = 'Declaration' })
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' })
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", { 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.declaration()<cr>", { buffer = bufnr, desc = "Declaration" })
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
vim.b['sessionfile'] = vim.fn.tempname() .. '.json'
startsession(vim.b['sessionfile'])
if vim.b["sessionfile"] == nil then
vim.b["sessionfile"] = vim.fn.tempname() .. ".json"
startsession(vim.b["sessionfile"])
end

View file

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

View file

@ -1,33 +1,37 @@
-- Highlight whatever is being yanked
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
command = 'silent! lua require"vim.highlight".on_yank{timeout=500}',
desc = "Highlight yanked text whenevery yanking something",
group = vim.api.nvim_create_augroup('highlightyanks', { clear = true })
command = 'silent! lua require"vim.highlight".on_yank{timeout=500}',
desc = "Highlight yanked text whenevery yanking something",
group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }),
})
-- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
pattern = {
"/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt",
"$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt"
},
command = 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=',
desc = "Don't leak any information when editing potential password files",
group = vim.api.nvim_create_augroup('passnoleak', { clear = true })
pattern = {
"/dev/shm/gopass.*",
"/dev/shm/pass.?*/?*.txt",
"$TMPDIR/pass.?*/?*.txt",
"/tmp/pass.?*/?*.txt",
},
command = "setlocal noswapfile nobackup noundofile nowritebackup viminfo=",
desc = "Don't leak any information when editing potential password files",
group = vim.api.nvim_create_augroup("passnoleak", { clear = true }),
})
-- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330)
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH
vim.defer_fn(function() vim.loop.kill(pid, WINCH) end, 20)
end,
desc = "Fix neovim sizing issues if opening same time as alacritty",
group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true })
callback = function()
local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH
vim.defer_fn(function()
vim.loop.kill(pid, WINCH)
end, 20)
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
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = '*',
command = 'setlocal nonumber norelativenumber'
pattern = "*",
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()
if vim.fn.filereadable(colorsfile) == 1 then
vim.cmd("source " .. colorsfile)
end
if vim.fn.filereadable(colorsfile) == 1 then
vim.cmd("source " .. colorsfile)
end
end
-- set on startup
source_colors()
-- continuously watch colors file for changes
local fwatch = require('fwatch')
local fwatch = require("fwatch")
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 prefix = require('which-key').register
local prefix = require("which-key").register
-- The general ideas behind these mappings:
--
@ -10,73 +10,77 @@ local prefix = require('which-key').register
-- In other words mostly filetype specific mappings
-- 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?
map('n', 'U', '<C-r>')
map("n", "U", "<C-r>")
-- 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
-- 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
map('n', 'Q', '@')
map("n", "Q", "@")
-- stronger versions of left,right - move all the way to beginning/end of line
map('n', 'H', '^')
map('n', 'L', '$')
map("n", "H", "^")
map("n", "L", "$")
-- 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
-- This makes relative linenumbers much more useful in prose docs since they
-- are always exactly correct
local function wrap_up()
if vim.v.count == 0 then return 'gk' end
return 'k'
if vim.v.count == 0 then
return "gk"
end
return "k"
end
local function wrap_down()
if vim.v.count == 0 then return 'gj' end
return 'j'
if vim.v.count == 0 then
return "gj"
end
return "j"
end
map('n', 'k', wrap_up, { expr = true })
map('n', 'j', wrap_down, { expr = true })
map("n", "k", wrap_up, { expr = true })
map("n", "j", wrap_down, { expr = true })
-- 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,
map('i', '<C-u>', '<esc>gUiw`]a')
map('i', '<C-y>', '<esc>guiw`]a')
map("i", "<C-u>", "<esc>gUiw`]a")
map("i", "<C-y>", "<esc>guiw`]a")
-- Add undo break-points at punctuations for plaintext editing
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
-- yank current filename/filepath to f buffer
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("%")<Cr>', { desc = "yank filename" })
map("n", "yP", ':let @p = expand("%:p")<Cr>', { desc = "yank filepath" })
-- 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:
-- (works with count prefixes)
-- Argument list
map('n', '[a', ':previous<cr>')
map('n', ']a', ':next<cr>')
map("n", "[a", ":previous<cr>")
map("n", "]a", ":next<cr>")
-- Buffers
map('n', '[b', ':bprevious<cr>')
map('n', ']b', ':bnext<cr>')
map("n", "[b", ":bprevious<cr>")
map("n", "]b", ":bnext<cr>")
-- Quickfix list
map('n', '[q', ':cprevious<cr>')
map('n', ']q', ':cnext<cr>')
map("n", "[q", ":cprevious<cr>")
map("n", "]q", ":cnext<cr>")
-- Location list
map('n', '[l', ':lprevious<cr>')
map('n', ']l', ':lnext<cr>')
map("n", "[l", ":lprevious<cr>")
map("n", "]l", ":lnext<cr>")
-- maps the leader for buffer local mappings
-- 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
-- by douple-tapping it.
-- FIXME does this work still (and is it necessary)?
if vim.g.maplocalleader == ',' then
map('', ',,', ',')
vim.keymap.del('', ',,', { silent = true })
if vim.g.maplocalleader == "," then
map("", ",,", ",")
vim.keymap.del("", ",,", { silent = true })
end
-- 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
-- tmux setup)
map('n', '<leader>-', ':sp<cr>', { desc = 'open horiz split' })
map('n', '<leader>\\', ':vsp<cr>', { desc = 'open vert split' })
map("n", "<leader>-", ":sp<cr>", { desc = "open horiz 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)
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
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
map('n', '<leader>a', 'ggVG', { desc = 'select all' })
map("n", "<leader>a", "ggVG", { desc = "select all" })
-- PLUGIN: Navigator.nvim
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>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>p', '<CMD>lua require("Navigator").previous()<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>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>p", '<CMD>lua require("Navigator").previous()<cr>', { silent = true })
-- PLUGIN: Vifm.vim
-- 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
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
prefix({ ['<leader>v'] = { name = "+vim" } })
map('n', '<leader>vc', ':Vifm ' .. vim.fn.stdpath('config') .. '/lua<cr>',
{ 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'.man_pages()<cr>",
{ desc = 'man pages' })
map('n', '<leader>vC',
":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'colorschemes' })
map('n', '<leader>vl', ":Lazy<cr>", { desc = 'Lazy' })
map('n', '<leader>vm', ":Mason<cr>", { desc = 'Mason' })
prefix({ ["<leader>v"] = { name = "+vim" } })
map("n", "<leader>vc", ":Vifm " .. vim.fn.stdpath("config") .. "/lua<cr>", { 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'.man_pages()<cr>", { desc = "man pages" })
map(
"n",
"<leader>vC",
":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())<cr>",
{ desc = "colorschemes" }
)
map("n", "<leader>vl", ":Lazy<cr>", { desc = "Lazy" })
map("n", "<leader>vm", ":Mason<cr>", { desc = "Mason" })
-- 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
-- buffers and files in current workdir
prefix({ ['<leader>f'] = { name = '+find' } })
map('n', '<leader>fb',
":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'list buffers' })
prefix({ ["<leader>f"] = { name = "+find" } })
map(
"n",
"<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
-- go-back intention than just buffers
map('n', '<leader>fo',
":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>",
{ desc = 'list old files' })
map(
"n",
"<leader>fo",
":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())<cr>",
{ desc = "list old files" }
)
-- fuzzy find files in cwd
map('n', '<leader>ff', ":lua require 'telescope.builtin'.find_files()<cr>",
{ desc = 'find files' })
map("n", "<leader>ff", ":lua require 'telescope.builtin'.find_files()<cr>", { desc = "find files" })
-- fuzzy find hidden files in cwd
map('n', '<leader>fh',
":lua require 'telescope.builtin'.find_files({hidden=true})<cr>",
{ desc = 'find hidden files' })
map("n", "<leader>fh", ":lua require 'telescope.builtin'.find_files({hidden=true})<cr>", { desc = "find hidden files" })
-- general full-text search in cwd with rg
map('n', '<leader>fw', ":lua require 'telescope.builtin'.live_grep()<cr>",
{ desc = 'grep search' })
map("n", "<leader>fw", ":lua require 'telescope.builtin'.live_grep()<cr>", { desc = "grep search" })
-- git status
map('n', '<leader>fg', ":lua require 'telescope.builtin'.git_status()<cr>",
{ desc = 'git status' })
map("n", "<leader>fg", ":lua require 'telescope.builtin'.git_status()<cr>", { desc = "git status" })
-- git buffercommits
map('n', '<leader>fc', ":lua require 'telescope.builtin'.git_bcommits()<cr>",
{ desc = 'git buffer commits' })
map("n", "<leader>fc", ":lua require 'telescope.builtin'.git_bcommits()<cr>", { desc = "git buffer commits" })
-- git commitlog
map('n', '<leader>fl', ":lua require 'telescope.builtin'.git_commits()<cr>",
{ desc = 'git commit log' })
map("n", "<leader>fl", ":lua require 'telescope.builtin'.git_commits()<cr>", { desc = "git commit log" })
-- spell suggestions
map('n', 'z=',
":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>")
map("n", "z=", ":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())<cr>")
-- Format current Paragraph (esp useful in prose writing)
map('n', '<localleader>q', 'gqap',
{ silent = true, desc = 'Format current paragraph' })
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", "gqap", { silent = true, desc = "Format current paragraph" })
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>mp', '<Plug>MarkdownPreviewToggle',
{ desc = 'Toggle md preview' })
map("n", "<localleader>mp", "<Plug>MarkdownPreviewToggle", { desc = "Toggle md preview" })
-- FORMAT code with
-- PLUGIN: formatter.nvim
map('n', '<localleader>f', ':FormatLock<cr>')
map('n', '<localleader>F', ':FormatWriteLock<cr>')
map("n", "<localleader>f", ":FormatLock<cr>")
map("n", "<localleader>F", ":FormatWriteLock<cr>")
-- SPELL CHECKING
-- Move to the prev/next spelling error with [S ]S
-- Move to the prev/next spelling error or suggestion with [s ]s
prefix({ ['<localleader>Z'] = { name = '+Spelling' } })
map('n', '<localleader>ZZ', ':setlocal spell! spelllang=en_us,de_de<cr>',
{ desc = 'Toggle spellcheck' })
map('n', '<localleader>ZE', ':setlocal spell! spelllang=en_us<cr>',
{ desc = 'Toggle EN spellcheck' })
map('n', '<localleader>ZG', ':setlocal spell! spelllang=de_de<cr>',
{ desc = 'Toggle DE spellcheck' })
prefix({ ["<localleader>Z"] = { name = "+Spelling" } })
map("n", "<localleader>ZZ", ":setlocal spell! spelllang=en_us,de_de<cr>", { desc = "Toggle spellcheck" })
map("n", "<localleader>ZE", ":setlocal spell! spelllang=en_us<cr>", { 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
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("i", "<c-z>", "<C-G>u<Esc>[s1z=`]a<C-G>u")
map("n", "<localleader>z", "ms[s1z=`s", { desc = "Fix last spell error" })
-- PLUGIN: mini.nvim
prefix({ ['<leader>s'] = { name = '+show' } })
map('n', '<leader>sm', ':lua MiniMap.toggle()<cr>',
{ silent = true, desc = 'toggle minimap' })
map('n', '<leader>ss', ":lua MiniStarter.open()<cr>", { desc = 'show startpage' })
prefix({ ["<leader>s"] = { name = "+show" } })
map("n", "<leader>sm", ":lua MiniMap.toggle()<cr>", { silent = true, desc = "toggle minimap" })
map("n", "<leader>ss", ":lua MiniStarter.open()<cr>", { desc = "show startpage" })
-- PLUGIN: symbols-outline.nvim
map('n', '<leader>so', '<cmd>SymbolsOutline<cr>',
{ silent = true, desc = 'toggle symbol outline' })
map("n", "<leader>so", "<cmd>SymbolsOutline<cr>", { silent = true, desc = "toggle symbol outline" })
-- PLUGIN: nvim-tree
map('n', '<leader>se', '<cmd>NvimTreeToggle<cr>',
{ silent = true, desc = 'toggle filetree' })
map("n", "<leader>se", "<cmd>NvimTreeToggle<cr>", { silent = true, desc = "toggle filetree" })
-- PLUGIN: easy-align
-- 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)
map('n', 'ga', '<Plug>(EasyAlign)')
map("n", "ga", "<Plug>(EasyAlign)")
-- trim trailing whitespaces with mini.nvim trailspace
map("n", "<localleader>w", function() require("mini.trailspace").trim() end,
{ noremap = true })
map("n", "<localleader>w", function()
require("mini.trailspace").trim()
end, { noremap = true })
-- PLUGIN: dial-increment
map("n", "<C-a>", '<Plug>(dial-increment)')
map("n", "<C-x>", '<Plug>(dial-decrement)')
map("v", "<C-a>", '<Plug>(dial-increment)')
map("v", "<C-x>", '<Plug>(dial-increment)')
map("v", "g<C-a>", 'g<Plug>(dial-increment)')
map("v", "g<C-x>", 'g<Plug>(dial-increment)')
map("n", "<C-a>", "<Plug>(dial-increment)")
map("n", "<C-x>", "<Plug>(dial-decrement)")
map("v", "<C-a>", "<Plug>(dial-increment)")
map("v", "<C-x>", "<Plug>(dial-increment)")
map("v", "g<C-a>", "g<Plug>(dial-increment)")
map("v", "g<C-x>", "g<Plug>(dial-increment)")
-- PLUGIN: zettelkasten.nvim
map('n', '<cr>', [[:silent lua require 'zettelkasten'.link_follow()<cr>]])
map('v', '<cr>', [[:lua require 'zettelkasten'.link_follow(true)<cr>]])
prefix({ ['<leader>n'] = { name = '+notes' } })
map('n', '<leader>ni', [[:lua require 'zettelkasten'.index_open()<cr> ]],
{ desc = "index page" })
map("n", "<cr>", [[:silent lua require 'zettelkasten'.link_follow()<cr>]])
map("v", "<cr>", [[:lua require 'zettelkasten'.link_follow(true)<cr>]])
prefix({ ["<leader>n"] = { name = "+notes" } })
map("n", "<leader>ni", [[:lua require 'zettelkasten'.index_open()<cr> ]], { desc = "index page" })
-- PLUGIN: zk
map('n', '<leader>nn', "<cmd>ZkNotes { sort = { 'modified' } }<cr>",
{ desc = "note list" })
map("n", "<leader>nf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>",
{ desc = "note search" })
map('n', '<leader>nt', "<cmd>ZkTags<cr>",
{ desc = "note tags" })
map('n', '<leader>nc', "<cmd>ZkCd<cr>",
{ desc = "notes directory" })
prefix({ ['<localleader>n'] = { name = '+note' } })
map('n', '<localleader>nl', "<cmd>ZkLinks<cr>",
{ desc = "note links" })
map('n', '<localleader>nb', "<cmd>ZkLinks<cr>",
{ desc = "note backlinks" })
map('n', '<localleader>nn', "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>",
{ desc = "new note" })
prefix({ ['<localleader>n'] = { name = '+note', mode = "v" } })
map('v', '<localleader>nn', ":ZkNewFromTitleSelection<cr>",
{ 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" })
map("n", "<leader>nn", "<cmd>ZkNotes { sort = { 'modified' } }<cr>", { desc = "note list" })
map(
"n",
"<leader>nf",
"<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>",
{ desc = "note search" }
)
map("n", "<leader>nt", "<cmd>ZkTags<cr>", { desc = "note tags" })
map("n", "<leader>nc", "<cmd>ZkCd<cr>", { desc = "notes directory" })
prefix({ ["<localleader>n"] = { name = "+note" } })
map("n", "<localleader>nl", "<cmd>ZkLinks<cr>", { desc = "note links" })
map("n", "<localleader>nb", "<cmd>ZkLinks<cr>", { desc = "note backlinks" })
map("n", "<localleader>nn", "<cmd>ZkNew { title = vim.fn.input('Title: ') }<cr>", { desc = "new note" })
prefix({ ["<localleader>n"] = { name = "+note", mode = "v" } })
map("v", "<localleader>nn", ":ZkNewFromTitleSelection<cr>", { 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
-- 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
map('n', '<localleader>sw', [[:lua require('wrapping').toggle_wrap_mode()<cr> ]],
{ silent = true, desc = 'toggle wrap mode' })
map(
"n",
"<localleader>sw",
[[:lua require('wrapping').toggle_wrap_mode()<cr> ]],
{ silent = true, desc = "toggle wrap mode" }
)
-- 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
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>',
{ silent = true, desc = 'toggle formula notation' })
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>',
{ silent = true, desc = "toggle formula notation" }
)
-- PLUGIN: nvim-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>',
{ silent = true, desc = 'colorize background' })
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>',
{ silent = true, desc = "colorize background" }
)

View file

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

View file

@ -9,34 +9,41 @@ window, otherwise opens a new split.
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`
variable to the intended filetype.
]] --
]]
--
local api = vim.api
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)
-- should we create a new split or switch out the current buffer?
if isempty(split) then
split = false
else
split = true
end
-- which filetype to set for the scratchpad, defaults to pandoc
if isempty(ft) then
ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "pandoc"
end
-- should we create a new split or switch out the current buffer?
if isempty(split) then
split = false
else
split = true
end
-- which filetype to set for the scratchpad, defaults to pandoc
if isempty(ft) then
ft = vim.b["scratchpad_ft"] or vim.g["scratchpad_ft"] or "pandoc"
end
local buf = api.nvim_create_buf(false, true)
if buf == 0 then print("Error opening scratch buffer.") end
api.nvim_buf_set_option(buf, "bufhidden", "hide")
api.nvim_buf_set_option(buf, "buftype", "nofile")
api.nvim_buf_set_option(buf, "swapfile", false)
api.nvim_buf_set_option(buf, "filetype", ft)
local buf = api.nvim_create_buf(false, true)
if buf == 0 then
print("Error opening scratch buffer.")
end
api.nvim_buf_set_option(buf, "bufhidden", "hide")
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
-- switch to scratchpad
api.nvim_win_set_buf(0, buf)
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
-- switch to scratchpad
api.nvim_win_set_buf(0, buf)
end
return M

View file

@ -1,44 +1,56 @@
require('gitsigns').setup {
numhl = true,
signcolumn = false,
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
require("gitsigns").setup({
numhl = true,
signcolumn = false,
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']h', function()
if vim.wo.diff then return ']h' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, { expr = true })
-- Navigation
map("n", "]h", function()
if vim.wo.diff then
return "]h"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map('n', '[h', function()
if vim.wo.diff then return '[h' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, { expr = true })
map("n", "[h", function()
if vim.wo.diff then
return "[h"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
-- Actions
require('which-key').register({ ['<localleader>h'] = { name = '+git' } })
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', '<localleader>hS', gs.stage_buffer, { desc = 'stage buffer' })
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>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', gs.toggle_current_line_blame, { desc = 'toggle blame' })
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' })
-- Actions
require("which-key").register({ ["<localleader>h"] = { name = "+git" } })
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", "<localleader>hS", gs.stage_buffer, { desc = "stage buffer" })
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>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", gs.toggle_current_line_blame, { desc = "toggle blame" })
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
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
map({ 'o', 'x' }, 'ah', ':<C-U>Gitsigns select_hunk<CR>')
end
}
-- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
map({ "o", "x" }, "ah", ":<C-U>Gitsigns select_hunk<CR>")
end,
})

View file

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

View file

@ -1,38 +1,38 @@
require('mini.ai').setup()
require('mini.comment').setup({
hooks = {
pre = function()
require('ts_context_commentstring.internal').update_commentstring()
end
}
require("mini.ai").setup()
require("mini.comment").setup({
hooks = {
pre = function()
require("ts_context_commentstring.internal").update_commentstring()
end,
},
})
require('mini.cursorword').setup({ delay = 500 })
require('mini.fuzzy').setup()
require('mini.indentscope').setup({
symbol = "",
draw = { animation = require('mini.indentscope').gen_animation.none() },
options = { indent_at_cursor = false }
require("mini.cursorword").setup({ delay = 500 })
require("mini.fuzzy").setup()
require("mini.indentscope").setup({
symbol = "",
draw = { animation = require("mini.indentscope").gen_animation.none() },
options = { indent_at_cursor = false },
})
require('mini.map').setup()
require("mini.map").setup()
-- require('mini.move').setup() -- has not hit stable yet
require('mini.pairs').setup()
require('mini.trailspace').setup()
require("mini.pairs").setup()
require("mini.trailspace").setup()
local starter = require('mini.starter')
local starter = require("mini.starter")
starter.setup({
evaluate_single = true,
items = {
starter.sections.builtin_actions(),
starter.sections.recent_files(10, false),
starter.sections.recent_files(10, true),
-- Use this if you set up 'mini.sessions'
starter.sections.telescope()
},
content_hooks = {
starter.gen_hook.adding_bullet(),
starter.gen_hook.padding(3, 2),
starter.gen_hook.aligning('center', 'center')
}
evaluate_single = true,
items = {
starter.sections.builtin_actions(),
starter.sections.recent_files(10, false),
starter.sections.recent_files(10, true),
-- Use this if you set up 'mini.sessions'
starter.sections.telescope(),
},
content_hooks = {
starter.gen_hook.adding_bullet(),
starter.gen_hook.padding(3, 2),
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
-- fd for quicker directory structure searches
-- lsp for a variety of lsp queries
require("telescope").setup {
defaults = {
vimgrep_arguments = {
'rg', '--ignore-vcs', '--hidden', '--color=never', '--no-heading',
'--with-filename', '--line-number', '--column', '--smart-case'
},
generic_sorter = require('mini.fuzzy').get_telescope_sorter
},
defaults = {
-- Appearance
prompt_prefix = '',
selection_caret = '󰳟 ',
color_devicons = true
},
pickers = {
buffers = {theme = "ivy"},
oldfiles = {theme = "ivy"},
find_files = {
theme = "dropdown",
-- nice minimal picker design
borderchars = {
{'', '', '', '', '', '', '', ''},
prompt = {"", "", " ", "", '', '', "", ""},
results = {
"", "", "", "", "", "", "", ""
},
preview = {
'', '', '', '', '', '', '', ''
}
},
width = 0.8,
previewer = false,
prompt_title = false
}
}
}
require("telescope").setup({
defaults = {
vimgrep_arguments = {
"rg",
"--ignore-vcs",
"--hidden",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
},
generic_sorter = require("mini.fuzzy").get_telescope_sorter,
},
defaults = {
-- Appearance
prompt_prefix = "",
selection_caret = "󰳟 ",
color_devicons = true,
},
pickers = {
buffers = { theme = "ivy" },
oldfiles = { theme = "ivy" },
find_files = {
theme = "dropdown",
-- nice minimal picker design
borderchars = {
{ "", "", "", "", "", "", "", "" },
prompt = { "", "", " ", "", "", "", "", "" },
results = {
"",
"",
"",
"",
"",
"",
"",
"",
},
preview = {
"",
"",
"",
"",
"",
"",
"",
"",
},
},
width = 0.8,
previewer = false,
prompt_title = false,
},
},
})
require("telescope").load_extension("fzf")

View file

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

View file

@ -1,21 +1,21 @@
local rainbow = require('ts-rainbow')
require 'nvim-treesitter.configs'.setup {
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all",
highlight = { enable = true },
incremental_selection = { enable = true },
textobjects = { enable = true },
indent = { enable = true },
local rainbow = require("ts-rainbow")
require("nvim-treesitter.configs").setup({
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = "all",
highlight = { enable = true },
incremental_selection = { enable = true },
textobjects = { enable = true },
indent = { enable = true },
-- enable rainbow brackets, needs p00f/nvim-ts-rainbow
rainbow = {
enable = true,
strategy = { rainbow.strategy.global }
},
-- enable rainbow brackets, needs p00f/nvim-ts-rainbow
rainbow = {
enable = true,
strategy = { rainbow.strategy.global },
},
-- for improved commentstrings, needs corresponding plugin
context_commentstring = {
enable = true,
enable_autocmd = false -- since we run it as a hook from the mini.comment plugin
}
}
-- for improved commentstrings, needs corresponding plugin
context_commentstring = {
enable = true,
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" }
return {
-- essential
{ '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
{ '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
{
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
config = function() require('plug._gitsigns') end,
event = "BufRead"
}, { "m4xshen/smartcolumn.nvim", config = true }, -- auto-hiding colorcolumn
-- files
{ 'vifm/vifm.vim' }, -- integrate file manager
{
'nvim-tree/nvim-tree.lua', -- integrate file tree
config = true,
dependencies = { 'nvim-tree/nvim-web-devicons', config = true },
cmd = "NvimTreeToggle"
}, -- colors
{
'RRethy/nvim-base16',
event = "BufWinEnter",
dependencies = { 'rktjmp/fwatch.nvim' }
}, {
'NvChad/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme
config = function()
require('colorizer').setup({
user_default_options = { mode = 'virtualtext' }
})
end,
event = "VeryLazy"
}, -- editing
{ 'kylechui/nvim-surround', version = '*', config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds
{
'monaqa/dial.nvim', -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers
config = function()
local augend = require("dial.augend")
require("dial.config").augends:register_group {
-- default augends used when no group name is specified
default = {
augend.integer.alias.decimal, augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
augend.date.alias["%Y-%m-%d"], augend.date.alias["%m/%d"],
augend.date.alias["%H:%M:%S"], augend.date.alias["%H:%M"],
augend.constant.alias.de_weekday_full,
augend.constant.alias.de_weekday,
augend.constant.alias.bool, augend.semver.alias.semver,
augend.constant.alias.Alpha, augend.constant.alias.alpha,
augend.hexcolor.new { case = "lower" }, augend.constant.new {
elements = { "and", "or" },
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true -- "or" is incremented into "and".
},
augend.constant
.new {
elements = { "&&", "||" },
word = false,
cyclic = true
}
}
}
end,
event = "VeryLazy"
}, {
'tommcdo/vim-exchange', -- adds exchange operator with cx. common use: cxiw . on 2 words to switch
event = "VeryLazy"
}, {
'junegunn/vim-easy-align', -- Align tables and other alignable things
event = "VeryLazy"
}, { 'edKotinsky/Arduino.nvim', ft = 'arduino', config = true }, -- statusline
{
'nvim-lualine/lualine.nvim',
requires = { 'nvim-tree/nvim-web-devicons', config = true },
config = function() require('plug._lualine') end
}, -- writing
{ 'vim-pandoc/vim-criticmarkup', ft = writing_ft }, {
'jbyuki/nabla.nvim',
ft = writing_ft,
config = function()
require('nabla').enable_virt({ autogen = true, silent = true })
end
}, {
'mickael-menu/zk-nvim',
config = function() require('zk').setup({ picker = "telescope" }) end
}, {
'andrewferrier/wrapping.nvim',
config = function()
require('wrapping').setup({
create_keymappings = false,
notify_on_switch = false
})
end
}, {
'quarto-dev/quarto-nvim',
dependencies = {
'jmbuhr/otter.nvim', 'neovim/nvim-lspconfig',
'vim-pandoc/vim-pandoc-syntax', 'hrsh7th/nvim-cmp',
'nvim-treesitter/nvim-treesitter'
},
config = function()
require 'quarto'.setup {
lspFeatures = {
enabled = true,
languages = { 'r', 'python', 'julia' },
diagnostics = { enabled = true, triggers = { "BufWrite" } },
completion = { enabled = true }
}
}
end,
ft = "quarto"
}, {
"lkhphuc/jupyter-kernel.nvim",
config = true,
cmd = "JupyterAttach",
build = ":UpdateRemotePlugins",
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
-- essential
{ "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
{ "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
{
"lewis6991/gitsigns.nvim", -- show vcs changes on left-hand gutter
config = function()
require("plug._gitsigns")
end,
event = "BufRead",
},
{ "m4xshen/smartcolumn.nvim", config = true }, -- auto-hiding colorcolumn
-- files
{ "vifm/vifm.vim" }, -- integrate file manager
{
"nvim-tree/nvim-tree.lua", -- integrate file tree
config = true,
dependencies = { "nvim-tree/nvim-web-devicons", config = true },
cmd = "NvimTreeToggle",
}, -- colors
{
"RRethy/nvim-base16",
event = "BufWinEnter",
dependencies = { "rktjmp/fwatch.nvim" },
},
{
"NvChad/nvim-colorizer.lua", -- color hex, named colors in the correct preview scheme
config = function()
require("colorizer").setup({
user_default_options = { mode = "virtualtext" },
})
end,
event = "VeryLazy",
}, -- editing
{ "kylechui/nvim-surround", version = "*", config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds
{
"monaqa/dial.nvim", -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers
config = function()
local augend = require("dial.augend")
require("dial.config").augends:register_group({
-- default augends used when no group name is specified
default = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
augend.date.alias["%Y-%m-%d"],
augend.date.alias["%m/%d"],
augend.date.alias["%H:%M:%S"],
augend.date.alias["%H:%M"],
augend.constant.alias.de_weekday_full,
augend.constant.alias.de_weekday,
augend.constant.alias.bool,
augend.semver.alias.semver,
augend.constant.alias.Alpha,
augend.constant.alias.alpha,
augend.hexcolor.new({ case = "lower" }),
augend.constant.new({
elements = { "and", "or" },
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true, -- "or" is incremented into "and".
}),
augend.constant.new({
elements = { "&&", "||" },
word = false,
cyclic = true,
}),
},
})
end,
event = "VeryLazy",
},
{
"tommcdo/vim-exchange", -- adds exchange operator with cx. common use: cxiw . on 2 words to switch
event = "VeryLazy",
},
{
"junegunn/vim-easy-align", -- Align tables and other alignable things
event = "VeryLazy",
},
{ "edKotinsky/Arduino.nvim", ft = "arduino", config = true }, -- statusline
{
"nvim-lualine/lualine.nvim",
requires = { "nvim-tree/nvim-web-devicons", config = true },
config = function()
require("plug._lualine")
end,
}, -- writing
{ "vim-pandoc/vim-criticmarkup", ft = writing_ft },
{
"jbyuki/nabla.nvim",
ft = writing_ft,
config = function()
require("nabla").enable_virt({ autogen = true, silent = true })
end,
},
{
"mickael-menu/zk-nvim",
config = function()
require("zk").setup({ picker = "telescope" })
end,
},
{
"andrewferrier/wrapping.nvim",
config = function()
require("wrapping").setup({
create_keymappings = false,
notify_on_switch = false,
})
end,
},
{
"quarto-dev/quarto-nvim",
dependencies = {
"jmbuhr/otter.nvim",
"neovim/nvim-lspconfig",
"vim-pandoc/vim-pandoc-syntax",
"hrsh7th/nvim-cmp",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("quarto").setup({
lspFeatures = {
enabled = true,
languages = { "r", "python", "julia" },
diagnostics = { enabled = true, triggers = { "BufWrite" } },
completion = { enabled = true },
},
})
end,
ft = "quarto",
},
{
"lkhphuc/jupyter-kernel.nvim",
config = true,
cmd = "JupyterAttach",
build = ":UpdateRemotePlugins",
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
{
'WhiteBlackGoose/magma-nvim-goose',
build = ":UpdateRemotePlugins",
config = function()
vim.g.magma_image_provider = "kitty"
vim.g.magma_automatically_open_output = false
end
}, {
'echasnovski/mini.nvim',
version = '*',
config = function() require('plug._mini') end
}, {
"akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim
config = function() require('plug._toggleterm') end
},
{
"folke/which-key.nvim",
config = function() require("which-key").setup {} end
}, -- fuzzy matching
{ "nvim-telescope/telescope-fzf-native.nvim", build = 'make' }, {
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" },
config = function() require('plug._telescope') end
}, {
"dense-analysis/neural",
dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" },
config = function()
require('neural').setup({
source = { openai = { api_key = vim.env.OPENAI_API_KEY } }
})
end
}, -- treesitter
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function() require('plug._treesitter') end,
event = "BufReadPre",
-- rainbow brackets using treesitter
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
'https://gitlab.com/HiPhish/nvim-ts-rainbow2.git',
{ 'romgrk/nvim-treesitter-context', config = true },
'JoosepAlviste/nvim-ts-context-commentstring'
}
}, { 'nvim-treesitter/playground', cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree
{
'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches
config = function()
require 'nvim-treesitter.configs'.setup {
textsubjects = {
enable = true,
keymaps = {
['.'] = 'textsubjects-smart',
[';'] = 'textsubjects-container-outer'
}
}
}
end,
event = "BufReadPre"
}, {
-- lsp
"VonHeikemen/lsp-zero.nvim",
dependencies = {
{ "neovim/nvim-lspconfig", branch = "master" },
"williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", {
"hrsh7th/nvim-cmp",
branch = "main",
dependencies = {
"andersevenrud/cmp-tmux", "cbarrete/completion-vcard",
"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",
"jc-doyle/cmp-pandoc-references",
"kdheepak/cmp-latex-symbols", "lukas-reineke/cmp-rg",
"crispgm/cmp-beancount", "ray-x/cmp-treesitter",
"saadparwaiz1/cmp_luasnip"
}
}, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets",
-- { "lukas-reineke/lsp-format.nvim", config = true },
{ "j-hui/fidget.nvim", config = true }, -- loading animations for some LSP
{
"jay-babu/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim", "jose-elias-alvarez/null-ls.nvim"
},
}
},
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
-- }
-- REPL work
{
"WhiteBlackGoose/magma-nvim-goose",
build = ":UpdateRemotePlugins",
config = function()
vim.g.magma_image_provider = "kitty"
vim.g.magma_automatically_open_output = false
end,
},
{
"echasnovski/mini.nvim",
version = "*",
config = function()
require("plug._mini")
end,
},
{
"akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim
config = function()
require("plug._toggleterm")
end,
},
{
"folke/which-key.nvim",
config = function()
require("which-key").setup({})
end,
}, -- fuzzy matching
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" },
config = function()
require("plug._telescope")
end,
},
{
"dense-analysis/neural",
dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" },
config = function()
require("neural").setup({
source = { openai = { api_key = vim.env.OPENAI_API_KEY } },
})
end,
}, -- treesitter
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
require("plug._treesitter")
end,
event = "BufReadPre",
-- rainbow brackets using treesitter
-- show current cursor context at top of buffer
-- improves commenting plugin above by using ts
dependencies = {
"https://gitlab.com/HiPhish/nvim-ts-rainbow2.git",
{ "romgrk/nvim-treesitter-context", config = true },
"JoosepAlviste/nvim-ts-context-commentstring",
},
},
{ "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree
{
"RRethy/nvim-treesitter-textsubjects", -- allows using . and ; to target treesitter branches
config = function()
require("nvim-treesitter.configs").setup({
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
},
},
})
end,
event = "BufReadPre",
},
{
-- lsp
"VonHeikemen/lsp-zero.nvim",
dependencies = {
{ "neovim/nvim-lspconfig", branch = "master" },
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
{
"hrsh7th/nvim-cmp",
branch = "main",
dependencies = {
"andersevenrud/cmp-tmux",
"cbarrete/completion-vcard",
"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",
"jc-doyle/cmp-pandoc-references",
"kdheepak/cmp-latex-symbols",
"lukas-reineke/cmp-rg",
"crispgm/cmp-beancount",
"ray-x/cmp-treesitter",
"saadparwaiz1/cmp_luasnip",
},
},
"L3MON4D3/LuaSnip",
"rafamadriz/friendly-snippets",
-- { "lukas-reineke/lsp-format.nvim", config = true },
{ "j-hui/fidget.nvim", config = true }, -- loading animations for some LSP
{
"jay-babu/mason-null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"williamboman/mason.nvim",
"jose-elias-alvarez/null-ls.nvim",
},
},
},
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 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
local o = {
termguicolors = true,
-- sets tabs to be 2 characters, expanded into spaces, but still removable with
-- one press of backspace.
-- great explanation: http://vimcasts.org/transcripts/2/en/
tabstop = 4,
shiftwidth = 4,
softtabstop = 4,
expandtab = true,
-- make jumplist behave more like browser, when jumping back
-- and then adding a new jump discards all the previous
-- 'future-jump' tree, making more sense for wiki-like movement
jumpoptions = 'stack',
-- 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
cursorline = true,
-- shows linenumbers relative to the one you are on, for easy movement and
-- dNUMBERd deletions
number = true,
relativenumber = true,
-- puts the numbers into the signcolumn so when git/lsp show signs there's no jump
signcolumn = 'number',
-- keeps an undofile next to files so that you can even undo if vim is closed
-- in between
undofile = true,
-- TODO o.undodir = '~/.cache/nvim/undodir'
termguicolors = true,
-- sets tabs to be 2 characters, expanded into spaces, but still removable with
-- one press of backspace.
-- great explanation: http://vimcasts.org/transcripts/2/en/
tabstop = 4,
shiftwidth = 4,
softtabstop = 4,
expandtab = true,
-- make jumplist behave more like browser, when jumping back
-- and then adding a new jump discards all the previous
-- 'future-jump' tree, making more sense for wiki-like movement
jumpoptions = "stack",
-- 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
cursorline = true,
-- shows linenumbers relative to the one you are on, for easy movement and
-- dNUMBERd deletions
number = true,
relativenumber = true,
-- puts the numbers into the signcolumn so when git/lsp show signs there's no jump
signcolumn = "number",
-- keeps an undofile next to files so that you can even undo if vim is closed
-- in between
undofile = true,
-- TODO o.undodir = '~/.cache/nvim/undodir'
-- ignores case by default but will use case when search is specifically not
-- all lowercased
ignorecase = true,
smartcase = true,
-- shows previews of what substitute command will do (and a couple others)
inccommand = 'split',
-- disables showing us the current mode in the command line since airline takes
-- care of it
showmode = false,
-- turn off modeline, to ensure security observation
modeline = false,
-- i feel foldlevel 2 is generally pretty usable, for headlines and similar
-- set to use treesitter in treesitter config
foldlevel = 2,
conceallevel = 2,
-- enable mouse, doesn't bug me and might come in useful at some point
mouse = 'a',
-- pump all clippings into the system clipboard
clipboard = 'unnamedplus',
-- turn of automatic resizing of individual splits
equalalways = false,
-- make sure there's always *some* context below cursor
scrolloff = 4,
-- open new buffers bottomright
splitright = true,
splitbelow = true,
-- remove command line if no command is currently present
cmdheight = 0,
-- ignores case by default but will use case when search is specifically not
-- all lowercased
ignorecase = true,
smartcase = true,
-- shows previews of what substitute command will do (and a couple others)
inccommand = "split",
-- disables showing us the current mode in the command line since airline takes
-- care of it
showmode = false,
-- turn off modeline, to ensure security observation
modeline = false,
-- i feel foldlevel 2 is generally pretty usable, for headlines and similar
-- set to use treesitter in treesitter config
foldlevel = 2,
conceallevel = 2,
-- enable mouse, doesn't bug me and might come in useful at some point
mouse = "a",
-- pump all clippings into the system clipboard
clipboard = "unnamedplus",
-- turn of automatic resizing of individual splits
equalalways = false,
-- make sure there's always *some* context below cursor
scrolloff = 4,
-- open new buffers bottomright
splitright = true,
splitbelow = true,
-- remove command line if no command is currently present
cmdheight = 0,
}
for k, v in pairs(o) do
vim.opt[k] = v
vim.opt[k] = v
end
vim.api.nvim_set_var('tex_flavor', 'latex')
vim.api.nvim_set_var("tex_flavor", "latex")
disable_builtins(default_builtins_disabled)

View file

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

View file

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

View file

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

View file

@ -20,67 +20,64 @@ CONTINUOUS = false
UPDATE_TIME = 120
-- 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
-- can be overridden with env var IMAPFILTER_FILTERDIR
function getConfigDir()
-- -- set directory for imapfilter files
local configdir
if os.getenv("IMAPFILTER_CONFIGDIR") then
configdir = os.getenv("IMAPFILTER_CONFIGDIR")
elseif os.getenv("XDG_CONFIG_HOME") then
configdir = os.getenv("XDG_CONFIG_HOME") .. "/imapfilter"
else
configdir = os.getenv("HOME") .. "/.config/imapfilter"
end
return configdir
-- -- set directory for imapfilter files
local configdir
if os.getenv("IMAPFILTER_CONFIGDIR") then
configdir = os.getenv("IMAPFILTER_CONFIGDIR")
elseif os.getenv("XDG_CONFIG_HOME") then
configdir = os.getenv("XDG_CONFIG_HOME") .. "/imapfilter"
else
configdir = os.getenv("HOME") .. "/.config/imapfilter"
end
return configdir
end
-- will set filters to be grabbed from XDG-compliant filter directory
-- can be overridden with env var IMAPFILTER_FILTERDIR
function getFilterDir()
-- -- set directory for imapfilter files
local imapfilterdir
if os.getenv("IMAPFILTER_FILTERDIR") then
imapfilterdir = os.getenv("IMAPFILTER_FILTERDIR")
else
imapfilterdir = configDir .. "/filters"
end
return imapfilterdir
-- -- set directory for imapfilter files
local imapfilterdir
if os.getenv("IMAPFILTER_FILTERDIR") then
imapfilterdir = os.getenv("IMAPFILTER_FILTERDIR")
else
imapfilterdir = configDir .. "/filters"
end
return imapfilterdir
end
-- dirlist, from https://stackoverflow.com/a/25266573
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.
for file in p:lines() do -- Loop through all files
loadfile(file)()
end
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
loadfile(file)()
end
end
-- create global variable containing the configuration files
configDir = getConfigDir()
assert(configDir,
"No configuration directory found. Ensure " .. os.getenv("HOME") ..
"/.config/imapfilter exists.")
assert(configDir, "No configuration directory found. Ensure " .. os.getenv("HOME") .. "/.config/imapfilter exists.")
-- create global variable containing account access
accounts = loadfile(configDir .. "/accounts.lua")()
assert(accounts,
"No accounts configured. Ensure accounts.lua exists and returns a table of accounts.")
assert(accounts, "No accounts configured. Ensure accounts.lua exists and returns a table of accounts.")
-- immediately act on the filters once
applyFilters(getFilterDir())
-- continuously watch for mail if needed
while CONTINUOUS == true do
local has_idle = accounts.gmail['Inbox']:enter_idle()
applyFilters(getFilterDir())
local has_idle = accounts.gmail["Inbox"]:enter_idle()
applyFilters(getFilterDir())
if has_idle == false then
print(
"Server does not support idle, application will be polling again in " ..
UPDATE_TIME .. "minutes.")
sleep(UPDATE_TIME)
end
if has_idle == false then
print("Server does not support idle, application will be polling again in " .. UPDATE_TIME .. "minutes.")
sleep(UPDATE_TIME)
end
end

View file

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

View file

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

View file

@ -1,127 +1,137 @@
local wezterm = require('wezterm')
local wezterm = require("wezterm")
local act = wezterm.action
local keys = {
{ 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 = "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") },
}
-- Leader + number to activate that tab
for i = 1, 8 do
table.insert(keys, {
key = tostring(i),
mods = 'LEADER',
action = act.ActivateTab(i - 1)
})
table.insert(keys, {
key = tostring(i),
mods = "LEADER",
action = act.ActivateTab(i - 1),
})
end
-- key table sub modes
local key_tables = {
-- mode to change size of any panes
resize_pane = {
{ key = 'h', action = act.AdjustPaneSize { 'Left', 1 } },
{ key = 'l', action = act.AdjustPaneSize { 'Right', 1 } },
{ key = 'k', action = act.AdjustPaneSize { 'Up', 1 } },
{ key = 'j', action = act.AdjustPaneSize { 'Down', 1 } },
{ key = 'H', action = act.AdjustPaneSize { 'Left', 10 } },
{ key = 'L', action = act.AdjustPaneSize { 'Right', 10 } },
{ key = 'K', action = act.AdjustPaneSize { 'Up', 10 } },
{ key = 'J', action = act.AdjustPaneSize { 'Down', 10 } },
{ key = 'Escape', action = 'PopKeyTable' }
},
scroll_mode = {
{ key = 'y', mods = 'CTRL', action = act.ScrollByLine(-1) },
{ key = 'e', mods = 'CTRL', action = act.ScrollByLine(1) },
{ key = 'f', mods = 'CTRL', action = act.ScrollByPage(1) },
{ key = 'b', mods = 'CTRL', action = act.ScrollByPage(-1) },
{ key = 'd', 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.ScrollToBottom },
{ key = 'Escape', action = 'PopKeyTable' }
}
-- mode to change size of any panes
resize_pane = {
{ key = "h", action = act.AdjustPaneSize({ "Left", 1 }) },
{ key = "l", action = act.AdjustPaneSize({ "Right", 1 }) },
{ key = "k", action = act.AdjustPaneSize({ "Up", 1 }) },
{ key = "j", action = act.AdjustPaneSize({ "Down", 1 }) },
{ key = "H", action = act.AdjustPaneSize({ "Left", 10 }) },
{ key = "L", action = act.AdjustPaneSize({ "Right", 10 }) },
{ key = "K", action = act.AdjustPaneSize({ "Up", 10 }) },
{ key = "J", action = act.AdjustPaneSize({ "Down", 10 }) },
{ key = "Escape", action = "PopKeyTable" },
},
scroll_mode = {
{ key = "y", mods = "CTRL", action = act.ScrollByLine(-1) },
{ key = "e", mods = "CTRL", action = act.ScrollByLine(1) },
{ key = "f", mods = "CTRL", action = act.ScrollByPage(1) },
{ key = "b", mods = "CTRL", action = act.ScrollByPage(-1) },
{ key = "d", 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.ScrollToBottom },
{ key = "Escape", action = "PopKeyTable" },
},
}
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()
-- STATUSBAR
-- show currently active key table in lower right status bar
-- mimicing Vim modes
wezterm.on('update-status', function(window, pane)
local displayed = { left = {}, right = {} }
local keytable = window:active_key_table()
if keytable then
displayed.left[#displayed.left + 1] = 'MODE: ' .. keytable
end
-- STATUSBAR
-- show currently active key table in lower right status bar
-- mimicing Vim modes
wezterm.on("update-status", function(window, pane)
local displayed = { left = {}, right = {} }
local keytable = window:active_key_table()
if keytable then
displayed.left[#displayed.left + 1] = "MODE: " .. keytable
end
local workspace = window:active_workspace()
if workspace and workspace ~= 'default' then
displayed.left[#displayed.left + 1] = 'WORKSPACE: ' .. workspace
end
local workspace = window:active_workspace()
if workspace and workspace ~= "default" then
displayed.left[#displayed.left + 1] = "WORKSPACE: " .. workspace
end
local bat = ''
for _, b in ipairs(wezterm.battery_info()) do
bat = '🔋 ' .. string.format('%.0f%%', b.state_of_charge * 100) ..
' ' .. b.state
end
displayed.right[#displayed.right + 1] = bat
local bat = ""
for _, b in ipairs(wezterm.battery_info()) do
bat = "🔋 " .. string.format("%.0f%%", b.state_of_charge * 100) .. " " .. b.state
end
displayed.right[#displayed.right + 1] = bat
local currentprogram = pane:get_foreground_process_name()
displayed.right[#displayed.right + 1] = basename(currentprogram)
local currentprogram = pane:get_foreground_process_name()
displayed.right[#displayed.right + 1] = basename(currentprogram)
local statusleft = ''
for _, v in ipairs(displayed.left) do
statusleft = statusleft .. v .. SEPARATOR
end
local statusright = ''
for _, v in ipairs(displayed.right) do
statusright = statusright .. v .. SEPARATOR
end
local statusleft = ""
for _, v in ipairs(displayed.left) do
statusleft = statusleft .. v .. SEPARATOR
end
local statusright = ""
for _, v in ipairs(displayed.right) do
statusright = statusright .. v .. SEPARATOR
end
window:set_left_status(statusleft or '')
window:set_right_status(statusright or '')
end)
window:set_left_status(statusleft or "")
window:set_right_status(statusright or "")
end)
end
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 'events'.setup()
require("statusbar").setup()
require("events").setup()
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- automatically reload colors file
local colorsfile = (os.getenv('XDG_STATE_HOME') or
(os.getenv('HOME') .. '/.local/state')) ..
'/wezterm/colors.toml'
local colorsfile = (os.getenv("XDG_STATE_HOME") or (os.getenv("HOME") .. "/.local/state")) .. "/wezterm/colors.toml"
local colors = {}
if file_exists(colorsfile) == true then
wezterm.add_to_config_reload_watch_list(colorsfile)
colors = wezterm.color.load_scheme(colorsfile)
wezterm.add_to_config_reload_watch_list(colorsfile)
colors = wezterm.color.load_scheme(colorsfile)
end
local settings = {
enable_wayland = true,
hide_tab_bar_if_only_one_tab = true,
use_fancy_tab_bar = false,
tab_bar_at_bottom = true,
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
colors = colors,
color_scheme = "Nord (base16)", -- will be overwritten by colors
-- default_prog = {"nu"},
scrollback_lines = 10000,
font = wezterm.font('Iosevka Nerd Font'),
-- add cursive italic font from Victor font for all weights
font_rules = {
{
intensity = 'Bold',
italic = true,
font = wezterm.font {
family = 'VictorMono Nerd Font',
weight = 'Bold',
style = 'Italic',
},
},
{
italic = true,
intensity = 'Half',
font = wezterm.font {
family = 'VictorMono Nerd Font',
weight = 'DemiBold',
style = 'Italic',
},
},
{
italic = true,
intensity = 'Normal',
font = wezterm.font {
family = 'VictorMono Nerd Font',
style = 'Italic',
},
},
},
line_height = 1.0,
leader = { key = 'a', mods = 'CTRL', timeout_milliseconds = 1500 },
keys = maps.keys,
key_tables = maps.key_tables,
mouse_bindings = {
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'NONE',
action = wezterm.action
.CompleteSelectionOrOpenLinkAtMouseCursor
'ClipboardAndPrimarySelection'
}
}
enable_wayland = true,
hide_tab_bar_if_only_one_tab = true,
use_fancy_tab_bar = false,
tab_bar_at_bottom = true,
window_padding = { left = 0, right = 0, top = 0, bottom = 0 },
colors = colors,
color_scheme = "Nord (base16)", -- will be overwritten by colors
-- default_prog = {"nu"},
scrollback_lines = 10000,
font = wezterm.font("Iosevka Nerd Font"),
-- add cursive italic font from Victor font for all weights
font_rules = {
{
intensity = "Bold",
italic = true,
font = wezterm.font({
family = "VictorMono Nerd Font",
weight = "Bold",
style = "Italic",
}),
},
{
italic = true,
intensity = "Half",
font = wezterm.font({
family = "VictorMono Nerd Font",
weight = "DemiBold",
style = "Italic",
}),
},
{
italic = true,
intensity = "Normal",
font = wezterm.font({
family = "VictorMono Nerd Font",
style = "Italic",
}),
},
},
line_height = 1.0,
leader = { key = "a", mods = "CTRL", timeout_milliseconds = 1500 },
keys = maps.keys,
key_tables = maps.key_tables,
mouse_bindings = {
{
event = { Up = { streak = 1, button = "Left" } },
mods = "NONE",
action = wezterm.action.CompleteSelectionOrOpenLinkAtMouseCursor("ClipboardAndPrimarySelection"),
},
},
}
return settings