diff --git a/linux/vim/asset/vim/vim.png b/linux/vim/asset/vim/vim.png new file mode 100644 index 0000000..02509fc Binary files /dev/null and b/linux/vim/asset/vim/vim.png differ diff --git a/linux/vim/vim.md b/linux/vim/vim.md new file mode 100644 index 0000000..7dfc1bd --- /dev/null +++ b/linux/vim/vim.md @@ -0,0 +1,161 @@ +# Vim + +Vim è un editor di testo molto potente, che può essere ampliato ulteriormente tramite **plugin** vari. + +## Plugin Manager + +Per poter installare dei plugin è necessario installare prima un plugin-manager. + +### Vundle + +```bash +git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim +``` + +Dopo aver clonato Vundle sulla propria macchina, inserire le seguenti righe di testo nel file `.vimrc` + +```vimrc +" 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 +" + +call vundle#end() " required + +" }}} +``` + +## Installazione plugin + +Installare un plugin è molto semplice, basta aggiungerlo nel file `.vimrc`, come da codice sottostante: + +```vim +" 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 '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' +Bundle 'https://github.com/prashanthellina/follow-markdown-links' +Plugin 'mracos/mermaid.vim' +Plugin 'mzlogin/vim-markdown-toc' +Plugin 'bbrtj/vim-vorg-md' +Plugin 'sheerun/vim-polyglot' + +call vundle#end() " required +``` + +Una volta salvato il file, digitare `:PluginInstall`. + +Quando l'installazione è completata, è buona norma cancellare la cache del buffer digitando il comando `:bdelete`. + +È possibile ricercare plugin nel Web oppure tramite il comando `:PluginSearch`. Per aggiornare l'elenco locale dei plugin dal sito vimscripts digitare: +`:PluginSearch!` + +### Alcuni plugin utili + +- [https://github.com/preservim/nerdtree](https://github.com/preservim/nerdtree) +- [https://github.com/VundleVim/Vundle.vim](https://github.com/VundleVim/Vundle.vim) +- [https://github.com/sheerun/vim-polyglot](https://github.com/sheerun/vim-polyglot) +- [https://github.com/alvan/vim-closetag](https://github.com/alvan/vim-closetag) +- [https://github.com/mattn/emmet-vim](https://github.com/mattn/emmet-vim) +- [https://github.com/ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons) +- [https://github.com/nopecha-ai/nopecha-extension](https://github.com/nopecha-ai/nopecha-extension) +- [https://github.com/thameera/vimv](https://github.com/thameera/vimv) +- [https://github.com/voldikss/vim-floaterm#requirements](https://github.com/voldikss/vim-floaterm#requirements) +- [https://github.com/akrawchyk/awesome-vim](https://github.com/akrawchyk/awesome-vim) +- [https://github.com/neoclide/coc.nvim](https://github.com/neoclide/coc.nvim) +- [https://github.com/fannheyward/coc-marketplace](https://github.com/fannheyward/coc-marketplace) +- [https://github.com/OmniSharp/omnisharp-vim](https://github.com/OmniSharp/omnisharp-vim) +- [https://github.com/ncm2/ncm2](https://github.com/ncm2/ncm2) +- [https://github.com/prashanthellina/follow-markdown-links](https://github.com/prashanthellina/follow-markdown-links) +- [https://github.com/itchyny/calendar.vim](https://github.com/itchyny/calendar.vim) +- [https://github.com/mracos/mermaid.vim](https://github.com/mracos/mermaid.vim) +- [https://github.com/bbrtj/vim-vorg-md](https://github.com/bbrtj/vim-vorg-md) +- [https://github.com/rderik/vim-markdown-toc](https://github.com/rderik/vim-markdown-toc) +- [https://github.com/tpope/vim-commentary](https://github.com/tpope/vim-commentary) +- [https://clay-atlas.com/us/blog/2021/07/04/vim-en-you-complete-me-plugin-auto-code/](https://clay-atlas.com/us/blog/2021/07/04/vim-en-you-complete-me-plugin-auto-code/) +- [https://github.com/ycm-core/YouCompleteMe](https://github.com/ycm-core/YouCompleteMe) +- [https://github.com/primitivorm/vim-predictive](https://github.com/primitivorm/vim-predictive) +- [https://github.com/itchyny/vim-cursorword](https://github.com/itchyny/vim-cursorword) + +Nel caso di `neoclide`, un plugin che abilita l'autocompletamento, da installare i seguenti moduli: + +```vim +CocInstall coc-cmake coc-css coc-cssmodules coc-docker coc-emmet coc-flutter coc-highlight coc-html coc-htmlhint coc-html-css-support coc-json coc-ltex coc-markdown-preview-enhanced coc-markdownlint coc-omnisharp coc-prettier coc-pytho +n coc-sh coc-sql coc-vimlsp coc-xml coc-yaml coc-markdown-preview-enhanced coc-webview +``` + +Quindi eseguire: + +```bash +cd ~/.vim/bundle/coc.nvim && git checkout release && yarn install && yarn build +``` + +![vim](./asset/vim/vim.png) + + +## Comandi utili + +| Comando | Funzione | +|---------------|------------------------------------------------------------------------------------------------------------------------------------------------| +| `gx` | Apre il link sotto al cursore nel browser | +| `:m +/-n` | Sposta la riga sopra o sotto di *n* posizioni | +| `"+y` | In Visual Mode, copia il testo selezionato nella clipboard del SO | +| `vimv` | Da terminale, permette di rinominare cartelle e file coi comandi di Vim ([https://github.com/thameera/vimv](https://github.com/thameera/vimv)) | +| `:args` | Seleziona dei file come argomenti. È possibile utilizzare i caratteri jolly | +| `:argdo` | Permette di eseguire un comando su n files | +| `gg=G` | Identazione automatica del codice | +| `dG` | Cancella l'intero documento | +| `^w` | In *insert mode*, cancella la parola precedente, dalla posizione del cursore | +| `^h` | In *insert mode*, cancella la parola precedente, dalla posizione del cursore | +| `^u` | In *insert mode*, cancella dalla posizione del cursore a inizio riga | +| `^o` | In *insert mode*, permette di digitare un comando | +| `das` | Cancella un'intera frase (sentence) | +| `dap` | Cancella un intero paragrafo | +| `gUU` | Tutta la riga in maiuscolo | +| `guu` | Tutta la riga in minuscolo | +| `(` | Sposta il cursore all'inizio della frase | +| `)` | Sposta il cursore alla fine della frase | +| `{` | Sposta il cursore all'inizio del paragrafo | +| `}` | Sposta il cursore alla fine del paragrafo | +| `H`, `M`, `L` | Rispettivamente, sposta il cursore alla prima riga, a metà o all'ultima riga del viewport | +| `^i`, `^o` | In *normal mode*, sposta il cursore alla posizione precedente/successiva | + +Ad esempio: + +```vim +:argdo %s/stringToBeReplaced/replacementString/g | update +``` +`update` serve per salvare le modifiche automaticamente. + +## Collegamenti + +- [https://irian.to/blogs/how-to-search-and-replace-string-across-multiple-files-in-vim/](https://irian.to/blogs/how-to-search-and-replace-string-across-multiple-files-in-vim/) +- [https://linuxhint.com/vim-copy-text-system-clipboard/](https://linuxhint.com/vim-copy-text-system-clipboard/) +- [https://vim.fandom.com/wiki/Accessing_the_system_clipboard](https://vim.fandom.com/wiki/Accessing_the_system_clipboard) +- [https://youtu.be/13gNtgqzzmM](https://youtu.be/13gNtgqzzmM) diff --git a/linux/vim/vimrc b/linux/vim/vimrc new file mode 100755 index 0000000..921408a --- /dev/null +++ b/linux/vim/vimrc @@ -0,0 +1,532 @@ +" IMPOSTAZIONI ----------------------------------------------------------- {{{ + +packadd! dracula +colorscheme dracula +" transparent bg +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 nowrap " Do not wrap lines. Allow long lines to extend as far as the line goes. +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 hlsearch " Use highlighting when doing 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 nobackup " Neoclide +set nowritebackup +set updatetime=300 +set signcolumn=yes +" }}} + + +" 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 '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' +Bundle 'https://github.com/prashanthellina/follow-markdown-links' +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 ------------------------------------------------------------- {{{ +" +let g:predictive#dict_path = expand($HOME . '/dict') +let g:predictive#disable_plugin = 0 +" +" }}} + + +" 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 + +" }}} +