Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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=<Tab> 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 <LeftRelease> "+y<LeftRelease>
- vnoremap <C-c> "+y<CR>
- vnoremap <C-x> "+d<CR>
- " disable hl with 2 esc
- noremap <silent><esc> <esc>:noh<CR><esc>
- " Plugins
- nmap <F5> :TagbarToggle<CR>
- " Buffer navigation
- nnoremap <silent> <tab> :BufferLineCycleNext<cr>
- nnoremap <silent> <S-tab> :BufferLineCyclePrev<cr>
- nnoremap <silent> kb <cmd>bdelete<cr>
- " new line in normal mode and back
- map <Enter> o<ESC>
- map <S-Enter> O<ESC>
- " Hop mappings
- nnoremap f <cmd>HopChar1<cr>
- nnoremap s <cmd>HopChar2<cr>
- nnoremap w <cmd>HopWord<cr>
- vnoremap f <cmd>HopChar1<cr>
- vnoremap s <cmd>HopChar2<cr>
- vnoremap w <cmd>HopWord<cr>
- " Telescope mappings
- nnoremap <leader>ff <cmd>Telescope find_files<cr>
- nnoremap <leader>fg <cmd>Telescope live_grep<cr>
- nnoremap <leader>fh <cmd>Telescope help_tags<cr>
- nnoremap <f4> <cmd>Telescope file_browser<cr>
- " Edit shortcuts
- nnoremap <silent> <leader>ev :execute 'edit' resolve($MYVIMRC)<cr>
- nnoremap <silent> <leader>xv :source $MYVIMRC<cr>
- """ 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 = "<Esc>",
- }
- 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 <c-space> to trigger completion.
- if has('nvim')
- inoremap <silent><expr> <c-space> coc#refresh()
- else
- inoremap <silent><expr> <c-@> coc#refresh()
- endif
- " Make <CR> auto-select the first completion item and notify coc.nvim to
- " format on enter, <cr> could be remapped by other vim plugin
- inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
- \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
- " Use tab for trigger completion with characters ahead and navigate.
- inoremap <silent><expr> <TAB>
- \ pumvisible() ? coc#_select_confirm() :
- \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
- \ <SID>check_back_space() ? "\<TAB>" :
- \ coc#refresh()
- function! s:check_back_space() abort
- let col = col('.') - 1
- return !col || getline('.')[col - 1] =~# '\s'
- endfunction
- let g:coc_snippet_next = '<tab>'
- let g:coc_snippet_prev = '<S-Tab>'
- " Use `[g` and `]g` to navigate diagnostics
- " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
- nmap <silent> [g <Plug>(coc-diagnostic-prev)
- nmap <silent> ]g <Plug>(coc-diagnostic-next)
- " GoTo code navigation.
- nmap <silent> gd <Plug>(coc-definition)
- nmap <silent> gy <Plug>(coc-type-definition)
- nmap <silent> gi <Plug>(coc-implementation)
- nmap <silent> gr <Plug>(coc-references)
- " Run the Code Lens action on the current line.
- nmap <leader>cl <Plug>(coc-codelens-action)
- " Use K to show documentation in preview window.
- nnoremap <silent> K :call <SID>show_documentation()<CR>
- function! s:show_documentation()
- if (index(['vim','help'], &filetype) >= 0)
- execute 'h '.expand('<cword>')
- elseif (coc#rpc#ready())
- call CocActionAsync('doHover')
- else
- execute '!' . &keywordprg . " " . expand('<cword>')
- endif
- endfunction
- " Highlight the symbol and its references when holding the cursor.
- autocmd CursorHold * silent call CocActionAsync('highlight')
- " Symbol renaming.
- nmap <leader>rn <Plug>(coc-rename)
- " Formatting selected code.
- xmap <F1> :Format<cr>
- nmap <F1> :Format<cr>
- " Applying codeAction to the selected region.
- " Example: `<leader>aap` for current paragraph
- xmap <leader>a <Plug>(coc-codeaction-selected)
- nmap <leader>a <Plug>(coc-codeaction-selected)
- " Remap keys for applying codeAction to the current buffer.
- nmap <leader>ac <Plug>(coc-codeaction)
- " Apply AutoFix to problem on the current line.
- nmap <leader>qf <Plug>(coc-fix-current)
- " Map function and class text objects
- " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
- xmap if <Plug>(coc-funcobj-i)
- omap if <Plug>(coc-funcobj-i)
- xmap af <Plug>(coc-funcobj-a)
- omap af <Plug>(coc-funcobj-a)
- xmap ic <Plug>(coc-classobj-i)
- omap ic <Plug>(coc-classobj-i)
- xmap ac <Plug>(coc-classobj-a)
- omap ac <Plug>(coc-classobj-a)
- " Remap <C-f> and <C-b> for scroll float windows/popups.
- if has('nvim-0.4.0') || has('patch-8.2.0750')
- nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
- nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
- inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
- inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
- vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
- vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
- endif
- " Use CTRL-S for selections ranges.
- " Requires 'textDocument/selectionRange' support of language server.
- nmap <silent> <C-s> <Plug>(coc-range-select)
- xmap <silent> <C-s> <Plug>(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', <f-args>)
- " 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'
- \]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement