" ==================== Plugins ==================== call plug#begin() " Git integration Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' " Nord Theme Plug 'nordtheme/vim' " Airline Plug 'bling/vim-airline' let g:airline_powerline_fonts = 1 " Commenter " Plug 'scrooloose/nerdcommenter' " Sayonara Plug 'mhinz/vim-sayonara', { 'on': 'Sayonara' } " Go support for Vim "Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } if has('nvim') Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } else Plug 'Shougo/deoplete.nvim' Plug 'roxma/nvim-yarp' Plug 'roxma/vim-hug-neovim-rpc' endif let g:deoplete#enable_at_startup = 1 " Python source for deoplete Plug 'zchee/deoplete-jedi', { 'for': 'python' } " Vim source for deoplete Plug 'Shougo/neco-vim', { 'for': 'vim' } " Python-related plugins " Python completion, goto definition etc. " Plug 'davidhalter/jedi-vim', { 'for': 'python' } " Python syntax highlighting and more " Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' } " Python auto formatting " Plug 'psf/black', { 'branch': 'stable' } " autocmd BufWritePre *.py execute ':Black' " Smart Line Numbers Plug 'myusuf3/numbers.vim' Plug 'tpope/vim-commentary' " Ale Plug 'dense-analysis/ale' " OpenSCAD Support Plug 'salkin-mada/openscad.nvim' call plug#end() " ==================== Vim Settings ==================== set number " show line numbers set backspace=indent,eol,start " backspace all the things set showcmd " show the command while typing it set noswapfile " no swap files needed set nobackup " backup files are clutter set nowritebackup set splitright " configure default splits set splitbelow set encoding=utf-8 " default to utf-8 encoding set autowrite " save before :next etc. set autoread " automatically pull in changes set hidden " allow buffers to be hidden with changes au FocusLost * :wa " save when focus is lost set incsearch " show matches while typing search string set hlsearch " highlight all search matches set ignorecase " search case insensitively set smartcase " use case when the search string has uppercase set ttyfast " assume we can handle faster refreshing set lazyredraw " do not redraw when running functions set scrolloff=5 " start scrolling 3 lines before bottom set showmatch " quickly show the matching bracket set autoindent " self explanatory set smarttab " setup tabs to be four spaces set tabstop=4 " setup tabs to be four spaces set shiftwidth=4 " setup tabs to be four spaces set expandtab " setup tabs to be four spaces set shiftround " use rounding when shifting tabs and spacing is uneven set clipboard=unnamed " use system clipboard " Scroll by row rather than line so wrapped lines get included. nnoremap j gj nnoremap k gk " never do this again --> :set paste :set no paste let &t_SI .= "\[?2004h" let &t_EI .= "\[?2004l" inoremap [200~ XTermPasteBegin() function! XTermPasteBegin() set pastetoggle=[201~ set paste return "" endfunction " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " 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 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END "==================== golang ==================== autocmd FileType go nnoremap :! go run *.go else endif " has("autocmd") "==================== colorscheme ==================== "let g:dracula_colorterm = 0 "silent! colorscheme dracula set background=dark silent! colorscheme nord " ==================== Code Folding ==================== set nofoldenable set foldlevel=2 set foldmethod=indent " ==================== Functions ==================== command! CLEAN retab | %s/\s\+$// " ==================== Keyboard Shortcuts ==================== " set our leader key to space let mapleader = "," let g:mapleader = "," " quit smartly nnoremap q :Sayonara " Remove search highlight nnoremap h :noh " Buffer prev/next nnoremap n :bnext nnoremap p :bprev " list buffers and switch nnoremap b :ls:b " Fast saving nnoremap w :w! " Better split switching map j map k map h map l " Just go out in insert mode imap jk l " Do not show stupid q: window map q: :q " Allow saving of files as sudo when I forgot to start vim using sudo. cmap w!! w !sudo tee > /dev/null % " Disable F1 key nmap " Go shortcuts just for .go files autocmd FileType go nmap r (go-run) autocmd FileType go nmap t (go-test) " ==================== File searching ==================== set wildmenu set wildmode=list:full set wildignorecase set path=.,** nnoremap f :find * nnoremap s :sfind * nnoremap v :vert sfind * nnoremap t :tabfind * " ==================== Fugitive ==================== nnoremap ga :Git add %:p nnoremap gs :Gstatus nnoremap gp :Gpush vnoremap gb :Gblame " =================== nvim ==================== if has('nvim') set inccommand=nosplit endif