Last active
June 14, 2022 15:10
-
-
Save maclunar/00d31cc5f97ad86a57f96c2a39468bdc to your computer and use it in GitHub Desktop.
.config/nvim/init.vim file, 2020-07-20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" maclunar's .vimrc file | |
" now more of a init.vim file | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set shell=/bin/sh | |
" ------------------------------------------------------------------------------ | |
" vim-plug | |
" ------------------------------------------------------------------------------ | |
call plug#begin() | |
Plug 'cloudhead/neovim-fuzzy' " fzy for searching | |
Plug 'junegunn/fzf' " fzf for searching | |
Plug 'junegunn/fzf.vim' " fzf for searching | |
"Plug 'jremmen/vim-ripgrep' " ripgrep for searching | |
Plug 'jsfaint/gen_tags.vim' " ctags/gtags | |
Plug 'scrooloose/nerdcommenter' " commenting multiple lines | |
Plug 'tpope/vim-commentary' " commenting with //+motion | |
Plug 'vim-scripts/ZoomWin' " zoom one split with <c-w>o | |
Plug 'tpope/vim-repeat' " repeat plugin maps with . | |
Plug 'preservim/nerdtree' " tree file browser | |
Plug 'AdamWhittingham/vim-copy-filename' " easy copying of filename | |
""" git | |
Plug 'tpope/vim-fugitive' " git stuff | |
Plug 'tpope/vim-rhubarb' " github stuff for git stuff | |
Plug 'airblade/vim-gitgutter' " mark git diff lines on the left | |
""" html/css | |
Plug 'alvan/vim-closetag' " autoclose html tags | |
Plug 'mattn/emmet-vim' " emmet for working with html/css | |
""" ruby/rails | |
Plug 'vim-ruby/vim-ruby' " ruby helper | |
Plug 'tpope/vim-rails' " rails helpers | |
Plug 'tpope/vim-endwise' " automatically add 'end' in Ruby | |
Plug 'skalnik/vim-vroom' " running ruby tests | |
Plug 'sheerun/vim-polyglot' " better language support | |
""" writing help | |
Plug 'junegunn/goyo.vim' " centers the text for writing | |
Plug 'reedes/vim-pencil' " better writing in vim | |
""" themes | |
Plug 'dracula/vim', { 'as': 'dracula' } " dracula theme | |
"Plug 'altercation/vim-colors-solarized' " solarized colorscheme | |
Plug 'bluz71/vim-nightfly-guicolors' " nightfly colorscheme | |
Plug 'rakr/vim-one' | |
Plug 'bluz71/vim-moonfly-colors' | |
Plug 'morhetz/gruvbox' | |
Plug 'sainnhe/everforest' | |
Plug 'sonph/onehalf' | |
Plug 'junegunn/seoul256.vim' | |
""" syntax highlighting | |
Plug 'pangloss/vim-javascript' " better JS syntax highlighting | |
Plug 'mustache/vim-mustache-handlebars' " hbs syntax highliting | |
Plug 'kchmck/vim-coffee-script' " coffeescript syntax highlighting | |
Plug 'posva/vim-vue' " vue.js syntax highlighting | |
Plug 'slim-template/vim-slim' " slim syntax highlighting | |
Plug 'leafgarland/typescript-vim' " typescript syntax highlighting | |
Plug 'godlygeek/tabular' " both this and the next one are... | |
Plug 'plasticboy/vim-markdown' " ...needed for markdown | |
call plug#end() | |
" ------------------------------------------------------------------------------ | |
" Basic setup | |
" ------------------------------------------------------------------------------ | |
set nocompatible | |
set encoding=utf-8 | |
" if the file is changed outside vim - reload automatically | |
set autoread | |
set ttyfast " faster redrawing | |
" Don't make backups at all | |
set nobackup | |
set nowritebackup | |
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp | |
" allow backspacing over everything in insert mode | |
set backspace=indent,eol,start | |
" Fix slow O inserts | |
:set timeout timeoutlen=1000 ttimeoutlen=100 | |
"" Colors | |
let base16colorspace=256 " access colors present in 256 colorspace | |
set t_Co=256 " tell vim that terminal supports 256 colors | |
"highlight ColorColumn ctermbg=235 guibg=#2c2d27 | |
"let &colorcolumn=join(range(101,999),",") "color past 100th line" | |
highlight LineNr ctermfg=grey | |
" highlight current line in active window only | |
augroup CursorLine | |
au! | |
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline | |
au WinLeave * setlocal nocursorline | |
augroup END | |
syntax on " older syntax highlighting engine, might be faster | |
set re=1 " might speed up vim in ruby files | |
if has('gui_running') | |
"colorscheme dracula | |
highlight Normal guibg=DarkBlue | |
set background=dark | |
set guifont=Inconsolata:h14 | |
set guioptions= | |
else | |
syntax enable | |
set termguicolors | |
set background=light | |
colorscheme everforest | |
"set background=dark | |
"colorscheme dracula | |
end | |
" increase CtrlP window height | |
let g:ctrlp_match_window = 'max:40' | |
" let CtrlP find hidden files | |
let g:ctrlp_show_hidden = 1 | |
" disable bell | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
autocmd! GUIEnter * set vb t_vb= | |
" basic visual config | |
set number " show current line number | |
set wrap linebreak nolist " line wrapping options | |
set showbreak=--> " display at the begining of wrapped lines | |
set showcmd " show partial commands below the status line | |
set scrolloff=3 " have some context | |
set hlsearch " highlight matches | |
set incsearch " incremental searching | |
set ignorecase " searches are case insensitive... | |
set smartcase " ... unless they contain at least one capital letter | |
"nnoremap <CR> :nohlsearch<cr> | |
" clear the search buffer when hitting return | |
"" Tabs and Indents | |
set expandtab " insert spacer rather than tabs | |
set smarttab " tab respects shiftwidth, tabstop and softtabstop | |
set shiftwidth=2 " number of spaces to use for (un)indent | |
set tabstop=2 " visible width of tabs | |
set softtabstop=2 " edit as if tabs are 2 chars wide | |
"set shiftround " round indent to a multiple of 'shiftwidth' | |
set autoindent | |
set smartindent | |
"" Control and Splits | |
if has('mouse') | |
set mouse=a | |
"set ttymouse=xterm2 | |
endif | |
" remap <leader> key to , | |
let mapleader = ',' | |
let g:mapleader = ',' | |
" easier buffer switching | |
" gb to see buffer list, then just type buffer number | |
nnoremap gb :ls<CR>:b<Space> | |
" easier split navigation | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-l> <C-w>l | |
" put cursor in the new split | |
nnoremap <leader>w <C-w>v<C-w>l | |
" more natural split opening | |
set splitbelow | |
set splitright | |
" Show current window big, but leave context for other splits | |
set winwidth=90 | |
" We have to have a winheight bigger than we want to set winminheight. But if | |
" we set winheight to be huge before winminheight, the winminheight set will | |
" fail. | |
set winheight=7 | |
set winminheight=7 | |
set winheight=999 | |
" disable Ex mode | |
noremap Q <NOP> | |
" double ,, for previous buffer | |
nnoremap <leader><leader> <c-^> | |
" yank to system clipboard | |
"set clipboard=unnamed | |
"set clipboard=unnamedplus,unnamed,autoselect | |
"set clipboard=unnamedplus | |
set clipboard+=unnamedplus | |
nmap <leader>y "+y | |
"paste lines from unnamed register and fix indentation | |
nmap <leader>p pV`]= | |
nmap <leader>P PV`]= | |
" scroll the viewport faster | |
nnoremap <C-e> 3<C-e> | |
nnoremap <C-y> 3<C-y> | |
" ------------------------------------------------------------------------------ | |
" Multipurpose TAB key | |
" ------------------------------------------------------------------------------ | |
" Indent if at the beginning of a lien. Else, do completion. | |
function! InsertTabWrapper() | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
else | |
return "\<c-p>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=InsertTabWrapper()<cr> | |
inoremap <s-tab> <c-n> | |
" ------------------------------------------------------------------------------ | |
" Trailing whitespaces | |
" ------------------------------------------------------------------------------ | |
" highlight them | |
match ErrorMsg '\s\+$' | |
" remove them ... | |
function! TrimWhiteSpace() | |
%s/\s\+$//e | |
endfunction | |
" ... manually ... | |
nnoremap <silent> <Leader>rts :call TrimWhiteSpace()<CR> | |
" ... and automatically | |
autocmd FileWritePre * :call TrimWhiteSpace() | |
autocmd FileAppendPre * :call TrimWhiteSpace() | |
autocmd FilterWritePre * :call TrimWhiteSpace() | |
autocmd BufWritePre * :call TrimWhiteSpace() | |
" ------------------------------------------------------------------------------ | |
" Status line | |
" ------------------------------------------------------------------------------ | |
if has("statusline") && !&cp | |
set laststatus=2 " always show the status bar | |
set statusline=%<%1*\ %f\ %* " filename | |
set statusline+=%2*%m%r%* " modified, readonly | |
set statusline+=%= " left-right separation point | |
set statusline+=%c, " cursos column | |
set statusline+=\ %4*%l%*/%L[%p%%] " current line/total lines | |
endif | |
" ------------------------------------------------------------------------------ | |
" Remove fancy characters | |
" ------------------------------------------------------------------------------ | |
function! RemoveFancyCharacters() | |
let typo = {} | |
let typo["“"] = '"' | |
let typo["”"] = '"' | |
let typo["‘"] = "'" | |
let typo["’"] = "'" | |
let typo["–"] = '--' | |
let typo["—"] = '---' | |
let typo["…"] = '...' | |
:exe ":%s/".join(keys(typo), '\|').'/\=typo[submatch(0)]/ge' | |
endfunction | |
command! RemoveFancyCharacters :call RemoveFancyCharacters() | |
" ------------------------------------------------------------------------------ | |
" Rails specific mappings | |
" ------------------------------------------------------------------------------ | |
" Open routes and Gemfile in top left, full height | |
map <leader>gr :topleft :split config/routes.rb<cr> | |
map <leader>gg :topleft 100 :split Gemfile<cr> | |
" ------------------------------------------------------------------------------ | |
" Folding | |
" ------------------------------------------------------------------------------ | |
set foldmethod=indent " fold based on indentation | |
set foldlevel=10 " high initial fold level | |
" toggle fold with leader f | |
nnoremap <leader>f za | |
" unfold all with leader F | |
nnoremap <leader>F zR | |
" ------------------------------------------------------------------------------ | |
" Fzy | |
" ------------------------------------------------------------------------------ | |
nnoremap <C-p> :FuzzyOpen<CR> | |
" ------------------------------------------------------------------------------ | |
" NERDTree | |
" ------------------------------------------------------------------------------ | |
"map <C-m> :NERDTreeToggle<CR> " open NERDTree with Ctrl+M | |
" open NERDTree with Ctrl+N on current file | |
map <C-n> :NERDTreeFind<CR> | |
" close NERDTree with Ctrl+B | |
map <C-b> :NERDTreeClose<CR> | |
" hide arrows for more screen realestate | |
let g:NERDTreeDirArrowExpandable = '' | |
let g:NERDTreeDirArrowCollapsible = '' | |
" ------------------------------------------------------------------------------ | |
" vim-copy-filename | |
" ------------------------------------------------------------------------------ | |
nmap <leader>cp :CopyRelativePath<CR> | |
nmap <leader>cL :CopyRelativePathAndLine<CR> | |
nmap <leader>cP :CopyAbsolutePath<CR> | |
nmap <leader>cf :CopyFileName<CR> | |
nmap <leader>cd :CopyDirectoryPath<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment