From cc79262336316cb0c73451c5c5f3797dd5164a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sun, 4 Jul 2021 22:47:10 +0200 Subject: [PATCH] Bars! Well, good enough. --- config/automatrop/roles/vim/tasks/main.yml | 2 + .../roles/vim/templates/init.vim.j2 | 3 - .../roles/vim/templates/pluginlist.j2 | 29 ++- .../roles/vim/templates/plugins/airline.j2 | 2 + .../roles/vim/templates/plugins/barbar.j2 | 21 +++ .../roles/vim/templates/plugins/colorizer.j2 | 7 + .../roles/vim/templates/plugins/feline.j2 | 169 ++++++++++++++++++ .../vim/templates/plugins/lsp_signature.j2 | 8 + .../roles/vim/templates/plugins/lspkind.j2 | 6 + .../roles/vim/templates/plugins/registers.j2 | 2 + .../roles/vim/templates/plugins/scrollview.j2 | 2 + .../roles/vim/templates/plugins/specs.j2 | 1 + .../vim/templates/plugins/symbols-outline.j2 | 26 +++ .../roles/vim/templates/plugins/telescope.j2 | 2 +- .../roles/vim/templates/plugins/undotree.j2 | 3 +- .../roles/vim/templates/plugins/vista.j2 | 4 +- .../roles/vim/templates/plugins/vsnip.j2 | 1 + 17 files changed, 277 insertions(+), 11 deletions(-) create mode 100644 config/automatrop/roles/vim/templates/plugins/barbar.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/colorizer.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/feline.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/lsp_signature.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/lspkind.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/registers.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/scrollview.j2 create mode 100644 config/automatrop/roles/vim/templates/plugins/symbols-outline.j2 diff --git a/config/automatrop/roles/vim/tasks/main.yml b/config/automatrop/roles/vim/tasks/main.yml index c8cb05f..0b13399 100644 --- a/config/automatrop/roles/vim/tasks/main.yml +++ b/config/automatrop/roles/vim/tasks/main.yml @@ -3,6 +3,7 @@ vim_variants: - vim - nvim + tags: g # TODO vim-minimal for bsh # TODO Select those in a clever way @@ -53,3 +54,4 @@ loop: "{{ vim_variants }}" loop_control: loop_var: variant + tags: g diff --git a/config/automatrop/roles/vim/templates/init.vim.j2 b/config/automatrop/roles/vim/templates/init.vim.j2 index 0acb693..d123945 100644 --- a/config/automatrop/roles/vim/templates/init.vim.j2 +++ b/config/automatrop/roles/vim/templates/init.vim.j2 @@ -21,6 +21,3 @@ source ~/.config/{{ variant }}/plugininstall.vim {% include 'pluginconfig.j2' %} -" THEME CONFIGURATION - -source ~/.config/vim/theme.vim diff --git a/config/automatrop/roles/vim/templates/pluginlist.j2 b/config/automatrop/roles/vim/templates/pluginlist.j2 index b0a7e5c..926c1fb 100644 --- a/config/automatrop/roles/vim/templates/pluginlist.j2 +++ b/config/automatrop/roles/vim/templates/pluginlist.j2 @@ -9,14 +9,22 @@ " Visuals {{ use_plugin('base16') }} -{{ use_plugin('airline') }} {{ use_plugin('devicons') }} {% if variant == 'nvim' %} -{{ use_plugin('lightbulb') }} -{{ use_plugin('ts-rainbow') }} {{ use_plugin('specs') }} +{{ use_plugin('scrollview') }} {% endif %} +" Theme +source ~/.config/vim/theme.vim + +" Status/tab lines +{% if variant == 'nvim' %} +{{ use_plugin('barbar') }} +{{ use_plugin('feline') }} +{% else %} +{{ use_plugin('airline') }} +{% endif %} " Goto utilities {% if variant == 'nvim' %} @@ -36,13 +44,24 @@ {{ use_plugin('shot_f') }} {{ use_plugin('quick_scope') }} -" Tags +" Registers +{{ use_plugin('registers') }} + + +" Tags/Symbols {{ use_plugin('gutentags') }} +{% if variant == 'nvim' %} +{{ use_plugin('symbols-outline') }} +{% else %} {{ use_plugin('vista') }} +{% endif %} " Language Server Client {% if variant == 'nvim' %} {{ use_plugin('nvim_lspconfig') }} +{{ use_plugin('lightbulb') }} +{{ use_plugin('lspkind') }} +{{ use_plugin('lsp_signature') }} {% else %} {{ use_plugin('vim_lsp') }} {% endif %} @@ -50,6 +69,7 @@ " Treesitter {% if variant == 'nvim' %} {{ use_plugin('treesitter') }} +{{ use_plugin('ts-rainbow') }} {% endif %} " Snippets @@ -80,6 +100,7 @@ {{ use_plugin('pandoc') }} {% if variant == 'nvim' %} {{ use_plugin('dap') }} +{{ use_plugin('colorizer') }} {% else %} {% if 'c' in dev_stuffs or 'c++' in dev_stuffs %} {{ use_plugin('vebugger') }} diff --git a/config/automatrop/roles/vim/templates/plugins/airline.j2 b/config/automatrop/roles/vim/templates/plugins/airline.j2 index 1e443e0..db93f55 100644 --- a/config/automatrop/roles/vim/templates/plugins/airline.j2 +++ b/config/automatrop/roles/vim/templates/plugins/airline.j2 @@ -3,7 +3,9 @@ set noshowmode set laststatus=2 let g:airline_powerline_fonts = 1 +{% if variant != 'nvim' %} let g:airline#extensions#tabline#enabled = 1 +{% endif %} let g:airline_section_a = airline#section#create(['mode']) let g:airline_section_b = airline#section#create(['branch', 'hunks']) diff --git a/config/automatrop/roles/vim/templates/plugins/barbar.j2 b/config/automatrop/roles/vim/templates/plugins/barbar.j2 new file mode 100644 index 0000000..ca9167e --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/barbar.j2 @@ -0,0 +1,21 @@ +{{ add_source('romgrk/barbar.nvim') -}} + +" Move to previous/next +nmap :BufferPrevious +nmap :BufferNext +" Re-order to previous/next +nmap :BufferMovePrevious +nmap :BufferMoveNext +" Goto buffer in position... +nmap :BufferGoto 1 +nmap :BufferGoto 2 +nmap :BufferGoto 3 +nmap :BufferGoto 4 +nmap :BufferGoto 5 +nmap :BufferGoto 6 +nmap :BufferGoto 7 +nmap :BufferGoto 8 +nmap :BufferGoto 0 +nmap :BufferLast + +nmap gb :BufferPick diff --git a/config/automatrop/roles/vim/templates/plugins/colorizer.j2 b/config/automatrop/roles/vim/templates/plugins/colorizer.j2 new file mode 100644 index 0000000..2ce1848 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/colorizer.j2 @@ -0,0 +1,7 @@ +{# Display the actual color for color codes " #} +{{ add_source('norcalli/nvim-colorizer.lua') -}} +set termguicolors +lua << EOF +require'colorizer'.setup() +EOF +{# TODO Enable for css functions too #} diff --git a/config/automatrop/roles/vim/templates/plugins/feline.j2 b/config/automatrop/roles/vim/templates/plugins/feline.j2 new file mode 100644 index 0000000..33c3dc8 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/feline.j2 @@ -0,0 +1,169 @@ +{# Customisable status line #} +{{ add_source('famiu/feline.nvim') -}} +set noshowmode +set laststatus=2 +lua << EOF +local base16_colors = require('base16-colorscheme').colors +local vi_mode_utils = require('feline.providers.vi_mode') +local lsp = require('feline.providers.lsp') +require('feline').setup({ + default_bg = 'base01', + default_fg = 'base04', + colors = { + base00 = base16_colors.base00, + base01 = base16_colors.base01, + base02 = base16_colors.base02, + base03 = base16_colors.base03, + base04 = base16_colors.base04, + base05 = base16_colors.base05, + base06 = base16_colors.base06, + base07 = base16_colors.base07, + base08 = base16_colors.base08, + base09 = base16_colors.base09, + base0A = base16_colors.base0A, + base0B = base16_colors.base0B, + base0C = base16_colors.base0C, + base0D = base16_colors.base0D, + base0E = base16_colors.base0E, + base0F = base16_colors.base0F, + }, + components = { + left = { + active = { + { + provider = function() return string.format(' %d ', vim.fn.line('$')) end, + -- If you can, make it depend on the actual bar size + left_sep = { + {str = 'block', fg = 'base05'} + }, + hl = { + fg = 'base01', + bg = 'base04', + }, + }, + { + provider = 'vi_mode', + hl = function() + return { + name = vi_mode_utils.get_mode_highlight_name(), + bg = vi_mode_utils.get_mode_color(), + fg = 'white', + style = 'bold', + } + end, + left_sep = {'█'}, + right_sep = {'█'}, + }, + { + provider='', + hl = function() + return { + bg = vi_mode_utils.get_mode_color(), + fg = (vim.bo.modified and 'base09') or 'base0D', + } + end, + }, + { + provider = 'file_info', + type = 'relative', + hl = function() + return { + fg = 'base06', + bg = (vim.bo.modified and 'base09') or 'base0D', + style = 'bold', + } + end, + left_sep = {'█'}, + right_sep = {'█'}, + }, + { + provider='', + hl = function() + return { + bg = 'base02', + fg = (vim.bo.modified and 'base09') or 'base0D', + } + end, + }, + { + provider = 'position', + hl = { fg = 'base05', bg = 'base02' }, + right_sep = {'█'}, + }, + -- If it miraculously became easy to do, add LSP position here + { + provider='', + hl = { bg = 'base01', fg = 'base02' }, + }, + } + }, + right = { + active = { + { + provider='', + hl = { bg = 'base03', fg = 'base01', }, + }, + { + provider='z', + enabled = function() return next(vim.lsp.buf_get_clients()) == nil end, + hl = { bg = 'base03', fg = 'base01', }, + left_sep = '█', + }, + { + provider = 'diagnostic_errors', + enabled = function() return lsp.diagnostics_exist('Error') end, + hl = { fg = 'red', bg = 'base03', }, + left_sep = '█', + }, + { + provider = 'diagnostic_warnings', + enabled = function() return lsp.diagnostics_exist('Warning') end, + hl = { fg = 'yellow', bg = 'base03', }, + left_sep = '█', + }, + { + provider = 'diagnostic_hints', + enabled = function() return lsp.diagnostics_exist('Hint') end, + hl = { fg = 'cyan', bg = 'base03', }, + left_sep = '█', + }, + { + provider = 'diagnostic_info', + enabled = function() return lsp.diagnostics_exist('Information') end, + hl = { fg = 'skyblue', bg = 'base03', }, + left_sep = '█', + }, + { + provider='█', + hl = { bg = 'base02', fg = 'base03', }, + }, + { + provider = 'git_diff_added', + hl = { fg = 'green', bg = 'base02', }, + left_sep = '█', + enabled = function() return vim.b.gitsigns_status_dict end, + }, + { + provider = 'git_diff_changed', + hl = { fg = 'orange', bg = 'base02', }, + left_sep = '█', + enabled = function() return vim.b.gitsigns_status_dict end, + }, + { + provider = 'git_diff_removed', + hl = { fg = 'red', bg = 'base02', }, + left_sep = '█', + enabled = function() return vim.b.gitsigns_status_dict end, + }, + { + provider = 'git_branch', + hl = { fg = 'base05', bg = 'base02', style = 'bold', }, + right_sep = '█', + left_sep = '█', + enabled = function() return vim.b.gitsigns_status_dict end, + }, + } + }, + } +}) +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/lsp_signature.j2 b/config/automatrop/roles/vim/templates/plugins/lsp_signature.j2 new file mode 100644 index 0000000..918a056 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/lsp_signature.j2 @@ -0,0 +1,8 @@ +{# Show argument documentation when typing a function #} +{{ add_source('ray-x/lsp_signature.nvim') -}} + +lua << EOF +require'lsp_signature'.on_attach({ + hint_enable = false, +}) +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/lspkind.j2 b/config/automatrop/roles/vim/templates/plugins/lspkind.j2 new file mode 100644 index 0000000..d81e404 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/lspkind.j2 @@ -0,0 +1,6 @@ +{# Add icons to LSP completions #} +{{ add_source('onsails/lspkind-nvim') -}} + +lua << EOF +require('lspkind').init() +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/registers.j2 b/config/automatrop/roles/vim/templates/plugins/registers.j2 new file mode 100644 index 0000000..04cf261 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/registers.j2 @@ -0,0 +1,2 @@ +{# Show register content when pressing " #} +{{ add_source('tversteeg/registers.nvim') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/scrollview.j2 b/config/automatrop/roles/vim/templates/plugins/scrollview.j2 new file mode 100644 index 0000000..c443dd8 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/scrollview.j2 @@ -0,0 +1,2 @@ +{# Customisable status line #} +{{ add_source('dstein64/nvim-scrollview') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/specs.j2 b/config/automatrop/roles/vim/templates/plugins/specs.j2 index c6b48f2..5eb5504 100644 --- a/config/automatrop/roles/vim/templates/plugins/specs.j2 +++ b/config/automatrop/roles/vim/templates/plugins/specs.j2 @@ -1,3 +1,4 @@ +{# Flashes under the cursor when moving far #} {{ add_source('edluffy/specs.nvim') -}} lua << EOF require('specs').setup{ diff --git a/config/automatrop/roles/vim/templates/plugins/symbols-outline.j2 b/config/automatrop/roles/vim/templates/plugins/symbols-outline.j2 new file mode 100644 index 0000000..abbe040 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/symbols-outline.j2 @@ -0,0 +1,26 @@ +{# Show a symbol panel on the right #} +{{ add_source('simrat39/symbols-outline.nvim') -}} + +nmap s :SymbolsOutline + +lua << EOF +vim.g.symbols_outline = { + highlight_hovered_item = true, + show_guides = true, + auto_preview = true, + position = 'right', + show_numbers = false, + show_relative_numbers = false, + show_symbol_details = true, + keymaps = { + close = "", + goto_location = "", + focus_location = "o", + hover_symbol = "", + rename_symbol = "r", + code_actions = "a", + }, + lsp_blacklist = {}, +} +EOF +{# TODO Should be hierarchical, doesn't seem to be :/ #} diff --git a/config/automatrop/roles/vim/templates/plugins/telescope.j2 b/config/automatrop/roles/vim/templates/plugins/telescope.j2 index 3f8c3ec..ce3ab0e 100644 --- a/config/automatrop/roles/vim/templates/plugins/telescope.j2 +++ b/config/automatrop/roles/vim/templates/plugins/telescope.j2 @@ -5,7 +5,7 @@ noremap gF Telescope find_files noremap gf Telescope git_files -noremap gb Telescope buffers +noremap gB Telescope buffers noremap gl Telescope current_buffer_fuzzy_find noremap gL Telescope live_grep noremap gT Telescope tags diff --git a/config/automatrop/roles/vim/templates/plugins/undotree.j2 b/config/automatrop/roles/vim/templates/plugins/undotree.j2 index 3c364c0..2ad56b1 100644 --- a/config/automatrop/roles/vim/templates/plugins/undotree.j2 +++ b/config/automatrop/roles/vim/templates/plugins/undotree.j2 @@ -1,2 +1,3 @@ +{# Navigate undo #} {{ add_source('mbbill/undotree') -}} -nmap :UndotreeToggle +nmap u :UndotreeToggle diff --git a/config/automatrop/roles/vim/templates/plugins/vista.j2 b/config/automatrop/roles/vim/templates/plugins/vista.j2 index ef15442..20cc836 100644 --- a/config/automatrop/roles/vim/templates/plugins/vista.j2 +++ b/config/automatrop/roles/vim/templates/plugins/vista.j2 @@ -1,9 +1,9 @@ {# Tag bar #} {{ add_source('liuchengxu/vista.vim') -}} -nmap :Vista!! +nmap s :Vista!! let g:vista_icon_indent = ["▸ ", ""] -let g:vista#renderer#enable_icon = 0 +let g:vista#renderer#enable_icon = 1 " The default icons can't be suitable for all the filetypes, you can extend it as you wish. let g:vista#renderer#icons = { diff --git a/config/automatrop/roles/vim/templates/plugins/vsnip.j2 b/config/automatrop/roles/vim/templates/plugins/vsnip.j2 index 06aa3bc..2c710ca 100644 --- a/config/automatrop/roles/vim/templates/plugins/vsnip.j2 +++ b/config/automatrop/roles/vim/templates/plugins/vsnip.j2 @@ -1,3 +1,4 @@ {{ add_source('hrsh7th/vim-vsnip') -}} {{ add_source('hrsh7th/vim-vsnip-integ') -}} {{ add_source('rafamadriz/friendly-snippets') -}} +{# TODO Ansible snippets? #}