You've already forked dotfiles
feat: Adding in a custom statuscolumn formatting function and lua file
This commit is contained in:
@@ -1,22 +1,43 @@
|
|||||||
|
-- Autocommands for handling large files and switching between large file buffers and others
|
||||||
|
local largefile_group = vim.api.nvim_create_augroup('largefile', { clear = true })
|
||||||
|
local max_filesize = 4 * (1024 * 1024) -- 4 MB
|
||||||
|
|
||||||
|
local old_eventignore = false
|
||||||
|
|
||||||
-- Disables syntax, treesitter and folding on larger files
|
-- Disables syntax, treesitter and folding on larger files
|
||||||
vim.api.nvim_create_autocmd({ 'BufReadPre' }, {
|
vim.api.nvim_create_autocmd({ 'BufReadPre' }, {
|
||||||
pattern = '*',
|
group = largefile_group,
|
||||||
group = vim.api.nvim_create_augroup('largefile', { clear = true }),
|
callback = function(ev)
|
||||||
callback = function(args)
|
if ev.file then
|
||||||
local max_filesize_MiB = 1
|
local status, size = pcall(function() return vim.loop.fs_stat(ev.file).size end)
|
||||||
|
if status and size > max_filesize then
|
||||||
|
old_eventignore = vim.o.eventignore
|
||||||
|
vim.o.eventignore = 'FileType' -- Reduce the calls for filetype specific plugins or syntax highlighting
|
||||||
|
|
||||||
local _, stats = pcall(function()
|
vim.b[ev.buf].is_large_file = true
|
||||||
return vim.loop.fs_stat(vim.api.nvim_buf_get_name(args.buf))
|
vim.bo['bufhidden'] = 'unload'
|
||||||
end)
|
vim.bo['buftype'] = 'nowrite'
|
||||||
|
vim.bo['swapfile'] = false
|
||||||
local file_size = math.floor(0.5 + (stats.size / (1024 * 1024)))
|
vim.bo['undofile'] = false
|
||||||
|
vim.bo['undolevels'] = -1
|
||||||
if file_size > max_filesize_MiB then
|
end
|
||||||
print(string.format('File detected above %sMiB. Disabling syntax, treesitter, and folding.', max_filesize_MiB))
|
|
||||||
vim.api.nvim_command('set foldmethod=manual')
|
|
||||||
vim.api.nvim_command('set noswapfile')
|
|
||||||
vim.api.nvim_command('set noundofile')
|
|
||||||
vim.api.nvim_command('set noloadplugins')
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
|
||||||
|
group = largefile_group,
|
||||||
|
callback = function(ev)
|
||||||
|
if old_eventignore ~= false then
|
||||||
|
vim.o.eventignore = old_eventignore -- Restore the old setting
|
||||||
|
old_eventignore = false
|
||||||
|
end
|
||||||
|
if vim.b[ev.buf].is_large_file then
|
||||||
|
vim.wo.wrap = false
|
||||||
|
else
|
||||||
|
vim.wo.wrap = vim.o.wrap -- Restore to default setting
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- End large file handling
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ vim.opt.listchars = 'tab:|·,trail:¬,extends:»,precedes:«,nbsp:+' -- Chara
|
|||||||
vim.opt.mouse = 'a' -- Enable mouse mode
|
vim.opt.mouse = 'a' -- Enable mouse mode
|
||||||
vim.opt.number = true -- Show the line number in the gutter.
|
vim.opt.number = true -- Show the line number in the gutter.
|
||||||
vim.opt.pumheight = 15 -- Maximum height of the auto complete floating window
|
vim.opt.pumheight = 15 -- Maximum height of the auto complete floating window
|
||||||
-- vim.opt.relativenumber = true -- Relative line number
|
|
||||||
vim.opt.sidescrolloff = 8 -- Side scrolling leadoff to keep the cursor a few characters from the screen edge instead of going all the way to it
|
vim.opt.sidescrolloff = 8 -- Side scrolling leadoff to keep the cursor a few characters from the screen edge instead of going all the way to it
|
||||||
vim.opt.shiftround = true -- Round indentation to shiftwidth
|
vim.opt.shiftround = true -- Round indentation to shiftwidth
|
||||||
vim.opt.shiftwidth = 4 -- Number of spaces a tab counts for when converting tabs to spaces
|
vim.opt.shiftwidth = 4 -- Number of spaces a tab counts for when converting tabs to spaces
|
||||||
@@ -34,6 +33,7 @@ vim.opt.smartindent = true -- Attempt t
|
|||||||
vim.opt.softtabstop = 4 -- Number of spaces a tab counts for when converting tabs to spaces
|
vim.opt.softtabstop = 4 -- Number of spaces a tab counts for when converting tabs to spaces
|
||||||
vim.opt.splitbelow = true -- Split windows below when horizontal splitting
|
vim.opt.splitbelow = true -- Split windows below when horizontal splitting
|
||||||
vim.opt.splitright = true -- Split windows right when vertical splitting
|
vim.opt.splitright = true -- Split windows right when vertical splitting
|
||||||
|
vim.opt.statuscolumn = "%!v:lua.require('statuscolumn').statusColumn()" -- Formatting for the statuscolumn (and gutter)
|
||||||
vim.opt.swapfile = false -- Disable the creation of swap files for open files
|
vim.opt.swapfile = false -- Disable the creation of swap files for open files
|
||||||
vim.opt.tabstop = 4 -- Setting the value of spaces per tab
|
vim.opt.tabstop = 4 -- Setting the value of spaces per tab
|
||||||
vim.opt.termguicolors = true -- Enable the truecolor GUI colors in a terminal
|
vim.opt.termguicolors = true -- Enable the truecolor GUI colors in a terminal
|
||||||
|
|||||||
23
nvim/lua/statuscolumn.lua
Normal file
23
nvim/lua/statuscolumn.lua
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
local statuscolumn = {}
|
||||||
|
|
||||||
|
statuscolumn.border = function ()
|
||||||
|
return '│'
|
||||||
|
end
|
||||||
|
|
||||||
|
statuscolumn.numbers = function (config)
|
||||||
|
return string.format('%-3s %2s ', vim.v.lnum, vim.v.relnum)
|
||||||
|
end
|
||||||
|
|
||||||
|
statuscolumn.statusColumn = function()
|
||||||
|
local column_text = ''
|
||||||
|
|
||||||
|
column_text = table.concat({
|
||||||
|
'%s',
|
||||||
|
statuscolumn.numbers(),
|
||||||
|
statuscolumn.border(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return column_text
|
||||||
|
end
|
||||||
|
|
||||||
|
return statuscolumn
|
||||||
Reference in New Issue
Block a user