157 lines
4.1 KiB
VimL
157 lines
4.1 KiB
VimL
if empty(glob('~/.config/nvim/autoload/plug.vim'))
|
||
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
|
||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||
endif
|
||
|
||
let g:pyxversion = 'python3'
|
||
|
||
set number
|
||
set relativenumber
|
||
set tabstop=4
|
||
set shiftwidth=4
|
||
set smarttab
|
||
set expandtab
|
||
set hidden
|
||
set showtabline=1
|
||
set termguicolors
|
||
set ttyfast
|
||
set wildmenu
|
||
set title
|
||
set list
|
||
set listchars=tab:→\ ,eol:¬,trail:•,extends:❯,precedes:❮,space:⨪
|
||
set showbreak=↪
|
||
set timeoutlen=500
|
||
set ignorecase
|
||
set smartcase
|
||
set splitbelow
|
||
set splitright
|
||
|
||
let g:mapleader="\<SPACE>"
|
||
let g:maplocallead=','
|
||
|
||
if has('nvim')
|
||
set inccommand=split
|
||
endif
|
||
|
||
if has("persistent_undo")
|
||
set undofile
|
||
set undodir=$HOME/.undodir
|
||
endif
|
||
|
||
call plug#begin('~/.config/nvim/plugged')
|
||
Plug 'junegunn/vim-plug'
|
||
|
||
"LSP Stuff
|
||
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||
Plug 'rust-lang/rust.vim'
|
||
Plug 'godlygeek/tabular'
|
||
Plug 'cespare/vim-toml'
|
||
Plug 'stephpy/vim-yaml'
|
||
|
||
Plug 'terryma/vim-expand-region'
|
||
Plug 'junegunn/rainbow_parentheses.vim'
|
||
|
||
Plug 'machakann/vim-highlightedyank'
|
||
Plug 'vim-airline/vim-airline'
|
||
Plug 'vim-airline/vim-airline-themes'
|
||
Plug 'morhetz/gruvbox'
|
||
Plug 'arzg/vim-corvine'
|
||
Plug 'tpope/vim-fugitive'
|
||
Plug 'mhinz/vim-signify'
|
||
Plug 'tpope/vim-commentary'
|
||
Plug 'mbbill/undotree'
|
||
Plug 'elmcast/elm-vim'
|
||
Plug 'liuchengxu/vim-which-key'
|
||
Plug 'airblade/vim-rooter'
|
||
|
||
"async.vim
|
||
Plug 'prabirshrestha/async.vim'
|
||
|
||
call plug#end()
|
||
|
||
inoremap <silent><expr> <TAB>
|
||
\ pumvisible() ? "\<C-n>" :
|
||
\ <SID>check_back_space() ? "\<TAB>" :
|
||
\ coc#refresh()
|
||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||
|
||
function! s:check_back_space() abort
|
||
let col = col('.') - 1
|
||
return !col || getline('.')[col - 1] =~# '\s'
|
||
endfunction
|
||
|
||
inoremap <silent><expr> <c-space> coc#refresh()
|
||
|
||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||
|
||
command! -nargs=0 Format :call CocAction('format')
|
||
|
||
set background=dark
|
||
colorscheme corvine
|
||
|
||
"Airline settings
|
||
let g:airline#extensions#tabline#enabled = 1
|
||
let g:airline_powerline_fonts = 1
|
||
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
|
||
let g:airline_theme='base16_tomorrow'
|
||
|
||
nnoremap <leader>u :UndotreeToggle<cr>
|
||
nnoremap <leader>h <C-W><C-H>
|
||
nnoremap <leader>j <C-W><C-J>
|
||
nnoremap <leader>k <C-W><C-K>
|
||
nnoremap <leader>l <C-W><C-L>
|
||
nnoremap <leader>n :nohl<cr>
|
||
nnoremap <C-k> <C-u>
|
||
nnoremap <C-j> <C-d>
|
||
|
||
" Read and write to system clipboard
|
||
vnoremap <Leader>y "+y
|
||
vnoremap <Leader>d "+d
|
||
nnoremap <Leader>p "+p
|
||
nnoremap <Leader>P "+P
|
||
vnoremap <Leader>p "+p
|
||
vnoremap <Leader>P "+P
|
||
|
||
" Keep expanding regions with v in visual mode
|
||
vmap v <Plug>(expand_region_expand)
|
||
vmap <C-v> <Plug>(expand_region_shrink)
|
||
|
||
"Coc Keymaps and options
|
||
nnoremap <silent> <leader><Space>d :call CocAction('jumpDefinition')<cr>
|
||
nnoremap <silent> <leader><Space>g :call CocAction('jumpTypeDefinition')<cr>
|
||
|
||
"which-key
|
||
let g:which_key_map = {}
|
||
autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
|
||
let g:which_key_map[' '] = {
|
||
\ 'name' : '+CoC' ,
|
||
\ 'd' : 'go-to-definition' ,
|
||
\ 'g' : 'go-to-type-definition' ,
|
||
\ }
|
||
call which_key#register('<Space>', "g:which_key_map")
|
||
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
|
||
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
|
||
|
||
"rainbow-parens
|
||
autocmd VimEnter * RainbowParentheses
|
||
let g:rainbow#blacklist = [248]
|
||
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]
|
||
|
||
function! s:transformed_url(url)
|
||
let l:rv = a:url
|
||
let l:rv = system("echo " . l:rv . ' | sed "s|:|/|" | sed "s|git@|https://|"')
|
||
return l:rv
|
||
endfunction
|
||
|
||
function! GetGitUrl()
|
||
let url = trim(system("git remote get-url origin"))
|
||
let t_url = s:transformed_url(url)
|
||
let branch = system("git branch --show-current")
|
||
let file_name = expand('%')
|
||
let line_num = line(".")
|
||
let @+ = trim(t_url) . "/blob/" . trim(branch) . "/" . trim(file_name) . "#L" . trim(line_num)
|
||
endfunction
|
||
|
||
nnoremap <silent> <leader>c :call GetGitUrl()<CR>
|