dotfiles/vimrc

276 lines
7.2 KiB
VimL
Raw Normal View History

2021-01-27 14:24:24 +00:00
set background=dark
2020-06-26 12:19:50 +00:00
syntax on
filetype plugin indent on
2021-02-25 12:49:17 +00:00
let mapleader=','
2020-12-29 07:02:41 +00:00
2021-01-06 13:34:33 +00:00
" netrw
2020-12-29 07:02:41 +00:00
let g:netrw_banner = 0
let g:netrw_liststyle = 1
let g:netrw_list_hide = '^\.'
2021-01-06 13:34:33 +00:00
let g:netrw_winsize=25
map <leader>n <esc>:Lexplore<cr>
2020-06-26 12:19:50 +00:00
2021-01-28 19:23:15 +00:00
" fix helptags for opt/ plugins
" https://vi.stackexchange.com/questions/17210/generating-help-tags-for-packages-that-are-loaded-by-vim-8s-package-management
command! -nargs=0 -bar Helptags
\ for p in glob('~/.vim/pack/git-plugins/opt/*', 1, 1)
\| exe 'packadd ' . fnamemodify(p, ':t')
\| endfor
\| helptags ALL
2020-06-26 12:19:50 +00:00
set shiftwidth=2
set shiftround
2021-02-02 11:37:36 +00:00
set tabstop=2
2020-06-26 12:19:50 +00:00
set expandtab
2021-01-28 19:23:15 +00:00
" set smarttab
2021-01-12 12:49:38 +00:00
set splitbelow
set splitright
2020-06-26 12:19:50 +00:00
set encoding=utf-8
set t_Co=256
2021-01-07 13:43:19 +00:00
set termguicolors
2020-06-26 12:19:50 +00:00
set hidden
2021-01-06 13:34:33 +00:00
set history=1000
2020-06-26 12:19:50 +00:00
set nowrap
set smartindent
set copyindent
set autoindent
set hlsearch
set showmatch
2020-12-18 12:49:36 +00:00
set wildmenu
2021-01-24 15:46:40 +00:00
set wildmode=list:full,full
2020-06-26 12:19:50 +00:00
set number
2021-02-22 09:45:05 +00:00
set relativenumber
2020-06-26 12:19:50 +00:00
set ruler
set backspace=indent,eol,start
set ignorecase
set smartcase
set incsearch
set history=1000
set undolevels=1000
set title
set novisualbell
set noerrorbells
set nobackup
set noswapfile
2020-12-29 07:02:41 +00:00
set ttymouse=sgr
2020-06-26 12:19:50 +00:00
set mouse=a
2020-12-29 07:02:41 +00:00
set mousemodel=popup_setpos
2020-06-26 12:19:50 +00:00
set lazyredraw
2021-02-22 09:45:05 +00:00
set timeoutlen=1000
2020-12-29 07:02:41 +00:00
set ballooneval
set balloonevalterm
set scrolloff=5
2021-02-22 09:45:05 +00:00
set dictionary=/usr/share/dict/words
2021-01-06 13:34:33 +00:00
set shortmess+=I
2021-01-28 08:21:55 +00:00
set updatetime=100
2021-01-12 12:49:38 +00:00
set pastetoggle=<f2>
2021-01-06 13:34:33 +00:00
" See :help thesaurus
set thesaurus=$HOME/Documents/thesaurus/thesaurus_pkg/thesaurus.txt
2021-01-27 14:24:24 +00:00
set pumheight=200
2021-03-08 08:34:00 +00:00
set completeopt=menu,menuone,popup,noselect
2021-01-27 14:24:24 +00:00
set completepopup=width:300,height:50,align:item,border:off
2020-06-26 12:19:50 +00:00
" Colour scheme:
2021-01-28 08:21:55 +00:00
colorscheme nord
2020-06-26 12:19:50 +00:00
2021-02-25 12:49:17 +00:00
augroup vimrc
2021-01-12 12:49:38 +00:00
autocmd!
2021-02-25 12:49:17 +00:00
" Automatically load/save views on files.
" https://vi.stackexchange.com/posts/13874/revisions
2021-01-12 12:49:38 +00:00
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
autocmd BufWinEnter ?* silent! loadview
2021-02-25 12:49:17 +00:00
" set cursor line highlight in insert mode.
autocmd InsertEnter * set cul
autocmd InsertLeavePre * set nocul
2021-01-12 12:49:38 +00:00
augroup end
2021-02-25 12:49:17 +00:00
2021-02-04 07:38:27 +00:00
" But, don't remember the current directory for a given file:
set viewoptions-=curdir
2020-06-26 12:19:50 +00:00
" Key mappings:
nmap <silent> ,/ :nohlsearch<CR>
2021-02-17 03:54:06 +00:00
nnoremap j gj
nnoremap k gk
2020-06-26 12:19:50 +00:00
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
2021-01-17 08:30:47 +00:00
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
2021-01-28 08:21:55 +00:00
nnoremap <silent> ,/ :nohlsearch<cr>
map <c-t> <esc>:tabnew<cr>
2020-06-26 12:19:50 +00:00
" Select just-pasted text:
2021-01-28 19:23:15 +00:00
nnoremap <silent> <leader>0 `[v`]
nnoremap <silent> <leader>1 :set relativenumber!<cr>
2021-01-15 13:46:24 +00:00
map <leader>m :marks<cr>
2021-02-25 12:49:52 +00:00
map <leader>R :ALERename<cr>
2021-01-15 13:46:24 +00:00
map <leader>v :vsplit<cr>
2021-01-27 14:32:26 +00:00
map <leader>s :split<cr>
2021-01-15 13:46:24 +00:00
map <leader>! <esc>:only<cr>
" ctrl-c to unload a buffer
2021-01-18 08:53:50 +00:00
nnoremap <silent> <c-q> :bp\|bd #<cr>
2021-01-06 13:34:33 +00:00
function! ToggleQuickFix()
if empty(filter(getwininfo(), 'v:val.quickfix'))
copen
else
cclose
endif
endfunction
2021-02-23 12:42:59 +00:00
nmap <silent> <leader>q :call ToggleQuickFix()<cr>
2021-02-22 18:46:23 +00:00
nmap <silent> <leader>l :lclose<cr>
2020-06-26 12:19:50 +00:00
2021-01-07 13:43:19 +00:00
" vim-ripgrep configuration:
let g:rg_highlight = 1
function RequestGrep()
call inputsave()
let s:pattern = trim(input("grep: "))
call inputrestore()
if len(s:pattern) > 0
execute 'Rg' s:pattern
endif
endfunction
map <Leader>* :call RequestGrep()<CR>
map <Leader>8 :call RequestGrep()<CR>
2021-01-17 09:14:53 +00:00
" deoplete configuration
2021-01-17 13:13:17 +00:00
packadd! deoplete.nvim
2021-01-17 09:14:53 +00:00
let g:deoplete#enable_at_startup = 1
2021-01-18 08:53:50 +00:00
call deoplete#custom#option('num_processes', 6)
2021-03-08 08:34:00 +00:00
call deoplete#custom#option('max_list', 50)
2021-01-29 13:53:15 +00:00
call deoplete#custom#option('auto_complete_delay', 10)
call deoplete#custom#option('auto_refresh_delay', 10)
2021-01-24 20:35:01 +00:00
" https://github.com/Shougo/deoplete.nvim/issues/965#issuecomment-482925193
2021-01-27 19:17:05 +00:00
" Seems to be causing autocomplete issues so removing for now.
2021-03-08 08:34:00 +00:00
call deoplete#custom#option('omni_patterns', {
\ 'go': '[^. *\t]\.\w*',
\})
2021-01-18 08:53:50 +00:00
" <TAB>: completion.
2021-02-25 12:49:17 +00:00
inoremap <expr><S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr><Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
2021-03-08 08:34:00 +00:00
inoremap <expr><C-]> pumvisible() ? "\<C-]>" : "\<Enter>"
2021-01-17 09:14:53 +00:00
2020-12-30 08:47:55 +00:00
" vim-markdown configuration:
2021-01-17 08:30:47 +00:00
let g:vim_markdown_conceal = 1
2020-06-26 12:19:50 +00:00
2021-03-09 18:34:35 +00:00
" Skim configuration:
nmap <leader>t :GFiles<cr>
nmap <leader>b :Buffers<cr>
2020-06-26 12:19:50 +00:00
" Lightline configuration:
set laststatus=2
2021-01-28 08:21:55 +00:00
" vim-gitgutter configuration
nnoremap hg :GitGutterLineHighlightsToggle<cr>
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
2020-12-18 08:00:19 +00:00
" Vim-Rust configuration:
2020-12-29 07:02:41 +00:00
let g:rustfmt_autosave = 1
2020-12-18 08:00:19 +00:00
2021-02-02 11:37:36 +00:00
" echodoc configuration:
set cmdheight=2
let g:echodoc#enable_at_startup = 1
2020-12-18 08:00:19 +00:00
" ALE configuration:
2020-12-29 07:02:41 +00:00
function SymbolSearch()
call inputsave()
2021-02-22 09:45:05 +00:00
let s:pattern = trim(input('symbol search: '))
2020-12-29 07:02:41 +00:00
call inputrestore()
if len(s:pattern) > 0
execute 'ALESymbolSearch' s:pattern
endif
endfunction
2021-01-07 13:43:19 +00:00
map <Leader>ss :call SymbolSearch()<CR>
2021-01-29 13:53:15 +00:00
nmap [L <Plug>(ale_first)
nmap ]L <Plug(ale_last)
2021-02-22 09:45:05 +00:00
nmap [e <Plug>(ale_previous_wrap_error)
nmap ]e <Plug>(ale_next_wrap_error)
nmap [w <Plug>(ale_previous_wrap)
nmap ]w <Plug>(ale_next_wrap)
2021-01-29 13:53:15 +00:00
2020-12-29 07:02:41 +00:00
nmap <leader>ad :ALEDetail<cr>
map <Leader>g :ALEGoToDefinition<CR>
map <Leader>f :ALEFindReferences<CR>
map <Leader>fv :ALEFindReferences -vsplit<CR>
map <Leader>fh :ALEFindReferences -split<CR>
map <Leader>ft :ALEFindReferences -tab<CR>
2021-02-17 03:54:06 +00:00
nnoremap <silent> gd :GoToDefinition
nnoremap <silent> gD :GoToTypeDefinition
2021-01-06 13:34:33 +00:00
command GoToDefinition ALEGoToDefinition
command GoToTypeDefinition ALEGoToTypeDefinition
command FindReferences ALEFindReferences
command Rename ALERename
2020-12-29 07:02:41 +00:00
let g:ale_sign_column_always = 1
2020-12-18 08:00:19 +00:00
let g:ale_fix_on_save = 1
2020-12-29 07:02:41 +00:00
let g:ale_lint_on_text_changed = 1
2020-12-18 08:00:19 +00:00
let g:ale_lint_on_enter = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_echo_cursor = 1
2021-01-29 13:53:15 +00:00
let g:ale_lint_delay = 100
2020-12-29 07:02:41 +00:00
let g:ale_set_balloons = 1
" NOTE: Needs https://github.com/dense-analysis/ale/issues/3350
let g:ale_rust_analyzer_config = {
\ 'diagnostics': { 'disabled': ['unresolved-import'] },
\ 'cargo': { 'loadOutDirsFromCheck': v:true },
2021-01-06 13:34:33 +00:00
\ 'procMacro': { 'enable': v:true },
2020-12-30 15:50:33 +00:00
\ 'checkOnSave': { 'command': 'clippy', 'enable': v:true },
2020-12-29 07:02:41 +00:00
\ }
2020-12-18 08:46:30 +00:00
let g:ale_go_goimports_options = '-local github.com/sensiblecodeio/cantabular'
2021-02-04 08:00:36 +00:00
let g:ale_go_gopls_init_options = {'ui.diagnostic.analyses': {
\ 'composites': v:false,
\ 'unusedparams': v:true,
\ 'unusedresult': v:true,
\ 'shadow': v:true,
\ }}
2021-02-02 11:40:09 +00:00
" let g:ale_command_wrapper = 'nice -n5'
2021-01-24 20:35:01 +00:00
let g:ale_completion_enabled = 0
2020-12-18 09:10:57 +00:00
let g:ale_close_preview_on_insert = 1
let g:ale_hover_to_preview = 1
let g:ale_sign_column_always = 1
2020-12-29 07:02:41 +00:00
let g:ale_history_log_output = 1
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'go': ['gopls'],
2021-01-06 13:34:33 +00:00
\ 'rust': ['analyzer'],
\ 'css': ['stylelint'],
2021-01-18 09:14:44 +00:00
\ 'python': ['pyls'],
2021-02-17 03:54:06 +00:00
\ 'ruby': ['rubocop'],
2020-12-29 07:02:41 +00:00
\ }
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier'],
2020-12-30 15:50:33 +00:00
\ 'rust': [],
2021-01-06 13:34:33 +00:00
\ 'go': [],
\ 'css': ['stylelint'],
2021-01-18 09:14:44 +00:00
\ 'python': ['autopep8'],
2021-02-17 03:54:06 +00:00
\ 'ruby': ['rubocop'],
2020-12-29 07:02:41 +00:00
\ }
2021-01-19 08:54:13 +00:00
" load internal plugins:
runtime macros/matchit.vim
2020-12-29 07:02:41 +00:00
" load ALE only after configured:
packadd! ale
2021-01-19 08:54:13 +00:00
" load other plugins:
2021-02-02 11:37:36 +00:00
packadd! echodoc.vim
2021-01-19 08:54:13 +00:00
packadd! lightline.vim
2021-01-24 20:35:01 +00:00
packadd! tmux-complete.vim
2021-01-19 08:54:13 +00:00
packadd! vim-commentary
2021-01-28 08:21:55 +00:00
packadd! vim-gitgutter
2021-03-09 18:34:35 +00:00
" Requires both skim.vim plugin to be manually installed:
" https://github.com/lotabout/skim/blob/master/plugin/skim.vim
" and also this separate plugin, which is loaded here:
" https://github.com/lotabout/skim.vim/blob/master/autoload/fzf/vim.vim
packadd! skim.vim
2021-01-28 19:23:15 +00:00
packadd! vim-go
2021-01-19 08:54:13 +00:00
packadd! vim-surround
2021-01-24 15:46:40 +00:00
packadd! vim-yaml-folds