call plug#begin('~/.vim/plugged') Plug 'joshdick/onedark.vim' " Colors Plug 'itchyny/lightline.vim' " Lightline statusbar Plug 'scrooloose/nerdtree' " Nerdtree Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Highlighting Nerdtree Plug 'ryanoasis/vim-devicons' " Icons for Nerdtree Plug 'ap/vim-css-color' " Color previews for CSS Plug 'junegunn/limelight.vim' Plug 'junegunn/fzf.vim' Plug 'xolox/vim-misc' Plug 'xolox/vim-session' Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'mfussenegger/nvim-dap' Plug 'rcarriga/nvim-dap-ui' Plug 'jackguo380/vim-lsp-cxx-highlight' Plug 'vim-syntastic/syntastic' Plug 'rhysd/vim-clang-format' Plug 'lambdalisue/suda.vim' call plug#end() " for transparent background function! AdaptColorscheme() highlight clear CursorLine highlight Normal ctermbg=none highlight LineNr ctermbg=none highlight Folded ctermbg=none highlight NonText ctermbg=none highlight SpecialKey ctermbg=none highlight VertSplit ctermbg=none highlight SignColumn ctermbg=none endfunction autocmd ColorScheme * call AdaptColorscheme() set cursorline " colorscheme syntax on " brackets inoremap " "" inoremap ' '' inoremap ( () inoremap [ [] inoremap { {} inoremap { {}O inoremap {; {};O filetype plugin on let g:instant_markdown_browser = "firefox --new-window" let g:session_autosave = "no" let g:session_autoload = "no" " Make Vim more useful set nocompatible " Long lines as one line set nowrap " Ruler set ruler " Horizontal splits will automatically be below set splitbelow " Vertical splits will automatically be to the right set splitright " Indent set smartindent set autoindent " Use the OS clipboard by default (on versions compiled with `+clipboard`) set clipboard+=unnamedplus " Enhance command-line completion set wildmenu " Disables automatic commenting on newline: autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Allow cursor keys in insert mode " Allow backspace in insert mode set backspace=indent,eol,start " Optimize for fast terminal connections set ttyfast " Add the g flag to search/replace by default set gdefault " Use UTF-8 without BOM set encoding=utf-8 " Change mapleader let mapleader="," " Don’t add empty newlines at the end of files set binary set noeol set smartcase set noswapfile set nobackup set undodir=~/.vim/undodir set undofile " 256 colors set t_Co=256 " Respect modeline in files set modeline set modelines=4 " Enable per-directory .vimrc files and disable unsafe commands in them set exrc set secure " Enable line numbers set number " Make tabs as wide as two spaces set tabstop=4 set shiftwidth=4 set smarttab set expandtab " Highlight searches set hlsearch " Ignore case of searches set ignorecase " Highlight dynamically as pattern is typed set incsearch " Always show status line set laststatus=2 " Enable mouse in all modes set mouse=a " Disable error bells set noerrorbells " Don’t reset cursor to start of line when moving around. set nostartofline " Show the cursor position set ruler " Don’t show the intro message when starting Vim set shortmess=atI " Show the current mode set showmode " Show the filename in the window titlebar set title " Show the (partial) command as it’s being typed set showcmd " Use relative line numbers set hidden set nobackup set nowritebackup set updatetime=300 set shortmess+=c " Give more space for displaying messages. set cmdheight=2 set pumheight=5 " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("nvim-0.5.0") || has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() 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 " Make auto-select the first completion item and notify coc.nvim to " format on enter, could be remapped by other vim plugin inoremap pumvisible() ? coc#_select_confirm() \: "\u\\=coc#on_enter()\" " 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 show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') elseif (coc#rpc#ready()) call CocActionAsync('doHover') else execute '!' . &keywordprg . " " . expand('') 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 codeAction to the selected region. " Example: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap ac (coc-codeaction) " Apply AutoFix to problem on the current line. nmap qf (coc-fix-current) " Run the Code Lens action on the current line. nmap cl (coc-codelens-action) " Remap and for 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 " 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') let g:lightline = { \ 'colorscheme': 'onedark', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'cocstatus': 'coc#status' \ }, \ } " Use autocmd to force lightline update. autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() " 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 " c++ syntax highlighting let g:cpp_class_scope_highlight = 1 let g:cpp_member_variable_highlight = 1 let g:cpp_class_decl_highlight = 1 " c++ linting let g:syntastic_cpp_checkers = ['cpplint'] let g:syntastic_c_checkers = ['cpplint'] let g:syntastic_cpp_cpplint_exec = 'cpplint' " The following two lines are optional. Configure it to your liking! let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 nnoremap f :ClangFormat " header guards function! s:insert_gates() let gatename = substitute(toupper(expand("%:t")), "\\.", "_", "g") execute "normal! i#ifndef " . gatename execute "normal! o#define " . gatename . " " execute "normal! Go#endif /* " . gatename . " */" normal! ko endfunction autocmd BufNewFile *.{h,hpp} call insert_gates() if exists("&relativenumber") set relativenumber au BufReadPost * set relativenumber endif " Start scrolling three lines before the horizontal window border set scrolloff=3 " Toggle spellchecking function! ToggleSpellCheck() set spell! if &spell echo "Spellcheck ON" else echo "Spellcheck OFF" endif endfunction " Better tabbing vnoremap < >gv " Better window navigation nnoremap h nnoremap j nnoremap k nnoremap l map c :w! \| !make map r v l :terminal ./run.sh % a map t :!st& map o :FZF map s :call ToggleSpellCheck() map n :NERDTreeToggle map Q gq " Insert mode completion imap (fzf-complete-word) imap (fzf-complete-path) imap (fzf-complete-line) vnoremap "+y " Write as root cnoremap w!! SudaWrite colorscheme onedark " Debugging map db :lua require'dap'.toggle_breakpoint() map dc :lua require'dap'.continue() map do :lua require'dap'.step_over() map di :lua require'dap'.step_into() map dn :lua require("dapui").toggle() lua require("dap-conf") lua require("dapui").setup()