set hidden set shortmess+=O " Install vim-plug let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " Configure plugins call plug#begin(stdpath('data') . '/plugged') " Nice defaults Plug 'tpope/vim-sensible' " Lua functions Plug 'nvim-lua/plenary.nvim' " UI Plug 'kyazdani42/nvim-web-devicons' " for file icons Plug 'akinsho/bufferline.nvim', { 'tag': 'v2.*' } Plug 'majutsushi/tagbar', { 'on': 'TagbarToggle' } Plug 'nvim-telescope/telescope.nvim' Plug 'nvim-telescope/telescope-file-browser.nvim' Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } Plug 'lukas-reineke/indent-blankline.nvim' Plug 'psliwka/vim-smoothie' Plug 'kaicataldo/material.vim', { 'branch': 'main' } Plug 'projekt0n/github-nvim-theme' Plug 'nvim-lualine/lualine.nvim' " Autocomplete Plug 'neoclide/coc.nvim', { 'branch': 'release' } Plug 'raimondi/delimitmate' " Git Plug 'tpope/vim-fugitive' " Lang Plug 'rust-lang/rust.vim', { 'for': 'rust' } Plug 'cespare/vim-toml', { 'for': 'toml' } Plug 'lervag/vimtex', { 'for': 'LaTeX' } Plug 'gregsexton/MatchTag', { 'for': 'html' } Plug 'sheerun/vim-polyglot' " Utility Plug 'tpope/vim-surround' Plug 'editorconfig/editorconfig-vim' Plug 'max397574/better-escape.nvim' Plug 'numToStr/Comment.nvim' Plug 'phaazon/hop.nvim' " Snipits Plug 'honza/vim-snippets' call plug#end() " Vim settings set encoding=utf-8 set nowrap set showmatch set hlsearch set number set mouse=a set wildchar= wildmenu wildmode=full syntax enable filetype plugin indent on set tabstop=4 set shiftwidth=4 set expandtab set conceallevel=2 set emoji set history=1000 set backspace=indent,eol,start set undofile set undodir=/tmp set foldlevel=0 set inccommand=nosplit " Performance set nocursorline set nocursorcolumn set scrolljump=5 set lazyredraw set redrawtime=10000 set synmaxcol=180 set re=0 " Coc set cmdheight=1 set updatetime=300 set signcolumn=yes set shortmess+=c set nobackup set nowritebackup """ Mappings " Remap leader let mapleader = "," " emulate windows copy, cut behavior vnoremap "+y vnoremap "+y vnoremap "+d " disable hl with 2 esc noremap :noh " Plugins nmap :TagbarToggle " Buffer navigation nnoremap :BufferLineCycleNext nnoremap :BufferLineCyclePrev nnoremap kb bdelete " new line in normal mode and back map o map O " Hop mappings nnoremap f HopChar1 nnoremap s HopChar2 nnoremap w HopWord vnoremap f HopChar1 vnoremap s HopChar2 vnoremap w HopWord " Telescope mappings nnoremap ff Telescope find_files nnoremap fg Telescope live_grep nnoremap fh Telescope help_tags nnoremap Telescope file_browser " Edit shortcuts nnoremap ev :execute 'edit' resolve($MYVIMRC) nnoremap xv :source $MYVIMRC """ End mappings " Tagbar configuration let g:tagbar_autofocus = 1 " GUI let g:material_theme_style = 'darker' let $NVIM_TUI_ENABLE_TRUE_COLOR = 1 set termguicolors silent! colorscheme github_dimmed set synmaxcol=500 " Lua settings lua << EOF require("bufferline").setup { options = { diagnostics = "coc", show_close_icon = false, show_buffer_close_icons = false, numbers = "buffer_id" } } require("indent_blankline").setup {} require("Comment").setup() require("hop").setup() require("better_escape").setup { mapping = {",,"}, timeout = 150, clear_empty_lines = false, keys = "", } require("telescope").setup { defaults = { file_ignore_patterns = {"node_modules"} }, extensions = { fzf = { fuzzy = true, override_generic_sorter = true, override_file_sorter = true, case_mode = "smart_case", } } } require("telescope").load_extension("file_browser") require("telescope").load_extension("fzf") require("lualine").setup { options = { icons_enabled = true, theme = "github_dimmed", component_separators = { left = '', right = ''}, section_separators = { left = '', right = ''}, disabled_filetypes = {}, always_divide_middle = true, globalstatus = false, }, sections = { lualine_a = {'mode'}, lualine_b = {'branch', 'diff', 'diagnostics'}, lualine_c = {}, lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_y = {'progress'}, lualine_z = {'location'} }, inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_c = {'filename'}, lualine_x = {'location'}, lualine_y = {}, lualine_z = {} }, tabline = {}, extensions = {} } EOF " LaTeX settings let g:tex_flavor = 'latex' let g:vimtex_quickfix_mode = 0 set conceallevel=1 let g:tex_conceal = 'abdmg' " Return to last edit position when opening files autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif " 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 tab for trigger completion with characters ahead and navigate. inoremap \ pumvisible() ? coc#_select_confirm() : \ coc#expandableOrJumpable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : \ check_back_space() ? "\" : \ coc#refresh() function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction let g:coc_snippet_next = '' let g:coc_snippet_prev = '' " 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) " Run the Code Lens action on the current line. nmap cl (coc-codelens-action) " 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 :Format nmap :Format " 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) " 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 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 " 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 CocAction('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 CocAction('runCommand', 'editor.action.organizeImport') " Coc languages let g:coc_global_extensions = [ \ 'coc-vimtex', \ 'coc-omni', \ 'coc-clangd', \ 'coc-snippets', \ 'coc-pyright', \ 'coc-json', \ 'coc-css', \ 'coc-yaml', \ 'coc-rust-analyzer', \ 'coc-vimlsp', \ 'coc-tsserver', \ 'coc-syntax', \ 'coc-prettier', \ 'coc-git', \ 'coc-sh', \ 'coc-highlight', \ 'coc-html', \ 'coc-eslint', \ 'coc-lists' \]