From e7740e9989ff8a709f94f2d07f6d8e572f0072d9 Mon Sep 17 00:00:00 2001
From: Barrett Ruth
Date: Tue, 10 Feb 2026 18:44:55 -0500
Subject: [PATCH] move old nvim config
---
config/nvim/after/plugin/lsp.lua | 30 +-
.../queries/html/highlights.scm.disabled | 5 -
.../after/queries/javascript/highlights.scm | 5 -
config/nvim/after/queries/jsx/highlights.scm | 2 -
config/nvim/after/queries/tsx/highlights.scm | 2 -
config/nvim/init.lua | 4 +-
config/nvim/lazy-lock.json | 30 +-
config/nvim/lua/config/fold.lua | 4 +-
config/nvim/lua/config/fzf_reload.lua | 6 +-
config/nvim/lua/config/lines/statuscolumn.lua | 38 ++-
config/nvim/lua/config/lines/utils.lua | 5 +-
config/nvim/lua/config/lsp.lua | 18 +-
config/nvim/lua/lsp/clangd.lua | 2 +-
config/nvim/lua/plugins/cp.lua | 259 ++++++++++------
config/nvim/lua/plugins/git.lua | 32 +-
config/nvim/lua/plugins/guard.lua | 43 +++
config/nvim/lua/plugins/lsp.lua | 95 +-----
config/nvim/lua/plugins/nvim.lua | 279 +++++++-----------
config/nvim/lua/plugins/treesitter.lua | 28 +-
config/nvim/luasnippets/c.lua | 19 --
config/nvim/luasnippets/cpp.lua | 179 -----------
config/nvim/luasnippets/html.lua | 11 -
config/nvim/luasnippets/python.lua | 14 -
config/nvim/nvim-pack-lock.json | 2 +-
config/nvim/plugin/autocmds.lua | 39 ++-
config/nvim/plugin/highlight-undo.lua | 30 ++
config/nvim/plugin/options.lua | 15 +
27 files changed, 492 insertions(+), 704 deletions(-)
delete mode 100644 config/nvim/after/queries/html/highlights.scm.disabled
delete mode 100644 config/nvim/after/queries/javascript/highlights.scm
delete mode 100644 config/nvim/after/queries/jsx/highlights.scm
delete mode 100644 config/nvim/after/queries/tsx/highlights.scm
create mode 100644 config/nvim/lua/plugins/guard.lua
delete mode 100644 config/nvim/luasnippets/c.lua
delete mode 100644 config/nvim/luasnippets/cpp.lua
delete mode 100644 config/nvim/luasnippets/html.lua
delete mode 100644 config/nvim/luasnippets/python.lua
create mode 100644 config/nvim/plugin/highlight-undo.lua
diff --git a/config/nvim/after/plugin/lsp.lua b/config/nvim/after/plugin/lsp.lua
index f096c48..d4033d5 100644
--- a/config/nvim/after/plugin/lsp.lua
+++ b/config/nvim/after/plugin/lsp.lua
@@ -27,35 +27,7 @@ vim.lsp.config('*', {
flags = { debounce_text_changes = 0 },
})
-vim.api.nvim_create_autocmd('LspAttach', {
- callback = function(opts)
- local client = vim.lsp.get_client_by_id(opts.data.client_id)
-
- if
- client
- and (
- client:supports_method('textDocument/formatting')
- or client:supports_method('formatting')
- )
- then
- local modes = { 'n' }
-
- if
- client:supports_method('textDocument/rangeFormatting')
- or client:supports_method('rangeFormatting')
- then
- table.insert(modes, 'x')
- end
-
- bmap({
- modes,
- 'gF',
- lsp.format,
- }, { buffer = opts.buf, silent = false })
- end
- end,
- group = vim.api.nvim_create_augroup('ALspFormat', { clear = true }),
-})
+map({ { 'n', 'x' }, 'gF', lsp.format })
for _, server in ipairs({
'bashls',
diff --git a/config/nvim/after/queries/html/highlights.scm.disabled b/config/nvim/after/queries/html/highlights.scm.disabled
deleted file mode 100644
index 79886a7..0000000
--- a/config/nvim/after/queries/html/highlights.scm.disabled
+++ /dev/null
@@ -1,5 +0,0 @@
-;; extends
-(attribute (attribute_name) @att_name (#eq? @att_name "class")
- (quoted_attribute_value (attribute_value) @att_val (#set! @att_val conceal ".")
- )
-)
diff --git a/config/nvim/after/queries/javascript/highlights.scm b/config/nvim/after/queries/javascript/highlights.scm
deleted file mode 100644
index e3c448c..0000000
--- a/config/nvim/after/queries/javascript/highlights.scm
+++ /dev/null
@@ -1,5 +0,0 @@
-;; extends
-(jsx_attribute (property_identifier) @att_name (#eq? @att_name "className")
- (string (string_fragment) @att_val (#set! @att_val conceal ".")
- )
-)
diff --git a/config/nvim/after/queries/jsx/highlights.scm b/config/nvim/after/queries/jsx/highlights.scm
deleted file mode 100644
index 3c16815..0000000
--- a/config/nvim/after/queries/jsx/highlights.scm
+++ /dev/null
@@ -1,2 +0,0 @@
-;; inherits: jsx
-;; extends
diff --git a/config/nvim/after/queries/tsx/highlights.scm b/config/nvim/after/queries/tsx/highlights.scm
deleted file mode 100644
index 3c16815..0000000
--- a/config/nvim/after/queries/tsx/highlights.scm
+++ /dev/null
@@ -1,2 +0,0 @@
-;; inherits: jsx
-;; extends
diff --git a/config/nvim/init.lua b/config/nvim/init.lua
index f6315d4..92020a3 100644
--- a/config/nvim/init.lua
+++ b/config/nvim/init.lua
@@ -12,18 +12,20 @@ end
function _G.bmap(mapping, opts)
_G.map(mapping, vim.tbl_extend('force', opts or {}, { buffer = 0 }))
end
+
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
- 'https://github.com/folke/lazy.nvim.git',
+ 'git@github.com:folke/lazy.nvim.git',
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup('plugins', {
+ git = { url_format = 'git@github.com:%s.git' },
change_detection = { enabled = false },
performance = {
cache = {
diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json
index 829f697..02fafb0 100644
--- a/config/nvim/lazy-lock.json
+++ b/config/nvim/lazy-lock.json
@@ -1,48 +1,34 @@
{
- "LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
- "SchemaStore.nvim": { "branch": "main", "commit": "b850ab25279ba04ada90e8b696ef5d0624af103d" },
"blink.cmp": { "branch": "main", "commit": "4b18c32adef2898f95cdef6192cbd5796c1a332d" },
"blink.indent": { "branch": "main", "commit": "9c80820ca77218a8d28e70075d6f44a1609911fe" },
- "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" },
- "cp.nvim": { "branch": "main", "commit": "029ea125b97320ff5c2884bf84bf5aa4e7077c79" },
"dial.nvim": { "branch": "master", "commit": "f2634758455cfa52a8acea6f142dcd6271a1bf57" },
- "fzf-lua": { "branch": "main", "commit": "fb8c50ba62a0daa433b7ac2b78834f318322b879" },
- "gitsigns.nvim": { "branch": "main", "commit": "f7cc6850517b8db59a41314b83bb7994eae33cdd" },
- "grapple.nvim": { "branch": "main", "commit": "b41ddfc1c39f87f3d1799b99c2f0f1daa524c5f7" },
+ "format-ts-errors.nvim": { "branch": "main", "commit": "4b7418d6689bc0fd3c1db0500c67133422522384" },
+ "fzf-lua": { "branch": "main", "commit": "36d60dd59cd9bc0442352119fc0e45e1c9011e03" },
+ "gitsigns.nvim": { "branch": "main", "commit": "1ce96a464fdbc24208e24c117e2021794259005d" },
+ "gruvbox-material": { "branch": "master", "commit": "790afe9dd085aa04eccd1da3626c5fa05c620e53" },
+ "guard.nvim": { "branch": "main", "commit": "addb8d2f40662b8b62d60dd7d18f503beb2332e7" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" },
"live-rename.nvim": { "branch": "main", "commit": "3a3cddf23b89a17992f9ca67afc5858077769462" },
- "live-server.nvim": { "branch": "main", "commit": "26dafe2f0883022ce2c1327c113cd6b40daaf533" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
- "midnight.nvim": { "branch": "main", "commit": "130a1899c2d5a0af431f3e41eeac429e90ea1d09" },
+ "mini.ai": { "branch": "main", "commit": "9eae720f2b20f6ad28cbfa0ddc524e10dc2c3201" },
"mini.bufremove": { "branch": "main", "commit": "10857aa39160c127694151828914df3131ba83b6" },
"mini.misc": { "branch": "main", "commit": "b647b64321c34d4868d158282bb89e49f0d6838b" },
"mini.pairs": { "branch": "main", "commit": "4089aa6ea6423e02e1a8326a7a7a00159f6f5e04" },
- "none-ls.nvim": { "branch": "main", "commit": "68ed8b9bf5dfdae4d579fcd19723926f84d7b6cb" },
"nvim-colorizer.lua": { "branch": "master", "commit": "338409dd8a6ed74767bad3eb5269f1b903ffb3cf" },
- "nvim-lspconfig": { "branch": "master", "commit": "66fd02ad1c7ea31616d3ca678fa04e6d0b360824" },
+ "nvim-lspconfig": { "branch": "master", "commit": "0480b120318ec8bab27b530ffab6ee76a8c4d806" },
"nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" },
"nvim-surround": { "branch": "main", "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" },
- "nvim-treesitter": { "branch": "main", "commit": "45a07f869b0cffba342276f2c77ba7c116d35db8" },
+ "nvim-treesitter": { "branch": "main", "commit": "4967fa48b0fe7a7f92cee546c76bb4bb61bb14d5" },
"nvim-treesitter-textobjects": { "branch": "main", "commit": "a0e182ae21fda68c59d1f36c9ed45600aef50311" },
"nvim-vtsls": { "branch": "main", "commit": "0b5f73c9e50ce95842ea07bb3f05c7d66d87d14a" },
"oil.nvim": { "branch": "master", "commit": "f55b25e493a7df76371cfadd0ded5004cb9cd48a" },
"overseer.nvim": { "branch": "master", "commit": "5828bdbd86677497613033c142f0a8624489216f" },
- "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
- "rustaceanvim": { "branch": "master", "commit": "bb57d9a9c3f547504e38df1fc17dbcc7065a23f3" },
"snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },
"treesj": { "branch": "main", "commit": "186084dee5e9c8eec40f6e39481c723dd567cb05" },
- "typescript-tools.nvim": { "branch": "master", "commit": "c2f5910074103705661e9651aa841e0d7eea9932" },
"typst-preview.nvim": { "branch": "master", "commit": "e123a7ab64e52d836e00dea9251e85b201f38966" },
"vim-abolish": { "branch": "master", "commit": "dcbfe065297d31823561ba787f51056c147aa682" },
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" },
- "vim-jsx-pretty": { "branch": "master", "commit": "6989f1663cc03d7da72b5ef1c03f87e6ddb70b41" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
- "vim-textobj-entire": { "branch": "master", "commit": "64a856c9dff3425ed8a863b9ec0a21dbaee6fb3a" },
- "vim-textobj-indent": { "branch": "master", "commit": "deb76867c302f933c8f21753806cbf2d8461b548" },
- "vim-textobj-line": { "branch": "master", "commit": "1a6780d29adcf7e464e8ddbcd0be0a9df1a37339" },
- "vim-textobj-sentence": { "branch": "master", "commit": "c5dd562aff2c389dfc8cd55e6499854d352a80b8" },
- "vim-textobj-user": { "branch": "master", "commit": "41a675ddbeefd6a93664a4dc52f302fe3086a933" },
- "vim-textobj-xmlattr": { "branch": "master", "commit": "694a297f1d75fd527e87da9769f3c6519a87ebb1" },
"vimtex": { "branch": "master", "commit": "f707368022cdb851716be0d2970b90599c84a6a6" }
}
diff --git a/config/nvim/lua/config/fold.lua b/config/nvim/lua/config/fold.lua
index 4fe65d6..8191abf 100644
--- a/config/nvim/lua/config/fold.lua
+++ b/config/nvim/lua/config/fold.lua
@@ -3,7 +3,7 @@ local M = {}
---@param bufnr number the buffer number
---@return boolean whether the below foldexpr() is applicable to the buffer
-local function is_foldexpr(bufnr)
+local function should_apply_foldexpr(bufnr)
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
return ok and parser
end
@@ -144,7 +144,7 @@ function M.setup()
pattern = '*',
callback = function(opts)
-- do not override fold settings if not applicable
- if is_foldexpr(opts.bufnr) then
+ if should_apply_foldexpr(opts.bufnr) then
vim.wo.foldmethod = 'expr'
vim.wo.foldexpr = 'v:lua.require("config.fold").foldexpr()'
end
diff --git a/config/nvim/lua/config/fzf_reload.lua b/config/nvim/lua/config/fzf_reload.lua
index edf73ca..9b49366 100644
--- a/config/nvim/lua/config/fzf_reload.lua
+++ b/config/nvim/lua/config/fzf_reload.lua
@@ -10,7 +10,11 @@ end
---@disable_fzf_lua_reload boolean?
function M.reload(disable_fzf_lua_reload)
- local lines = vim.fn.readfile(vim.fn.expand('~/.config/fzf/themes/theme'))
+ local path = vim.fn.expand('~/.config/fzf/themes/theme')
+ if vim.fn.filereadable(path) == 0 then
+ return
+ end
+ local lines = vim.fn.readfile(path)
if not lines or #lines == 0 then
return
end
diff --git a/config/nvim/lua/config/lines/statuscolumn.lua b/config/nvim/lua/config/lines/statuscolumn.lua
index 7cb7e39..3038c1f 100644
--- a/config/nvim/lua/config/lines/statuscolumn.lua
+++ b/config/nvim/lua/config/lines/statuscolumn.lua
@@ -1,25 +1,37 @@
return {
+ -- overlay relative numbers and line numbers directly on top of eachother
num = function()
if math.abs(vim.v.virtnum) > 0 then
return ''
- elseif vim.v.relnum == 0 then
- return '%#CursorLineNr#' .. vim.v.lnum
end
- return '%#LineNr#' .. vim.v.relnum
- end,
- fold = function()
- local expr = require('config.fold').foldexpr()
- if expr:sub(1, 1) == '>' then
- if vim.fn.foldclosed(vim.v.lnum) ~= -1 then
- return '>'
- else
- return 'v'
+ local lnum = vim.v.lnum
+ local relnum = vim.v.relnum
+ local hl = relnum == 0 and 'CursorLineNr' or 'LineNr'
+
+ local marks = vim.api.nvim_buf_get_extmarks(0, -1, { lnum - 1, 0 }, { lnum - 1, 0 }, { details = true })
+ for _, mark in ipairs(marks) do
+ if mark[4] and mark[4].number_hl_group then
+ hl = mark[4].number_hl_group
+ break
end
end
- return ' '
+
+ return '%#' .. hl .. '#' .. (relnum == 0 and lnum or relnum)
end,
+ -- fold = function()
+ -- local expr = require('config.fold').foldexpr()
+ -- if expr:sub(1, 1) == '>' then
+ -- if vim.fn.foldclosed(vim.v.lnum) ~= -1 then
+ -- return '>'
+ -- else
+ -- return 'v'
+ -- end
+ -- end
+ -- return ' '
+ -- end,
statuscolumn = function()
- return '%{%v:lua.require("config.lines.statuscolumn").fold()%}%s%=%{%v:lua.require("config.lines.statuscolumn").num()%} '
+ -- return '%{%v:lua.require("config.lines.statuscolumn").fold()%}%s%=%{%v:lua.require("config.lines.statuscolumn").num()%} '
+ return '%=%{%v:lua.require("config.lines.statuscolumn").num()%} '
end,
}
diff --git a/config/nvim/lua/config/lines/utils.lua b/config/nvim/lua/config/lines/utils.lua
index 3101dfc..fb13089 100644
--- a/config/nvim/lua/config/lines/utils.lua
+++ b/config/nvim/lua/config/lines/utils.lua
@@ -16,15 +16,12 @@ function M.format_components(components)
for i = 1, #components do
local component = components[i]
- local highlight = vim.env.THEME == 'midnight' and 'Normal'
- or component.highlight
-
if
vorfn(component.condition) ~= false
and not utils.empty(vorfn(component.value))
then
side[#side + 1] = ('%%#%s#%s%%#%s#'):format(
- highlight,
+ component.highlight or 'Normal',
vorfn(component.value),
component.highlight or 'Normal'
)
diff --git a/config/nvim/lua/config/lsp.lua b/config/nvim/lua/config/lsp.lua
index 4a60340..8f8e476 100644
--- a/config/nvim/lua/config/lsp.lua
+++ b/config/nvim/lua/config/lsp.lua
@@ -79,19 +79,13 @@ function M.on_attach(client, bufnr)
end
end
-local FORMAT_LSPS = { 'null-ls', 'clangd', 'tinymist', 'ruff' }
-
function M.format(opts)
- local format_opts = vim.tbl_extend('force', opts or {}, {
- filter = function(c)
- if c.name == 'typescript-tools' then
- vim.cmd.TSToolsOrganizeImports()
- end
- return vim.tbl_contains(FORMAT_LSPS, c.name)
- end,
- })
- vim.lsp.buf.format(format_opts)
- vim.cmd.w()
+ local ok, guard = pcall(require, 'guard')
+ if ok then
+ guard.fmt()
+ else
+ vim.lsp.buf.format(opts or { async = true })
+ end
end
return M
diff --git a/config/nvim/lua/lsp/clangd.lua b/config/nvim/lua/lsp/clangd.lua
index dc66564..bb52bbd 100644
--- a/config/nvim/lua/lsp/clangd.lua
+++ b/config/nvim/lua/lsp/clangd.lua
@@ -33,7 +33,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
)
end
end,
- group = vim.api.nvim_creat_augroup('AClangdKeymap', { clear = true }),
+ group = vim.api.nvim_create_augroup('AClangdKeymap', { clear = true }),
})
return vim.tbl_extend('force', clangd_settings, project_settings or {})
diff --git a/config/nvim/lua/plugins/cp.lua b/config/nvim/lua/plugins/cp.lua
index b370e04..d9f8921 100644
--- a/config/nvim/lua/plugins/cp.lua
+++ b/config/nvim/lua/plugins/cp.lua
@@ -1,50 +1,4 @@
-local default_cpp_lang = {
- extension = 'cc',
- commands = {
- build = {
- 'g++',
- '-std=c++23',
- '-O2',
- '-Wall',
- '-Wextra',
- '-Wpedantic',
- '-Wshadow',
- '-Wconversion',
- '-Wformat=2',
- '-Wfloat-equal',
- '-Wundef',
- '-fdiagnostics-color=always',
- '-DLOCAL',
- '{source}',
- '-o',
- '{binary}',
- },
- run = { '{binary}' },
- debug = {
- 'g++',
- '-std=c++23',
- '-g3',
- '-fsanitize=address,undefined',
- '-fno-omit-frame-pointer',
- '-fstack-protector-all',
- '-D_GLIBCXX_DEBUG',
- '-DLOCAL',
- '{source}',
- '-o',
- '{binary}',
- },
- },
-}
-
-local default_python_lang = {
- extension = 'py',
- commands = {
- run = { 'python', '{source}' },
- debug = { 'python', '{source}' },
- },
-}
-
-local clang_format_content = [[BasedOnStyle: LLVM
+local clang_format = [[BasedOnStyle: LLVM
IndentWidth: 2
UseTab: Never
@@ -62,27 +16,177 @@ AlignAfterOpenBracket: Align
BinPackArguments: false
BinPackParameters: false]]
+local cpp_base = [[#include // {{{
+
+#include
+#ifdef __cpp_lib_ranges_enumerate
+#include
+namespace rv = std::views;
+namespace rs = std::ranges;
+#endif
+
+#pragma GCC optimize("O2,unroll-loops")
+#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
+
+using namespace std;
+
+using i32 = int32_t;
+using u32 = uint32_t;
+using i64 = int64_t;
+using u64 = uint64_t;
+using f64 = double;
+using f128 = long double;
+
+#if __cplusplus >= 202002L
+template
+constexpr T MIN = std::numeric_limits::min();
+
+template
+constexpr T MAX = std::numeric_limits::max();
+#endif
+
+#ifdef LOCAL
+#define db(...) std::print(__VA_ARGS__)
+#define dbln(...) std::println(__VA_ARGS__)
+#else
+#define db(...)
+#define dbln(...)
+#endif
+// }}}
+
+void solve() {
+ <++>
+}
+
+int main() { // {{{
+ std::cin.exceptions(std::cin.failbit);
+#ifdef LOCAL
+ std::cerr.rdbuf(std::cout.rdbuf());
+ std::cout.setf(std::ios::unitbuf);
+ std::cerr.setf(std::ios::unitbuf);
+#else
+ std::cin.tie(nullptr)->sync_with_stdio(false);
+#endif
+]]
+
+local cpp_single = cpp_base .. [[ solve();
+ return 0;
+} // }}}]]
+
+local cpp_multi = cpp_base .. [[ u32 tc = 1;
+ std::cin >> tc;
+ for (u32 t = 0; t < tc; ++t) {
+ solve();
+ }
+ return 0;
+} // }}}]]
+
+local templates = {
+ cpp = {
+ default = cpp_multi,
+ codeforces = cpp_multi,
+ atcoder = cpp_single,
+ cses = cpp_single,
+ },
+ python = {
+ default = [[def main() -> None:
+ <++>
+
+
+if __name__ == '__main__':
+ main()]],
+ },
+}
+
+local function insert_template(buf, lang, platform)
+ local lang_templates = templates[lang]
+ if not lang_templates then
+ return false
+ end
+
+ local template = lang_templates[platform] or lang_templates.default
+ if not template then
+ return false
+ end
+
+ local lines = vim.split(template, '\n')
+ vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
+
+ for lnum, line in ipairs(lines) do
+ local col = line:find('<++>', 1, true)
+ if col then
+ local new_line = line:sub(1, col - 1) .. line:sub(col + 4)
+ vim.api.nvim_buf_set_lines(buf, lnum - 1, lnum, false, { new_line })
+ vim.api.nvim_win_set_cursor(0, { lnum, col - 1 })
+ break
+ end
+ end
+
+ return true
+end
+
return {
'barrettruth/cp.nvim',
+ dir = '~/dev/cp.nvim',
cmd = 'CP',
keys = {
{ 'ce', 'CP edit' },
{ 'cp', 'CP panel' },
{ 'cP', 'CP pick' },
- { 'cr', 'CP run' },
+ { 'cr', 'CP run all' },
{ 'cd', 'CP run --debug' },
{ 'cc', 'CP cache read' },
{ ']c', 'CP next' },
{ '[c', 'CP prev' },
},
- dependencies = {
- 'ibhagwan/fzf-lua'
- },
- config = function()
- require('cp').setup({
+ init = function()
+ vim.g.cp = {
+ debug = false,
languages = {
- cpp = default_cpp_lang,
- python = default_python_lang,
+ cpp = {
+ extension = 'cc',
+ commands = {
+ build = {
+ 'g++',
+ '-std=c++23',
+ '-O2',
+ '-Wall',
+ '-Wextra',
+ '-Wpedantic',
+ '-Wshadow',
+ '-Wconversion',
+ '-Wformat=2',
+ '-Wfloat-equal',
+ '-Wundef',
+ '-fdiagnostics-color=always',
+ '-DLOCAL',
+ '{source}',
+ '-o',
+ '{binary}',
+ },
+ run = { '{binary}' },
+ debug = {
+ 'g++',
+ '-std=c++23',
+ '-g3',
+ '-fsanitize=address,undefined',
+ '-fno-omit-frame-pointer',
+ '-fstack-protector-all',
+ '-D_GLIBCXX_DEBUG',
+ '-DLOCAL',
+ '{source}',
+ '-o',
+ '{binary}',
+ },
+ },
+ },
+ python = {
+ extension = 'py',
+ commands = {
+ run = { 'python', '{source}' },
+ debug = { 'python', '{source}' },
+ },
+ },
},
platforms = {
codeforces = {
@@ -95,7 +199,10 @@ return {
},
cses = {},
},
- ui = { picker = 'fzf-lua' },
+ ui = {
+ picker = 'fzf-lua',
+ panel = { diff_modes = { 'side-by-side', 'git' } },
+ },
hooks = {
setup_io_input = function(buf)
require('cp.helpers').clearcol(buf)
@@ -120,48 +227,22 @@ return {
local buf = vim.api.nvim_get_current_buf()
local lines = vim.api.nvim_buf_get_lines(buf, 0, 1, true)
if #lines > 1 or (#lines == 1 and lines[1] ~= '') then
- local pos = vim.api.nvim_win_get_cursor(0)
- vim.cmd('normal! zx')
- vim.api.nvim_win_set_cursor(0, pos)
return
end
- local trigger = state.get_platform() or ''
- vim.api.nvim_buf_set_lines(buf, 0, -1, false, { trigger })
- vim.api.nvim_win_set_cursor(0, { 1, #trigger })
- vim.cmd.startinsert({ bang = true })
- vim.schedule(function()
- local ls = require('luasnip')
- if ls.expandable() then
- vim.api.nvim_create_autocmd('TextChanged', {
- buffer = buf,
- once = true,
- callback = function()
- vim.schedule(function()
- local pos =
- vim.api.nvim_win_get_cursor(0)
- vim.cmd('normal! zx')
- vim.api.nvim_win_set_cursor(0, pos)
- end)
- end,
- })
- ls.expand()
- end
- vim.cmd.stopinsert()
- end)
- local clang_format_path = vim.fn.getcwd()
- .. '/.clang-format'
+ local lang = state.get_language()
+ local platform = state.get_platform()
+ insert_template(buf, lang, platform)
+
+ local clang_format_path = vim.fn.getcwd() .. '/.clang-format'
if vim.fn.filereadable(clang_format_path) == 0 then
- vim.fn.writefile(
- vim.split(clang_format_content, '\n'),
- clang_format_path
- )
+ vim.fn.writefile(vim.split(clang_format, '\n'), clang_format_path)
end
end,
},
filename = function(_, _, problem_id)
return problem_id
end,
- })
+ }
end,
}
diff --git a/config/nvim/lua/plugins/git.lua b/config/nvim/lua/plugins/git.lua
index da3ea6f..cb02a90 100644
--- a/config/nvim/lua/plugins/git.lua
+++ b/config/nvim/lua/plugins/git.lua
@@ -1,15 +1,33 @@
----@type number|nil
-local git_tab = nil
-
---@type string|nil
-local prev = nil
+local prev_gitsigns_signcol = nil
return {
{
'tpope/vim-fugitive',
- cmd = 'Git',
+ cmd = { 'Git', 'G', 'Gread', 'Gwrite', 'Gdiffsplit', 'Gvdiffsplit' },
},
{
+ 'barrettruth/diffs.nvim',
+ dir = '~/dev/diffs.nvim',
+ enabled = true,
+ init = function()
+ vim.g.diffs = {
+ debug = false,
+ hide_prefix = true,
+ highlights = {
+ vim = {
+ enabled = true,
+ },
+ intra = {
+ enabled = true,
+ max_lines = 500,
+ },
+ },
+ }
+ end,
+ },
+ {
+ -- TODO: find out a way to remove this/better overall github integration
'folke/snacks.nvim',
---@type snacks.Config
opts = { gitbrowse = {} },
@@ -29,10 +47,10 @@ return {
'Gs',
function()
if vim.opt.signcolumn:get() == 'no' then
- prev = vim.opt.signcolumn:get()
+ prev_gitsigns_signcol = vim.opt.signcolumn:get()
vim.opt.signcolumn = 'yes'
else
- vim.opt.signcolumn = prev
+ vim.opt.signcolumn = prev_gitsigns_signcol
end
vim.cmd.Gitsigns('toggle_signs')
end,
diff --git a/config/nvim/lua/plugins/guard.lua b/config/nvim/lua/plugins/guard.lua
new file mode 100644
index 0000000..139da35
--- /dev/null
+++ b/config/nvim/lua/plugins/guard.lua
@@ -0,0 +1,43 @@
+return {
+ 'nvimdev/guard.nvim',
+ -- TODO: use main repo when #76 merged
+ dependencies = {
+ { dir = '~/dev/guard-collection', 'barrettruth/guard-collection' },
+ },
+ init = function()
+ vim.g.guard_config = {
+ fmt_on_save = false,
+ save_on_fmt = true,
+ lsp_as_default_formatter = true,
+ }
+ end,
+ config = function()
+ local ft = require('guard.filetype')
+
+ ft('python'):fmt({
+ cmd = 'isort',
+ args = { '--profile', 'black', '-' },
+ stdin = true,
+ }):append('black'):lint('mypy')
+
+ ft('lua'):fmt('stylua'):lint('selene')
+
+ ft('javascript,javascriptreact,typescript,typescriptreact'):fmt('prettierd'):lint('eslint_d')
+ ft('css,graphql,html,json,jsonc,mdx,yaml'):fmt('prettierd')
+
+ ft('sh,bash,zsh'):fmt({
+ cmd = 'shfmt',
+ args = { '-i', '2' },
+ stdin = true,
+ })
+ ft('zsh'):lint('zsh')
+
+ ft('proto'):fmt('buf'):lint('buf')
+ ft('dockerfile'):lint('hadolint')
+ ft('tex'):fmt('latexindent')
+ ft('cmake'):fmt('cmake-format')
+ ft('make'):lint('checkmake')
+ ft('cpp'):lint('cpplint')
+ ft('markdown'):fmt('cbfmt'):append('prettierd')
+ end,
+}
diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua
index 3115a90..b5de052 100644
--- a/config/nvim/lua/plugins/lsp.lua
+++ b/config/nvim/lua/plugins/lsp.lua
@@ -11,11 +11,11 @@ return {
},
{
'saghen/blink.cmp',
- version = '1.*',
- dependencies = { 'folke/lazydev.nvim', 'L3MON4D3/LuaSnip' },
+ build = 'cargo build --release',
+ dependencies = 'folke/lazydev.nvim',
---@module 'blink.cmp'
---@type blink.cmp.Config
- event = { 'InsertEnter', 'CmdlineEnter' },
+ event = { 'InsertEnter', 'LspAttach' },
config = function(_, opts)
vim.o.pumheight = 15
opts.completion.menu.max_height = vim.o.pumheight
@@ -56,15 +56,16 @@ return {
},
},
cmdline = {
- completion = {
- menu = {
- auto_show = true,
- },
- },
- keymap = {
- [''] = false,
- [''] = false,
- },
+ enabled = false,
+ -- completion = {
+ -- menu = {
+ -- auto_show = true,
+ -- },
+ -- },
+ -- keymap = {
+ -- [''] = false,
+ -- [''] = false,
+ -- },
},
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
@@ -80,9 +81,6 @@ return {
keys = { { '', mode = 'i' } },
opts_extend = { 'sources.default' },
},
- {
- 'b0o/SchemaStore.nvim',
- },
{
'saecki/live-rename.nvim',
event = 'LspAttach',
@@ -113,7 +111,6 @@ return {
},
{
'yioneko/nvim-vtsls',
- enabled = false,
config = function(_, opts)
require('vtsls').config(opts)
end,
@@ -180,72 +177,6 @@ return {
},
},
},
- {
- 'pmizio/typescript-tools.nvim',
- enabled = false,
- opts = {
- on_attach = function(_, bufnr)
- bmap(
- { 'n', 'gD', vim.cmd.TSToolsGoToSourceDefinition },
- { buffer = bufnr }
- )
- end,
- handlers = {
- ['textDocument/publishDiagnostics'] = function(_, result, ctx)
- if not result.diagnostics then
- return
- end
-
- local idx = 1
- while idx <= #result.diagnostics do
- local entry = result.diagnostics[idx]
-
- local formatter =
- require('format-ts-errors')[entry.code]
- entry.message = formatter and formatter(entry.message)
- or entry.message
-
- if vim.tbl_contains({ 80001, 80006 }, entry.code) then
- table.remove(result.diagnostics, idx)
- else
- idx = idx + 1
- end
- end
-
- vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx)
- end,
- },
-
- settings = {
- expose_as_code_action = 'all',
- -- tsserver_path = vim.env.XDG_DATA_HOME .. '/pnpm/tsserver',
- tsserver_file_preferences = {
- includeInlayarameterNameHints = 'all',
- includeInlayarameterNameHintsWhenArgumentMatchesName = false,
- includeInlayFunctionParameterTypeHints = true,
- includeInlayVariableTypeHints = true,
- includeInlayVariableTypeHintsWhenTypeMatchesName = false,
- includeInlayPropertyDeclarationTypeHints = true,
- includeInlayFunctionLikeReturnTypeHints = true,
- includeInlayEnumMemberValueHints = true,
- },
- },
- },
- dependencies = {
- 'nvim-lua/plenary.nvim',
- },
- ft = {
- 'javascript',
- 'javascriptreact',
- 'typescript',
- 'typescriptreact',
- },
- },
- {
- 'mrcjkb/rustaceanvim',
- enabled = false,
- ft = { 'rust' },
- },
{
'SmiteshP/nvim-navic',
opts = {
diff --git a/config/nvim/lua/plugins/nvim.lua b/config/nvim/lua/plugins/nvim.lua
index a49861f..a7af3ba 100644
--- a/config/nvim/lua/plugins/nvim.lua
+++ b/config/nvim/lua/plugins/nvim.lua
@@ -1,16 +1,116 @@
return {
- {
- 'barrettruth/live-server.nvim',
- build = 'pnpm add -g live-server',
- cmd = { 'LiveServerStart', 'LiveServerStart' },
- config = true,
- keys = { { 'L', 'LiveServerToggle' } },
- },
{
'echasnovski/mini.pairs',
config = true,
event = 'InsertEnter',
},
+ {
+ 'echasnovski/mini.ai',
+ opts = {
+ custom_textobjects = {
+ b = false,
+ f = false,
+ e = function(ai_type)
+ local n_lines = vim.fn.line('$')
+ local start_line, end_line = 1, n_lines
+ if ai_type == 'i' then
+ while
+ start_line <= n_lines
+ and vim.fn.getline(start_line):match('^%s*$')
+ do
+ start_line = start_line + 1
+ end
+ while
+ end_line >= start_line
+ and vim.fn.getline(end_line):match('^%s*$')
+ do
+ end_line = end_line - 1
+ end
+ end
+ local to_col = math.max(vim.fn.getline(end_line):len(), 1)
+ return {
+ from = { line = start_line, col = 1 },
+ to = { line = end_line, col = to_col },
+ }
+ end,
+ l = function(ai_type)
+ local line_num = vim.fn.line('.')
+ local line = vim.fn.getline(line_num)
+ if line == '' then
+ return {
+ from = { line = line_num, col = 1 },
+ to = { line = line_num, col = 1 },
+ }
+ end
+ local start_col, end_col
+ if ai_type == 'i' then
+ start_col = line:find('%S') or 1
+ end_col = line:match('.*%S()') or 1
+ else
+ start_col, end_col = 1, line:len()
+ end
+ return {
+ from = { line = line_num, col = start_col },
+ to = { line = line_num, col = end_col },
+ }
+ end,
+ I = function(ai_type)
+ local cur_line = vim.fn.line('.')
+ local cur_indent = vim.fn.indent(cur_line)
+ if vim.fn.getline(cur_line):match('^%s*$') then
+ local search_line = cur_line + 1
+ while
+ search_line <= vim.fn.line('$')
+ and vim.fn.getline(search_line):match('^%s*$')
+ do
+ search_line = search_line + 1
+ end
+ if search_line <= vim.fn.line('$') then
+ cur_indent = vim.fn.indent(search_line)
+ end
+ end
+ local start_line, end_line = cur_line, cur_line
+ while start_line > 1 do
+ local prev = start_line - 1
+ local prev_blank = vim.fn.getline(prev):match('^%s*$')
+ if ai_type == 'i' and prev_blank then
+ break
+ end
+ if
+ not prev_blank
+ and vim.fn.indent(prev) < cur_indent
+ then
+ break
+ end
+ start_line = prev
+ end
+ while end_line < vim.fn.line('$') do
+ local next = end_line + 1
+ local next_blank = vim.fn.getline(next):match('^%s*$')
+ if ai_type == 'i' and next_blank then
+ break
+ end
+ if
+ not next_blank
+ and vim.fn.indent(next) < cur_indent
+ then
+ break
+ end
+ end_line = next
+ end
+ local to_col = math.max(vim.fn.getline(end_line):len(), 1)
+ return {
+ from = { line = start_line, col = 1 },
+ to = { line = end_line, col = to_col },
+ }
+ end,
+ },
+ },
+ keys = {
+ { 'a', mode = { 'x', 'o' } },
+ { 'i', mode = { 'x', 'o' } },
+ },
+ },
{
'iamcco/markdown-preview.nvim',
build = 'pnpm up && cd app && pnpm install',
@@ -40,7 +140,6 @@ return {
},
{
'lervag/vimtex',
- enabled = false,
init = function()
vim.g.vimtex_view_method = 'general'
vim.g.vimtex_compiler_method = 'latexmk'
@@ -49,88 +148,6 @@ return {
end,
ft = { 'plaintext', 'tex' },
},
- {
- 'L3MON4D3/LuaSnip',
- build = 'make install_jsregexp',
- config = function()
- local ls = require('luasnip')
-
- ls.filetype_extend('htmldjango', { 'html' })
- ls.filetype_extend('markdown', { 'html' })
- ls.filetype_extend('javascriptreact', { 'javascript', 'html' })
- ls.filetype_extend('typescript', { 'javascript' })
- ls.filetype_extend(
- 'typescriptreact',
- { 'javascriptreact', 'javascript', 'html' }
- )
-
- require('luasnip.loaders.from_lua').lazy_load()
- end,
- keys = {
- -- restore digraph mapping
- { '', '', mode = 'i' },
- {
- '',
- 'lua require("luasnip").expand()',
- mode = 'i',
- },
- {
- '',
- 'lua if require("luasnip").jumpable(-1) then require("luasnip").jump(-1) end',
- mode = { 'i', 's' },
- },
- {
- '',
- 'lua if require("luasnip").jumpable(1) then require("luasnip").jump(1) end',
- mode = { 'i', 's' },
- },
- {
- '',
- 'lua if require("luasnip").choice_active() then require("luasnip").change_choice(-1) end',
- mode = 'i',
- },
- {
- '',
- 'lua if require("luasnip").choice_active() then require("luasnip").change_choice(1) end',
- mode = 'i',
- },
- },
- opts = {
- region_check_events = 'InsertEnter',
- delete_check_events = {
- 'TextChanged',
- 'TextChangedI',
- 'InsertLeave',
- },
- ext_opts = {
- [require('luasnip.util.types').choiceNode] = {
- active = {
- virt_text = {
- {
- ' <- ',
- vim.wo.cursorline and 'CursorLine' or 'Normal',
- },
- },
- },
- },
- },
- },
- },
- {
- 'laytan/cloak.nvim',
- config = true,
- keys = { { 'Ct', 'CloakToggle' } },
- event = 'BufReadPre .env*',
- },
- {
- 'maxmellon/vim-jsx-pretty',
- ft = {
- 'javascript',
- 'javascriptreact',
- 'typescript',
- 'typescriptreact',
- },
- },
{
'monaqa/dial.nvim',
config = function(_)
@@ -208,31 +225,6 @@ return {
},
},
},
- {
- 'cbochs/grapple.nvim',
- opts = {
- scope = 'git_branch',
- icons = false,
- status = false,
- win_opts = {
- title = '',
- footer = '',
- },
- },
- keys = {
- { 'ha', 'Grapple toggle' },
- { 'hd', 'Grapple untag' },
- { 'hq', 'Grapple toggle_tags' },
-
- { '', 'Grapple select index=1' },
- { '', 'Grapple select index=2' },
- { '', 'Grapple select index=3' },
- { '', 'Grapple select index=4' },
-
- { ']h', 'Grapple cycle_tags next' },
- { '[h', 'Grapple cycle_tags prev' },
- },
- },
{
'catgoose/nvim-colorizer.lua',
opts = {
@@ -348,46 +340,6 @@ return {
{ 'ySs', mode = 'n' },
},
},
- {
- 'kana/vim-textobj-user',
- dependencies = {
- {
- 'kana/vim-textobj-entire',
- keys = {
- { 'ae', mode = { 'o', 'x' } },
- { 'ie', mode = { 'o', 'x' } },
- },
- },
- {
- 'kana/vim-textobj-line',
- keys = {
- { 'al', mode = { 'o', 'x' } },
- { 'il', mode = { 'o', 'x' } },
- },
- },
- {
- 'kana/vim-textobj-indent',
- keys = {
- { 'ai', mode = { 'o', 'x' } },
- { 'ii', mode = { 'o', 'x' } },
- },
- },
- {
- 'preservim/vim-textobj-sentence',
- keys = {
- { 'as', mode = { 'o', 'x' } },
- { 'is', mode = { 'o', 'x' } },
- },
- },
- {
- 'whatyouhide/vim-textobj-xmlattr',
- keys = {
- { 'ax', mode = { 'o', 'x' } },
- { 'ix', mode = { 'o', 'x' } },
- },
- },
- },
- },
{
'saghen/blink.indent',
opts = {
@@ -397,6 +349,7 @@ return {
'fugitive',
'markdown',
'typst',
+ 'git',
},
},
static = {
@@ -407,19 +360,9 @@ return {
},
{
'barrettruth/midnight.nvim',
- init = function()
- vim.api.nvim_create_autocmd({ 'OptionSet' }, {
- pattern = 'background',
- callback = function()
- vim.cmd.colorscheme(
- vim.o.background == 'dark' and 'midnight' or 'daylight'
- )
- end,
- group = vim.api.nvim_create_augroup(
- 'AColorScheme',
- { clear = true }
- ),
- })
+ dir = '~/dev/midnight.nvim',
+ config = function()
+ vim.cmd.colorscheme('midnight')
end,
},
}
diff --git a/config/nvim/lua/plugins/treesitter.lua b/config/nvim/lua/plugins/treesitter.lua
index 41ae1a2..f811885 100644
--- a/config/nvim/lua/plugins/treesitter.lua
+++ b/config/nvim/lua/plugins/treesitter.lua
@@ -28,30 +28,8 @@ return {
),
})
end,
- keys = {
- {
- 'T',
- function()
- local lang_map = { htmldjango = 'html' }
- local bufnr = vim.api.nvim_get_current_buf()
- local parser = vim.treesitter.get_parser(bufnr)
- local lang = parser:lang()
- local path = (
- vim.env.NVIM_APPNAME or vim.fn.stdpath('config')
- )
- .. ('/after/queries/%s/highlights.scm'):format(
- lang_map[lang] or lang
- )
-
- if vim.loop.fs_stat(path) then
- vim.fn.rename(path, path .. '.disabled')
- elseif vim.loop.fs_stat(path .. '.disabled') then
- vim.fn.rename(path .. '.disabled', path)
- end
- vim.cmd.TSBufToggle('highlight')
- vim.cmd.TSBufToggle('highlight')
- end,
- },
+ opts = {
+ auto_install = true,
},
},
{
@@ -78,8 +56,6 @@ return {
local select_maps = {
{ 'aa', '@parameter.outer' },
{ 'ia', '@parameter.inner' },
- { 'ab', '@block.outer' },
- { 'ib', '@block.inner' },
{ 'as', '@class.outer' },
{ 'is', '@class.inner' },
{ 'aC', '@call.outer' },
diff --git a/config/nvim/luasnippets/c.lua b/config/nvim/luasnippets/c.lua
deleted file mode 100644
index f72aa53..0000000
--- a/config/nvim/luasnippets/c.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-return {
- s('/* ', fmt('/* {} */', { i(1) })),
- s('pr', fmt('printf("{}", {});', { i(1), i(2) })),
- s(
- 'main',
- fmt(
- [[
- #include
-
- int main(void) {{
- {}
-
- return 0;
- }}
- ]],
- { i(1) }
- )
- ),
-}
diff --git a/config/nvim/luasnippets/cpp.lua b/config/nvim/luasnippets/cpp.lua
deleted file mode 100644
index 26193da..0000000
--- a/config/nvim/luasnippets/cpp.lua
+++ /dev/null
@@ -1,179 +0,0 @@
-local ls = require('luasnip')
-local s, i, fmt = ls.snippet, ls.insert_node, require('luasnip.extras.fmt').fmt
-
-local cppsnippets = {}
-
-local template = [=[#include // {{{{{{
-
-#include
-#ifdef __cpp_lib_ranges_enumerate
-#include
-namespace rv = std::views;
-namespace rs = std::ranges;
-#endif
-
-#pragma GCC optimize("O2,unroll-loops")
-#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
-
-using namespace std;
-
-using i32 = int32_t;
-using u32 = uint32_t;
-using i64 = int64_t;
-using u64 = uint64_t;
-using f64 = double;
-using f128 = long double;
-
-#if __cplusplus >= 202002L
-template
-constexpr T MIN = std::numeric_limits::min();
-
-template
-constexpr T MAX = std::numeric_limits::max();
-#endif
-
-#ifdef LOCAL
-#define db(...) std::print(__VA_ARGS__)
-#define dbln(...) std::println(__VA_ARGS__)
-#else
-#define db(...)
-#define dbln(...)
-#endif
-// }}}}}}]=]
-
--- utility snippets
-for _, snippet in ipairs({
- s('in', fmt('#include {}', { i(1) })),
- s(
- 'main',
- fmt(
- [[#include
-
-int main() {{
- {}
-
- return 0;
-}}]],
- { i(1) }
- )
- ),
- s('pr', fmt('std::cout << {}', { i(1) })),
- s('s', fmt('std::{}', { i(1) })),
- s(
- 'pbds',
- fmt(
- [[
-#include
-#include
-
-namespace pbds = __gnu_pbds;
-
-template
-using hashset = pbds::gp_hash_table;
-
-template
-using hashmap = pbds::gp_hash_table;
-
-template
-using multitreemap =
- pbds::tree, pbds::rb_tree_tag,
- pbds::tree_order_statistics_node_update>;
-
-template
-using treeset =
- pbds::tree, pbds::rb_tree_tag,
- pbds::tree_order_statistics_node_update>;
-
-template
-using treemap =
- pbds::tree, pbds::rb_tree_tag,
- pbds::tree_order_statistics_node_update>;
-
-template
-using treemultiset =
- pbds::tree, pbds::rb_tree_tag,
- pbds::tree_order_statistics_node_update>;
- ]],
- {}
- )
- ),
-}) do
- table.insert(cppsnippets, snippet)
-end
-
-for _, entry in ipairs({
- {
- trig = 'codeforces',
- body = template .. [[
-
-
-void solve() {{
- {}
-}}
-
-int main() {{ // {{{{{{
- std::cin.exceptions(std::cin.failbit);
-#ifdef LOCAL
- std::cerr.rdbuf(std::cout.rdbuf());
- std::cout.setf(std::ios::unitbuf);
- std::cerr.setf(std::ios::unitbuf);
-#else
- std::cin.tie(nullptr)->sync_with_stdio(false);
-#endif
- u32 tc = 1;
- std::cin >> tc;
- for (u32 t = 0; t < tc; ++t) {{
- solve();
- }}
- return 0;
-}} // vim: set foldmethod=marker foldmarker={{{{{{,}}}}}}]],
- },
- {
- trig = 'atcoder',
- body = template .. [[
-
-
-void solve() {{
- {}
-}}
-
-int main() {{ // {{{{{{
- std::cin.exceptions(std::cin.failbit);
-#ifdef LOCAL
- std::cerr.rdbuf(std::cout.rdbuf());
- std::cout.setf(std::ios::unitbuf);
- std::cerr.setf(std::ios::unitbuf);
-#else
- std::cin.tie(nullptr)->sync_with_stdio(false);
-#endif
- solve();
- return 0;
-}} // vim: set foldmethod=marker foldmarker={{{{{{,}}}}}}]],
- },
- {
- trig = 'cses',
- body = template .. [[
-
-
-void solve() {{
- {}
-}}
-
-int main() {{ // {{{{{{
- std::cin.exceptions(std::cin.failbit);
-#ifdef LOCAL
- std::cerr.rdbuf(std::cout.rdbuf());
- std::cout.setf(std::ios::unitbuf);
- std::cerr.setf(std::ios::unitbuf);
-#else
- std::cin.tie(nullptr)->sync_with_stdio(false);
-#endif
- solve();
- return 0;
-}} // vim: set foldmethod=marker foldmarker={{{{{{,}}}}}}]],
- },
-}) do
- table.insert(cppsnippets, s(entry.trig, fmt(entry.body, { i(1) })))
-end
-
-return cppsnippets
diff --git a/config/nvim/luasnippets/html.lua b/config/nvim/luasnippets/html.lua
deleted file mode 100644
index 0e4d411..0000000
--- a/config/nvim/luasnippets/html.lua
+++ /dev/null
@@ -1,11 +0,0 @@
-local word = function(index)
- return f(function(name)
- return name[1][1]:match('([^ ]*)')
- end, { index })
-end
-
-return {
- s('<', fmt('<{}>\n\t{}\n{}>', { i(1), i(2), word(1) })),
- s('>', fmt('<{}>{}{}>', { i(1), i(2), word(1) })),
- s('/', fmt('<{} />', { i(1) })),
-}
diff --git a/config/nvim/luasnippets/python.lua b/config/nvim/luasnippets/python.lua
deleted file mode 100644
index 18d49a4..0000000
--- a/config/nvim/luasnippets/python.lua
+++ /dev/null
@@ -1,14 +0,0 @@
-return {
- s(
- 'main',
- fmt(
- [[def main() -> None:
- {}
-
-if __name__ == '__main__':
- main()
-]],
- { i(1) }
- )
- ),
-}
diff --git a/config/nvim/nvim-pack-lock.json b/config/nvim/nvim-pack-lock.json
index 5a07ddc..c8cfaa0 100644
--- a/config/nvim/nvim-pack-lock.json
+++ b/config/nvim/nvim-pack-lock.json
@@ -2,7 +2,7 @@
"plugins": {
"midnight.nvim": {
"rev": "45c447a1902e7bd5b8e0de99bb5068de9ac1efba",
- "src": "https://github.com/barrettruth/midnight.nvim.git"
+ "src": "https://github.com/barrett-ruth/midnight.nvim.git"
},
"nvim-treesitter": {
"rev": "6e42d823ce0a5a76180c473c119c7677738a09d1",
diff --git a/config/nvim/plugin/autocmds.lua b/config/nvim/plugin/autocmds.lua
index 3da2c47..cbdea1e 100644
--- a/config/nvim/plugin/autocmds.lua
+++ b/config/nvim/plugin/autocmds.lua
@@ -7,6 +7,28 @@ au('BufEnter', {
group = aug,
})
+au('BufWritePost', {
+ pattern = (vim.env.XDG_CONFIG_HOME or (vim.env.HOME .. '/.config'))
+ .. '/firefox/userChrome.css',
+ callback = function()
+ if not vim.tbl_contains({ 'firefox', 'zen-browser' }, vim.env.BROWSER) then
+ return
+ end
+ vim.notify(
+ 'Updating firefox-based browser userChrome.css...',
+ vim.log.levels.INFO
+ )
+ local src = (vim.env.XDG_CONFIG_HOME or (vim.env.HOME .. '/.config'))
+ .. '/firefox/userChrome.css'
+ local targets =
+ vim.fn.glob(vim.env.HOME .. '/.zen/*release*/chrome', true, true)
+ for _, dir in ipairs(targets) do
+ vim.fn.system({ 'cp', '-f', src, dir .. '/userChrome.css' })
+ end
+ end,
+ group = aug,
+})
+
au({ 'TermOpen', 'BufWinEnter' }, {
callback = function(args)
if vim.bo[args.buf].buftype == 'terminal' then
@@ -18,7 +40,6 @@ au({ 'TermOpen', 'BufWinEnter' }, {
group = aug,
})
--- TODO: out of date (config no longer in $XDG_CONFIG_HOME/nvim)
au('BufWritePost', {
pattern = (
os.getenv('XDG_CONFIG_HOME') or (os.getenv('HOME') .. '/.config')
@@ -61,16 +82,16 @@ au({ 'FocusLost', 'BufLeave', 'VimLeave' }, {
group = aug,
})
-au({ 'VimEnter', 'BufWinEnter', 'BufEnter' }, {
- callback = function()
- vim.api.nvim_set_option_value('cursorline', true, { scope = 'local' })
- end,
+vim.api.nvim_create_autocmd('WinEnter', {
group = aug,
+ callback = function()
+ vim.wo.cursorline = true
+ end,
})
-au('WinLeave', {
- callback = function()
- vim.api.nvim_set_option_value('cursorline', false, { scope = 'local' })
- end,
+vim.api.nvim_create_autocmd('WinLeave', {
group = aug,
+ callback = function()
+ vim.wo.cursorline = false
+ end,
})
diff --git a/config/nvim/plugin/highlight-undo.lua b/config/nvim/plugin/highlight-undo.lua
new file mode 100644
index 0000000..578d13a
--- /dev/null
+++ b/config/nvim/plugin/highlight-undo.lua
@@ -0,0 +1,30 @@
+local api = vim.api
+local ns = api.nvim_create_namespace('highlight_undo')
+
+api.nvim_set_hl(0, 'HighlightUndo', { link = 'IncSearch', default = true })
+
+for _, key in ipairs({ 'u', '', 'U' }) do
+ vim.keymap.set('n', key, function()
+ api.nvim_buf_attach(0, false, {
+ on_bytes = function(_, buf, _, sr, sc, _, _, _, _, ner, nec)
+ local er, ec = sr + ner, sc + nec
+ if er >= api.nvim_buf_line_count(buf) then
+ ec = #(api.nvim_buf_get_lines(buf, -2, -1, false)[1] or '')
+ end
+ vim.schedule(function()
+ if not api.nvim_buf_is_valid(buf) then
+ return
+ end
+ vim.hl.range(buf, ns, 'HighlightUndo', { sr, sc }, { er, ec })
+ vim.defer_fn(function()
+ if api.nvim_buf_is_valid(buf) then
+ api.nvim_buf_clear_namespace(buf, ns, 0, -1)
+ end
+ end, 300)
+ end)
+ return true
+ end,
+ })
+ return key
+ end, { expr = true })
+end
diff --git a/config/nvim/plugin/options.lua b/config/nvim/plugin/options.lua
index 831748f..464a994 100644
--- a/config/nvim/plugin/options.lua
+++ b/config/nvim/plugin/options.lua
@@ -2,8 +2,23 @@ local o, opt = vim.o, vim.opt
o.autowrite = true
+local f, background = io.open(vim.env.HOME .. '/.zshenv', 'r'), 'light'
+if f then
+ local content = f:read('*a')
+ f:close()
+ local theme = content:match('export THEME=(%S+)')
+ background = theme
+elseif vim.env.THEME then
+ background = vim.env.THEME
+end
+
+o.background = background == 'daylight' and 'light' or 'dark'
+
o.breakindent = true
+o.cursorline = true
+
+o.cmdheight = 0
o.conceallevel = 0
opt.diffopt:append('linematch:60')