add helpful indentation status/changing things to neovim
This commit is contained in:
parent
f7470b179e
commit
5485b784e0
|
@ -26,6 +26,7 @@ vim.g.have_nerd_font = true
|
|||
require 'options'
|
||||
require 'keymaps'
|
||||
require 'autocmds'
|
||||
require 'cmds'
|
||||
require 'lazy-bootstrap'
|
||||
require 'lazy-plugins'
|
||||
|
||||
|
|
17
nvim/lua/cmds.lua
Normal file
17
nvim/lua/cmds.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local function set_indent(use_spaces, size)
|
||||
vim.o.expandtab = use_spaces
|
||||
vim.o.shiftwidth = size
|
||||
vim.o.tabstop = size
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('IndentTabs', function(opts)
|
||||
local size = tonumber(opts.fargs[1])
|
||||
set_indent(false, size)
|
||||
print('Set buffer indentation to tabs with indent/tab size of', size)
|
||||
end, { nargs = 1 })
|
||||
|
||||
vim.api.nvim_create_user_command('IndentSpaces', function(opts)
|
||||
local size = tonumber(opts.fargs[1])
|
||||
set_indent(true, size)
|
||||
print('Set buffer indentation to spaces with indent/tab size of', size)
|
||||
end, { nargs = 1 })
|
|
@ -5,6 +5,20 @@ return {
|
|||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
local current_indent = function()
|
||||
local output = ''
|
||||
if vim.o.expandtab then
|
||||
output = output .. 'S'
|
||||
else
|
||||
output = output .. 'T'
|
||||
end
|
||||
output = output .. ':' .. vim.o.shiftwidth
|
||||
if vim.o.shiftwidth ~= vim.o.tabstop then
|
||||
output = output .. ':' .. vim.o.tabstop
|
||||
end
|
||||
return output
|
||||
end
|
||||
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
globalstatus = false,
|
||||
|
@ -18,7 +32,7 @@ return {
|
|||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = { { 'filename', path = 2 } },
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype', current_indent },
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = { 'location' },
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
return {
|
||||
{ -- Detect tabstop and shiftwidth automatically
|
||||
-- Run `:verbose Sleuth` to have the plugin display the reason it set options to what
|
||||
'tpope/vim-sleuth',
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue