dotfiles/nvim/init.vim

202 lines
4.0 KiB
VimL
Raw Normal View History

2019-10-22 15:19:35 +00:00
call plug#begin(stdpath('data') . '/plugged')
Plug 'altercation/vim-colors-solarized'
Plug 'itchyny/lightline.vim'
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'christoomey/vim-tmux-navigator'
2019-11-04 08:31:20 +00:00
Plug 'tpope/vim-dispatch'
2019-11-21 19:36:52 +00:00
Plug 'RRethy/vim-illuminate'
Plug 'tpope/vim-surround'
2020-04-09 06:27:19 +00:00
Plug 'tpope/vim-commentary'
2019-11-21 19:36:52 +00:00
2020-05-24 10:58:51 +00:00
Plug 'Lenovsky/nuake'
2020-05-24 11:00:45 +00:00
Plug 'junegunn/vim-peekaboo'
2020-10-01 11:58:45 +00:00
Plug 'cespare/vim-toml'
2020-10-23 09:52:05 +00:00
Plug 'vimwiki/vimwiki'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
2021-08-03 06:47:01 +00:00
" typescript syntax highlighting
2020-12-07 20:25:59 +00:00
Plug 'HerringtonDarkholme/yats.vim'
2021-07-08 06:45:52 +00:00
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
2021-08-28 08:48:32 +00:00
Plug 'folke/which-key.nvim'
2021-09-10 11:37:58 +00:00
Plug 'wellle/targets.vim'
2022-01-15 12:45:53 +00:00
Plug 'lukas-reineke/indent-blankline.nvim'
2019-10-22 15:19:35 +00:00
call plug#end()
" tabwidth
set tabstop=4
set shiftwidth=4
2021-01-18 07:43:51 +00:00
" indent with spaces
set expandtab
2019-10-28 07:39:49 +00:00
" scroll offset
set scrolloff=4
2022-02-02 18:25:29 +00:00
" don't warp lines
set nowrap
2021-08-28 08:47:52 +00:00
" split to right/below
set splitright
set splitbelow
2020-09-01 12:22:12 +00:00
" presistent undo
set undofile
2019-10-22 15:19:35 +00:00
" solarized dark theme
2020-05-30 17:38:47 +00:00
silent! colorscheme solarized
2019-10-22 15:19:35 +00:00
set background=dark
" line numbers
set number
2020-04-09 06:26:11 +00:00
" searching
set ignorecase
set smartcase
2019-10-22 17:09:13 +00:00
" preview commands
set inccommand=split
2021-08-03 06:47:15 +00:00
" reload init.vim on save
augroup InitVimReload
autocmd!
autocmd BufWritePost init.vim source $MYVIMRC
augroup END
2019-11-29 14:04:58 +00:00
" set cursorline in active window
augroup CursorLine
2019-12-22 11:55:19 +00:00
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
2019-11-29 14:04:58 +00:00
augroup END
2019-10-22 16:52:41 +00:00
" terminal mode options
2019-10-28 07:40:25 +00:00
augroup terminal_mode
autocmd!
autocmd TermOpen * startinsert
augroup END
2019-10-22 16:52:41 +00:00
" map esc to exit insert mode in terminal
tnoremap <expr> <esc> (&filetype == "fzf") ? "<esc>" : "<c-\><c-n>"
" git-gutter
highlight SignColumn ctermbg=0
2019-10-22 15:19:35 +00:00
" lightline config
let g:lightline = { 'colorscheme': 'solarized' }
" prosession
let g:prosession_tmux_title = 1
let g:prosession_per_branch = 1
" fzf.vim
2020-05-24 10:59:28 +00:00
nnoremap <C-P> :GFiles<CR>
2020-11-17 15:29:50 +00:00
nnoremap <C-G> :Rg<CR>
2019-10-22 17:08:56 +00:00
nnoremap <C-F> :Rg \b<C-R><C-W>\b<CR>
2019-10-22 15:19:35 +00:00
2019-11-29 14:06:19 +00:00
" vim-illuminate
highlight illuminatedWord ctermbg=23
2020-09-01 12:17:36 +00:00
augroup close_preview
autocmd InsertLeave * silent! pclose!
augroup end
2019-10-22 15:19:35 +00:00
" autoread/checktime timer {{{
set autoread
function! CheckTime(timer)
checktime
endfunction
let timerChecktime = timer_start(4000, 'CheckTime', {'repeat': -1})
" }}}
2020-05-24 10:58:51 +00:00
" nuake console
nnoremap <F4> :Nuake<CR>
inoremap <F4> <C-\><C-n>:Nuake<CR>
tnoremap <F4> <C-\><C-n>:Nuake<CR>
2020-09-01 12:17:06 +00:00
augroup color_column
2019-10-28 07:40:25 +00:00
autocmd!
2021-01-18 07:43:59 +00:00
autocmd Filetype cpp,python,javascript,javascriptreact,typescript,typescriptreact set colorcolumn=101
2020-09-01 12:17:06 +00:00
augroup end
2020-10-23 09:52:05 +00:00
" vimwiki
let g:vimwiki_list = [
\ {'name': 'personal', 'path': '~/vimwiki/personal'},
\ {'name': 'swp', 'path': '~/vimwiki/swp'}
\ ]
let g:vimwiki_table_mappings = 0
let g:vimwiki_global_ext = 0
2022-01-15 12:45:53 +00:00
" indent-blankline
let g:indent_blankline_char = '┊'
" coc
set updatetime=300
2021-07-08 06:44:51 +00:00
highlight CocHintSign ctermfg=10
let g:coc_global_extensions = [
\ 'coc-clangd',
\ 'coc-cmake',
2021-01-15 08:46:31 +00:00
\ 'coc-eslint',
2020-11-13 13:02:55 +00:00
\ 'coc-html',
\ 'coc-json',
2021-07-19 09:28:14 +00:00
\ 'coc-prettier',
\ 'coc-python',
\ 'coc-rust-analyzer',
\ 'coc-sh',
2020-11-07 13:24:39 +00:00
\ 'coc-toml',
2021-01-13 07:50:44 +00:00
\ 'coc-tsserver',
\ 'coc-vimlsp',
\ 'coc-yaml',
\ ]
nnoremap <silent> K :call CocAction('doHover')<CR>
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gr <Plug>(coc-references)
2021-01-15 08:46:31 +00:00
nmap <silent> ga <Plug>(coc-codeaction)
2021-01-11 12:18:22 +00:00
nmap <silent> <leader>rn <Plug>(coc-rename)
2021-08-03 06:47:01 +00:00
" use <tab> for trigger completion and navigate to the next complete item {{{
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
inoremap <silent><expr> <S-Tab>
\ pumvisible() ? "\<C-p>" :
\ <SID>check_back_space() ? "\<S-Tab>" :
\ coc#refresh()
2021-08-03 06:47:01 +00:00
" }}}
" select completion items with enter
inoremap <silent><expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"