" IMPOSTAZIONI ----------------------------------------------------------- {{{ packadd! dracula colorscheme dracula set completeopt=longest,menuone setlocal complete+=k set dictionary+=/home/davide/.vim/dict/dict_it.txt set wrap set linebreak set expandtab autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE set spell spelllang=it,en syntax on " Enable type file detection. Vim will be able to try to detect the type of file in use. filetype off " Enable plugins and load plugin for the detected file type. set nocompatible " be iMproved, required filetype plugin indent on " required set omnifunc=syntaxcomplete " Enable Omnicomplete features filetype plugin on " Load an indent file for the detected file type. filetype indent on set foldenable set autoindent " Automatically guesses the indentation given the previous one set hlsearch " Automatically highlights search results, to hide them run :noh set incsearch " Searches incrementally as you type. set ruler " Shows the rulers set showcmd " Shows current cursor info set ignorecase " Ignores cases when searching set noswapfile " Disables swap files set undofile " Enable keeping history across sessions, don't forget to mkdir set undodir=~/.vim/undo/ set nofixeol " Do not insert a new line at the end of the file automatically set backspace=indent,eol,start " Enable backspace key to delete stuffs properly set termguicolors set number " Add numbers to each line on the left-hand side. set relativenumber set clipboard=unnamedplus set cursorline " Highlight cursor line underneath the cursor horizontally. set nobackup " Do not save backup files. set incsearch " While searching though a file incrementally highlight matching characters as you type. set ignorecase " Ignore capital letters during search. set smartcase " This will allow you to search specifically for capital letters. set showmode " Show the mode you are on the last line. set showmatch " Show matching words during a search. set wildmenu " Enable auto completion menu after pressing TAB. set wildmode=list:longest " Make wildmenu behave like similar to Bash completion. set foldenable set foldmethod=indent set ttyfast " Speed up scrolling in Vim set encoding=UTF-8 "set nowritebackup set updatetime=300 set signcolumn=yes set smarttab "la tabulazione viene eseguita in automatico in modo intelligente set tabstop=8 "imposta il valore della tabulazione (solitamente viene cosigliato 4 o 8) " }}} " PLUGINS ---------------------------------------------------------------- {{{ " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' " " All of your Plugins must be added before the following line " "Plugin 'lifepillar/vim-mucomplete' Plugin 'neoclide/coc.nvim', {'branch': 'release'} Plugin 'itchyny/vim-cursorword' Plugin 'preservim/nerdtree' Plugin 'iamcco/markdown-preview.nvim' Plugin 'alvan/vim-closetag' Plugin 'mattn/emmet-vim' Plugin 'jiangmiao/auto-pairs' Plugin 'ryanoasis/vim-devicons' Plugin 'frazrepo/vim-rainbow' Plugin 'mg979/vim-visual-multi', {'branch': 'master'} Plugin 'itchyny/lightline.vim' Plugin 'voldikss/vim-floaterm' Plugin 'mracos/mermaid.vim' Plugin 'mzlogin/vim-markdown-toc' Plugin 'bbrtj/vim-vorg-md' Plugin 'sheerun/vim-polyglot' call vundle#end() " required " }}}zo " MAPPINGS --------------------------------------------------------------- {{{ " Mappings code goes here. " }}} " VIMSCRIPT -------------------------------------------------------------- {{{ " This will enable code folding. " zo per aprire una singola piega sotto il cursore. " zc per chiudere la piega sotto il cursore. " zR per aprire tutte le pieghe. " zM per chiudere tutte le pieghe. augroup filetype_vim autocmd! autocmd FileType vim setlocal foldmethod=marker augroup END " More Vimscripts code goes here. " }}} " PREDICTIVE ------------------------------------------------------------- {{{ " " https://www.reddit.com/r/vim/comments/12qezjf/english_dictionary_autocompletion/?rdt=55684 "let g:mucomplete#enable_auto_at_startup = v:true "let g:mucomplete#chains = #{default: ['dict']} "set dictionary=/home/davide/.vim/dict/dict_it.txt " " }}} " YOUCOMPLETEME ------------------------------------------------------------- {{{ " let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py' let g:ycm_confirm_extra_conf=0 let g:ycm_python_binary_path='/usr/bin/python3' " " }}} " NERD-TREE ------------------------------------------------------------- {{{ " " Start NERDTree and put the cursor back in the other window. autocmd VimEnter * NERDTree | wincmd p" " " Exit Vim if NERDTree is the only window remaining in the only tab. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" " " Close the tab if NERDTree is the only window remaining in it. autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif " " Open the existing NERDTree on each new tab. autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " }}} " MD-FOLDING ------------------------------------------------------------- {{{ " let g:markdown_folding = 1 " "zo open current fold "zO recursively open current fold "zc close current fold "zC recursively close current fold "za toggle current fold "zA recursively open/close current fold "zm reduce foldlevel by one "zM close all folds "zr increase foldlevel by one "zR open all folds " }}} " MARK-DOWN-PREVIEW ----------------------------------------------------- {{{ " https://github.com/iamcco/markdown-preview.nvim " " set to 1, nvim will open the preview window after entering the markdown buffer " default: 0 let g:mkdp_auto_start = 0 " set to 1, the nvim will auto close current preview window when change " from markdown buffer to another buffer " default: 1 let g:mkdp_auto_close = 1 " set to 1, the vim will refresh markdown when save the buffer or " leave from insert mode, default 0 is auto refresh markdown as you edit or " move the cursor " default: 0 let g:mkdp_refresh_slow = 0 " set to 1, the MarkdownPreview command can be use for all files, " by default it can be use in markdown file " default: 0 let g:mkdp_command_for_global = 0 " set to 1, preview server available to others in your network " by default, the server listens on localhost (127.0.0.1) " default: 0 let g:mkdp_open_to_the_world = 0 " use custom IP to open preview page " useful when you work in remote vim and preview on local browser " more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 " default empty let g:mkdp_open_ip = '' " specify browser to open preview page " for path with space " valid: `/path/with\ space/xxx` " invalid: `/path/with\\ space/xxx` " default: '' let g:mkdp_browser = '' " set to 1, echo preview page url in command line when open preview page " default is 0 let g:mkdp_echo_preview_url = 0 " a custom vim function name to open preview page " this function will receive url as param " default is empty let g:mkdp_browserfunc = '' " options for markdown render " mkit: markdown-it options for render " katex: katex options for math " uml: markdown-it-plantuml options " maid: mermaid options " disable_sync_scroll: if disable sync scroll, default 0 " sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' " middle: mean the cursor position alway show at the middle of the preview page " top: mean the vim top viewport alway show at the top of the preview page " relative: mean the cursor position alway show at the relative positon of the preview page " hide_yaml_meta: if hide yaml metadata, default is 1 " sequence_diagrams: js-sequence-diagrams options " content_editable: if enable content editable for preview page, default: v:false " disable_filename: if disable filename header for preview page, default: 0 let g:mkdp_preview_options = { \ 'mkit': {}, \ 'katex': {}, \ 'uml': {}, \ 'maid': {}, \ 'disable_sync_scroll': 0, \ 'sync_scroll_type': 'middle', \ 'hide_yaml_meta': 1, \ 'sequence_diagrams': {}, \ 'flowchart_diagrams': {}, \ 'content_editable': v:false, \ 'disable_filename': 0, \ 'toc': {} \ } " use a custom markdown style must be absolute path " like '/Users/username/markdown.css' or expand('~/markdown.css') let g:mkdp_markdown_css = '' " use a custom highlight style must absolute path " like '/Users/username/highlight.css' or expand('~/highlight.css') let g:mkdp_highlight_css = '' " use a custom port to start server or empty for random let g:mkdp_port = '' " preview page title " ${name} will be replace with the file name let g:mkdp_page_title = '「${name}」' " recognized filetypes " these filetypes will have MarkdownPreview... commands let g:mkdp_filetypes = ['markdown'] " set default theme (dark or light) " By default the theme is define according to the preferences of the system let g:mkdp_theme = 'dark' " }}} " VIM-TAG --------------------------------------------------------------- {{{ " " filenames like *.xml, *.html, *.xhtml, ... " These are the file extensions where this plugin is enabled. " let g:closetag_filenames = '*.html,*.xhtml,*.phtml' " filenames like *.xml, *.xhtml, ... " This will make the list of non-closing tags self-closing in the specified files. " let g:closetag_xhtml_filenames = '*.xhtml,*.jsx' " filetypes like xml, html, xhtml, ... " These are the file types where this plugin is enabled. " let g:closetag_filetypes = 'html,xhtml,phtml' " filetypes like xml, xhtml, ... " This will make the list of non-closing tags self-closing in the specified files. " let g:closetag_xhtml_filetypes = 'xhtml,jsx' " integer value [0|1] " This will make the list of non-closing tags case-sensitive (e.g. `` will be closed while `` won't.) " let g:closetag_emptyTags_caseSensitive = 1 " dict " Disables auto-close if not in a "valid" region (based on filetype) " let g:closetag_regions = { \ 'typescript.tsx': 'jsxRegion,tsxRegion', \ 'javascript.jsx': 'jsxRegion', \ 'typescriptreact': 'jsxRegion,tsxRegion', \ 'javascriptreact': 'jsxRegion', \ } " Shortcut for closing tags, default is '>' " let g:closetag_shortcut = '>' " Add > at current position without closing the current tag, default is '' " let g:closetag_close_shortcut = '>' " }}} " EMMET-PLUGIN --------------------------------------------------------- {{{ let g:user_emmet_settings = { \ 'variables': {'lang': 'ja'}, \ 'html': { \ 'default_attributes': { \ 'option': {'value': v:null}, \ 'textarea': {'id': v:null, 'name': v:null, 'cols': 10, 'rows': 10}, \ }, \ 'snippets': { \ 'html:5': "\n" \ ."\n" \ ."\n" \ ."\t\n" \ ."\t\n" \ ."\t\n" \ ."\t\n" \ ."\n" \ ."\n\t${child}|\n\n" \ ."", \ }, \ }, \} " }}} " RAINBOW PARENTHESES -------------------------------------------------- {{{ " https://github.com/frazrepo/vim-rainbow let g:rainbow_ctermfgs = ['lightblue', 'lightgreen', 'yellow', 'red', 'magenta'] "}}} " MULTI-CURSOR --------------------------------------------------------- {{{ " https://github.com/mg979/vim-visual-multi "To make a basic selection, use the Ctrl+N keystroke in normal mode, followed by a motion: "c – change text. "I – insert at start of range. "A – insert at end of range. let g:multi_cursor_use_default_mapping=0 " Default mapping let g:multi_cursor_start_word_key = '' let g:multi_cursor_select_all_word_key = '' let g:multi_cursor_start_key = 'g' let g:multi_cursor_select_all_key = 'g' let g:multi_cursor_next_key = '' let g:multi_cursor_prev_key = '' let g:multi_cursor_skip_key = '' let g:multi_cursor_quit_key = '' "}}} " VIM-LIGHTLINE --------------------------------------------------------- {{{ " https://github.com/itchyny/lightline.vim let g:lightline = { \ 'colorscheme': 'wombat', \ } " }}} " COC-NEOCLIDE ---------------------------------------------------------- {{{ " https://github.com/neoclide/coc.nvim " https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions " Use tab for trigger completion with characters ahead and navigate " NOTE: There's always complete item selected by default, you may want to enable " no select by `"suggest.noselect": true` in your configuration file " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config inoremap \ coc#pum#visible() ? coc#pum#next(1) : \ CheckBackspace() ? "\" : \ coc#refresh() inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" " Make to accept selected completion item or notify coc.nvim to format " u breaks current undo, please make your own choice inoremap coc#pum#visible() ? coc#pum#confirm() \: "\u\\=coc#on_enter()\" function! CheckBackspace() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion if has('nvim') inoremap coc#refresh() else inoremap coc#refresh() 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 K to show documentation in preview window nnoremap K :call ShowDocumentation() function! ShowDocumentation() if CocAction('hasProvider', 'hover') call CocActionAsync('doHover') else call feedkeys('K', 'in') endif endfunction " Highlight the symbol and its references when holding the cursor autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming nmap rn (coc-rename) " Formatting selected code xmap f (coc-format-selected) nmap f (coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s) autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Applying code actions to the selected code block " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying code actions at the cursor position nmap ac (coc-codeaction-cursor) " Remap keys for apply code actions affect whole buffer nmap as (coc-codeaction-source) " Apply the most preferred quickfix action to fix diagnostic on the current line nmap qf (coc-fix-current) " Remap keys for applying refactor code actions nmap re (coc-codeaction-refactor) xmap r (coc-codeaction-refactor-selected) nmap r (coc-codeaction-refactor-selected) " Run the Code Lens action on the current line nmap cl (coc-codelens-action) " 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) " Remap and to scroll float windows/popups if has('nvim-0.4.0') || has('patch-8.2.0750') nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" endif " Use CTRL-S for selections ranges " Requires 'textDocument/selectionRange' support of language server nmap (coc-range-select) xmap (coc-range-select) " Add `:Format` command to format current buffer command! -nargs=0 Format :call CocActionAsync('format') " Add `:Fold` command to fold current buffer command! -nargs=? Fold :call CocAction('fold', ) " Add `:OR` command for organize imports of the current buffer command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') " Add (Neo)Vim's native statusline support " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Mappings for CoCList " Show all diagnostics nnoremap a :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols nnoremap s :CocList -I symbols " Do default action for next item nnoremap j :CocNext " Do default action for previous item nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume " }}}