" My awesome vimrc let mapleader ="," if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) echo "Downloading junegunn/vim-plug to manage plugins..." silent !mkdir -p ~/.config/nvim/autoload/ silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim autocmd VimEnter * PlugInstall endif function! Cond(cond, ...) let opts = get(a:000, 0, {}) return a:cond ? opts : extend(opts, { 'on': [], 'for': [] }) endfunction call plug#begin('~/.config/nvim/plugged') Plug 'neoclide/coc.nvim', Cond(!exists('g:vscode')) Plug 'nvim-lua/popup.nvim', Cond(!exists('g:vscode')) Plug 'nvim-lua/plenary.nvim', Cond(!exists('g:vscode')) Plug 'nvim-telescope/telescope.nvim', Cond(!exists('g:vscode')) Plug 'nvim-telescope/telescope-fzy-native.nvim', Cond(!exists('g:vscode')) Plug 'Rican7/php-doc-modded' Plug 'udalov/kotlin-vim' Plug 'f-person/git-blame.nvim' Plug 'vimwiki/vimwiki', Cond(!exists('g:vscode')) Plug 'ap/vim-css-color', Cond(!exists('g:vscode')) Plug 'dart-lang/dart-vim-plugin' Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } call plug#end() " Some basics: set clipboard+=unnamedplus set nohlsearch set incsearch set ignorecase autocmd BufWritePre * :%s/\s\+$//e set go=a set mouse=a set smartcase set linebreak set noswapfile set nobackup set undodir=~/.config/nvim/undodir set undofile nnoremap c "_c set nocompatible filetype plugin on syntax on set encoding=utf-8 set number relativenumber autocmd BufWritePre * :%s/\s\+$//e nnoremap vs :vsplit nnoremap hs :split " Tab 2 spaces filetype plugin indent on set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab let g:tabStop=4 function! ToggleTabWidth() if g:tabStop == 2 set tabstop=4 softtabstop=4 shiftwidth=4 let g:tabStop=4 else set tabstop=2 softtabstop=2 shiftwidth=2 let g:tabStop=2 endif endfunction nnoremap t :call ToggleTabWidth() autocmd BufNewFile,BufRead *.dart setlocal tabstop=2 softtabstop=2 shiftwidth=2 autocmd BufNewFile,BufRead *.dart let g:tabStop=2 " Disables automatic commenting on newline: autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o nnoremap t :call ToggleTabWidth() " Disables automatic commenting on newline: autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Remember last cursor position autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif " Automatically save the current session whenever vim is closed autocmd VimLeave * mksession! ~/.config/nvim/session/shutdown_session.vim " restores that 'shutdown session' noremap :source ~/.config/nvim/session/shutdown_session.vim " If you really want to, this next line should restore the shutdown session " automatically, whenever you start vim. (Commented out for now, in case " somebody just copy/pastes this whole block) " " autocmd VimEnter source ~/.vim/shutdown_session.vim " manually save a session with noremap :mksession! ~/.config/nvim/session/manual_session.vim " recall the manually saved session with noremap :source ~/.config/nvim/session/manual_session.vim " Copy entire document noremap y ggyG map y ggyG " Set gohtml template files to html syntax autocmd BufNewFile,BufRead *.gohtml set syntax=html nnoremap 1 1gt nnoremap 2 2gt nnoremap 3 3gt nnoremap 4 4gt nnoremap 5 5gt " NETRW let g:netrw_liststyle = 3 let g:netrw_banner = 0 let g:netrw_browse_split = 4 let g:netrw_winsize = 20 let g:netrw_altv = 1 let g:NetrwIsOpen=0 function! ToggleNetrw() if g:NetrwIsOpen let i = bufnr("$") while (i >= 1) if (getbufvar(i, "&filetype") == "netrw") silent exe "bwipeout " . i endif let i-=1 endwhile let g:NetrwIsOpen=0 else let g:NetrwIsOpen=1 silent Lexplore endif endfunction " Add your own mapping. For example: noremap :call ToggleNetrw() " coc highlight CocErrorSign ctermfg=Black ctermbg=Magenta 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 nmap gd (coc-definition) nmap gr (coc-references) nmap rr (coc-rename) nnoremap prw :CocSearch =expand("") inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " PHP Doc nnoremap h :call UpdatePhpDocIfExists() function! UpdatePhpDocIfExists() normal! k if getline('.') =~ '/' normal! V%d else normal! j endif call PhpDocSingle() normal! k^%k$ if getline('.') =~ ';' exe "normal! $svoid" endif endfunction nnoremap :call UpdatePhpDocIfExists() " VimWiki au filetype vimwiki silent! iunmap try nmap ej :call CocAction('diagnosticNext') nmap ek :call CocAction('diagnosticPrevious') endtry " Telescope remaps lua require("telescope") nnoremap :lua require('telescope.builtin').grep_string({ search = vim.fn.input("Grep For > ")}) nnoremap :lua require('telescope.builtin').git_files() nnoremap :lua require('telescope.builtin').find_files() nnoremap fb lua require('telescope.builtin').buffers() " Spell-check map o :setlocal spell! spelllang=en_au " Shortcutting split navigation, saving a keypress: nnoremap h nnoremap j nnoremap k nnoremap l " Replace all is aliased to S. nnoremap :%s//g " Navigating with guides inoremap /<++>"_c4l vnoremap /<++>"_c4l map /<++>"_c4l augroup twig_ft au! autocmd BufNewFile,BufRead *.docker set syntax=dockerfile augroup END