dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search custom tabline and statusline 8bb690cd1c6df9245bc07839cb84f5d211ecc1fa
Oliver Krylow <o.krylow@isp-insoft.de > · 13 Aug 2021
unsigned
Browse files Compare with HEAD
Changed files (7) 37 - local cheatsheet, setup_cheatsheet
= require (
"cheatsheet" )()
37 + local cheatsheet
= require (
"cheatsheet" ).print
38 + local setup_cheatsheet
= require (
"cheatsheet" ).setup
39 40 cheatsheet(
"Stuff for bugabinga to remember about NeoVim" )
41 42 local settings
= require (
"general_editor_settings" )
42 43 settings(autocommand, data_path)
46 + local setup_tabline
= require (
"tabline" ).setup
50 + local setup_statusline
= require (
"statusline" ).setup
51 + setup_statusline(autocommand)
45 54 require (
"keybinds" )(cheatsheet)
48 57 require (
"filetype.yaml" )(autocommand)
49 58 require (
"filetype.ansi_c" )(autocommand)
50 - local _, setup_mkdir
= require (
"mkdir" )()
59 + local setup_mkdir
= require (
"mkdir" ).setup
51 60 setup_mkdir(autocommand)
neovim/lua/cheatsheet.lua Modified 11 - local cheatsheet_lines
= {
'CHEATSHEET VIM COMMANDS' }
12 - local is_setup
= false 13 - return function (message)
14 - table .
insert (cheatsheet_lines, message)
15 - if is_setup
and vim.api.nvim_buf_get_name(
0 ):match
'cheatsheet' then 16 - vim.cmd
[[noautocmd setlocal modifiable]] 18 - vim.api.nvim_buf_set_lines(
0 ,
- 1 ,
- 1 ,
false , { message })
19 - vim.cmd
[[noautocmd setlocal nomodifiable nomodified]] 27 - or vim.fn.line2byte
'$' ~= - 1 31 - or not vim.o.modifiable
37 - vim.o.shortmess
= vim.o.shortmess
.. 'I' 39 - vim.o.eventignore
= 'all' 40 - vim.cmd
[[noautocmd silent! setlocal bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= nobuflisted nocursorcolumn nocursorline nolist nonumber norelativenumber nospell noswapfile signcolumn=no synmaxcol& statusline=cheatsheet filetype=intro]] 42 - vim.api.nvim_buf_set_name(
0 ,
'cheatsheet' )
43 - vim.api.nvim_buf_set_lines(
50 - vim.cmd
[[noautocmd setlocal nomodifiable nomodified]] 51 - vim.cmd
[[silent! %foldopen!]] 52 - vim.cmd
[[normal! zb]] 54 - vim.cmd
[[nnoremap <buffer><nowait><silent> i :enew <bar> startinsert<cr>]] 55 - vim.o.eventignore
= '' 11 + local cheatsheet_lines
= {
"CHEATSHEET VIM COMMANDS" }
12 + local is_setup
= false 15 + print =
function (message)
16 + table .
insert (cheatsheet_lines, message)
17 + if is_setup
and vim.api.nvim_buf_get_name(
0 ):match(
"cheatsheet" )
then 18 + vim.cmd(
[[noautocmd setlocal modifiable]] )
20 + vim.api.nvim_buf_set_lines(
0 ,
- 1 ,
- 1 ,
false , { message })
21 + vim.cmd(
[[noautocmd setlocal nomodifiable nomodified]] )
29 + or vim.fn.line2byte(
"$" )
~= - 1 33 + or not vim.o.modifiable
39 + vim.o.shortmess
= vim.o.shortmess
.. "I" 41 + vim.o.eventignore
= "all" 43 + [[noautocmd silent! setlocal bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= nobuflisted nocursorcolumn nocursorline nolist nonumber norelativenumber nospell noswapfile signcolumn=no synmaxcol& statusline=cheatsheet filetype=intro]] 46 + vim.api.nvim_buf_set_name(
0 ,
"cheatsheet" )
47 + vim.api.nvim_buf_set_lines(
0 ,
0 ,
# cheatsheet_lines,
false , cheatsheet_lines)
48 + vim.cmd(
[[noautocmd setlocal nomodifiable nomodified]] )
49 + vim.cmd(
[[silent! %foldopen!]] )
50 + vim.cmd(
[[normal! zb]] )
52 + vim.cmd(
[[nnoremap <buffer><nowait><silent> i :enew <bar> startinsert<cr>]] )
53 + vim.o.eventignore
= "" neovim/lua/general_editor_settings.lua Modified 10 10 vim.opt.laststatus
= 2 11 11 vim.opt.showtabline
= 2 13 - vim.opt.tabline
= [[%!v:lua.require'tabline'()]] 15 13 vim.opt.expandtab
= true neovim/lua/mkdir.lua Modified 13 - local directory
= vim.fn.expand(
"%:p:h" )
14 - if vim.fn.isdirectory(directory)
== 0 then 15 - vim.fn.mkdir(directory,
'p' )
18 - function (autocommand)
19 - autocommand{
setup_mkdir_before_save =
[[ BufWritePre * lua require'mkdir'() ]] }
13 + local directory
= vim.fn.expand(
"%:p:h" )
14 + if vim.fn.isdirectory(directory)
== 0 then 15 + vim.fn.mkdir(directory,
"p" )
18 + setup =
function (autocommand)
19 + autocommand({
setup_mkdir_before_save =
[[ BufWritePre * lua require'mkdir'.run() ]] })
neovim/lua/plugins.lua Modified 135 135 "nvim-treesitter/playground" ,
136 136 config =
function ()
137 - local cheatsheet
= require (
"cheatsheet" )
137 + local cheatsheet
= require (
"cheatsheet" ).print
139 140 ":TSHighlightCapturesUnderCursor => This command shows the highlight group under the cursor, when TreeSitter is used" neovim/lua/statusline.lua Modified 1 + local branch_icon
= "" 2 + local vcs_branch_name
= "" 3 + local special_windows
= {
4 + intro = {
"CheatSheet" ,
"" },
5 + NvimTree = {
"Files" ,
"" },
6 + packer = {
"Plugins" ,
"" },
7 + help = {
"Help" ,
"龎" },
9 + local lsp_symbols
= {
Error =
"" ,
Information =
"" ,
Warning =
"" ,
Hint =
"" }
11 + local get_lsp_diagnostics_count = function ()
12 + local diagnostics_count
= "" 13 + for type , icon
in pairs (lsp_symbols)
do 14 + local count
= vim.lsp.diagnostic.get_count(
0 ,
type )
15 + local highlight
= "%#LspDiagnosticsDefault" .. type .. "#" 16 + local rendered_count
= count
> 0 and highlight
.. icon
.. " " .. count
.. " " or "" 17 + diagnostics_count
= diagnostics_count
.. rendered_count
19 + return diagnostics_count
25 + update_statuslines =
function ()
26 + for _, window_number
in pairs (vim.api.nvim_list_wins())
do 27 + if vim.api.nvim_get_current_win()
== window_number
then 28 + vim.opt.statusline
= [[%!v:lua.require'statusline'.render("current")]] 29 + elseif vim.api.nvim_buf_get_name(
0 )
~= "" then 30 + vim.opt.statusline
= [[%!v:lua.require'statusline'.render()]] 35 + update_vcs_branch_name =
function ()
36 + if not pcall (
require ,
"plenary" )
then 39 + require (
"plenary.job" )
42 + args = {
"branch" ,
"--show-current" },
43 + cwd = vim.fn.expand(
"%:p:h" ),
44 + on_exit =
function (output)
45 + local result
= output:result()[
1 ]
47 + vcs_branch_name
= "%#LineNr#%=" .. branch_icon
.. " " .. result
49 + vcs_branch_name
= "" 56 + render =
function (active)
57 + local filetype
= vim.bo.filetype
58 + local special_window
= special_windows[filetype]
59 + if active
and special_window
then 60 + return "%#LineNr#%=" .. special_window[
2 ]
.. " " .. special_window[
1 ]
.. "%=" 62 + local edited
= vim.bo.mod
and "" or "" 63 + local modifiable
= vim.bo.modifiable
and "" or "" 64 + local diagnostics
= get_lsp_diagnostics_count()
66 + local statusline
= "%#Statusline" 67 + .. (active
and "" or "NC" )
74 + .. (diagnostics
~= "" and " " .. diagnostics
.. " " or " " )
75 + .. (active
and vcs_branch_name
or "" )
80 + setup =
function (autocommand)
82 + update_statusline =
"CursorHold,CursorHoldI * lua require'statusline'.update_statuslines()" ,
83 + update_vcs_branch_name =
"BufEnter,BufWinEnter,WinEnter,BufReadPost * lua require'statusline'.update_vcs_branch_name()" ,
neovim/lua/tabline.lua Modified 2 - local buffer_names_to_ignore
= {
"NvimTree" }
3 - local get_icon = function (name, extension)
4 - if pcall (
require ,
"nvim-web-devicons" )
then return require "nvim-web-devicons" .get_icon(name ,extension, {
default =
true })
end 8 - for _, buffer_number
in pairs (vim.api.nvim_list_bufs())
do 9 - if vim.api.nvim_buf_is_valid(buffer_number)
and vim.api.nvim_buf_is_loaded(buffer_number)
then 10 - local modified
= vim.bo.modified
and "" or " " 12 - local stylish_buffer_name
= vim.api.nvim_buf_get_name(buffer_number):match(
".-([^\\/]-)$" )
or "" 13 - if vim.tbl_contains(buffer_names_to_ignore, stylish_buffer_name)
then goto continue
end 15 - if stylish_buffer_name
== "" then 16 - stylish_buffer_name
= "no name" 18 - elseif stylish_buffer_name
== "cheatsheet" then 9 + local get_icon = function (name, extension)
10 + if pcall (
require ,
"nvim-web-devicons" )
then return require "nvim-web-devicons" .get_icon(name ,extension, {
default =
true })
end 18 + local buffer_names_to_ignore
= {
'NvimTree' }
21 + for _, buffer_number
in pairs (vim.api.nvim_list_bufs())
do 22 + if vim.api.nvim_buf_is_valid(buffer_number)
and vim.api.nvim_buf_is_loaded(buffer_number)
then 23 + local modified
= vim.bo.modified
and "" or " " 25 + local stylish_buffer_name
= vim.api.nvim_buf_get_name(buffer_number):match(
".-([^\\/]-)$" )
or "" 26 + if vim.tbl_contains(buffer_names_to_ignore, stylish_buffer_name)
or stylish_buffer_name
== "" then goto continue
end 32 + if stylish_buffer_name
== "cheatsheet" then 21 35 local extension
= stylish_buffer_name:match(
"%w+%.(.+)" )
22 36 icon
= get_icon(stylish_buffer_name, extension)
24 - stylish_buffer_name
= " " .. stylish_buffer_name
.. " " 25 - local is_current_buffer
= vim.api.nvim_get_current_buf()
== buffer_number
26 - tabline
= tabline
.. "%#TabLine" .. 27 - (is_current_buffer
and "Sel" or "" )
.. "#" .. 28 - " " .. icon
.. stylish_buffer_name
.. (is_current_buffer
and modified
or " " )
33 - return tabline
.. "%#TabLineFill#" 38 + stylish_buffer_name
= " " .. stylish_buffer_name
.. " " 39 + local is_current_buffer
= vim.api.nvim_get_current_buf()
== buffer_number
40 + tabline
= tabline
.. "%#TabLine" .. 41 + (is_current_buffer
and "Sel" or "" )
.. "#" .. 42 + " " .. icon
.. stylish_buffer_name
.. (is_current_buffer
and modified
or " " )
47 + return tabline
.. "%#TabLineFill#" 53 + vim.opt.tabline
= [[%!v:lua.require'tabline'.render()]]