From 6b48ca7940022a6a421948e338e9341a2cd7d46a Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Fri, 22 Oct 2021 23:39:43 +0700 Subject: [PATCH] neovim: add venn.nvim, simplify bufferline --- home/.config/nvim/lua/mappings.lua | 34 +++++++++++++++++++++-- home/.config/nvim/lua/modules/ui.lua | 40 ++++++++++++++-------------- home/.config/nvim/lua/plugins.lua | 1 + 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 7f718f7..17d07f6 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -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', 'Syntax groups under cursor'}, s = {':ISwapWith', 'Swap elements'}, t = {':Twilight', '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', '', 'h:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', '', 'j:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', '', 'k:VBox', {noremap = true, silent = true}) + vim.api.nvim_buf_set_keymap(0, 'n', '', 'l:VBox', {noremap = true, silent = true}) + -- Draw boxes by pressing 'f' with visual selection + vim.api.nvim_buf_set_keymap(0, 'v', 'f', ':VBox', {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 ') -- this also deletes buf keymap for lsp + vim.api.nvim_buf_del_keymap(0, 'v', 'f') + vim.api.nvim_buf_del_keymap(0, 'n', '') + vim.api.nvim_buf_del_keymap(0, 'n', '') + vim.api.nvim_buf_del_keymap(0, 'n', '') + vim.api.nvim_buf_del_keymap(0, 'n', '') + + vim.notify('Virtual box edit disabled.', vim.log.levels.INFO) + end + end, + 'Toggle virtual box edit' + }, z = {':ZenMode', 'Zen mode'} }, diff --git a/home/.config/nvim/lua/modules/ui.lua b/home/.config/nvim/lua/modules/ui.lua index 3511e97..347744c 100644 --- a/home/.config/nvim/lua/modules/ui.lua +++ b/home/.config/nvim/lua/modules/ui.lua @@ -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 diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 3bab459..1b94224 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -167,6 +167,7 @@ return packer.startup(function(use) keys = {'gy', 'gY'}, config = editor.gitlinker_conf } + use {'jbyuki/venn.nvim', cmd = 'VBox'} --------- -- LSP --