Compare commits
8 Commits
49f4a7398d
...
ea7eb8c056
Author | SHA1 | Date | |
---|---|---|---|
ea7eb8c056 | |||
35a9439ed4 | |||
5e5b5c818d | |||
736499a0ad | |||
390cb418ea | |||
e36b84cca7 | |||
6b47e1a919 | |||
1b23a42e23 |
18
.gitmodules
vendored
18
.gitmodules
vendored
@ -53,18 +53,6 @@
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_nvim-treesitter-textobjects
|
||||
url = https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
||||
|
||||
# error/warning/info box
|
||||
# coding.lua
|
||||
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_trouble.nvim"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_trouble.nvim
|
||||
url = https://github.com/folke/trouble.nvim
|
||||
|
||||
# aesthetic changes
|
||||
# init.lua
|
||||
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_dressing.nvim"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_dressing.nvim
|
||||
url = https://github.com/stevearc/dressing.nvim.git
|
||||
|
||||
# plain-text-accounting ledger ftplugin
|
||||
# ftplugin/ledger.vim
|
||||
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_vim-ledger"]
|
||||
@ -134,12 +122,6 @@
|
||||
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_nvim-treesitter-textobjects.path"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_nvim-treesitter-textobjects
|
||||
url = https://github.com/nvim-treesitter/nvim-treesitter-textobjects
|
||||
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_trouble.nvim.path"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_trouble.nvim
|
||||
url = https://github.com/folke/trouble.nvim
|
||||
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_dressing.nvim.path"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_dressing.nvim
|
||||
url = https://github.com/stevearc/dressing.nvim.git
|
||||
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_vim-ledger.path"]
|
||||
path = src/dot_local/share/nvim/site/pack/3pp/start/external_vim-ledger
|
||||
url = https://github.com/ledger/vim-ledger.git
|
||||
|
1
programs
1
programs
@ -7,6 +7,7 @@ ttf-roboto
|
||||
inter-font
|
||||
noto-fonts
|
||||
noto-fonts-emoji
|
||||
gsfonts
|
||||
git
|
||||
xwallpaper
|
||||
dunst
|
||||
|
5
src/dot_config/bat/config
Normal file
5
src/dot_config/bat/config
Normal file
@ -0,0 +1,5 @@
|
||||
# For all themes, run `bat --list-themes`
|
||||
--theme="ansi"
|
||||
|
||||
# disable decorations
|
||||
--plain
|
@ -20,6 +20,25 @@ tnoremap <silent> <esc> <c-\><c-n><c-\><c-n>
|
||||
" enable line numbers
|
||||
set number relativenumber
|
||||
|
||||
" use same colors as alacritty for integrated terminals
|
||||
let g:terminal_color_0 = "#000000"
|
||||
let g:terminal_color_1 = "#afaaaa"
|
||||
let g:terminal_color_2 = "#505559"
|
||||
let g:terminal_color_3 = "#a7a7a7"
|
||||
let g:terminal_color_4 = "#56698a"
|
||||
let g:terminal_color_5 = "#d5d5d5"
|
||||
let g:terminal_color_6 = "#99AABB"
|
||||
let g:terminal_color_7 = "#e5e9f0"
|
||||
|
||||
let g:terminal_color_8 = "#4c566a"
|
||||
let g:terminal_color_9 = "#bf616a"
|
||||
let g:terminal_color_10 = "#a3be8c"
|
||||
let g:terminal_color_11 = "#ebcb8b"
|
||||
let g:terminal_color_12 = "#81a1c1"
|
||||
let g:terminal_color_13 = "#b48ead"
|
||||
let g:terminal_color_14 = "#8fbcbb"
|
||||
let g:terminal_color_15 = "#eceff4"
|
||||
|
||||
" disable bottom right status line
|
||||
set noruler
|
||||
set showtabline=0
|
||||
|
@ -100,52 +100,7 @@ require("nvim-treesitter.configs").setup {
|
||||
------
|
||||
-- diagnostics box
|
||||
------
|
||||
vim.cmd.packadd("trouble.nvim")
|
||||
require('trouble').setup({
|
||||
auto_preview = false,
|
||||
-- default config available at https://github.com/folke/trouble.nvim
|
||||
icons = {
|
||||
indent = {
|
||||
middle = " ",
|
||||
last = " ",
|
||||
top = " ",
|
||||
ws = "│ ",
|
||||
},
|
||||
folder_closed = "- ",
|
||||
folder_open = "@ ",
|
||||
kinds = {
|
||||
Array = "a ",
|
||||
Boolean = "b ",
|
||||
Class = "C ",
|
||||
Constant = "π ",
|
||||
Constructor = "Π ",
|
||||
Enum = "Σ ",
|
||||
EnumMember = "Σ ",
|
||||
Event = "ε ",
|
||||
Field = "f ",
|
||||
File = "F ",
|
||||
Function = "λ ",
|
||||
Interface = "I ",
|
||||
Key = "β ",
|
||||
Method = "λ ",
|
||||
Module = "M ",
|
||||
Namespace = "N ",
|
||||
Null = "0 ",
|
||||
Number = "1 ",
|
||||
Object = "O ",
|
||||
Operator = "% ",
|
||||
Package = "P ",
|
||||
Property = "β ",
|
||||
String = "s ",
|
||||
Struct = "S ",
|
||||
TypeParameter = "T ",
|
||||
Variable = "α ",
|
||||
},
|
||||
},
|
||||
})
|
||||
keymap("<leader>dxx", "<cmd>Trouble diagnostics toggle<cr>")
|
||||
keymap("gR", "<cmd>Trouble lsp_references toggle<cr>")
|
||||
|
||||
keymap('<leader>dx', vim.diagnostic.open_float, { noremap=true, silent=true })
|
||||
|
||||
|
||||
--------------------------------
|
||||
|
@ -2,7 +2,13 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
-- nnoremap, etc.
|
||||
---@class KeymapOpts: vim.keymap.set.Opts
|
||||
--- @field mode? string|string[]
|
||||
|
||||
---Keymap helper.
|
||||
---@param key string
|
||||
---@param cmd string|function
|
||||
---@param params? KeymapOpts
|
||||
function M.keymap(key, cmd, params)
|
||||
if params == nil then
|
||||
params = {}
|
||||
@ -20,7 +26,7 @@ function M.keymap(key, cmd, params)
|
||||
buffer = false,
|
||||
}
|
||||
setmetatable(params, {
|
||||
__index = function(table, k)
|
||||
__index = function(_, k)
|
||||
return default_params[k]
|
||||
end
|
||||
})
|
||||
|
@ -16,25 +16,23 @@ local dotprofile, profile_table = confutil.dotprofile, confutil.profile_table
|
||||
-- bind to copy URL under cursor
|
||||
keymap("<leader>uu", ":let @+ = expand('<cfile>')<cr>")
|
||||
|
||||
------
|
||||
-- fancy prompts
|
||||
------
|
||||
vim.cmd.packadd("dressing.nvim")
|
||||
require('dressing').setup({
|
||||
input = {
|
||||
insert_only = false,
|
||||
}
|
||||
})
|
||||
|
||||
-- requires plenary.nvim
|
||||
vim.cmd.packadd("telescope.nvim")
|
||||
keymap("<leader>ef", "<cmd>Telescope find_files<cr>")
|
||||
keymap("<leader>eg", "<cmd>Telescope live_grep<cr>")
|
||||
keymap("<leader>em", "<cmd>Telescope buffers<cr>")
|
||||
keymap("<leader>eh", "<cmd>Telescope help_tags<cr>")
|
||||
keymap("<leader>es", "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>")
|
||||
keymap("<leader>eb", "<cmd>Telescope keymaps<cr>")
|
||||
|
||||
--------
|
||||
-- generic brand fuzzy finder
|
||||
--------
|
||||
local scope = require("scope")
|
||||
scope.setup()
|
||||
|
||||
keymap("<leader>ef", scope.file_finder)
|
||||
keymap("<leader>em", scope.buffer_list)
|
||||
keymap("<leader>es", vim.lsp.buf.workspace_symbol)
|
||||
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- imports (see .config/nvim/lua/)
|
||||
|
245
src/dot_config/nvim/lua/scope.lua
Normal file
245
src/dot_config/nvim/lua/scope.lua
Normal file
@ -0,0 +1,245 @@
|
||||
-- telescope without telescope80
|
||||
-- depends on: fzf, bat
|
||||
|
||||
M = {}
|
||||
|
||||
--------------------------------
|
||||
-- helpers
|
||||
--------------------------------
|
||||
|
||||
---Hacky debug print utility (do not use outside testing)
|
||||
---@param s any Thing to print
|
||||
---@param pre string? Message that goes before thing
|
||||
---@diagnostic disable-next-line: unused-function, unused-local
|
||||
local function dbg_print(s, pre)
|
||||
vim.system({ "sh", "-c", string.format("echo '%s' >> /tmp/nvim_scope_log", (pre or "") .. vim.inspect(s)) })
|
||||
end
|
||||
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- main implementation
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
---@class ScopeOpts
|
||||
---@field fzf_opts string? Command-line flags to pass to fzf.
|
||||
---@field allow_empty boolean? If true, will call `command` even if user cancelled. Defaults to false.
|
||||
---@field mode ("window" | "float")? Sets the window used to show the scope. Defaults to "window".
|
||||
--- - "window": fills the entire window
|
||||
--- - "float": floating window
|
||||
---@field float_opts vim.api.keyset.win_config? Options to pass to `nvim_open_win` if mode is set to "float".
|
||||
|
||||
---Generic brand fuzzy selector
|
||||
---@param choice_gen string | function Lua function or shell command that generates choices to display in fzf.
|
||||
---@param command string | function Vim command or Lua function to run on the selected choice.
|
||||
---@param scope_opts ScopeOpts | nil
|
||||
function M.scope_fzf(choice_gen, command, scope_opts)
|
||||
local opts = scope_opts or {}
|
||||
|
||||
local win_mode = opts.mode or "window"
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
if win_mode == "window" then
|
||||
vim.cmd.buf(buf)
|
||||
elseif win_mode == "float" then
|
||||
vim.api.nvim_open_win(buf, true,
|
||||
opts.float_opts or { relative = "cursor", width = 40, height = 20, col = 1, row = 1 })
|
||||
end
|
||||
|
||||
vim.wo.statusline = "Scope"
|
||||
|
||||
vim.cmd("startinsert")
|
||||
|
||||
local fzf_opts = opts.fzf_opts or ""
|
||||
|
||||
local choice_cmd = ""
|
||||
local choices_file = nil
|
||||
if type(choice_gen) == "string" then
|
||||
choice_cmd = choice_gen .. " | "
|
||||
elseif type(choice_gen) == "function" then
|
||||
choices_file = vim.fn.tempname()
|
||||
local f = io.open(choices_file, "w")
|
||||
assert(f, "Stdin file could not be opened.")
|
||||
f:write(choice_gen())
|
||||
choice_cmd = "cat " .. choices_file .. " | "
|
||||
f:close()
|
||||
end
|
||||
|
||||
local stdout_file = vim.fn.tempname()
|
||||
|
||||
local fzf_cmd = choice_cmd .. "fzf " .. fzf_opts .. " > " .. stdout_file
|
||||
|
||||
vim.fn.termopen(fzf_cmd, {
|
||||
on_exit = function()
|
||||
local f = io.open(stdout_file, "r")
|
||||
assert(f, "Stdout file could not be opened.")
|
||||
|
||||
if win_mode == "window" then
|
||||
vim.cmd("bp | bd! #") -- see https://stackoverflow.com/a/4468491
|
||||
elseif win_mode == "float" then
|
||||
vim.api.nvim_win_close(0, false)
|
||||
end
|
||||
|
||||
local stdout = f:read("*all")
|
||||
f:close()
|
||||
os.remove(stdout_file)
|
||||
if choices_file then
|
||||
os.remove(choices_file)
|
||||
end
|
||||
|
||||
if (stdout and stdout ~= "") or opts.allow_empty then
|
||||
if type(command) == "function" then
|
||||
command(stdout)
|
||||
elseif type(command) == "string" then
|
||||
vim.cmd(command .. stdout)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- vim.ui overwrites
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
--- Replacement for `vim.ui.select`.
|
||||
---@param items any[] Arbitrary items
|
||||
---@param opts table? Additional options
|
||||
--- - prompt (string|nil)
|
||||
--- - format_item (function item -> text)
|
||||
--- - kind (string|nil)
|
||||
---@param on_choice fun(item: any|nil, idx: integer|nil)
|
||||
local function select_new(items, opts, on_choice)
|
||||
vim.validate({
|
||||
items = { items, 'table', false },
|
||||
on_choice = { on_choice, 'function', false },
|
||||
})
|
||||
opts = opts or {}
|
||||
|
||||
M.scope_fzf(
|
||||
function()
|
||||
---@type string[]
|
||||
local items_fmt = {}
|
||||
|
||||
local fmt = opts.format_item or tostring
|
||||
for i, v in ipairs(items) do
|
||||
table.insert(items_fmt, string.format("%d: %s", i, fmt(v)))
|
||||
end
|
||||
|
||||
return table.concat(items_fmt, "\n")
|
||||
end,
|
||||
function(sel)
|
||||
if not sel or sel == "" then
|
||||
on_choice(nil, nil)
|
||||
return
|
||||
end
|
||||
|
||||
local _, _, idx_str = string.find(sel, "^(%d+):")
|
||||
local idx = tonumber(idx_str)
|
||||
assert(idx, "Could not parse fzf output.")
|
||||
on_choice(items[idx], idx)
|
||||
end,
|
||||
{
|
||||
allow_empty = true,
|
||||
fzf_opts = string.format("--border=rounded --border-label '%s'", (opts.prompt or "Select")),
|
||||
mode = "float",
|
||||
float_opts = { relative = "cursor", width = 70, height = #items + 4, col = 1, row = 1 }
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
--- Replacement for `vim.ui.input`.
|
||||
---@param opts table? Additional options. See |input()|
|
||||
--- - prompt (string|nil)
|
||||
--- - default (string|nil)
|
||||
---@param on_confirm function ((input|nil) -> ())
|
||||
local function input_new(opts, on_confirm)
|
||||
vim.validate({
|
||||
opts = { opts, 'table', true },
|
||||
on_confirm = { on_confirm, 'function', false },
|
||||
})
|
||||
|
||||
opts = (opts and not vim.tbl_isempty(opts)) and opts or vim.empty_dict()
|
||||
|
||||
opts.on_confirm = opts.on_confirm or function() end
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_open_win(buf, true,
|
||||
{
|
||||
relative = "cursor",
|
||||
width = 30,
|
||||
height = 1,
|
||||
col = 1,
|
||||
row = 1,
|
||||
border = "rounded",
|
||||
title = opts.prompt,
|
||||
})
|
||||
|
||||
if opts.default then
|
||||
vim.api.nvim_buf_set_lines(buf, 0, 1, true, { opts.default })
|
||||
end
|
||||
|
||||
vim.wo.number = false
|
||||
vim.wo.relativenumber = false
|
||||
vim.cmd [[startinsert!]]
|
||||
|
||||
local map_opts = { noremap = true, buffer = buf }
|
||||
|
||||
local function close_win()
|
||||
vim.api.nvim_win_close(0, false)
|
||||
vim.cmd.stopinsert()
|
||||
end
|
||||
|
||||
vim.keymap.set({ "i", "n" }, "<Enter>",
|
||||
function()
|
||||
on_confirm(table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, true), "\n"))
|
||||
close_win()
|
||||
end,
|
||||
map_opts
|
||||
)
|
||||
vim.keymap.set({ "i" }, "<C-c>", function ()
|
||||
on_confirm(nil)
|
||||
close_win()
|
||||
end, map_opts)
|
||||
end
|
||||
|
||||
---Sets up `vim.ui` hooks to use scope.
|
||||
function M.setup()
|
||||
vim.ui.select = select_new
|
||||
vim.ui.input = input_new
|
||||
end
|
||||
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
-- preset modes
|
||||
--------------------------------
|
||||
--------------------------------
|
||||
|
||||
---Find and open a file.
|
||||
function M.file_finder()
|
||||
M.scope_fzf(
|
||||
"rg --files",
|
||||
":e ",
|
||||
{ fzf_opts = '--preview "bat --color always --line-range=:500 {}"' }
|
||||
)
|
||||
end
|
||||
|
||||
---List and navigate buffers
|
||||
function M.buffer_list()
|
||||
M.scope_fzf(
|
||||
function()
|
||||
return vim.api.nvim_exec2("ls", { output = true }).output
|
||||
end,
|
||||
function(s)
|
||||
local _, _, bufnr = string.find(s, "^%s*(%d+)")
|
||||
if bufnr then
|
||||
vim.cmd.buf(bufnr)
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
return M
|
@ -55,7 +55,7 @@ Group.link("@keyword.return", groups["keyword.return"])
|
||||
Group.link("type.qualifier", groups["keyword.return"])
|
||||
Group.link("@type.qualifier", groups["keyword.return"])
|
||||
|
||||
Group.new("NormalFloat", colors.noir_1, colors.noir_9, nil)
|
||||
Group.new("NormalFloat", colors.noir_1, colors.none, nil)
|
||||
|
||||
Group.new("NonText", colors.noir_9, nil, nil)
|
||||
|
||||
|
@ -9,6 +9,11 @@ return {
|
||||
s({ trig = "qu", name = "square (qu-artic) exponent", wordTrig = false }, t("^2")),
|
||||
s({ trig = "cub", name = "cub-ed exponent", wordTrig = false }, t("^3")),
|
||||
|
||||
-- limits
|
||||
s({ trig = "plus", name = "plus exponent", wordTrig = false }, t("^+")),
|
||||
s({ trig = "min", name = "minus exponent", wordTrig = false }, t("^-")),
|
||||
s({ trig = "lim", name = "limit", wordTrig = false }, fmt("lim_({}) ", { i(1) })),
|
||||
|
||||
s({
|
||||
trig = "numb",
|
||||
name = "numbered equation",
|
||||
|
@ -8,7 +8,7 @@ set font "Liberation Sans 13"
|
||||
|
||||
set recolor-darkcolor "#dddddd"
|
||||
set recolor-lightcolor rgba(0,0,0,0)
|
||||
set recolor true
|
||||
set recolor false
|
||||
set recolor-keephue true
|
||||
set recolor-reverse-video true
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 6741f1062d3dc6e4755367a7e9b347b553623f04
|
@ -1 +0,0 @@
|
||||
Subproject commit 6efc446226679fda0547c0fd6a7892fd5f5b15d8
|
Loading…
Reference in New Issue
Block a user