diff --git a/config/automatrop/roles/vim/handlers/main.yml b/config/automatrop/roles/vim/handlers/main.yml index bd090a3..e11ae85 100644 --- a/config/automatrop/roles/vim/handlers/main.yml +++ b/config/automatrop/roles/vim/handlers/main.yml @@ -1,5 +1,11 @@ - name: Upgrade Neovim plugins - command: "nvim +PlugUpgrade +PlugUpdate +PlugInstall +qall" - failed_when: no - listen: neovim plugins changed + command: "nvim +PlugUpgrade +PlugUpdate +PlugInstall +qall!" + listen: nvim plugins changed + environment: + VIMINIT: "source {{ ansible_user_dir }}/.config/nvim/plugininstall.vim" +- name: Upgrade Vim plugins + command: "vim +PlugUpgrade +PlugUpdate +PlugInstall +qall!" + listen: vim plugins changed + environment: + VIMINIT: "source {{ ansible_user_dir }}/.config/vim/plugininstall.vim" diff --git a/config/automatrop/roles/vim/tasks/main.yml b/config/automatrop/roles/vim/tasks/main.yml index 97e4c5e..7da910a 100644 --- a/config/automatrop/roles/vim/tasks/main.yml +++ b/config/automatrop/roles/vim/tasks/main.yml @@ -1,14 +1,46 @@ -- name: Create nvim configuration directory +- name: Set vim variants to use + set_fact: + vim_variants: + - vim + - nvim +# TODO vim-minimal for bsh +# TODO Select those in a clever way + +- name: Create vim configuration directory file: state: directory path: "{{ ansible_user_dir }}/.config/{{ item }}" mode: "u=rwx,g=rx,o=rx" - with_items: - - nvim + loop: "{{ vim_variants }}" -- name: Configure nvim - template: - src: nvim.j2 - dest: "{{ ansible_user_dir }}/.config/nvim/init.vim" +- name: Install vim-plug + get_url: + url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + dest: "{{ ansible_user_dir }}/.config/vim/plug.vim" mode: "u=rw,g=r,o=r" - tags: g + +- name: Install loader + template: + src: loader.j2 + dest: "{{ ansible_user_dir }}/.config/vim/loader.vim" + mode: "u=rw,g=r,o=r" + +- name: Configure vim plugin list + template: + src: plugininstall.j2 + dest: "{{ ansible_user_dir }}/.config/{{ variant }}/plugininstall.vim" + mode: "u=rw,g=r,o=r" + notify: + - "{{ variant }} plugins changed" + loop: "{{ vim_variants }}" + loop_control: + loop_var: variant + +- name: Configure vim + template: + src: init.vim.j2 + dest: "{{ ansible_user_dir }}/.config/{{ variant }}/init.vim" + mode: "u=rw,g=r,o=r" + loop: "{{ vim_variants }}" + loop_control: + loop_var: variant diff --git a/config/vim/vimconfig.vim b/config/automatrop/roles/vim/templates/editor.j2 similarity index 87% rename from config/vim/vimconfig.vim rename to config/automatrop/roles/vim/templates/editor.j2 index a112035..9b1070c 100644 --- a/config/vim/vimconfig.vim +++ b/config/automatrop/roles/vim/templates/editor.j2 @@ -1,5 +1,3 @@ -""" VIM SETTINGS """ - " From https://www.hillelwayne.com/post/intermediate-vim/ set encoding=utf-8 @@ -49,6 +47,15 @@ if has('nvim') augroup END endif +" Keep undo history across sessions by storing it in a file +if has('persistent_undo') + let myUndoDir = expand(vimDir . '/undodir') + " Create dirs + call system('mkdir ' . myUndoDir) + let &undodir = myUndoDir + set undofile +endif + syntax enable " From http://stackoverflow.com/a/5004785/2766106 diff --git a/config/automatrop/roles/vim/templates/init.vim.j2 b/config/automatrop/roles/vim/templates/init.vim.j2 new file mode 100644 index 0000000..d52d811 --- /dev/null +++ b/config/automatrop/roles/vim/templates/init.vim.j2 @@ -0,0 +1,22 @@ +set nocompatible +filetype on + +" SET PATHS + +set runtimepath+=~/.config/{{ variant }} +let vimDir = '$HOME/.cache/{{ variant }}' +call system('mkdir ' . vimDir) +let &runtimepath.=','.vimDir +set viminfo+=n~/.cache/{{ variant }}/viminfo + +" PLUGIN INSTALLATION + +source ~/.config/{{ variant }}/plugininstall.vim + +" EDITOR CONFIGURATION + +{% include 'editor.j2' %} + +" PLUGINS CONFIGURATION + +{% include 'pluginconfig.j2' %} diff --git a/config/automatrop/roles/vim/templates/loader.j2 b/config/automatrop/roles/vim/templates/loader.j2 new file mode 100644 index 0000000..3b1fcff --- /dev/null +++ b/config/automatrop/roles/vim/templates/loader.j2 @@ -0,0 +1,5 @@ +if has('nvim') + source ~/.config/nvim/init.vim +else + source ~/.config/vim/init.vim +endif diff --git a/config/automatrop/roles/vim/templates/nvim.j2 b/config/automatrop/roles/vim/templates/nvim.j2 deleted file mode 100644 index d6a50ef..0000000 --- a/config/automatrop/roles/vim/templates/nvim.j2 +++ /dev/null @@ -1,8 +0,0 @@ -set nocompatible -filetype on - -set runtimepath+=~/.config/vim,~/.cache/vim -set viminfo+=n~/.cache/vim/viminfo - -{% include 'plugins.j2' %} - diff --git a/config/automatrop/roles/vim/templates/pluginconfig.j2 b/config/automatrop/roles/vim/templates/pluginconfig.j2 new file mode 100644 index 0000000..1be4279 --- /dev/null +++ b/config/automatrop/roles/vim/templates/pluginconfig.j2 @@ -0,0 +1,2 @@ +{% set plugins = namespace(sources=[]) %} +{% include 'pluginlist.j2' %} diff --git a/config/automatrop/roles/vim/templates/plugininstall.j2 b/config/automatrop/roles/vim/templates/plugininstall.j2 new file mode 100644 index 0000000..6747065 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugininstall.j2 @@ -0,0 +1,13 @@ +source ~/.config/vim/plug.vim +{% set plugins = namespace(sources=[]) %} +{% import 'pluginlist.j2' as pluginlist with context %} + +call plug#begin('~/.cache/{{ variant }}/plugged') +{% for link, extra in plugins.sources %} +{% if extra %} +Plug '{{ link }}', { {% for k, v in extra.items() %}'{{ k }}': '{{ v }}', {% endfor %} } +{% else %} +Plug '{{ link }}' +{% endif %} +{% endfor %} +call plug#end() diff --git a/config/automatrop/roles/vim/templates/pluginlist.j2 b/config/automatrop/roles/vim/templates/pluginlist.j2 index 8e34e9e..5641012 100644 --- a/config/automatrop/roles/vim/templates/pluginlist.j2 +++ b/config/automatrop/roles/vim/templates/pluginlist.j2 @@ -2,8 +2,57 @@ {% set plugins.sources = plugins.sources + [(link, extra)] %} {%- endmacro -%} {% macro use_plugin(name) -%} -{% include 'plugins/' + name + '.j2' %} +" START PLUGIN CONFIG {{ name }} +{% include 'plugins/' + name + '.j2' +%} +" END PLUGIN CONFIG {{ name }} {%- endmacro -%} -{{ use_plugin('ale') }} +" Theming +{{ use_plugin('base16') }} +{{ use_plugin('airline') }} + +" Goto utilities +{{ use_plugin('fzf') }} + +" Search/replace +{{ use_plugin('abolish') }} + +" Sourounding pairs +{{ use_plugin('surround') }} +{{ use_plugin('targets') }} + +" f/F mode +{{ use_plugin('shot_f') }} +{{ use_plugin('quick_scope') }} + +" Tags +{{ use_plugin('gutentags') }} +{{ use_plugin('vista') }} + +" Language Server Client +{{ use_plugin('vim_lsp') }} + +" Auto-completion {{ use_plugin('deoplete') }} +{{ use_plugin('supertab') }} + +" Undo management +{{ use_plugin('undotree') }} + +" Git helpers +{{ use_plugin('fugitive') }} +{{ use_plugin('gitgutter') }} + +" Language-specific stuff +{{ use_plugin('tcomment') }} +{{ use_plugin('languagetool') }} +{{ use_plugin('pandoc') }} +{% 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.j2 b/config/automatrop/roles/vim/templates/plugins.j2 deleted file mode 100644 index ced41b2..0000000 --- a/config/automatrop/roles/vim/templates/plugins.j2 +++ /dev/null @@ -1,21 +0,0 @@ -" Auto-install vim-plug -if empty(glob('~/.cache/vim/autoload/plug.vim')) - silent !curl -fLo ~/.cache/vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -{% set plugins = namespace(sources=[]) %} -{% import 'pluginlist.j2' as pluginlist with context %} - -call plug#begin('~/.cache/vim/plugged') -{% for link, extra in plugins.sources %} -{% if extra %} -Plug '{{ link }}', { {% for k, v in extra.items() %}'{{ k }}': '{{ v }}', {% endfor %} } -{% else %} -Plug '{{ link }}' -{% endif %} -{% endfor %} -call plug#end() - -{% include 'pluginlist.j2' %} diff --git a/config/automatrop/roles/vim/templates/plugins/abolish.j2 b/config/automatrop/roles/vim/templates/plugins/abolish.j2 new file mode 100644 index 0000000..3a5f5d4 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/abolish.j2 @@ -0,0 +1,2 @@ +{# Regex for words, with case in mind #} +{{ add_source('tpope/tpope-vim-abolish') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/airline.j2 b/config/automatrop/roles/vim/templates/plugins/airline.j2 new file mode 100644 index 0000000..0d33420 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/airline.j2 @@ -0,0 +1,14 @@ +{{ add_source('vim-airline/vim-airline') -}} +{{ add_source('vim-airline/vim-airline-themes') -}} +set noshowmode +set laststatus=2 +let g:airline_powerline_fonts = 1 +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/ale.j2 b/config/automatrop/roles/vim/templates/plugins/ale.j2 index 50089d7..99040cb 100644 --- a/config/automatrop/roles/vim/templates/plugins/ale.j2 +++ b/config/automatrop/roles/vim/templates/plugins/ale.j2 @@ -1,3 +1,5 @@ +" Asynchronous Lint Engine +" LSP client for vim and nvim {{ add_source('dense-analysis/ale') }} nmap :ALEFix @@ -6,4 +8,3 @@ let g:ale_sign_error = '×' let g:ale_sign_warning = '!' let g:ale_completion_enabled = 1 let g:ale_fixers = ['autopep8', 'shfmt', 'uncrustify', 'remove_trailing_lines', 'trim_whitespace', 'phpcbf'] -let g:ale_php_phpcs_standard = '/srv/http/machines/ruleset.xml' diff --git a/config/automatrop/roles/vim/templates/plugins/ansible.j2 b/config/automatrop/roles/vim/templates/plugins/ansible.j2 new file mode 100644 index 0000000..0fb51fa --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/ansible.j2 @@ -0,0 +1,2 @@ +{# Various for Ansible #} +{{ add_source('pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh'}) -}} diff --git a/config/automatrop/roles/vim/templates/plugins/asyncomplete.j2 b/config/automatrop/roles/vim/templates/plugins/asyncomplete.j2 new file mode 100644 index 0000000..dcf0070 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/asyncomplete.j2 @@ -0,0 +1,14 @@ +{{ add_source('prabirshrestha/asyncomplete.vim') -}} +let g:asyncomplete_auto_popup = 1 +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +imap (asyncomplete_force_refresh) + +{{ add_source('prabirshrestha/asyncomplete-file.vim') -}} +au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({ + \ 'name': 'file', + \ 'whitelist': ['*'], + \ 'priority': 10, + \ 'completor': function('asyncomplete#sources#file#completor') + \ })) diff --git a/config/automatrop/roles/vim/templates/plugins/base16.j2 b/config/automatrop/roles/vim/templates/plugins/base16.j2 new file mode 100644 index 0000000..555fb41 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/base16.j2 @@ -0,0 +1,8 @@ +{{ add_source('chriskempson/base16-vim') -}} +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/deoplete.j2 b/config/automatrop/roles/vim/templates/plugins/deoplete.j2 index 870abda..7219c8c 100644 --- a/config/automatrop/roles/vim/templates/plugins/deoplete.j2 +++ b/config/automatrop/roles/vim/templates/plugins/deoplete.j2 @@ -1 +1,26 @@ -{{ add_source('Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}) }} +{# Auto-completion for vim and nvim #} +{% if variant == 'nvim' -%} +{{ add_source('Shougo/deoplete.nvim', {'do': ':UpdateRemotePlugins'}) -}} +{% else -%} +{{ add_source('Shougo/deoplete.nvim') -}} +{{ add_source('roxma/nvim-yarp') -}} +{{ add_source('roxma/vim-hug-neovim-rpc') -}} +{% endif -%} +{% raw %} +let g:deoplete#enable_at_startup = 1 +inoremap +\ pumvisible() ? "\" : +\ check_back_space() ? "\" : +\ deoplete#manual_complete() +function! s:check_back_space() abort "{{{ +let col = col('.') - 1 +return !col || getline('.')[col - 1] =~ '\s' +endfunction"}}} +{% endraw %} + +" suggested by ssemshi to make it not too slow +" let g:deoplete#auto_complete_delay = 100 +call deoplete#custom#option({ +\ 'auto_complete_delay': 100, +\ 'smart_case': v:true, +\ }) diff --git a/config/automatrop/roles/vim/templates/plugins/easy_align.j2 b/config/automatrop/roles/vim/templates/plugins/easy_align.j2 new file mode 100644 index 0000000..c5fe06d --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/easy_align.j2 @@ -0,0 +1,4 @@ +{# Aligning lines around a certain character #} +{{ add_source('junegunn/vim-easy-align') -}} +" Align GitHub-flavored Markdown tables +au FileType markdown vmap :EasyAlign* diff --git a/config/automatrop/roles/vim/templates/plugins/fugitive.j2 b/config/automatrop/roles/vim/templates/plugins/fugitive.j2 new file mode 100644 index 0000000..6abf2e7 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/fugitive.j2 @@ -0,0 +1,4 @@ +{# Git basics #} +{{ add_source('tpope/vim-fugitive') -}} +{# Open files in GitLab #} +{{ add_source('shumphrey/fugitive-gitlab.vim') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/fzf.j2 b/config/automatrop/roles/vim/templates/plugins/fzf.j2 new file mode 100644 index 0000000..08815c7 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/fzf.j2 @@ -0,0 +1,36 @@ +{# Fuzzy matching for all kind of stuff #} +{{ add_source('junegunn/fzf', {'do': './install --bin'}) }} +{{ add_source('junegunn/fzf.vim') -}} +let g:fzf_layout = { 'down': '~40%' } +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + +let g:fzf_command_prefix = 'Fzf' +nmap gF :FzfFiles +nmap gf :FzfGFiles +nmap gb :FzfBuffers +nmap gL :FzfLines +nmap gl :FzfBLines +nmap gT :FzfTags +nmap gt :FzfBTags +nmap gm :FzfMarks +nmap gw :FzfWindows +nmap gh :FzfHistory +nmap gH :FzfHistory: +nmap gS :FzfHistory/ +nmap gs :FzfSnippets + +" TODO `gd` → go to tag matching selected word, or show a list with that +" of tags pre-filtered with that word diff --git a/config/automatrop/roles/vim/templates/plugins/gitgutter.j2 b/config/automatrop/roles/vim/templates/plugins/gitgutter.j2 new file mode 100644 index 0000000..d6b4fad --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/gitgutter.j2 @@ -0,0 +1,2 @@ +{# Show changed git lines in the gutter #} +{{ add_source('airblade/vim-gitgutter') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/gutentags.j2 b/config/automatrop/roles/vim/templates/plugins/gutentags.j2 new file mode 100644 index 0000000..28dd01b --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/gutentags.j2 @@ -0,0 +1,3 @@ +{# Generate tags #} +{{ add_source('ludovicchabant/vim-gutentags') -}} +let g:gutentags_cache_dir = expand('~/.cache/{{ variant }}/tags') diff --git a/config/automatrop/roles/vim/templates/plugins/languageclient.j2 b/config/automatrop/roles/vim/templates/plugins/languageclient.j2 new file mode 100644 index 0000000..6f319d9 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/languageclient.j2 @@ -0,0 +1,20 @@ +{{ add_source('autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh'}) -}} + +let g:LanguageClient_serverCommands = { + \ 'python': ['pyls'], + \ 'sh': ['bash-language-server', 'start'], + \ } +let g:LanguageClient_loggingFile = expand('~/.cache/{{ variant }}/LanguageClient.log') + +function LC_maps() + if has_key(g:LanguageClient_serverCommands, &filetype) + nnoremap K :call LanguageClient#textDocument_hover() + nnoremap gd :call LanguageClient#textDocument_definition() + nnoremap gD :call LanguageClient#textDocument_references() + nnoremap :call LanguageClient#textDocument_rename() + nnoremap :call LanguageClient#textDocument_formatting() + set completefunc=LanguageClient#complete + set omnifunc=LanguageClient#complete + endif +endfunction +autocmd FileType * call LC_maps() diff --git a/config/automatrop/roles/vim/templates/plugins/languagetool.j2 b/config/automatrop/roles/vim/templates/plugins/languagetool.j2 new file mode 100644 index 0000000..a677f9a --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/languagetool.j2 @@ -0,0 +1,3 @@ +{# Check grammar for human languages #} +{{ add_source('dpelle/vim-LanguageTool') -}} +let g:languagetool_jar = "/usr/share/java/languagetool/languagetool-commandline.jar" diff --git a/config/automatrop/roles/vim/templates/plugins/pandoc.j2 b/config/automatrop/roles/vim/templates/plugins/pandoc.j2 new file mode 100644 index 0000000..f2acc5d --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/pandoc.j2 @@ -0,0 +1,6 @@ +{# Pandoc specific stuff because there's no LSP for it #} +{{ add_source('vim-pandoc/vim-pandoc') -}} +{{ add_source('vim-pandoc/vim-pandoc-syntax') -}} +let g:pandoc#modules#disabled = ["folding"] +let g:pandoc#spell#enabled = 0 +let g:pandoc#syntax#conceal#use = 0 diff --git a/config/automatrop/roles/vim/templates/plugins/quick_scope.j2 b/config/automatrop/roles/vim/templates/plugins/quick_scope.j2 new file mode 100644 index 0000000..8e0692f --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/quick_scope.j2 @@ -0,0 +1,2 @@ +{# Auto-highlight one character per word for quick f/F movement #} +{{ add_source('unblevable/quick-scope') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/semshi.j2 b/config/automatrop/roles/vim/templates/plugins/semshi.j2 new file mode 100644 index 0000000..1a77fe0 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/semshi.j2 @@ -0,0 +1,2 @@ +{# Semantic highlighting for Python for neovim #} +{{ add_source('numirias/semshi', {'do': ':UpdateRemotePlugins'}) -}} diff --git a/config/automatrop/roles/vim/templates/plugins/shot_f.j2 b/config/automatrop/roles/vim/templates/plugins/shot_f.j2 new file mode 100644 index 0000000..20808d2 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/shot_f.j2 @@ -0,0 +1,2 @@ +{# When in f/F/t/T mode, highlight in red the characters that can be jumped to #} +{{ add_source('deris/vim-shot-f') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/smooth_scroll.j2 b/config/automatrop/roles/vim/templates/plugins/smooth_scroll.j2 new file mode 100644 index 0000000..36d9752 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/smooth_scroll.j2 @@ -0,0 +1,2 @@ +{# Smoooooth scrolling #} +{{ add_source('terryma/vim-smooth-scroll') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/supertab.j2 b/config/automatrop/roles/vim/templates/plugins/supertab.j2 new file mode 100644 index 0000000..29e9ce3 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/supertab.j2 @@ -0,0 +1,4 @@ +{# Use TAB for autocompletion #} +{{ add_source('ervandew/supertab') -}} +let g:SuperTabDefaultCompletionType = "" " Go down when completing +let g:SuperTabContextDefaultCompletionType = "" diff --git a/config/automatrop/roles/vim/templates/plugins/surround.j2 b/config/automatrop/roles/vim/templates/plugins/surround.j2 new file mode 100644 index 0000000..d4dfb9a --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/surround.j2 @@ -0,0 +1,2 @@ +{# Change surroundings pairs (e.g. brackets, quotes… #} +{{ add_source('tpope/vim-surround') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/targets.j2 b/config/automatrop/roles/vim/templates/plugins/targets.j2 new file mode 100644 index 0000000..b9a7de7 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/targets.j2 @@ -0,0 +1,2 @@ +{# Better interaction with surrounding pairs #} +{{ add_source('wellle/targets.vim') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/tcomment.j2 b/config/automatrop/roles/vim/templates/plugins/tcomment.j2 new file mode 100644 index 0000000..0539d77 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/tcomment.j2 @@ -0,0 +1,2 @@ +{# Language-aware (un)commenting #} +{{ add_source('tomtom/tcomment_vim') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/undotree.j2 b/config/automatrop/roles/vim/templates/plugins/undotree.j2 new file mode 100644 index 0000000..3c364c0 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/undotree.j2 @@ -0,0 +1,2 @@ +{{ add_source('mbbill/undotree') -}} +nmap :UndotreeToggle diff --git a/config/automatrop/roles/vim/templates/plugins/vebugger.j2 b/config/automatrop/roles/vim/templates/plugins/vebugger.j2 new file mode 100644 index 0000000..013a066 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/vebugger.j2 @@ -0,0 +1,2 @@ +{# Debug from the editor #} +{{ add_source('idanarye/vim-vebugger') -}} diff --git a/config/automatrop/roles/vim/templates/plugins/vim_lsp.j2 b/config/automatrop/roles/vim/templates/plugins/vim_lsp.j2 new file mode 100644 index 0000000..b175265 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/vim_lsp.j2 @@ -0,0 +1,23 @@ +{# LSP client for Vim8 and neovim #} +{{ add_source('prabirshrestha/vim-lsp') -}} +{{ add_source('mattn/vim-lsp-settings') -}} +" (providers are automatically detected thanks to vim-lsp-settings. +" You can even install some locally using :LspInstallServer) + +nnoremap gd :LspDefinition +nnoremap gD :LspDeclaration +nnoremap :LspDocumentFormat +vnoremap :LspDocumentRangeFormat +nnoremap gE :LspNextDiagnostic +nnoremap ge :LspNextError +nnoremap :LspRename + +let g:lsp_signs_enabled = 1 +let g:lsp_diagnostics_echo_cursor = 1 + +let g:lsp_signs_error = {'text': '✗'} +let g:lsp_signs_warning = {'text': '‼'} +let g:lsp_signs_information = {'text': 'ℹ'} +let g:lsp_signs_hint = {'text': '?'} + +let g:lsp_highlight_references_enabled = 1 diff --git a/config/automatrop/roles/vim/templates/plugins/vista.j2 b/config/automatrop/roles/vim/templates/plugins/vista.j2 new file mode 100644 index 0000000..ef15442 --- /dev/null +++ b/config/automatrop/roles/vim/templates/plugins/vista.j2 @@ -0,0 +1,12 @@ +{# Tag bar #} +{{ add_source('liuchengxu/vista.vim') -}} +nmap :Vista!! +let g:vista_icon_indent = ["▸ ", ""] + +let g:vista#renderer#enable_icon = 0 + +" The default icons can't be suitable for all the filetypes, you can extend it as you wish. +let g:vista#renderer#icons = { +\ "function": "f", +\ "variable": "x", +\ } diff --git a/config/shell/shenv b/config/shell/shenv index a6859c6..0ee3fc0 100644 --- a/config/shell/shenv +++ b/config/shell/shenv @@ -44,8 +44,7 @@ export SCREENRC="$HOME/.config/screenrc" export SQLITE_HISTFILE="$HOME/.cache/sqlite_history" direnv TERMINFO "$HOME/.config/terminfo" export RXVT_SOCKET="$HOME/.cache/urxvtd-$HOST" -export MYVIMRC="$HOME/.config/vim/vimrc" -export VIMINIT="source $MYVIMRC" +export VIMINIT="source $HOME/.config/vim/loader.vim" direnv WINEPREFIX "$HOME/.cache/wineprefix/default" direnv YARN_CACHE_FOLDER "$HOME/.cache/yarn" export YARN_DISABLE_SELF_UPDATE_CHECK=true # This also disable the creation of a ~/.yarnrc file diff --git a/config/vim/.gitignore b/config/vim/.gitignore deleted file mode 100644 index a56b89a..0000000 --- a/config/vim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -colorscheme.vim diff --git a/config/vim/paths.vim b/config/vim/paths.vim deleted file mode 100644 index 1242289..0000000 --- a/config/vim/paths.vim +++ /dev/null @@ -1,23 +0,0 @@ -" Put plugins and dictionaries in this dir (also on Windows) -let vimDir = '$HOME/.cache/vim' -let &runtimepath.=','.vimDir - -" let base16colorspace=256 -" set termguicolors -" source $HOME/.config/vim/colorscheme.vim -" 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 - -colorscheme base16-default-dark - -" Keep undo history across sessions by storing it in a file -if has('persistent_undo') - let myUndoDir = expand(vimDir . '/undodir') - " Create dirs - call system('mkdir ' . vimDir) - call system('mkdir ' . myUndoDir) - let &undodir = myUndoDir - set undofile -endif - diff --git a/config/vim/pluginconfig.vim b/config/vim/pluginconfig.vim deleted file mode 100644 index fb598a8..0000000 --- a/config/vim/pluginconfig.vim +++ /dev/null @@ -1,187 +0,0 @@ -""" ALE """ - -" nmap :ALEFix -" -" let g:ale_sign_error = '×' -" let g:ale_sign_warning = '!' -" let g:ale_completion_enabled = 1 -" let g:ale_fixers = ['autopep8', 'shfmt', 'uncrustify', 'remove_trailing_lines', 'trim_whitespace', 'phpcbf'] -" let g:ale_php_phpcs_standard = '/srv/http/machines/ruleset.xml' - -" For PHP, install https://pear.php.net/package/PHP_CodeSniffer - - -""" UNDOTREE """ - -nmap :UndotreeToggle - -""" VIM-AIRLINE """ - -set noshowmode -set laststatus=2 -let g:airline_powerline_fonts = 1 -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 = '⚠ ' - -""" FZF """ - -let g:fzf_layout = { 'down': '~40%' } -let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - -let g:fzf_command_prefix = 'Fzf' -nmap gF :FzfFiles -nmap gf :FzfGFiles -nmap gb :FzfBuffers -nmap gL :FzfLines -nmap gl :FzfBLines -nmap gT :FzfTags -nmap gt :FzfBTags -nmap gm :FzfMarks -nmap gw :FzfWindows -nmap gh :FzfHistory -nmap gH :FzfHistory: -nmap gS :FzfHistory/ -nmap gs :FzfSnippets - -" TODO `gd` → go to tag matching selected word, or show a list with that -" of tags pre-filtered with that word - -""" SUPERTAB """ - -let g:SuperTabDefaultCompletionType = "" " Go down when completing -let g:SuperTabContextDefaultCompletionType = "" - -""" LanguageTool """ - -let g:languagetool_jar = "/usr/share/java/languagetool/languagetool-commandline.jar" - -""" vim-pandoc """ -let g:pandoc#modules#disabled = ["folding"] -let g:pandoc#spell#enabled = 0 -let g:pandoc#syntax#conceal#use = 0 - -""" LanguageClient-neovim """ - -" let g:LanguageClient_serverCommands = { -" \ 'python': ['pyls'], -" \ 'sh': ['bash-language-server', 'start'], -" \ } -" let g:LanguageClient_loggingFile = expand('~/.cache/vim/LanguageClient.log') -" -" -" function LC_maps() -" if has_key(g:LanguageClient_serverCommands, &filetype) -" nnoremap K :call LanguageClient#textDocument_hover() -" nnoremap gd :call LanguageClient#textDocument_definition() -" nnoremap gD :call LanguageClient#textDocument_references() -" nnoremap :call LanguageClient#textDocument_rename() -" nnoremap :call LanguageClient#textDocument_formatting() -" set completefunc=LanguageClient#complete -" set omnifunc=LanguageClient#complete -" endif -" endfunction -" autocmd FileType * call LC_maps() - -""" vim-lsp """ - -" (providers are automatically detected thanks to vim-lsp-settings. -" You can even install some locally using :LspInstallServer) - -nnoremap gd :LspDefinition -nnoremap gD :LspDeclaration -nnoremap :LspDocumentFormat -vnoremap :LspDocumentRangeFormat -nnoremap gE :LspNextDiagnostic -nnoremap ge :LspNextError -nnoremap :LspRename - -let g:lsp_signs_enabled = 1 -let g:lsp_diagnostics_echo_cursor = 1 - -let g:lsp_signs_error = {'text': '✗'} -let g:lsp_signs_warning = {'text': '‼'} -let g:lsp_signs_information = {'text': 'ℹ'} -let g:lsp_signs_hint = {'text': '?'} - -let g:lsp_highlight_references_enabled = 1 - -""" deoplete """ - -let g:deoplete#enable_at_startup = 1 -inoremap -\ pumvisible() ? "\" : -\ check_back_space() ? "\" : -\ deoplete#manual_complete() -function! s:check_back_space() abort "{{{ -let col = col('.') - 1 -return !col || getline('.')[col - 1] =~ '\s' -endfunction"}}} - -" suggested by ssemshi to make it not too slow -" let g:deoplete#auto_complete_delay = 100 -call deoplete#custom#option({ -\ 'auto_complete_delay': 100, -\ 'smart_case': v:true, -\ }) - -""" asyncomplete """ - -" let g:asyncomplete_auto_popup = 1 -" inoremap pumvisible() ? "\" : "\" -" inoremap pumvisible() ? "\" : "\" -" inoremap pumvisible() ? "\" : "\" -" imap (asyncomplete_force_refresh) - -""" asyncomplete-file - -" au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({ -" \ 'name': 'file', -" \ 'whitelist': ['*'], -" \ 'priority': 10, -" \ 'completor': function('asyncomplete#sources#file#completor') -" \ })) - -""" vista.vim """ - -nmap :Vista!! -let g:vista_icon_indent = ["▸ ", ""] - -let g:vista#renderer#enable_icon = 0 - -" The default icons can't be suitable for all the filetypes, you can extend it as you wish. -let g:vista#renderer#icons = { -\ "function": "f", -\ "variable": "x", -\ } - -" EasyAlign - -" Align GitHub-flavored Markdown tables -au FileType markdown vmap :EasyAlign* - -" SmoothScroll -noremap :call smooth_scroll#up(20, 5, 1) -noremap :call smooth_scroll#down(20, 5, 1) - -" gutentags -let g:gutentags_cache_dir = expand('~/.cache/vim/tags') diff --git a/config/vim/pluginlist.vim b/config/vim/pluginlist.vim deleted file mode 100644 index 3c229de..0000000 --- a/config/vim/pluginlist.vim +++ /dev/null @@ -1,105 +0,0 @@ -""" PLUGINS MANAGEMENT """ - -" NOTE 18-06-24 Got rid of Vundle in favor of vim-plug (why: more recent, supports -" Neovim, simpler). Commented out plugins that seemed useless, feel free to -" uncomment them again if you need to - -" Auto-install vim-plug -if empty(glob('~/.cache/vim/autoload/plug.vim')) - silent !curl -fLo ~/.cache/vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -" Plugin definition -call plug#begin('~/.cache/vim/plugged') - -" Plug 'L9' -" Plug 'rstacruz/sparkup', {'rtp': 'vim/'} -Plug 'chriskempson/base16-vim' -Plug 'tpope/vim-surround' -Plug 'tpope/vim-fugitive' -Plug 'shumphrey/fugitive-gitlab.vim' -" Plug 'tpope/vim-repeat' - -" Regex for words, with case in mind -Plug 'tpope/tpope-vim-abolish' - -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'airblade/vim-gitgutter' -Plug 'mbbill/undotree' -Plug 'ludovicchabant/vim-gutentags' -" Plug 'majutsushi/tagbar' -Plug 'wellle/targets.vim' -" Plug 'Chiel92/vim-autoformat' -Plug 'tomtom/tcomment_vim' -" Plug 'Shougo/denite.nvim' -" Plug 'tomlion/vim-solidity' -" Plug 'godlygeek/tabular' -" Plug 'jrozner/vim-antlr' - -" When in f/F/t/T mode, highlight in red the characters that can be jumped to -Plug 'deris/vim-shot-f' - -" Auto-highlight one character per word for quick f/F movement -Plug 'unblevable/quick-scope' - -" Auto-completion - -if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -else - Plug 'Shougo/deoplete.nvim' - Plug 'roxma/nvim-yarp' - Plug 'roxma/vim-hug-neovim-rpc' -endif - -" Plug 'prabirshrestha/asyncomplete.vim' -" Plug 'prabirshrestha/asyncomplete-file.vim' - -" Plug 'python-mode/python-mode', { 'branch': 'develop' } -Plug 'junegunn/fzf', {'do': './install --bin'} -Plug 'junegunn/fzf.vim' -Plug 'ervandew/supertab' -Plug 'dpelle/vim-LanguageTool' -Plug 'terryma/vim-smooth-scroll' -Plug 'vim-pandoc/vim-pandoc' -Plug 'vim-pandoc/vim-pandoc-syntax' -Plug 'idanarye/vim-vebugger' - -" " Language Server Procotol client - -" Plug 'autozimu/LanguageClient-neovim', { -" \ 'branch': 'next', -" \ 'do': 'bash install.sh', -" \ } - -Plug 'prabirshrestha/async.vim' -Plug 'prabirshrestha/vim-lsp' -Plug 'mattn/vim-lsp-settings' - - -" Automatically closes brackets, quotes and parentheses -" Plug 'jiangmiao/auto-pairs' -" Disabled : While it works correctly when typing code, -" when modifying existing one it's another thing - -" Plug 'ActivityWatch/aw-watcher-vim' -" Activity watch -" (might not want this on every install) - -" Tag bar -Plug 'liuchengxu/vista.vim' - -" Semantic highlighting for Python -Plug 'numirias/semshi', {'do': ':UpdateRemotePlugins'} - -" Aligning lines around a certain character -Plug 'junegunn/vim-easy-align' - -" Various for Ansible -Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' } - -call plug#end() - diff --git a/config/vim/vimrc b/config/vim/vimrc deleted file mode 100644 index 53aa792..0000000 --- a/config/vim/vimrc +++ /dev/null @@ -1,14 +0,0 @@ -" VIM Configuration - Geoffrey FROGEYE -" - -set nocompatible -filetype on - -set runtimepath+=~/.config/vim,~/.cache/vim -set viminfo+=n~/.cache/vim/viminfo - -source ~/.config/vim/pluginlist.vim -source ~/.config/vim/paths.vim -source ~/.config/vim/vimconfig.vim -source ~/.config/vim/pluginconfig.vim -