move old nvim config

This commit is contained in:
Barrett Ruth 2026-02-10 18:44:55 -05:00
parent c9ae53e233
commit e7740e9989
27 changed files with 492 additions and 704 deletions

View file

@ -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

View file

@ -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

View file

@ -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,
}

View file

@ -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'
)

View file

@ -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