neovim: add venn.nvim, simplify bufferline

This commit is contained in:
FollieHiyuki 2021-10-22 23:39:43 +07:00
parent 6df7ee09a5
commit 6b48ca7940
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
3 changed files with 53 additions and 22 deletions

View File

@ -69,12 +69,12 @@ wk.register({
vim.opt.expandtab = false
vim.opt.smarttab = false
vim.opt.softtabstop = 0 -- reset to default
vim.notify('Switched to indent with tabs', vim.log.levels.INFO)
vim.notify('Switched to indent with tabs.', vim.log.levels.INFO)
else
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.softtabstop = -1 -- fallback to shiftwidth
vim.notify('Switched to indent with spaces', vim.log.levels.INFO)
vim.notify('Switched to indent with spaces.', vim.log.levels.INFO)
end
end,
'Switch indent style'
@ -218,6 +218,36 @@ wk.register({
h = {':TSHighlightCapturesUnderCursor<CR>', 'Syntax groups under cursor'},
s = {':ISwapWith<CR>', 'Swap elements'},
t = {':Twilight<CR>', 'Twilight mode'},
v = {
function()
local venn_enabled = vim.inspect(vim.b.venn_enabled)
if venn_enabled == 'nil' then
vim.b.venn_enabled = true
vim.api.nvim_command('setlocal virtualedit=all')
-- Draw lines with HJKL keystroke
vim.api.nvim_buf_set_keymap(0, 'n', '<Left>', '<C-v>h:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Down>', '<C-v>j:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Up>', '<C-v>k:VBox<CR>', {noremap = true, silent = true})
vim.api.nvim_buf_set_keymap(0, 'n', '<Right>', '<C-v>l:VBox<CR>', {noremap = true, silent = true})
-- Draw boxes by pressing 'f' with visual selection
vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox<CR>', {noremap = true, silent = true})
vim.notify('Virtual box edit enabled.', vim.log.levels.INFO)
else
vim.b.venn_enabled = nil
vim.api.nvim_command('setlocal virtualedit=block')
-- vim.api.nvim_command('mapclear <buffer>') -- this also deletes buf keymap for lsp
vim.api.nvim_buf_del_keymap(0, 'v', 'f')
vim.api.nvim_buf_del_keymap(0, 'n', '<Left>')
vim.api.nvim_buf_del_keymap(0, 'n', '<Down>')
vim.api.nvim_buf_del_keymap(0, 'n', '<Up>')
vim.api.nvim_buf_del_keymap(0, 'n', '<Right>')
vim.notify('Virtual box edit disabled.', vim.log.levels.INFO)
end
end,
'Toggle virtual box edit'
},
z = {':ZenMode<CR>', 'Zen mode'}
},

View File

@ -323,23 +323,23 @@ function M.bufferline_conf()
options = {
numbers = 'none',
max_name_length = 16,
max_prefix_length = 14,
tab_size = 20,
diagnostics = 'nvim_lsp',
diagnostics_update_in_insert = false,
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local s = ' '
for e, n in pairs(diagnostics_dict) do
local sym = e == 'error' and 'x ' or (e == 'warning' and '! ' or (e == 'info' and 'i ' or '? '))
s = s .. n .. sym
end
return s
end,
max_prefix_length = 13,
tab_size = 16,
diagnostics = false, -- 'nvim_lsp'
-- diagnostics_update_in_insert = false,
-- diagnostics_indicator = function(count, level, diagnostics_dict, context)
-- local s = ''
-- for e, n in pairs(diagnostics_dict) do
-- local sym = e == 'error' and 'x ' or (e == 'warning' and '! ' or (e == 'info' and 'i ' or '? '))
-- s = s .. n .. sym
-- end
-- return s
-- end,
show_close_icon = false,
show_buffer_icons = true,
show_tab_indicators = true,
enforce_regular_tabs = false,
show_buffer_close_icons = true,
show_buffer_close_icons = false,
always_show_bufferline = true,
offsets = {
{filetype = 'NvimTree', text = 'NvimTree', text_align = 'center'},
@ -350,13 +350,13 @@ function M.bufferline_conf()
highlights = {
fill = {guibg = {attribute = 'bg', highlight = 'TabLineFill'}},
indicator_selected = {guifg = {attribute = 'fg', highlight = 'TabLineSel'}},
diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignHint', gui = 'bold,italic'}},
info_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignInformation', gui = 'bold,italic'}},
info_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultInformation', gui = 'bold,italic'}},
warning_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignWarning', gui = 'bold,italic'}},
warning_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultWarning', gui = 'bold,italic'}},
error_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignError', gui = 'bold,italic'}},
error_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultError', gui = 'bold,italic'}}
-- diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignHint', gui = 'bold,italic'}},
-- info_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignInformation', gui = 'bold,italic'}},
-- info_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultInformation', gui = 'bold,italic'}},
-- warning_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignWarning', gui = 'bold,italic'}},
-- warning_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultWarning', gui = 'bold,italic'}},
-- error_diagnostic_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsSignError', gui = 'bold,italic'}},
-- error_selected = {guifg = {attribute = 'fg', highlight = 'LspDiagnosticsDefaultError', gui = 'bold,italic'}}
}
}
end

View File

@ -167,6 +167,7 @@ return packer.startup(function(use)
keys = {'<leader>gy', '<leader>gY'},
config = editor.gitlinker_conf
}
use {'jbyuki/venn.nvim', cmd = 'VBox'}
---------
-- LSP --