This commit is contained in:
Daniel Flanagan 2021-06-01 22:29:17 -05:00
parent 1939ce2e3d
commit e3adbdf814
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -9,7 +9,7 @@ local vimdir = vim.fn.getenv("XDG_CONFIG_HOME")..'/nvim'
local packer_install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' local packer_install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(packer_install_path)) > 0 then if vim.fn.empty(vim.fn.glob(packer_install_path)) > 0 then
execute("!git clone https://github.com/wbthomason/packer.nvim "..install_path) execute("!git clone https://github.com/wbthomason/packer.nvim "..packer_install_path)
end end
vim.api.nvim_exec([[ vim.api.nvim_exec([[
@ -205,97 +205,94 @@ kmap('n', '<silent> <leader>h', ':b#<CR>')
kmap('n', '<silent> <leader>k', ':bnext<CR>') kmap('n', '<silent> <leader>k', ':bnext<CR>')
kmap('n', '<silent> <leader>j', ':bprevious<CR>') kmap('n', '<silent> <leader>j', ':bprevious<CR>')
kmap('n', '<leader>/', ':let @/ = ""<CR>:<BACKSPACE>') kmap('n', '<leader>/', ':let @/ = ""<CR>:<BACKSPACE>')
kmapnore('n', '<leader>t', ':split<CR>:term<CR>:resize 24<CR>:startinsert<CR>')
kmapnore('t', '<C-w>', '<C-\\><C-n>:q!<CR>')
nnoremap <leader>t :split<CR>:term<CR>:resize 24<CR>:startinsert<CR> function neatFoldText()
tnoremap <C-w> <C-\><C-n>:q!<CR> -- TODO: finish this!
-- local lines_count = vim.foldend - vim.foldstart + 1
-- local foldchar = vim.fn.matchstr(vim.fillchars, 'fold:\\zs.')
-- local foldtextstart = vim.fn.strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
-- let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count)
-- let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
-- return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count)
end
-- set foldtext=NeatFoldText()
function! NeatFoldText() -- TODO: only update this portion when needed instead of every render?
" TODO: finish this! function statusLineBufferByNum(bufnum)
let lines_count = v:foldend - v:foldstart + 1 local bufinfo = vim.fn.getbufinfo(bufnum)[0]
let foldchar = matchstr(&fillchars, 'fold:\zs.') local prefix = ' %#InactiveBuffer#'
let foldtextstart = strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3) local suffix = '%* '
let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count)
endfunction
set foldtext=NeatFoldText()
" TODO: only update this portion when needed instead of every render? if bufinfo.changed then
function! StatusLineBufferByNum(bufnum) prefix = '%#DirtyBuffer# '
let l:bufinfo = getbufinfo(a:bufnum)[0] suffix = ' %*'
let l:prefix = ' %#InactiveBuffer#'
let l:suffix = '%* '
if l:bufinfo.changed
let l:prefix = '%#DirtyBuffer# '
let l:suffix = ' %*'
end end
if l:bufinfo['hidden'] == 0 && index(l:bufinfo['windows'], g:statusline_winid) >= 0 if bufinfo.hidden == 0 and vim.fn.index(bufinfo.windows, vim.g.statusline_winid) >= 0 then
let l:prefix = '%#ActiveBuffer# ' prefix = '%#ActiveBuffer# '
let l:suffix = ' %*' suffix = ' %*'
if l:bufinfo.changed if bufinfo.changed then
let l:prefix = '%#ActiveBuffer# *' prefix = '%#ActiveBuffer# *'
let l:suffix = ' %*' suffix = ' %*'
end end
endif
return l:prefix . fnamemodify(bufname(a:bufnum), ':t') . l:suffix
endfunction
au BufReadPost * | if stridx(&ft, 'commit') >= 0 | exe "startinsert!" | endif
let g:status_line_max_length = 5
function! StatusLineBuffers()
" TODO: mark buffers with unsaved changes
let l:active_index = -1
let l:acc = []
for l:bufnum in nvim_list_bufs()
let l:bufinfo = getbufinfo(l:bufnum)[0]
if l:bufinfo.listed == 0
continue
end end
let l:entry = StatusLineBufferByNum(bufnum)
let l:acc = add(l:acc, l:entry) return prefix..vim.fn.fnamemodify(vim.fn.bufname(bufnum), ':t')..suffix
if l:entry =~ "^%#ActiveBuffer#" end
let l:active_index = index(l:acc, l:entry)
endif execute[[au BufReadPost * | if stridx(&ft, 'commit') >= 0 | exe "startinsert!" | endif]]
endfor
if l:active_index >= 0 local status_line_max_length = 5
" TODO: instead implement this as a wraparound carousel?
let l:offset = g:status_line_max_length / 2 function statusLineBuffers()
let l:min_buf_num = max([0, (l:active_index - offset)]) -- TODO: mark buffers with unsaved changes
let l:max_buf_num = min([(len(l:acc) - 1), (l:min_buf_num + g:status_line_max_length - 1)])
let l:min_buf_num = max([0, (l:max_buf_num - g:status_line_max_length + 1)]) local active_index = -1
let l:buflist = join(l:acc[(l:min_buf_num):(l:max_buf_num)], '') local acc = {}
let l:prefix = "" for bufnum in vim.fn.nvim_list_bufs() do
let l:suffix = "" local bufinfo = vim.fn.getbufinfo(bufnum)[0]
if l:min_buf_num > 0 if bufinfo.listed ~= 0 then
let l:prefix = "< " local entry = statusLineBufferByNum(bufnum)
endif table.insert(acc, entry)
if l:max_buf_num < len(l:acc) - 1 if vim.fn.matchstr(entry, '^%#ActiveBuffer#') then
let l:suffix = " >" active_index = vim.fn.index(acc, entry)
endif end
return l:prefix . l:buflist . l:suffix end
end
if active_index >= 0 then
-- TODO: instead implement this as a wraparound carousel?
local offset = status_line_max_length / 2
local min_buf_num = math.max(0, (active_index - offset))
local max_buf_num = math.min(#acc - 1, min_buf_num + status_line_max_length - 1)
min_buf_num = math.max(0, max_buf_num - status_line_max_length + 1)
local buflist = table.concat({table.unpack(acc, min_buf_num, max_buf_num)}, '')
local prefix = ''
local suffix = ''
if min_buf_num > 0 then
prefix = '< '
end
if max_buf_num < (#acc - 1) then
suffix = ' >'
end
return prefix..buflist..suffix
else else
return join(l:acc, '') return table.concat(acc, '')
endif end
endfunction end
function! StatusLine() function statusLine()
" try return statusLineBuffers()..'%*%=%c,%l/%L (%p%%)'
return StatusLineBuffers().'%*%=%c,%l/%L (%p%%)' end
" catch
" return 'buflisterr%*%=%c,%l/%L (%p%%)'
" endtry
endfunction
vim.api.nvim_exec[[
augroup slime augroup slime
au! au!
autocmd BufNewFile,BufRead *.slimleex set syntax=slim autocmd BufNewFile,BufRead *.slimleex set syntax=slim
augroup END augroup END
]]
" set laststatus=0 showtabline tabline=%!StatusLine() vim.o.statusline = '%'..statusLine()
set statusline=%!StatusLine()
imap <silent> <c-n> <Plug>(completion_trigger) kmap('i', '<silent> <c-n>', '<Plug>(completion_trigger)')