move old nvim config
This commit is contained in:
parent
c9ae53e233
commit
e7740e9989
27 changed files with 492 additions and 704 deletions
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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 ".")
|
||||
)
|
||||
)
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
;; extends
|
||||
(jsx_attribute (property_identifier) @att_name (#eq? @att_name "className")
|
||||
(string (string_fragment) @att_val (#set! @att_val conceal ".")
|
||||
)
|
||||
)
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
;; inherits: jsx
|
||||
;; extends
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
;; inherits: jsx
|
||||
;; extends
|
||||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {})
|
||||
|
|
|
|||
|
|
@ -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 <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/cp.nvim',
|
||||
dir = '~/dev/cp.nvim',
|
||||
cmd = 'CP',
|
||||
keys = {
|
||||
{ '<leader>ce', '<cmd>CP edit<cr>' },
|
||||
{ '<leader>cp', '<cmd>CP panel<cr>' },
|
||||
{ '<leader>cP', '<cmd>CP pick<cr>' },
|
||||
{ '<leader>cr', '<cmd>CP run<cr>' },
|
||||
{ '<leader>cr', '<cmd>CP run all<cr>' },
|
||||
{ '<leader>cd', '<cmd>CP run --debug<cr>' },
|
||||
{ '<leader>cc', '<cmd>CP cache read<cr>' },
|
||||
{ ']c', '<cmd>CP next<cr>' },
|
||||
{ '[c', '<cmd>CP prev<cr>' },
|
||||
},
|
||||
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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
'<leader>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,
|
||||
|
|
|
|||
43
config/nvim/lua/plugins/guard.lua
Normal file
43
config/nvim/lua/plugins/guard.lua
Normal file
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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 = {
|
||||
['<left>'] = false,
|
||||
['<right>'] = false,
|
||||
},
|
||||
enabled = false,
|
||||
-- completion = {
|
||||
-- menu = {
|
||||
-- auto_show = true,
|
||||
-- },
|
||||
-- },
|
||||
-- keymap = {
|
||||
-- ['<left>'] = false,
|
||||
-- ['<right>'] = false,
|
||||
-- },
|
||||
},
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
|
|
@ -80,9 +81,6 @@ return {
|
|||
keys = { { '<c-n>', 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 = {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,116 @@
|
|||
return {
|
||||
{
|
||||
'barrettruth/live-server.nvim',
|
||||
build = 'pnpm add -g live-server',
|
||||
cmd = { 'LiveServerStart', 'LiveServerStart' },
|
||||
config = true,
|
||||
keys = { { '<leader>L', '<cmd>LiveServerToggle<cr>' } },
|
||||
},
|
||||
{
|
||||
'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
|
||||
{ '<c-d>', '<c-k>', mode = 'i' },
|
||||
{
|
||||
'<c-space>',
|
||||
'<cmd>lua require("luasnip").expand()<cr>',
|
||||
mode = 'i',
|
||||
},
|
||||
{
|
||||
'<c-h>',
|
||||
'<cmd>lua if require("luasnip").jumpable(-1) then require("luasnip").jump(-1) end<cr>',
|
||||
mode = { 'i', 's' },
|
||||
},
|
||||
{
|
||||
'<c-l>',
|
||||
'<cmd>lua if require("luasnip").jumpable(1) then require("luasnip").jump(1) end<cr>',
|
||||
mode = { 'i', 's' },
|
||||
},
|
||||
{
|
||||
'<c-j>',
|
||||
'<cmd>lua if require("luasnip").choice_active() then require("luasnip").change_choice(-1) end<cr>',
|
||||
mode = 'i',
|
||||
},
|
||||
{
|
||||
'<c-k>',
|
||||
'<cmd>lua if require("luasnip").choice_active() then require("luasnip").change_choice(1) end<cr>',
|
||||
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 = { { '<leader>Ct', '<cmd>CloakToggle<cr>' } },
|
||||
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 = {
|
||||
{ '<leader>ha', '<cmd>Grapple toggle<cr>' },
|
||||
{ '<leader>hd', '<cmd>Grapple untag<cr>' },
|
||||
{ '<leader>hq', '<cmd>Grapple toggle_tags<cr>' },
|
||||
|
||||
{ '<c-1>', '<cmd>Grapple select index=1<cr>' },
|
||||
{ '<c-2>', '<cmd>Grapple select index=2<cr>' },
|
||||
{ '<c-3>', '<cmd>Grapple select index=3<cr>' },
|
||||
{ '<c-4>', '<cmd>Grapple select index=4<cr>' },
|
||||
|
||||
{ ']h', '<cmd>Grapple cycle_tags next<cr>' },
|
||||
{ '[h', '<cmd>Grapple cycle_tags prev<cr>' },
|
||||
},
|
||||
},
|
||||
{
|
||||
'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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,30 +28,8 @@ return {
|
|||
),
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'<leader>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' },
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
return {
|
||||
s('/* ', fmt('/* {} */', { i(1) })),
|
||||
s('pr', fmt('printf("{}", {});', { i(1), i(2) })),
|
||||
s(
|
||||
'main',
|
||||
fmt(
|
||||
[[
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {{
|
||||
{}
|
||||
|
||||
return 0;
|
||||
}}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
}
|
||||
|
|
@ -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 <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
|
||||
// }}}}}}]=]
|
||||
|
||||
-- utility snippets
|
||||
for _, snippet in ipairs({
|
||||
s('in', fmt('#include {}', { i(1) })),
|
||||
s(
|
||||
'main',
|
||||
fmt(
|
||||
[[#include <iostream>
|
||||
|
||||
int main() {{
|
||||
{}
|
||||
|
||||
return 0;
|
||||
}}]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
s('pr', fmt('std::cout << {}', { i(1) })),
|
||||
s('s', fmt('std::{}', { i(1) })),
|
||||
s(
|
||||
'pbds',
|
||||
fmt(
|
||||
[[
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
namespace pbds = __gnu_pbds;
|
||||
|
||||
template <class T>
|
||||
using hashset = pbds::gp_hash_table<T, pbds::null_type>;
|
||||
|
||||
template <class K, class V>
|
||||
using hashmap = pbds::gp_hash_table<K, V>;
|
||||
|
||||
template <class K, class V>
|
||||
using multitreemap =
|
||||
pbds::tree<K, V, less_equal<K>, pbds::rb_tree_tag,
|
||||
pbds::tree_order_statistics_node_update>;
|
||||
|
||||
template <class T>
|
||||
using treeset =
|
||||
pbds::tree<T, pbds::null_type, less<T>, pbds::rb_tree_tag,
|
||||
pbds::tree_order_statistics_node_update>;
|
||||
|
||||
template <class K, class V>
|
||||
using treemap =
|
||||
pbds::tree<K, V, less<K>, pbds::rb_tree_tag,
|
||||
pbds::tree_order_statistics_node_update>;
|
||||
|
||||
template <class T>
|
||||
using treemultiset =
|
||||
pbds::tree<T, pbds::null_type, less_equal<T>, 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
|
||||
|
|
@ -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) })),
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
return {
|
||||
s(
|
||||
'main',
|
||||
fmt(
|
||||
[[def main() -> None:
|
||||
{}
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
30
config/nvim/plugin/highlight-undo.lua
Normal file
30
config/nvim/plugin/highlight-undo.lua
Normal file
|
|
@ -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', '<C-r>', '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
|
||||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue