feat(waybar): use slider, not gtk
This commit is contained in:
parent
db7edb13b8
commit
58d0d818dc
14 changed files with 285 additions and 294 deletions
|
|
@ -1,12 +1,12 @@
|
|||
local dev_plugins = {
|
||||
'midnight.nvim',
|
||||
'live-server.nvim',
|
||||
'nonicons.nvim',
|
||||
'canola.nvim',
|
||||
'pending.nvim',
|
||||
'cp.nvim',
|
||||
'diffs.nvim',
|
||||
'render.nvim',
|
||||
'preview.nvim',
|
||||
'fzf-lua',
|
||||
}
|
||||
|
||||
local opt_dir = vim.fn.stdpath('data') .. '/site/pack/dev/opt/'
|
||||
|
|
@ -76,116 +76,6 @@ AlignAfterOpenBracket: Align
|
|||
BinPackArguments: false
|
||||
BinPackParameters: false]]
|
||||
|
||||
local cpp_base = [[#include <bits/stdc++.h> // {{{
|
||||
|
||||
#include <version>
|
||||
#ifdef __cpp_lib_ranges_enumerate
|
||||
#include <ranges>
|
||||
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 <typename T>
|
||||
constexpr T MIN = std::numeric_limits<T>::min();
|
||||
|
||||
template <typename T>
|
||||
constexpr T MAX = std::numeric_limits<T>::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/midnight.nvim',
|
||||
|
|
@ -196,7 +86,7 @@ return {
|
|||
},
|
||||
{
|
||||
'barrettruth/live-server.nvim',
|
||||
enabled = false,
|
||||
enabled = true,
|
||||
before = function()
|
||||
vim.g.live_server = {
|
||||
debug = false,
|
||||
|
|
@ -204,10 +94,6 @@ return {
|
|||
end,
|
||||
keys = { { '<leader>l', '<cmd>LiveServerToggle<cr>' } },
|
||||
},
|
||||
{
|
||||
'barrettruth/nonicons.nvim',
|
||||
enabled = true,
|
||||
},
|
||||
{
|
||||
'barrettruth/canola.nvim',
|
||||
enabled = true,
|
||||
|
|
@ -281,7 +167,7 @@ return {
|
|||
before = function()
|
||||
vim.g.pending = { debug = true }
|
||||
end,
|
||||
keys = { { '<leader>p', '<cmd>Pending<cr>' } },
|
||||
keys = { { '<leader>P', '<cmd>Pending<cr>' } },
|
||||
},
|
||||
{
|
||||
'barrettruth/cp.nvim',
|
||||
|
|
@ -301,6 +187,7 @@ return {
|
|||
languages = {
|
||||
cpp = {
|
||||
extension = 'cc',
|
||||
template = '~/.config/nix/config/cp/template_multi.cc',
|
||||
commands = {
|
||||
build = {
|
||||
'g++',
|
||||
|
|
@ -338,6 +225,7 @@ return {
|
|||
},
|
||||
python = {
|
||||
extension = 'py',
|
||||
template = '~/.config/nix/config/cp/template.py',
|
||||
commands = {
|
||||
run = { 'python', '{source}' },
|
||||
debug = { 'python', '{source}' },
|
||||
|
|
@ -352,8 +240,15 @@ return {
|
|||
atcoder = {
|
||||
enabled_languages = { 'cpp', 'python' },
|
||||
default_language = 'cpp',
|
||||
overrides = {
|
||||
cpp = { template = '~/.config/nix/config/cp/template_single.cc' },
|
||||
},
|
||||
},
|
||||
cses = {
|
||||
overrides = {
|
||||
cpp = { template = '~/.config/nix/config/cp/template_single.cc' },
|
||||
},
|
||||
},
|
||||
cses = {},
|
||||
},
|
||||
ui = {
|
||||
picker = 'fzf-lua',
|
||||
|
|
@ -372,7 +267,7 @@ return {
|
|||
before_debug = function(_)
|
||||
require('config.lsp').format()
|
||||
end,
|
||||
setup_code = function(state)
|
||||
setup_code = function(_)
|
||||
vim.opt_local.winbar = ''
|
||||
vim.opt_local.foldlevel = 0
|
||||
vim.opt_local.foldmethod = 'marker'
|
||||
|
|
@ -381,18 +276,18 @@ return {
|
|||
vim.diagnostic.enable(false)
|
||||
|
||||
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
|
||||
return
|
||||
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
|
||||
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
|
||||
|
||||
local lang = state.get_language()
|
||||
local platform = state.get_platform()
|
||||
insert_template(buf, lang, platform)
|
||||
|
||||
local clang_format_path = vim.fn.getcwd()
|
||||
.. '/.clang-format'
|
||||
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, '\n'),
|
||||
|
|
@ -408,55 +303,20 @@ return {
|
|||
end,
|
||||
},
|
||||
{
|
||||
'barrettruth/render.nvim',
|
||||
'barrettruth/preview.nvim',
|
||||
ft = { 'typst', 'tex', 'markdown' },
|
||||
before = function()
|
||||
vim.g.render = {
|
||||
providers = {
|
||||
typst = {
|
||||
cmd = { 'typst', 'compile' },
|
||||
args = function(ctx)
|
||||
return { ctx.file }
|
||||
end,
|
||||
output = function(ctx)
|
||||
return ctx.file:gsub('%.typ$', '.pdf')
|
||||
end,
|
||||
},
|
||||
latexmk = {
|
||||
cmd = { 'latexmk' },
|
||||
args = function(ctx)
|
||||
return { '-pdf', '-interaction=nonstopmode', ctx.file }
|
||||
end,
|
||||
output = function(ctx)
|
||||
return ctx.file:gsub('%.tex$', '.pdf')
|
||||
end,
|
||||
clean = { 'latexmk', '-c' },
|
||||
},
|
||||
pandoc = {
|
||||
cmd = { 'pandoc' },
|
||||
args = function(ctx)
|
||||
local output = ctx.file:gsub('%.md$', '.html')
|
||||
return { ctx.file, '-s', '--embed-resources', '-o', output }
|
||||
end,
|
||||
output = function(ctx)
|
||||
return ctx.file:gsub('%.md$', '.html')
|
||||
end,
|
||||
clean = function(ctx)
|
||||
return { 'rm', '-f', ctx.file:gsub('%.md$', '.html') }
|
||||
end,
|
||||
},
|
||||
},
|
||||
providers_by_ft = {
|
||||
typst = 'typst',
|
||||
tex = 'latexmk',
|
||||
markdown = 'pandoc',
|
||||
},
|
||||
}
|
||||
after = function()
|
||||
local presets = require('preview.presets')
|
||||
require('preview').setup({
|
||||
'github',
|
||||
typst = vim.tbl_deep_extend('force', presets.typst, {
|
||||
open = { 'sioyek', '--new-instance' },
|
||||
}),
|
||||
tex = vim.tbl_deep_extend('force', presets.latex, {
|
||||
open = { 'sioyek', '--new-instance' },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ '<leader>rr', '<cmd>Render compile<cr>' },
|
||||
{ '<leader>rs', '<cmd>Render stop<cr>' },
|
||||
{ '<leader>rc', '<cmd>Render clean<cr>' },
|
||||
},
|
||||
keys = { { '<leader>p', '<cmd>Preview toggle<cr>' } },
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue