Skip to content

Instantly share code, notes, and snippets.

@feresr
Last active June 8, 2022 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feresr/f6784a5075bdfe919bce3e0eef5bcbd7 to your computer and use it in GitHub Desktop.
Save feresr/f6784a5075bdfe919bce3e0eef5bcbd7 to your computer and use it in GitHub Desktop.
My vim config
"TODO: install Ag: brew install the_silver_searcher
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"Do not try to read the filetype from the file name
filetype off
" All horizontal splits open below current one
set splitbelow
filetype plugin indent on
" #### Plugin managment ####
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
" Download plug-ins to the ~/.vim/pluged/ directory
call vundle#begin('~/.vim/plugged')
" Let Vundle manage Vundle
Plugin 'VundleVim/Vundle.vim'
Plugin 'sheerun/vim-polyglot'
Plugin 'preservim/nerdtree'
Plugin 'neoclide/coc.nvim'
Plugin 'vim-airline/vim-airline'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'joshdick/onedark.vim'
Plugin 'vim-airline/vim-airline-themes'
Bundle 'wellle/targets.vim'
Plugin 'tpope/vim-surround'
Plugin 'jiangmiao/auto-pairs'
Plugin 'ryanoasis/vim-devicons'
Plugin 'puremourning/vimspector'
Plugin 'sainnhe/edge'
Plugin 'preservim/tagbar'
Plugin 'derekwyatt/vim-fswitch'
Plugin 'wellle/context.vim'
Plugin 'ilyachur/cmake4vim'
call vundle#end()
set mouse=a
set cursorline
syntax on " highlight syntax
let g:edge_style = 'aura'
let g:edge_enable_italic = 0
let g:edge_disable_italic_comment = 1
if has('termguicolors')
" Turns on 24-bit RGB color support
set termguicolors
endif
" Important!!
if has('termguicolors')
set termguicolors
endif
" The configuration options should be placed before `colorscheme edge`.
let g:edge_style = 'aura'
let g:edge_better_performance = 1
let g:airline_theme = 'edge'
colorscheme edge
set makeprg=cmakedbg
set number
set path+=**
set tabstop=4
set softtabstop=4
set expandtab
set foldmethod=manual
set foldlevelstart=1
"set guifont=JetBrainsMono\ Nerd\ Font:h17
let g:airline_powerline_fonts = 1
" esc esc clear search highlights
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
" no bell sound
set belloff=all
" When started as "evim", evim.vim will already have done these settings, bail
" out.
if v:progname =~? "evim"
finish
endif
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
augroup END
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
syntax enable
set autoindent
set title
set nocompatible
set ruler
set hidden " do not ask to save buffers?c
set relativenumber
set number " show line numbers
set showcmd
set cursorline
set wildmenu
set lazyredraw
set showmatch
set incsearch
set hlsearch
set foldenable
set noswapfile " disable the swapfile
set hlsearch " highlight all results
set ignorecase " ignore case in search
set incsearch " show search results as you typ
if v:progname =~? "evim"
finish
endif
" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif
if &t_Co > 2 || has("gui_running")
" Switch on highlighting the last used search pattern.
set hlsearch
endif
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
augroup END
" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
packadd! matchit
endif
set encoding=utf-8
" TextEdit might fail if hidden is not set.
set hidden
set nowrap
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" 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
noremap <leader>o :Files .<cr>
noremap <leader>e :History %<cr>
noremap <leader>f :Ag<cr>
noremap <F5> :wa<cr>:!cd build/ && cmake --build . --target game --config Debug<cr><cr><F6>
noremap <F6> :!cd bin/&& ./game<cr>
noremap <F4> :CMakeGenerate Debug<cr>
noremap <F3> :!make -C build<cr>
nmap <F8> :TagbarToggle<CR>
nmap <leader>s :FSHere<CR>
" NERDTree
let NERDTreeMinimalMenu = 1 " Use the minimal menu (m)
let NERDTreeWinPos = "left" " Panel opens on the left side
"autocmd BufWritePost * NERDTreeFocus | execute 'normal R' | wincmd p "auto update nerdtree"
nmap <leader><F2> :NERDTreeToggle<CR>
set tags=./tags,tags;$HOME
" #### From CoC.nvim readme.md ####
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" 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)
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
" use <tab> for trigger completion and navigate to the next complete item
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()"
" 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 K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader><leader>f <Plug>(coc-format-selected)
nmap <leader><leader>f <Plug>(coc-format-selected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment