diff --git a/config/automatrop/roles/vim/tasks/main.yml b/config/automatrop/roles/vim/tasks/main.yml index 7da910a..c8cb05f 100644 --- a/config/automatrop/roles/vim/tasks/main.yml +++ b/config/automatrop/roles/vim/tasks/main.yml @@ -24,6 +24,15 @@ src: loader.j2 dest: "{{ ansible_user_dir }}/.config/vim/loader.vim" mode: "u=rw,g=r,o=r" + tags: g + +- name: Install theme + template: + src: theme.j2 + dest: "{{ ansible_user_dir }}/.config/vim/theme.vim" + mode: "u=rw,g=r,o=r" + tags: + - color - name: Configure vim plugin list template: diff --git a/config/automatrop/roles/vim/templates/init.vim.j2 b/config/automatrop/roles/vim/templates/init.vim.j2 index d52d811..0acb693 100644 --- a/config/automatrop/roles/vim/templates/init.vim.j2 +++ b/config/automatrop/roles/vim/templates/init.vim.j2 @@ -20,3 +20,7 @@ source ~/.config/{{ variant }}/plugininstall.vim " PLUGINS CONFIGURATION {% include 'pluginconfig.j2' %} + +" THEME CONFIGURATION + +source ~/.config/vim/theme.vim diff --git a/config/automatrop/roles/vim/templates/loader.j2 b/config/automatrop/roles/vim/templates/loader.j2 index 3b1fcff..0417ff5 100644 --- a/config/automatrop/roles/vim/templates/loader.j2 +++ b/config/automatrop/roles/vim/templates/loader.j2 @@ -1,5 +1,6 @@ if has('nvim') - source ~/.config/nvim/init.vim + let $MYVIMRC="~/.config/nvim/init.vim" else - source ~/.config/vim/init.vim + let $MYVIMRC="~/.config/vim/init.vim" endif +source $MYVIMRC diff --git a/config/automatrop/roles/vim/templates/pluginlist.j2 b/config/automatrop/roles/vim/templates/pluginlist.j2 index b2f3342..ffdc0f9 100644 --- a/config/automatrop/roles/vim/templates/pluginlist.j2 +++ b/config/automatrop/roles/vim/templates/pluginlist.j2 @@ -7,10 +7,21 @@ " END PLUGIN CONFIG {{ name }} {%- endmacro -%} +" Config reload +{% if variant == 'nvim' %} +{{ use_plugin('reload') }} +{% endif %} + " Visuals {{ use_plugin('base16') }} {{ use_plugin('airline') }} {{ use_plugin('devicons') }} +{% if variant == 'nvim' %} +{{ use_plugin('lightbulb') }} +{{ use_plugin('ts-rainbow') }} +{{ use_plugin('specs') }} +{% endif %} + " Goto utilities {% if variant == 'nvim' %} @@ -62,20 +73,23 @@ " Git helpers {{ use_plugin('fugitive') }} +{% if variant == 'nvim' %} +{{ use_plugin('gitsigns') }} +{% else %} {{ use_plugin('gitgutter') }} +{% endif %} " Language-specific stuff {{ use_plugin('tcomment') }} {{ use_plugin('languagetool') }} {{ use_plugin('pandoc') }} +{% if variant == 'nvim' %} +{{ use_plugin('dap') }} +{% else %} {% if 'c' in dev_stuffs or 'c++' in dev_stuffs %} {{ use_plugin('vebugger') }} {% endif %} -{# -{% if 'python' in dev_stuffs and variant == 'nvim' %} -{{ use_plugin('semshi') }} {% endif %} -#} {% if 'ansible' in dev_stuffs %} {{ use_plugin('ansible') }} {% endif %} diff --git a/config/automatrop/roles/vim/templates/plugins/airline.j2 b/config/automatrop/roles/vim/templates/plugins/airline.j2 index 0d33420..1e443e0 100644 --- a/config/automatrop/roles/vim/templates/plugins/airline.j2 +++ b/config/automatrop/roles/vim/templates/plugins/airline.j2 @@ -8,7 +8,6 @@ let g:airline#extensions#tabline#enabled = 1 let g:airline_section_a = airline#section#create(['mode']) let g:airline_section_b = airline#section#create(['branch', 'hunks']) " let g:airline_section_z = airline#section#create(['%B', '@', '%l', ':', '%c']) -let g:airline_theme = 'base16_monokai' let airline#extensions#languageclient#error_symbol = '✖ ' let airline#extensions#languageclient#warning_symbol = '⚠ ' diff --git a/config/automatrop/roles/vim/templates/plugins/base16.j2 b/config/automatrop/roles/vim/templates/plugins/base16.j2 index 90e1fca..54f96a1 100644 --- a/config/automatrop/roles/vim/templates/plugins/base16.j2 +++ b/config/automatrop/roles/vim/templates/plugins/base16.j2 @@ -1,17 +1,7 @@ -{# -" nvim plugin doesn't support terminal colors {% if variant == 'nvim' %} +{# Beware, doesn't work without RGB colors #} {{ add_source('RRethy/nvim-base16') -}} {% else %} -#} {{ add_source('chriskempson/base16-vim') -}} -{# {% endif %} -#} -colorscheme base16-default-dark -" let base16colorspace=256 -" set termguicolors -" Some terminals requires a combination of the previous -" (the last one being setting the colorscheme to the exact theme in use), -" but it's a mess so I let you to figure out which one needs which diff --git a/config/automatrop/roles/vim/templates/plugins/dap.j2 b/config/automatrop/roles/vim/templates/plugins/dap.j2 new file mode 100644 index 0000000..616b124 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/dap.j2 @@ -0,0 +1,2 @@ +{# Debug Adapter Protocol client #} +{{ add_source('mfussenegger/nvim-dap') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/gitsigns.j2 b/config/automatrop/roles/vim/templates/plugins/gitsigns.j2 new file mode 100644 index 0000000..ca5608f --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/gitsigns.j2 @@ -0,0 +1,7 @@ +{# Show changed git lines in the gutter #} +{{ add_source('lewis6991/gitsigns.nvim') -}} +{# Dependency #} +{{ add_source('nvim-lua/plenary.nvim') -}} +lua << EOF +require('gitsigns').setup() +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/lightbulb.j2 b/config/automatrop/roles/vim/templates/plugins/lightbulb.j2 new file mode 100644 index 0000000..426fbd8 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/lightbulb.j2 @@ -0,0 +1,3 @@ +{# Shows a lightbulb whenever a codeAction is available under the cursor #} +{{ add_source('kosayoda/nvim-lightbulb') -}} +autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb() diff --git a/config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2 b/config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2 index 790c842..53ff5fe 100644 --- a/config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2 +++ b/config/automatrop/roles/vim/templates/plugins/nvim_lspconfig.j2 @@ -7,19 +7,6 @@ local nvim_lsp = require('lspconfig') -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - -- disable virtual text - virtual_text = false, - - -- show signs - signs = true, - - -- delay update diagnostics - update_in_insert = false, - } - ) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end @@ -34,7 +21,7 @@ local on_attach = function(client, bufnr) -- buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) + buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) @@ -42,9 +29,9 @@ local on_attach = function(client, bufnr) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) -- buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) -- buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) - buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + buf_set_keymap('n', '[e', 'lua vim.lsp.diagnostic.goto_prev()', opts) + buf_set_keymap('n', ']e', 'lua vim.lsp.diagnostic.goto_next()', opts) -- buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) buf_set_keymap("v", "f", "lua vim.lsp.buf.range_formatting()", opts) diff --git a/config/automatrop/roles/vim/templates/plugins/reload.j2 b/config/automatrop/roles/vim/templates/plugins/reload.j2 new file mode 100644 index 0000000..a3b7806 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/reload.j2 @@ -0,0 +1,2 @@ +{{ add_source('famiu/nvim-reload') -}} +{{ add_source('nvim-lua/plenary.nvim') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/shade.j2 b/config/automatrop/roles/vim/templates/plugins/shade.j2 new file mode 100644 index 0000000..1cddf54 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/shade.j2 @@ -0,0 +1,6 @@ +{# Dim inactive windows #} +{# Not working very well, at least with undotree #} +{{add_source('sunjon/shade.nvim')-}} +lua << EOF +require'shade'.setup() +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/specs.j2 b/config/automatrop/roles/vim/templates/plugins/specs.j2 new file mode 100644 index 0000000..c6b48f2 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/specs.j2 @@ -0,0 +1,20 @@ +{{ add_source('edluffy/specs.nvim') -}} +lua << EOF +require('specs').setup{ + show_jumps = true, + min_jump = 5, + popup = { + delay_ms = 0, -- delay before popup displays + inc_ms = 10, -- time increments used for fade/resize effects + blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend + width = 10, + winhl = "PMenu", + fader = require('specs').pulse_fader, + resizer = require('specs').shrink_resizer + }, + ignore_filetypes = {}, + ignore_buftypes = { + nofile = true, + }, +} +EOF diff --git a/config/automatrop/roles/vim/templates/plugins/telescope.j2 b/config/automatrop/roles/vim/templates/plugins/telescope.j2 index bc62da4..3f8c3ec 100644 --- a/config/automatrop/roles/vim/templates/plugins/telescope.j2 +++ b/config/automatrop/roles/vim/templates/plugins/telescope.j2 @@ -19,8 +19,8 @@ noremap gr Telescope lsp_references noremap ga Telescope lsp_code_actions vnoremap ga Telescope lsp_range_code_actions noremap gq Telescope lsp_document_diagnostics -noremap gQ Telescope lsp_workspace_diagnostics -noremap gd Telescope lsp_definitions +noremap gE Telescope lsp_workspace_diagnostics +noremap ge Telescope lsp_definitions lua << EOF require('telescope').setup{ diff --git a/config/automatrop/roles/vim/templates/plugins/treesitter.j2 b/config/automatrop/roles/vim/templates/plugins/treesitter.j2 index 46aeab6..be789d8 100644 --- a/config/automatrop/roles/vim/templates/plugins/treesitter.j2 +++ b/config/automatrop/roles/vim/templates/plugins/treesitter.j2 @@ -3,4 +3,28 @@ {# To check if it's really working {{ add_source('nvim-treesitter/playground') -}} #} -{# TODO Find a way to run `:TSInstall all` non-interactively #} +lua < boolean + max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int + } +} +EOF diff --git a/config/automatrop/roles/vim/templates/theme.j2 b/config/automatrop/roles/vim/templates/theme.j2 new file mode 100644 index 0000000..8300fcc --- /dev/null +++ b/config/automatrop/roles/vim/templates/theme.j2 @@ -0,0 +1 @@ +colorscheme base16-{{ base16_scheme }}