This commit is contained in:
2025-05-09 00:17:42 -05:00
parent f3bd08968a
commit 922dfb8c7e

View File

@ -6,8 +6,6 @@ if vim.fn.has("termguicolors") then
vim.opt.termguicolors = true vim.opt.termguicolors = true
end end
vim.opt.laststatus = 3
-- numbers -- numbers
vim.opt.number = true vim.opt.number = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
@ -64,95 +62,101 @@ vim.g.netrw_liststyle = 1
vim.g.netrw_sizestyle = "H" vim.g.netrw_sizestyle = "H"
vim.g.netrw_hide = 1 vim.g.netrw_hide = 1
-- border (this doesn"t actually do anything within vim, I"m just setting it -- border (this doesn't actually do anything within vim, I"m just setting it
-- here so it"s easy to find) -- here so it"s easy to find)
vim.g.border_style = "solid" vim.g.border_style = "solid"
-- folding do -- folding
auto("FileType", { auto("FileType", {
callback = function() callback = function()
-- FIXME: it causes errors every once in a while -- use treesitter for folding
-- support lsp folding if require("nvim-treesitter.parsers").has_parser() then
-- if vim.fn.has("nvim-0.11") then vim.opt.foldmethod = "expr"
-- auto("LspAttach", { vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
-- callback = function(args) else
-- local client = vim.lsp.get_client_by_id(args.data.client_id) vim.opt.foldmethod = "syntax"
-- if not client then end
-- return
-- end
-- if client:supports_method("textDocument/foldingRange") then
-- local win = vim.api.nvim_get_current_win()
-- vim.wo[win][0].foldmethod = "expr"
-- vim.wo[win][0].foldexpr = "v:lua.vim.lsp.foldexpr()"
-- end
-- end,
-- })
-- end
-- or just rely on treesitter
if require("nvim-treesitter.parsers").has_parser() then
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
else
vim.opt.foldmethod = "syntax"
end end
end })
})
-- lsp folding: vim.o.foldexpr = "v:lua.vim.lsp.foldexpr()" vim.opt.foldlevelstart = 99
-- waiting on https://github.com/neovim/neovim/pull/31311 to hit a release vim.opt.foldlevel = 99
vim.lsp.config['*'] = { vim.opt.foldenable = true
capabilities = { vim.o.fillchars = "fold: "
textDocument = {
foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
}
}
}
vim.opt.foldlevelstart = 99 _G.Fold_text = require("core.folding")
vim.opt.foldlevel = 99 vim.opt.foldtext = "v:lua.Fold_text()"
vim.opt.foldenable = true end
vim.o.fillchars = "fold: "
do -- statusline
_G.Fold_text = require("core.folding") local last_bufnr, i = 1, 1
vim.opt.foldtext = "v:lua.Fold_text()" --- status line
---@return string out formatted status line
-- statusline function _G.Status()
function _G.Status() --- get the percentage through the file
local function percentage() ---@return string out the formatted percentage
local percent, line, lines local function percentage()
local percent, line, lines
line = vim.api.nvim_win_get_cursor(0)[1]
lines = vim.api.nvim_buf_line_count(0) -- get the current and total # of lines
line = vim.api.nvim_win_get_cursor(0)[1]
percent = math.floor((line / lines) * 100) lines = vim.api.nvim_buf_line_count(0)
if percent == 0 then
return "Top" -- calculate the percentage through the file
elseif percent == 100 then percent = math.floor((line / lines) * 100)
return "Bot" if percent == 0 or line == 1 then
end return "Top"
elseif percent == 100 or line == lines then
return percent.."%%" return "Bot"
end end
return table.concat { return percent.."%%"
"%t", -- file name end
" %h", -- help buffer tag
"%m", -- modify tag --- get the number of lsp servers
"%r", -- readonly flag ---@return string out the formatted number of servers
"%=", -- seperate left and right side local function lsp_servers()
local out, nclients, hi
-- print out the number of lsp clients attached local hi_groups = { "@boolean", "@constant", "@keyword", "@number" }
"λ"..#vim.lsp.get_clients({ bufnr = 0 }).." ",
-- get the number of clients
"%<", -- we can start truncating here (I want to keep the file name) nclients = #vim.lsp.get_clients({ bufnr = 0 })
"%l,%c%V", -- line, column-virtual column
"%<", -- we can start truncating here -- set the client display
" "..percentage() -- percentage through the buffer out = "λ"..nclients
} if nclients > 0 then
local bufnr = vim.api.nvim_win_get_buf(0)
if bufnr ~= last_bufnr then
last_bufnr = bufnr
i = i + 1
if i > #hi_groups then
i = 1
end
end
hi = "%#"..hi_groups[i].."#"
out = hi..out.."%#StatusLine#"
end
return out
end
return table.concat {
"%t", -- file name
" %h", -- help buffer tag
"%m", -- modify tag
"%r", -- readonly flag
"%=", -- seperate left and right side
-- print out the number of lsp clients attached with nice colors :)
lsp_servers(), " ",
"%<", -- we can start truncating here (I want to keep the file name)
"%l,%c%V", -- line, column-virtual column
"%<", -- we can start truncating here
" "..percentage() -- percentage through the buffer
}
end
vim.opt.statusline="%!v:lua.Status()"
vim.opt.laststatus = 3
end end
vim.o.statusline="%!v:lua.Status()"