Wiiip
This commit is contained in:
parent
e3adbdf814
commit
a7b4b583e4
3 changed files with 160 additions and 485 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,3 +8,5 @@ fishd.tmp.*
|
|||
# TODO: should be unnecessary once color generation is homegrown
|
||||
/colors/gen/vendor
|
||||
/colors/gen/tmp
|
||||
|
||||
/tags
|
||||
|
|
|
@ -1,193 +1,189 @@
|
|||
local execute = vim.api.nvim_command
|
||||
local kmap = vim.api.nvim_set_keymap
|
||||
local kmapnore = function(mode, keys, command)
|
||||
kmap(mode, keys, command, {noremap=true})
|
||||
end
|
||||
vim.g.vimdir = vim.fn.getenv('XDG_CONFIG_HOME')..'/nvim'
|
||||
|
||||
-- plugin manager
|
||||
local vimdir = vim.fn.getenv("XDG_CONFIG_HOME")..'/nvim'
|
||||
local packer_install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
|
||||
|
||||
local execute = vim.api.nvim_command
|
||||
|
||||
if vim.fn.empty(vim.fn.glob(packer_install_path)) > 0 then
|
||||
execute("!git clone https://github.com/wbthomason/packer.nvim "..packer_install_path)
|
||||
vim.fn.system{'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path}
|
||||
execute'packadd packer.nvim'
|
||||
end
|
||||
|
||||
vim.api.nvim_exec([[
|
||||
augroup Packer
|
||||
autocmd!
|
||||
autocmd BufWritePost init.lua PackerCompile
|
||||
augroup end
|
||||
augroup Packer
|
||||
autocmd!
|
||||
autocmd BufWritePost init.lua PackerCompile
|
||||
augroup end
|
||||
]], false)
|
||||
|
||||
local use = require('packer').use
|
||||
|
||||
require('packer').startup(function()
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'editorconfig/editorconfig-vim'
|
||||
use 'tpope/vim-sleuth'
|
||||
use 'vim-scripts/LargeFile'
|
||||
use 'vim-scripts/restore_view.vim'
|
||||
use 'christoomey/vim-tmux-navigator'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rhubarb'
|
||||
use 'tpope/vim-commentary'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rhubarb'
|
||||
use 'tpope/vim-commentary'
|
||||
use 'tpope/vim-repeat'
|
||||
use 'machakann/vim-sandwich'
|
||||
use 'michaeljsmith/vim-indent-object'
|
||||
use 'wellle/targets.vim'
|
||||
use 'bkad/CamelCaseMotion'
|
||||
use 'ludovicchabant/vim-gutentags'
|
||||
use 'ludovicchabant/vim-gutentags'
|
||||
use 'tpope/vim-obsession'
|
||||
use 'dhruvasagar/vim-prosession'
|
||||
use {'nvim-telescope/telescope.nvim', requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}}
|
||||
use 'joshdick/onedark.vim'
|
||||
use {'lukas-reineke/indent-blankline.nvim', branch="lua"}
|
||||
use {'lewis6991/gitsigns.nvim', requires = {'nvim-lua/plenary.nvim'}}
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'hrsh7th/nvim-compe'
|
||||
use {'nvim-telescope/telescope.nvim', requires={{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}}}
|
||||
use 'joshdick/onedark.vim'
|
||||
use {'lukas-reineke/indent-blankline.nvim', branch='lua'}
|
||||
use {'lewis6991/gitsigns.nvim', requires={'nvim-lua/plenary.nvim'}}
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'hrsh7th/nvim-compe'
|
||||
use 'sheerun/vim-polyglot'
|
||||
use {'neoclide/coc.nvim', branch='release'}
|
||||
end)
|
||||
|
||||
local globals = {
|
||||
mapleader=" ",
|
||||
maplocalleader=" ",
|
||||
completion_enable_auto_popup=0,
|
||||
indent_guide_auto_colors=1,
|
||||
indent_guides_enable_on_vim_startup=1,
|
||||
skipview_files={'COMMIT_EDITMSG'},
|
||||
indent_blankline_char="┊",
|
||||
indent_blankline_filetype_exclude={'help', 'packer'},
|
||||
indent_blankline_buftype_exclude={'terminal', 'nofile'},
|
||||
indent_blankline_char_highlight='LineNr',
|
||||
mapleader=' ',
|
||||
maplocalleader=' ',
|
||||
completion_enable_auto_popup=0,
|
||||
skipview_files={'COMMIT_EDITMSG'},
|
||||
indent_blankline_char='▏',
|
||||
indent_blankline_filetype_exclude={'help', 'packer'},
|
||||
indent_blankline_buftype_exclude={'terminal', 'nofile'},
|
||||
indent_blankline_char_highlight='LineNr',
|
||||
}
|
||||
|
||||
for k,v in pairs(globals) do
|
||||
vim.g[k] = v
|
||||
vim.g[k] = v
|
||||
end
|
||||
|
||||
local options = {
|
||||
inccommand="nosplit",
|
||||
tabstop=2,
|
||||
softtabstop=2,
|
||||
smartindent=true,
|
||||
list=true,
|
||||
listchars='trail:-,tab: ,trail:~',
|
||||
linebreak=true,
|
||||
formatoptions='crql1jn',
|
||||
synmaxcol=200,
|
||||
lazyredraw=true,
|
||||
scrolloff=8,
|
||||
sidescrolloff=15,
|
||||
mouse='a',
|
||||
splitright=true,
|
||||
splitbelow=true,
|
||||
errorbells=false,
|
||||
visualbell=true,
|
||||
backup=false,
|
||||
writebackup=false,
|
||||
swapfile=false,
|
||||
timeout=true,
|
||||
timeoutlen=150,
|
||||
hidden=true,
|
||||
shortmess='filnxToOFIac',
|
||||
history=100000,
|
||||
undofile=true,
|
||||
undofir=vimdir..'/undo',
|
||||
undolevels=100000,
|
||||
undoreload=100000,
|
||||
spellfile=vimdir..'/spell/en.utf-8.add',
|
||||
ignorecase=true,
|
||||
smartcase=true,
|
||||
incsearch=true,
|
||||
wrapscan=true,
|
||||
hlsearch=true,
|
||||
foldmethod='syntax',
|
||||
foldlevel=99,
|
||||
foldnextmax=10,
|
||||
foldlevelstart=99,
|
||||
autowrite=false,
|
||||
autochdir=true,
|
||||
autoread=true,
|
||||
modeline=false,
|
||||
showmode=false,
|
||||
showcmd=false,
|
||||
laststatus=2,
|
||||
ruler=false,
|
||||
termguicolors=true,
|
||||
inccommand='nosplit',
|
||||
tabstop=2,
|
||||
softtabstop=2,
|
||||
shiftwidth=2,
|
||||
smartindent=true,
|
||||
list=true,
|
||||
listchars='trail:·,tab: ,trail:~',
|
||||
linebreak=true,
|
||||
formatoptions='crql1jn',
|
||||
synmaxcol=200,
|
||||
lazyredraw=true,
|
||||
scrolloff=8,
|
||||
sidescrolloff=15,
|
||||
mouse='a',
|
||||
splitright=true,
|
||||
splitbelow=true,
|
||||
errorbells=false,
|
||||
visualbell=true,
|
||||
backup=false,
|
||||
writebackup=false,
|
||||
swapfile=false,
|
||||
timeout=true,
|
||||
timeoutlen=150,
|
||||
hidden=true,
|
||||
shortmess='filnxToOFIac',
|
||||
history=1000,
|
||||
undofile=true,
|
||||
undodir=vim.g.vimdir..'/undo',
|
||||
undolevels=1000,
|
||||
undoreload=1000,
|
||||
spellfile=vim.g.vimdir..'/spell/en.utf-8.add',
|
||||
ignorecase=true,
|
||||
smartcase=true,
|
||||
incsearch=true,
|
||||
wrapscan=true,
|
||||
hlsearch=true,
|
||||
foldmethod='syntax',
|
||||
foldlevel=99,
|
||||
foldnestmax=10,
|
||||
foldlevelstart=99,
|
||||
autowrite=false,
|
||||
autochdir=true,
|
||||
autoread=true,
|
||||
modeline=false,
|
||||
showmode=false,
|
||||
showcmd=false,
|
||||
laststatus=2,
|
||||
ruler=false,
|
||||
termguicolors=true,
|
||||
}
|
||||
|
||||
for k,v in pairs(options) do
|
||||
vim.o[k] = v
|
||||
-- print(tostring(k)..tostring(v))
|
||||
vim.o[k] = v
|
||||
end
|
||||
|
||||
-- let &fcs = 'eob: '
|
||||
|
||||
vim.cmd[[colorscheme base16-donokai]]
|
||||
|
||||
-- hi Search cterm=NONE ctermbg=blue ctermfg=black
|
||||
-- hi LineNr ctermbg=none ctermfg=8
|
||||
-- hi CursorLineNr ctermbg=18 ctermfg=gray
|
||||
-- hi IndentGuidesEven ctermbg=18
|
||||
-- hi Normal ctermbg=NONE
|
||||
-- hi ColorColumn ctermbg=18
|
||||
-- hi TooLongColorColumn ctermbg=18 ctermfg=1
|
||||
-- hi ActiveBuffer ctermbg=4 ctermfg=0
|
||||
-- hi DirtyBuffer ctermbg=3 ctermfg=0
|
||||
-- hi StatusLine ctermbg=18 ctermfg=7
|
||||
-- hi StatusLineNC ctermbg=18 ctermfg=7
|
||||
vim.cmd[[
|
||||
hi Search cterm=NONE ctermbg=blue ctermfg=black
|
||||
hi LineNr ctermbg=none ctermfg=8
|
||||
hi CursorLineNr ctermbg=18 ctermfg=gray
|
||||
hi IndentGuidesEven ctermbg=18
|
||||
hi Normal ctermbg=NONE
|
||||
hi ColorColumn ctermbg=18
|
||||
hi TooLongColorColumn ctermbg=18 ctermfg=1
|
||||
hi ActiveBuffer ctermbg=4 ctermfg=0
|
||||
hi DirtyBuffer ctermbg=3 ctermfg=0
|
||||
hi StatusLine ctermbg=18 ctermfg=7
|
||||
hi StatusLineNC ctermbg=18 ctermfg=7
|
||||
]]
|
||||
|
||||
execute[[call matchadd('ColorColumn', '\\%81v', 100)]]
|
||||
execute[[call matchadd('TooLongColorColumn', '\\%121v', 200)]]
|
||||
|
||||
vim.cmd[[command! W write]]
|
||||
|
||||
local escapes = {'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK'}
|
||||
for keys in escapes do
|
||||
kmap('i', keys, '<Esc>')
|
||||
function kmap(mode, keys, command, opts)
|
||||
if opts == nil then opts = {} end
|
||||
vim.api.nvim_set_keymap(mode, keys, command, opts)
|
||||
end
|
||||
|
||||
kmapnore('n', '<C-q>', ':qa<CR>')
|
||||
function kmapnore(mode, keys, command)
|
||||
kmap(mode, keys, command, {noremap=true})
|
||||
end
|
||||
|
||||
local escapes = {'jj', 'jJ', 'Jj', 'JJ', 'jk', 'jK', 'Jk', 'JK'}
|
||||
for _,keys in ipairs(escapes) do
|
||||
kmap('i', keys, '<Esc>')
|
||||
end
|
||||
|
||||
kmapnore('n', '<C-q>', ':qa<cr>')
|
||||
kmapnore('n', '<C-q>', '<Esc><C-q>')
|
||||
|
||||
require('telescope').setup{
|
||||
defaults={
|
||||
mappings={
|
||||
i={
|
||||
["<C-u>"]=false,
|
||||
["<C-d>"]=false,
|
||||
},
|
||||
},
|
||||
generic_sorter=require'telescope.sorters'.get_fzy_sorter,
|
||||
file_sorter=require'telescope.sorters'.get_fzy_sorter,
|
||||
}
|
||||
}
|
||||
kmapnore('n', '<C-p>', '<cmd>Telescope git_files<cr>')
|
||||
kmapnore('n', '<C-g>', '<cmd>Telescope live_grep<cr>')
|
||||
kmapnore('n', '<C-b>', '<cmd>Telescope buffers<cr>')
|
||||
-- kmapnore('n', '???', '<cmd>Telescope help_tags<cr>')
|
||||
|
||||
-- TODO: telescope bindings
|
||||
-- kmapnore('n', '<C-p>', ':GitFiles<CR>')
|
||||
-- nnoremap <C-o> :Files<CR>
|
||||
-- nnoremap <C-u> :GFiles?<CR>
|
||||
-- nnoremap <C-b> :Buffers<CR>
|
||||
kmapnore('n', '<C-h>', ':TmuxNavigateLeft<cr>')
|
||||
kmapnore('n', '<C-j>', ':TmuxNavigateDown<cr>')
|
||||
kmapnore('n', '<C-k>', ':TmuxNavigateUp<cr>')
|
||||
kmapnore('n', '<C-l>', ':TmuxNavigateRight<cr>')
|
||||
kmapnore('t', '<C-h>', '<C-\\><C-n>:TmuxNavigateLeft<cr>')
|
||||
kmapnore('t', '<C-j>', '<C-\\><C-n>:TmuxNavigateDown<cr>')
|
||||
kmapnore('t', '<C-k>', '<C-\\><C-n>:TmuxNavigateUp<cr>')
|
||||
kmapnore('t', '<C-l>', '<C-\\><C-n>:TmuxNavigateRight<cr>')
|
||||
|
||||
kmapnore('n', '<C-h>', ':TmuxNavigateLeft<CR>')
|
||||
kmapnore('n', '<C-j>', ':TmuxNavigateDown<CR>')
|
||||
kmapnore('n', '<C-k>', ':TmuxNavigateUp<CR>')
|
||||
kmapnore('n', '<C-l>', ':TmuxNavigateRight<CR>')
|
||||
kmapnore('t', '<C-h>', '<C-\\><C-n>:TmuxNavigateLeft<CR>')
|
||||
kmapnore('t', '<C-j>', '<C-\\><C-n>:TmuxNavigateDown<CR>')
|
||||
kmapnore('t', '<C-k>', '<C-\\><C-n>:TmuxNavigateUp<CR>')
|
||||
kmapnore('t', '<C-l>', '<C-\\><C-n>:TmuxNavigateRight<CR>')
|
||||
kmap('', ',w', '<Plug>CamelCaseMotion_w', {silent=true})
|
||||
kmap('', ',b', '<Plug>CamelCaseMotion_b', {silent=true})
|
||||
kmap('', ',e', '<Plug>CamelCaseMotion_e', {silent=true})
|
||||
kmap('', ',ge', '<Plug>CamelCaseMotion_ge', {silent=true})
|
||||
kmap('o', 'ib', '<Plug>CamelCaseMotion_ib', {silent=true})
|
||||
kmap('x', 'ib', '<Plug>CamelCaseMotion_ib', {silent=true})
|
||||
kmap('o', 'ie', '<Plug>CamelCaseMotion_ie', {silent=true})
|
||||
kmap('x', 'ie', '<Plug>CamelCaseMotion_ie', {silent=true})
|
||||
|
||||
kmap('', '<silent> ,w', '<Plug>CamelCaseMotion_w')
|
||||
kmap('', '<silent> ,b', '<Plug>CamelCaseMotion_b')
|
||||
kmap('', '<silent> ,e', '<Plug>CamelCaseMotion_e')
|
||||
kmap('', '<silent> ,ge', '<Plug>CamelCaseMotion_ge')
|
||||
kmap('o', '<silent> ib', '<Plug>CamelCaseMotion_ib')
|
||||
kmap('x', '<silent> ib', '<Plug>CamelCaseMotion_ib')
|
||||
kmap('o', '<silent> ie', '<Plug>CamelCaseMotion_ie')
|
||||
kmap('x', '<silent> ie', '<Plug>CamelCaseMotion_ie')
|
||||
|
||||
kmap('', '<F3>', 'mw:%s/\\s\\+$//<CR>:let @/ = ""<CR>\'w')
|
||||
kmap('', '<F4>', ':setlocal spell!<CR>')
|
||||
kmap('', '<F3>', 'mw:%s/\\s\\+$//<cr>:let @/ = ""<cr>\'w')
|
||||
kmap('', '<F4>', ':setlocal spell!<cr>')
|
||||
kmapnore('n', '<expr> n', "'Nn'[v:searchforward]")
|
||||
kmapnore('n', '<expr> N', "'nN'[v:searchforward]")
|
||||
kmapnore('c', '<c-n>', '<down>')
|
||||
|
@ -198,101 +194,40 @@ kmapnore('x', '>', '>gv')
|
|||
-- TODO: learn about the wildmenu `q:`
|
||||
kmap('', '<Space>', '<Nop>', {noremap=true, silent=true})
|
||||
|
||||
kmap('n', '<silent> <leader>r', ':source '..vimdir..'/init.vim<CR>:echo \'Reloaded init.vim\'<CR>')
|
||||
kmap('n', '<silent> <leader>gv', ':e '..vimdir..'/init.vim<CR>')
|
||||
kmap('n', '<silent> <leader>w', ':bd<CR>')
|
||||
kmap('n', '<silent> <leader>h', ':b#<CR>')
|
||||
kmap('n', '<silent> <leader>k', ':bnext<CR>')
|
||||
kmap('n', '<silent> <leader>j', ':bprevious<CR>')
|
||||
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>')
|
||||
kmap('n', '<leader>r', ':luafile '..vim.g.vimdir..'/init.lua<cr>:echo \'Reloaded init.lua\'<cr>', {silent=true})
|
||||
kmap('n', '<leader>gv', ':e '..vim.g.vimdir..'/init.lua<cr>', {silent=true})
|
||||
kmap('n', '<leader>w', ':bd<cr>', {silent=true})
|
||||
kmap('n', '<leader>h', ':b#<cr>', {silent=true})
|
||||
kmap('n', '<leader>k', ':bnext<cr>', {silent=true})
|
||||
kmap('n', '<leader>j', ':bprevious<cr>', {silent=true})
|
||||
kmap('n', '<leader>/', ':let @/ = ""<cr>:<BACKSPACE>', {silent=true})
|
||||
kmapnore('n', '<leader>t', ':split<cr>:term<cr>:resize 24<cr>:startinsert<cr>', {silent=true})
|
||||
kmapnore('t', '<C-w>', '<C-\\><C-n>:q!<cr>', {silent=true})
|
||||
|
||||
function neatFoldText()
|
||||
-- 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()
|
||||
|
||||
-- TODO: only update this portion when needed instead of every render?
|
||||
function statusLineBufferByNum(bufnum)
|
||||
local bufinfo = vim.fn.getbufinfo(bufnum)[0]
|
||||
local prefix = ' %#InactiveBuffer#'
|
||||
local suffix = '%* '
|
||||
|
||||
if bufinfo.changed then
|
||||
prefix = '%#DirtyBuffer# '
|
||||
suffix = ' %*'
|
||||
end
|
||||
|
||||
if bufinfo.hidden == 0 and vim.fn.index(bufinfo.windows, vim.g.statusline_winid) >= 0 then
|
||||
prefix = '%#ActiveBuffer# '
|
||||
suffix = ' %*'
|
||||
if bufinfo.changed then
|
||||
prefix = '%#ActiveBuffer# *'
|
||||
suffix = ' %*'
|
||||
end
|
||||
end
|
||||
|
||||
return prefix..vim.fn.fnamemodify(vim.fn.bufname(bufnum), ':t')..suffix
|
||||
end
|
||||
kmap('i', '<c-n>', '<Plug>(completion_trigger)', {silent=true})
|
||||
|
||||
execute[[au BufReadPost * | if stridx(&ft, 'commit') >= 0 | exe "startinsert!" | endif]]
|
||||
|
||||
local status_line_max_length = 5
|
||||
|
||||
function statusLineBuffers()
|
||||
-- TODO: mark buffers with unsaved changes
|
||||
|
||||
local active_index = -1
|
||||
local acc = {}
|
||||
for bufnum in vim.fn.nvim_list_bufs() do
|
||||
local bufinfo = vim.fn.getbufinfo(bufnum)[0]
|
||||
if bufinfo.listed ~= 0 then
|
||||
local entry = statusLineBufferByNum(bufnum)
|
||||
table.insert(acc, entry)
|
||||
if vim.fn.matchstr(entry, '^%#ActiveBuffer#') then
|
||||
active_index = vim.fn.index(acc, entry)
|
||||
end
|
||||
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
|
||||
return table.concat(acc, '')
|
||||
end
|
||||
end
|
||||
|
||||
function statusLine()
|
||||
return statusLineBuffers()..'%*%=%c,%l/%L (%p%%)'
|
||||
end
|
||||
|
||||
vim.api.nvim_exec[[
|
||||
vim.api.nvim_exec([[
|
||||
augroup slime
|
||||
au!
|
||||
autocmd BufNewFile,BufRead *.slimleex set syntax=slim
|
||||
au!
|
||||
autocmd BufNewFile,BufRead *.slimleex set syntax=slim
|
||||
augroup END
|
||||
]]
|
||||
]], false)
|
||||
|
||||
vim.o.statusline = '%'..statusLine()
|
||||
require('telescope').setup{
|
||||
defaults={
|
||||
mappings={
|
||||
i={
|
||||
['<C-u>']=false,
|
||||
['<C-d>']=false,
|
||||
},
|
||||
},
|
||||
generic_sorter=require'telescope.sorters'.get_fzy_sorter,
|
||||
file_sorter=require'telescope.sorters'.get_fzy_sorter,
|
||||
}
|
||||
}
|
||||
|
||||
kmap('i', '<silent> <c-n>', '<Plug>(completion_trigger)')
|
||||
require('fold').setup()
|
||||
require('statusline').setup()
|
||||
require('lsp').setup()
|
||||
|
|
|
@ -1,262 +0,0 @@
|
|||
set fileencoding=utf8
|
||||
|
||||
let $vimdir = $XDG_CONFIG_HOME.'/nvim'
|
||||
|
||||
if empty(glob($vimdir.'/autoload/plug.vim'))
|
||||
silent !curl -fLo $vimdir/autoload/plug.vim --create-dirs
|
||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
autocmd VimEnter * PlugInstall --sync | source $vimdir.'/init.vim'
|
||||
endif
|
||||
|
||||
" let g:coc_global_extensions = ['coc-elixir', 'coc-diagnostic']
|
||||
let g:completion_enable_auto_popup = 0
|
||||
let g:indent_guide_auto_colors = 1
|
||||
let g:indent_guides_enable_on_vim_startup = 1
|
||||
let g:jsonnet_fmt_on_save = 0
|
||||
let g:skipview_files = ['COMMIT_EDITMSG']
|
||||
let g:prosession_dir = $vimdir.'/sessions'
|
||||
" let g:fzf_preview_window = ['down:40%:hidden', 'ctrl-/']
|
||||
|
||||
call plug#begin($vimdir.'/plugged')
|
||||
Plug 'junegunn/vim-plug' " plugin manager should manage itself
|
||||
Plug 'sheerun/vim-polyglot' " handles language-specific configuration
|
||||
Plug 'neovim/nvim-lspconfig' " deeper language integration via language servers
|
||||
Plug 'nvim-lua/completion-nvim' " language server completion
|
||||
Plug 'junegunn/fzf' " fzf
|
||||
Plug 'junegunn/fzf.vim' " helpers for using fzf in vim
|
||||
Plug 'editorconfig/editorconfig-vim' " loads project-specific editor settings
|
||||
Plug 'tpope/vim-sleuth' " try and detect indent method
|
||||
Plug 'vim-scripts/LargeFile' " gracefully handle very large files
|
||||
Plug 'vim-scripts/restore_view.vim' " persistent buffer views
|
||||
Plug 'nathanaelkane/vim-indent-guides' " indentation guides
|
||||
Plug 'christoomey/vim-tmux-navigator' " allow window navigation to play nicely with tmux
|
||||
Plug 'tpope/vim-commentary' " toggle comments in code easily
|
||||
Plug 'tpope/vim-repeat' " better vim repeating for plugin-provided actions
|
||||
Plug 'machakann/vim-sandwich' " quickly modify text surrounding objects
|
||||
Plug 'michaeljsmith/vim-indent-object' " adds an indentation level text object
|
||||
Plug 'bkad/CamelCaseMotion' " camel case and underscore word movements
|
||||
Plug 'wellle/targets.vim' " adds some more handy text objects
|
||||
Plug 'tpope/vim-obsession' " even better session handling
|
||||
Plug 'dhruvasagar/vim-prosession' " even better session handling
|
||||
Plug 'jjo/vim-cue' " CUE lang
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
call plug#end()
|
||||
|
||||
" luafile $vimdir/lsp.lua
|
||||
" autocmd BufEnter * lua require('completion').on_attach()
|
||||
|
||||
filetype on
|
||||
filetype indent on
|
||||
filetype plugin on
|
||||
|
||||
" use :h option-list if you need to know what these do
|
||||
set encoding=utf8
|
||||
set tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
|
||||
set autoindent smartindent
|
||||
set list nostartofline listchars=trail:·,tab:\ \ ,trail:~
|
||||
set linebreak formatoptions=crql1jn " TODO: see if there is more in `:h fo-table`
|
||||
set synmaxcol=200
|
||||
set lazyredraw
|
||||
set scrolloff=8 sidescrolloff=15
|
||||
set mouse=a
|
||||
set splitright splitbelow
|
||||
set noerrorbells visualbell t_vb=
|
||||
set nobackup nowritebackup noswapfile
|
||||
set timeout ttimeoutlen=100 timeoutlen=150
|
||||
set hidden shortmess+=Iac
|
||||
set history=1000
|
||||
set undofile undodir=$vimdir/undo undolevels=1000 undoreload=10000
|
||||
set spellfile=$vimdir/spell/en.utf-8.add
|
||||
set ignorecase smartcase incsearch wrapscan hlsearch
|
||||
set foldmethod=syntax foldlevel=99 foldnestmax=10 foldlevelstart=99 " TODO: get good at folding
|
||||
set noautowrite autochdir autoread
|
||||
set nomodeline noshowmode noshowcmd laststatus=2 noruler
|
||||
set clipboard+=unnamedplus
|
||||
set t_Co=256
|
||||
let &fcs = 'eob: '
|
||||
|
||||
syntax enable
|
||||
colorscheme base16-donokai
|
||||
|
||||
hi Search cterm=NONE ctermbg=blue ctermfg=black
|
||||
hi LineNr ctermbg=none ctermfg=8
|
||||
hi CursorLineNr ctermbg=18 ctermfg=gray
|
||||
hi IndentGuidesEven ctermbg=18
|
||||
hi Normal ctermbg=NONE
|
||||
hi ColorColumn ctermbg=18
|
||||
hi TooLongColorColumn ctermbg=18 ctermfg=1
|
||||
hi ActiveBuffer ctermbg=4 ctermfg=0
|
||||
hi DirtyBuffer ctermbg=3 ctermfg=0
|
||||
hi StatusLine ctermbg=18 ctermfg=7
|
||||
hi StatusLineNC ctermbg=18 ctermfg=7
|
||||
|
||||
call matchadd('ColorColumn', '\%81v', 100)
|
||||
call matchadd('TooLongColorColumn', '\%121v', 200)
|
||||
|
||||
command! W write
|
||||
|
||||
inoremap jj <Esc>
|
||||
inoremap jJ <Esc>
|
||||
inoremap Jj <Esc>
|
||||
inoremap JJ <Esc>
|
||||
inoremap jk <Esc>
|
||||
inoremap jK <Esc>
|
||||
inoremap Jk <Esc>
|
||||
inoremap JK <Esc>
|
||||
|
||||
nnoremap <C-q> :qa<CR>
|
||||
inoremap <C-q> <Esc><C-q>
|
||||
|
||||
nnoremap <C-p> :GitFiles<CR>
|
||||
nnoremap <C-o> :Files<CR>
|
||||
nnoremap <C-u> :GFiles?<CR>
|
||||
nnoremap <C-b> :Buffers<CR>
|
||||
|
||||
nnoremap <C-h> :TmuxNavigateLeft<CR>
|
||||
nnoremap <C-j> :TmuxNavigateDown<CR>
|
||||
nnoremap <C-k> :TmuxNavigateUp<CR>
|
||||
nnoremap <C-l> :TmuxNavigateRight<CR>
|
||||
tnoremap <C-h> <C-\><C-n>:TmuxNavigateLeft<CR>
|
||||
tnoremap <C-j> <C-\><C-n>:TmuxNavigateDown<CR>
|
||||
tnoremap <C-k> <C-\><C-n>:TmuxNavigateUp<CR>
|
||||
tnoremap <C-l> <C-\><C-n>:TmuxNavigateRight<CR>
|
||||
|
||||
map <silent> ,w <Plug>CamelCaseMotion_w
|
||||
map <silent> ,b <Plug>CamelCaseMotion_b
|
||||
map <silent> ,e <Plug>CamelCaseMotion_e
|
||||
map <silent> ,ge <Plug>CamelCaseMotion_ge
|
||||
omap <silent> ib <Plug>CamelCaseMotion_ib
|
||||
xmap <silent> ib <Plug>CamelCaseMotion_ib
|
||||
omap <silent> ie <Plug>CamelCaseMotion_ie
|
||||
xmap <silent> ie <Plug>CamelCaseMotion_ie
|
||||
|
||||
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
|
||||
map <F4> :setlocal spell!<CR>
|
||||
|
||||
nnoremap <expr> n 'Nn'[v:searchforward]
|
||||
nnoremap <expr> N 'nN'[v:searchforward]
|
||||
|
||||
cnoremap <c-n> <down>
|
||||
cnoremap <c-p> <up>
|
||||
|
||||
xnoremap < <gv
|
||||
xnoremap > >gv
|
||||
|
||||
nnoremap gd :call CocAction('jumpDefinition')<CR>
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy :call CocActionAsync('doHover')<CR>
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" TODO: learn about the wildmenu `q:`
|
||||
|
||||
let mapleader = "\<Space>"
|
||||
nnoremap <silent> <leader>r :source $vimdir/init.vim<CR>:echo 'Reloaded init.vim'<CR>
|
||||
nnoremap <silent> <leader>gv :e $vimdir/init.vim<CR>
|
||||
nnoremap <silent> <leader>w :bd<CR>
|
||||
nnoremap <silent> <leader>h :b#<CR>
|
||||
nnoremap <silent> <leader>k :bnext<CR>
|
||||
nnoremap <silent> <leader>j :bprevious<CR>
|
||||
nnoremap <leader>/ :let @/ = ""<CR>:<BACKSPACE>
|
||||
|
||||
nnoremap <leader>t :split<CR>:term<CR>:resize 24<CR>:startinsert<CR>
|
||||
tnoremap <C-w> <C-\><C-n>:q!<CR>
|
||||
|
||||
function! NeatFoldText()
|
||||
" TODO: finish this!
|
||||
let lines_count = v:foldend - v:foldstart + 1
|
||||
let foldchar = matchstr(&fillchars, 'fold:\zs.')
|
||||
let foldtextstart = 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)
|
||||
endfunction
|
||||
set foldtext=NeatFoldText()
|
||||
|
||||
" TODO: only update this portion when needed instead of every render?
|
||||
function! StatusLineBufferByNum(bufnum)
|
||||
let l:bufinfo = getbufinfo(a:bufnum)[0]
|
||||
let l:prefix = ' %#InactiveBuffer#'
|
||||
let l:suffix = '%* '
|
||||
|
||||
if l:bufinfo.changed
|
||||
let l:prefix = '%#DirtyBuffer# '
|
||||
let l:suffix = ' %*'
|
||||
end
|
||||
|
||||
if l:bufinfo['hidden'] == 0 && index(l:bufinfo['windows'], g:statusline_winid) >= 0
|
||||
let l:prefix = '%#ActiveBuffer# '
|
||||
let l:suffix = ' %*'
|
||||
if l:bufinfo.changed
|
||||
let l:prefix = '%#ActiveBuffer# *'
|
||||
let l:suffix = ' %*'
|
||||
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
|
||||
let l:entry = StatusLineBufferByNum(bufnum)
|
||||
let l:acc = add(l:acc, l:entry)
|
||||
if l:entry =~ "^%#ActiveBuffer#"
|
||||
let l:active_index = index(l:acc, l:entry)
|
||||
endif
|
||||
endfor
|
||||
if l:active_index >= 0
|
||||
" TODO: instead implement this as a wraparound carousel?
|
||||
let l:offset = g:status_line_max_length / 2
|
||||
let l:min_buf_num = max([0, (l:active_index - offset)])
|
||||
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)])
|
||||
let l:buflist = join(l:acc[(l:min_buf_num):(l:max_buf_num)], '')
|
||||
let l:prefix = ""
|
||||
let l:suffix = ""
|
||||
if l:min_buf_num > 0
|
||||
let l:prefix = "< "
|
||||
endif
|
||||
if l:max_buf_num < len(l:acc) - 1
|
||||
let l:suffix = " >"
|
||||
endif
|
||||
return l:prefix . l:buflist . l:suffix
|
||||
else
|
||||
return join(l:acc, '')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! StatusLine()
|
||||
" try
|
||||
return StatusLineBuffers().'%*%=%c,%l/%L (%p%%)'
|
||||
" catch
|
||||
" return 'buflisterr%*%=%c,%l/%L (%p%%)'
|
||||
" endtry
|
||||
endfunction
|
||||
|
||||
augroup slime | au! BufNewFile,BufRead *.slimleex set syntax=slim | augroup END
|
||||
augroup ctmpl | au! BufNewFile,BufRead *.ctmpl set syntax=gohtmltmpl | augroup END
|
||||
|
||||
" set laststatus=0 showtabline tabline=%!StatusLine()
|
||||
set statusline=%!StatusLine()
|
||||
|
||||
imap <silent> <c-n> <Plug>(completion_trigger)
|
||||
|
||||
if filereadable(expand($ENV_PATH.'/init.vim'))
|
||||
source "$ENV_PATH/init.vim"
|
||||
endif
|
||||
|
||||
for f in glob($ENV_PATH.'/*/init.d.vim', 0, 1)
|
||||
source "$f"
|
||||
endfor
|
||||
|
||||
set number
|
Reference in a new issue