" {{@@ header() @@}} " LEL " _ " _ ____ _(_)_ __ ___ " | '_ \ \ / / | '_ ` _ \ " | | | \ V /| | | | | | | " |_| |_|\_/ |_|_| |_| |_| " Plugins{{{ " " Install plug if it isn't already if empty(glob('~/.config/nvim/autoload/plug.vim')) silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim augroup PLUG au! autocmd VimEnter * PlugInstall augroup END endif call plug#begin('~/.config/nvim/plugged') Plug 'airblade/vim-gitgutter' Plug 'chrisbra/Colorizer' " Language server support " {%@@ set lsp = "vim-lsp" @@%} {%@@ if lsp == "vim-lsp" @@%} Plug 'prabirshrestha/vim-lsp' Plug 'mattn/vim-lsp-settings' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'prabirshrestha/asyncomplete-file.vim' {%@@ elif lsp == "coc" @@%} Plug 'neoclide/coc.nvim', {'branch': 'release'} {%@@ endif @@%} Plug 'sheerun/vim-polyglot' " Plug 'autozimu/LanguageClient-neovim', { " \ 'branch': 'next', " \ 'do': 'bash install.sh', " \} " Debugger " Plug 'vim-vdebug/vdebug' " Fuzzy find Plug 'junegunn/fzf' Plug 'junegunn/fzf.vim' " Completions " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " HTML shortcuts Plug 'mattn/emmet-vim' Plug 'jiangmiao/auto-pairs' Plug 'tpope/vim-surround' Plug 'junegunn/vim-easy-align' Plug 'tpope/vim-commentary' " Status bar Plug 'vim-airline/vim-airline' " Plug 'vim-airline/vim-airline-themes' {%@@ if lsp == "ale" @@%} let g:airline#extensions#ale#enabled = 1 {%@@ endif @@%} " Bufferlist (integrates with airline) " Plug 'bling/vim-bufferline' " Color scheme Plug 'dikiaap/minimalist' " Plug 'morhetz/gruvbox' " Not that good " Utilities "Plug 'xolox/vim-misc' " Notes "Plug 'xolox/vim-notes' " Latex Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } Plug 'vim-latex/vim-latex', { 'for': 'tex' } Plug 'vim-scripts/AnsiEsc.vim', { 'for': 'man' } " Plug 'powerman/vim-plugin-AnsiEsc' " Language sytax highlight improvements " Plug 'mboughaba/i3config.vim' " Plug 'dag/vim-fish' " Plug 'arrufat/vala.vim' " Plug 'NLKNguyen/c-syntax.vim' " Plug 'vim-python/python-syntax' " Plug 'stephpy/vim-yaml' call plug#end() "}}} " Syntax options{{{ " " Enable syntax and set color scheme syntax on set tabstop=4 set shiftwidth=4 set expandtab set smarttab set virtualedit=all set scrolloff=8 set sidescrolloff=8 set nowrap "destaque no númer de linhas set number set relativenumber "display whitespace set listchars=tab:>-,trail:~,extends:>,precedes:< set listchars=space:_,eol:;,tab:>-,trail:~,extends:>,precedes:< set list "ativa o mouse set mouse =a set clipboard +=unnamedplus set title let g:python_highlight_all = 1 "}}} " Gay colors{{{ " if (empty($TMUX)) if (has('nvim')) let $NVIM_TUI_ENABLE_TRUE_COLOR = 1 endif if (has('termguicolors')) set termguicolors endif " endif colorscheme minimalist set background=dark "background color is transparent highlight Normal guibg=None highlight EndOfBuffer guibg=None guifg={{@@ color.bg_light @@}} highlight SpecialKey guibg=None guifg={{@@ color.accent @@}} highlight SignColumn guibg=None highlight GitGutterAdd guifg=lightgreen highlight GitGutterChange guifg=yellow highlight GitGutterDelete guifg=lightred "Line numers highlight LineNr term=bold ctermfg=9 guifg={{@@ color.bg_light @@}} guibg=None "Make whitespace dark highlight NonText ctermfg=darkgray guifg={{@@ color.nontxt @@}} guibg=None " highlight SpecialKey ctermfg=black guifg=#252525 guibg=None "Current line set cursorline highlight CursorLine term=bold cterm=bold gui=Bold guibg={{@@ color.bg_dark @@}} highlight CursorLineNr term=bold cterm=bold gui=Bold guibg={{@@ color.bg_dark @@}} guifg=white "Splits highlight VertSplit guibg=None guifg={{@@ color.bg_dark @@}} " set fillchars=vert:/ highlight Identifier guifg={{@@ color.accent @@}} highlight MatchParen gui=bold guifg=yellow "}}} " Keys{{{ " " Basic motion noremap {{@@ key.left @@}} noremap {{@@ key.down @@}} noremap {{@@ key.up @@}} noremap {{@@ key.right @@}} noremap {{@@ key.left @@}} :wincmd h noremap {{@@ key.down @@}} :wincmd j noremap {{@@ key.up @@}} :wincmd k noremap {{@@ key.right @@}} :wincmd l noremap {{@@ key.next @@}} n noremap {{@@ key.next.upper() @@}} N " Added benefits noremap - $ noremap _ ^ " noremap N " noremap T noremap H 8 noremap T 8 " noremap D " Single charater traversal imap imap "I deserve the death sentence nmap :wa "open and close folds nmap {{@@ key.right @@}} noremap :silent! foldopen " Easy comment toggle nmap gc :Commentary xmap gc :Commentary " Toggle file manager " map :NERDTreeToggle %:p:h " EasyAlign xmap ga (EasyAlign) nmap ga (EasyAlign) "EasyMotion " map e (easymotion-prefix) set ignorecase map :GFiles map :Files "}}} " Lanugage Server{{{ " set foldmethod=marker set hidden set autoread autocmd BufWritePre * :call StripTrailingWhitespaces() function! StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfun " Allow saving of files as sudo when I forgot to start vim using sudo. cmap w!! w !sudo tee % >/dev/null " Auto deploy dotfiles autocmd BufWritePost {{@@ parent_dir( _dotdrop_dotpath ) @@}}/{config.yaml,dotfiles/**} silent !dotdrop install -f {%@@ if lsp == "vim-lsp" @@%} " vim-lsp{{{ "allow json comments autocmd FileType json syntax match Comment +\/\/.\+$+ " Workaround for bug let g:lsp_documentation_float = 0 " Complete inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" imap (asyncomplete_force_refresh) " Fix nmap gf (lsp-document-format) vmap gf (lsp-document-range-format) nmap gr (lsp-rename) nmap gl (lsp-code-action) nmap gs (lsp-references) " Move around nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap gd :LspDefinition nmap K :LspHover " Colors highlight LspErrorHighlight gui=undercurl guisp={{@@ color.normal.red @@}} highlight LspErrorText gui=bold guifg={{@@ color.normal.red @@}} guibg=none highlight LspErrorVirtual gui=underline guifg={{@@ color.normal.red @@}} guibg=none highlight LspWarningHighlight gui=undercurl guisp={{@@ color.normal.yellow @@}} highlight LspWarningText gui=bold guifg={{@@ color.normal.yellow @@}} guibg=none highlight LspWarningVirtual gui=underline guifg={{@@ color.normal.yellow @@}} guibg=none " Highlight all references, looks pretty *-* let g:lsp_highlight_references_enabled = 1 highlight LspReference gui=bold guifg={{@@ color.normal.yellow @@}} "}}} {%@@ elif lsp == "coc" @@%} "" coc {{{ "allow json comments autocmd FileType json syntax match Comment +\/\/.\+$+ " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif " Use `[g` and `]g` to navigate diagnostics " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " GoTo code navigation. nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use gd to show documentation in preview window. nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap gr (coc-rename) " use for trigger completion and navigate to the next complete item function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" " Formatting selected code. xmap gf (coc-format-selected) nmap gf (coc-format-selected) " Add `:Format` command to format current buffer. command! -nargs=0 Format :call CocAction('format') " Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap af (coc-funcobj-a) xmap ic (coc-classobj-i) omap ic (coc-classobj-i) xmap ac (coc-classobj-a) omap ac (coc-classobj-a) "}}} {%@@ elif lsp == "ale" @@%} " ale{{{ " Lint let g:ale_echo_msg_error_str = 'E' let g:ale_echo_msg_warning_str = 'W' let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' " let g:ale_python_pyls_executable = '/usr/bin/pyls' let g:ale_use_global_executables = 1 let g:ale_python_mypy_options = '--ignore-missing-imports' let g:ale_linters = { \ 'python': ['pyls'], \ } " Fix " let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['autopep8'], \} let g:ale_fix_on_save = 1 " Complete " " Use deoplete. let g:deoplete#enable_at_startup = 1 call deoplete#custom#option('sources', { \ '_': ['ale'], \}) " let g:ale_completion_symbols = { " \ 'text': '', " \ 'method': '', " \ 'function': '', " \ 'constructor': '', " \ 'field': '', " \ 'variable': '', " \ 'class': '', " \ 'interface': '', " \ 'module': '', " \ 'property': '', " \ 'unit': 'unit', " \ 'value': 'val', " \ 'enum': '', " \ 'keyword': 'keyword', " \ 'snippet': '', " \ 'color': 'color', " \ 'file': '', " \ 'reference': 'ref', " \ 'folder': '', " \ 'enum member': '', " \ 'constant': '', " \ 'struct': '', " \ 'event': 'event', " \ 'operator': '', " \ 'type_parameter': 'type param', " \ '': 'v' " \ } " Move " " move around nmap [g (ale_previous_wrap) nmap ]g (ale_next_wrap) " Colors highlight ALEError gui=undercurl guisp=red highlight ALEErrorSign guifg=red highlight ALEWarning gui=undercurl guisp=yellow highlight ALEWarningSign guifg=yellow "}}} {%@@ endif @@%} "python env{{{ let g:python_host_prog = '/usr/bin/python2' let g:python3_host_prog = '/usr/bin/python' " MUST NOT BE INDENTED! py3 << EOF import os import sys if 'VIRTUAL_ENV' in os.environ: project_base_dir = os.environ['VIRTUAL_ENV'] activate_this = os.path.join(project_base_dir, 'bin/activate_this.py') execfile(activate_this, dict(__file__=activate_this)) EOF "}}} " Latex{{{ let g:livepreview_previewer = 'zathura' autocmd FileType tex LLPStartPreview "}}} "groff{{{ augroup filetrype_groff autocmd VimEnter *.ms set ft=groff autocmd VimEnter *.ms silent !zathura (string replace --regex .ms\$ .pdf "%" ) & jobs -lp > /tmp/groff-preview autocmd VimLeave *.ms silent !kill (cat /tmp/groff-preview ) autocmd BufWritePost *.ms silent !compile % " autocmd FileType groff setlocal commentstring=\\\"\ %s augroup END "}}} "}}} "Hide statusbar{{{ let s:hidden_all = 0 function! ToggleHiddenAll() if s:hidden_all == 0 let s:hidden_all = 1 set noshowmode set noruler set laststatus=0 set noshowcmd else let s:hidden_all = 0 set showmode set ruler set laststatus=2 set showcmd endif endfunction " nnoremap :call ToggleHiddenAll() call ToggleHiddenAll() "}}} " vim:foldmethod=marker