mirror of
https://github.com/mentos1386/dotfiles.git
synced 2024-11-23 08:03:34 +00:00
186 lines
4.8 KiB
VimL
186 lines
4.8 KiB
VimL
" Install vim-plug if not found
|
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
endif
|
|
|
|
" Run PlugInstall if there are missing plugins
|
|
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
\| PlugInstall --sync | source $MYVIMRC
|
|
\| endif
|
|
|
|
"--- Plugins
|
|
call plug#begin('~/.vim/plugged')
|
|
|
|
" General
|
|
Plug 'ojroques/vim-oscyank'
|
|
Plug 'tpope/vim-obsession'
|
|
Plug 'tmux-plugins/vim-tmux-focus-events'
|
|
" Look
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'sonph/onehalf', { 'rtp': 'vim' }
|
|
Plug 'Yggdroot/indentLine'
|
|
" Git
|
|
Plug 'tpope/vim-fugitive'
|
|
Plug 'airblade/vim-gitgutter'
|
|
" Search/Files
|
|
Plug 'junegunn/fzf.vim'
|
|
Plug 'preservim/nerdtree'
|
|
Plug 'ctrlpvim/ctrlp.vim'
|
|
" Ignore/Edit files
|
|
Plug 'editorconfig/editorconfig-vim'
|
|
Plug 'vim-scripts/gitignore'
|
|
" Languages
|
|
Plug 'fatih/vim-go'
|
|
Plug 'pangloss/vim-javascript'
|
|
Plug 'leafgarland/typescript-vim'
|
|
Plug 'peitalin/vim-jsx-typescript'
|
|
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
|
|
Plug 'jparise/vim-graphql'
|
|
Plug 'kevinoid/vim-jsonc'
|
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
call plug#end()
|
|
|
|
"--- CodeServer Configurations
|
|
let g:coc_global_extensions = [
|
|
\ 'coc-tsserver',
|
|
\ 'coc-prettier',
|
|
\ 'coc-yaml',
|
|
\ 'coc-json',
|
|
\ 'coc-git',
|
|
\ 'coc-pyright'
|
|
\ ]
|
|
if isdirectory('./node_modules') && isdirectory('./node_modules/prettier')
|
|
let g:coc_global_extensions += ['coc-prettier']
|
|
endif
|
|
if isdirectory('./node_modules') && isdirectory('./node_modules/eslint')
|
|
let g:coc_global_extensions += ['coc-eslint']
|
|
endif
|
|
|
|
" Diagnostic list
|
|
nnoremap <silent> <space>d :<C-u>CocList diagnostics<cr>
|
|
" Symbols list
|
|
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
|
|
" Code actions
|
|
nmap <leader>do <Plug>(coc-codeaction)
|
|
" 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
|
|
" 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)
|
|
|
|
"--- TMUX/Clipboard fixes
|
|
set t_Co=256
|
|
set t_ut=
|
|
" Set Vim-specific sequences for RGB colors
|
|
" Fixes 'termguicolors' usage in vim+tmux
|
|
" :h xterm-true-color
|
|
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
" Enables 24-bit RGB color in the terminal
|
|
if has('termguicolors')
|
|
if empty($COLORTERM) || $COLORTERM =~# 'truecolor\|24bit'
|
|
set termguicolors
|
|
endif
|
|
endif
|
|
" Use system clipboard to get buffers synced between TMUX and VIM
|
|
if has('clipboard') && has('vim_starting')
|
|
" set clipboard& clipboard+=unnamedplus
|
|
set clipboard& clipboard^=unnamed,unnamedplus
|
|
endif
|
|
if exists('##TextYankPost')
|
|
augroup BlinkClipboardIntegration
|
|
autocmd!
|
|
autocmd TextYankPost * silent! if v:event.operator ==# 'y' | call YankOSC52(join(v:event["regcontents"],"\n")) | endif
|
|
augroup END
|
|
endif
|
|
|
|
"--- VIM Configuration
|
|
set encoding=UTF-8
|
|
set autoread " will re-read opened file if changed externaly
|
|
set autowrite
|
|
set splitright
|
|
set splitbelow
|
|
|
|
set smarttab
|
|
set autoindent
|
|
set tabstop=2
|
|
set softtabstop=0
|
|
set vartabstop=
|
|
set shiftwidth=2
|
|
set expandtab
|
|
|
|
set noswapfile
|
|
set nobackup
|
|
set nowritebackup
|
|
set incsearch " search as you type
|
|
set ignorecase
|
|
set smartcase
|
|
set mouse=a
|
|
set ttymouse=sgr
|
|
set spell spelllang=en_us
|
|
set updatetime=300
|
|
set cmdheight=1
|
|
set hidden
|
|
set shortmess+=c
|
|
|
|
"- Custom commands
|
|
command! -nargs=0 Prettier :CocCommand prettier.formatFile
|
|
|
|
"- CtrlP
|
|
let g:ctrlp_custom_ignore = {
|
|
\ 'dir': '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
|
|
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
|
|
\ }
|
|
|
|
"- NERDTree
|
|
nnoremap <leader>n :NERDTreeFocus<CR>
|
|
nnoremap <C-n> :NERDTree<CR>
|
|
nnoremap <C-f> :NERDTreeFind<CR>
|
|
nnoremap <leader>f 1z= " fix spelling
|
|
map <C-t> :call NERDTreeToggleAndRefresh()<CR>
|
|
function NERDTreeToggleAndRefresh()
|
|
:NERDTreeToggle
|
|
if g:NERDTree.IsOpen()
|
|
:NERDTreeRefreshRoot
|
|
endif
|
|
endfunction
|
|
|
|
"- Keybindings
|
|
let mapleader = "'"
|
|
|
|
let g:ctrlp_map = '<c-p>'
|
|
let g:ctrlp_cmd = 'CtrlP'
|
|
|
|
"- Visuals
|
|
set noshowmode
|
|
set number
|
|
set cursorline
|
|
set hlsearch " highlight all results
|
|
set signcolumn=yes " always show git diff column
|
|
colorscheme onehalflight
|
|
|
|
if !exists('g:airline_symbols')
|
|
let g:airline_symbols = {}
|
|
endif
|
|
let g:airline_symbols.branch = ''
|
|
let g:airline_symbols.dirty=' '
|
|
let g:airline_symbols.linenr = '☰ '
|
|
let g:airline_symbols.maxlinenr = ' '
|
|
let g:airline_left_sep=''
|
|
let g:airline_right_sep=''
|
|
|
|
let g:airline_detect_spell=0
|
|
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
|
|
let g:airline_theme = 'onehalflight'
|