245 lines
6.4 KiB
VimL
245 lines
6.4 KiB
VimL
syntax on
|
|
filetype plugin indent on
|
|
|
|
let mapleader=","
|
|
|
|
" netrw
|
|
let g:netrw_banner = 0
|
|
let g:netrw_liststyle = 1
|
|
let g:netrw_list_hide = '^\.'
|
|
let g:netrw_winsize=25
|
|
map <leader>n <esc>:Lexplore<cr>
|
|
|
|
set shiftwidth=2
|
|
set shiftround
|
|
set tabstop=2
|
|
set expandtab
|
|
set smarttab
|
|
set splitbelow
|
|
set splitright
|
|
set encoding=utf-8
|
|
set nocompatible
|
|
set t_Co=256
|
|
set termguicolors
|
|
set hidden
|
|
set history=1000
|
|
set nowrap
|
|
set smartindent
|
|
set copyindent
|
|
set autoindent
|
|
set hlsearch
|
|
set showmatch
|
|
set wildignore+=*.log,*.sql,*.cache
|
|
set wildmode=longest,list,full
|
|
set wildmenu
|
|
set number
|
|
set norelativenumber
|
|
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
|
|
set ttymouse=sgr
|
|
set mouse=a
|
|
set mousemodel=popup_setpos
|
|
set lazyredraw
|
|
set timeoutlen=600
|
|
set ballooneval
|
|
set balloonevalterm
|
|
set scrolloff=5
|
|
set dict=/usr/share/dict/words
|
|
set shortmess+=I
|
|
set pastetoggle=<f2>
|
|
" See :help thesaurus
|
|
set thesaurus=$HOME/Documents/thesaurus/thesaurus_pkg/thesaurus.txt
|
|
set completeopt=menu,menuone,popup,longest
|
|
set completepopup=width:100,height:50,align:menu,border:off
|
|
|
|
" Colour scheme:
|
|
colorscheme iceberg
|
|
set background=light
|
|
|
|
" Automatically load/save views on files.
|
|
" https://vi.stackexchange.com/posts/13874/revisions
|
|
augroup AutoSaveFolds
|
|
autocmd!
|
|
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
|
|
autocmd BufWinEnter ?* silent! loadview
|
|
augroup end
|
|
|
|
" Key mappings:
|
|
nmap <silent> ,/ :nohlsearch<CR>
|
|
map <up> <nop>
|
|
map <down> <nop>
|
|
map <left> <nop>
|
|
map <right> <nop>
|
|
imap <up> <nop>
|
|
imap <down> <nop>
|
|
imap <left> <nop>
|
|
imap <right> <nop>
|
|
|
|
nnoremap <silent> ,/ :nohlsearch<CR>
|
|
map <c-t> <esc>:tabnew<cr>
|
|
" Select just-pasted text:
|
|
nnoremap <Leader>0 `[v`]
|
|
map <leader>m :marks<cr>
|
|
map <leader>R :registers<cr>
|
|
map <leader>v :vsplit<cr>
|
|
map <leader>h :split<cr>file browser
|
|
map <leader>! <esc>:only<cr>
|
|
" ctrl-c to unload a buffer
|
|
nnoremap <silent> <c-q> :bp\|bd #<cr>
|
|
nnoremap <silent> br :GoDebugBreakpoint<cr>
|
|
nnoremap <silent> d! :GoDebugStart<cr>
|
|
nnoremap <silent> dc :GoDebugContinue<cr>
|
|
nnoremap <silent> dq :GoDebugStop<cr>
|
|
nnoremap <silent> dn :GoDebugNext<cr>
|
|
nnoremap <silent> ds :GoDebugStep<cr>
|
|
|
|
function! ToggleQuickFix()
|
|
if empty(filter(getwininfo(), 'v:val.quickfix'))
|
|
copen
|
|
else
|
|
cclose
|
|
endif
|
|
endfunction
|
|
map <silent> <leader>q <esc>:call ToggleQuickFix()<cr>
|
|
|
|
" 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>
|
|
|
|
" deoplete configuration
|
|
packadd! deoplete.nvim
|
|
let g:deoplete#enable_at_startup = 1
|
|
call deoplete#custom#option('num_processes', 6)
|
|
" <TAB>: completion.
|
|
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
|
|
inoremap <expr><s-TAB> pumvisible() ? "\<C-p>" : "\<s-TAB>"
|
|
|
|
" vim-markdown configuration:
|
|
let g:vim_markdown_conceal = 1
|
|
|
|
" Command-T configuration:
|
|
let switchbuf="usetab"
|
|
map <leader>T :CommandTFlush<CR>
|
|
map <Leader>r :CommandTMRU<CR>
|
|
map <Leader>k :CommandTHelp<CR>
|
|
map <Leader>c :CommandTCommand<CR>
|
|
let g:CommandTFileScanner="git"
|
|
let g:CommandTGitScanSubmodules=1
|
|
let g:CommandTGitIncludeUntracked=1
|
|
let g:CommandTMatchWindowAtTop=0
|
|
let g:CommandTMaxHeight=20
|
|
packadd! command-t
|
|
|
|
" Lightline configuration:
|
|
set laststatus=2
|
|
|
|
" Vim-Go configuration:
|
|
let g:go_fmt_autosave = 0
|
|
" Vim-Go seems to handle fix-on-save better than ALE:
|
|
let g:go_imports_autosave = 1
|
|
let g:go_fmt_options = {
|
|
\ 'goimports': '-local github.com/sensiblecode.com/cantabular',
|
|
\ }
|
|
autocmd BufNewFile,BufRead *.gohtml set syntax=gohtmltmpl
|
|
" https://github.com/golang/tools/blob/master/gopls/doc/vim.md#vim-go
|
|
let g:go_def_mode='gopls'
|
|
let g:go_info_mode='gopls'
|
|
|
|
" Vim-Rust configuration:
|
|
let g:rustfmt_autosave = 1
|
|
|
|
" ALE configuration:
|
|
" Note: needs https://github.com/dense-analysis/ale/issues/3373
|
|
" to avoid "json decode error" during deoplete resolution.
|
|
set omnifunc=ale#completion#OmniFunc
|
|
function SymbolSearch()
|
|
call inputsave()
|
|
let s:pattern = trim(input("symbol search: "))
|
|
call inputrestore()
|
|
if len(s:pattern) > 0
|
|
execute 'ALESymbolSearch' s:pattern
|
|
endif
|
|
endfunction
|
|
map <Leader>ss :call SymbolSearch()<CR>
|
|
nmap <silent> <leader>af :ALEFirst<cr>
|
|
nmap <silent> <leader>al :ALELast<cr>
|
|
nmap <silent> <leader>an :ALENextWrap<cr>
|
|
nmap <silent> <leader>ap :ALEPreviousWrap<cr>
|
|
nmap <silent> <leader>aN :ALENext -error<cr>
|
|
nmap <silent> <leader>aP :ALEPrevious -error<cr>
|
|
nmap <leader>ad :ALEDetail<cr>
|
|
map <Leader>g :ALEGoToDefinition<CR>
|
|
map <Leader>gt :ALEGoToTypeDefinition<CR>
|
|
map <Leader>f :ALEFindReferences<CR>
|
|
map <Leader>fv :ALEFindReferences -vsplit<CR>
|
|
map <Leader>fh :ALEFindReferences -split<CR>
|
|
map <Leader>ft :ALEFindReferences -tab<CR>
|
|
command GoToDefinition ALEGoToDefinition
|
|
command GoToTypeDefinition ALEGoToTypeDefinition
|
|
command FindReferences ALEFindReferences
|
|
command Rename ALERename
|
|
|
|
let g:ale_sign_column_always = 1
|
|
let g:ale_fix_on_save = 1
|
|
let g:ale_lint_on_text_changed = 1
|
|
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
|
|
let g:ale_lint_delay = 50
|
|
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 },
|
|
\ 'procMacro': { 'enable': v:true },
|
|
\ 'checkOnSave': { 'command': 'clippy', 'enable': v:true },
|
|
\ }
|
|
let g:ale_go_goimports_options = '-local github.com/sensiblecodeio/cantabular'
|
|
let g:ale_go_gopls_options = '' " TODO: composite keys?
|
|
let g:ale_command_wrapper = 'nice -n5'
|
|
let g:ale_completion_enabled = 1
|
|
let g:ale_close_preview_on_insert = 1
|
|
let g:ale_hover_to_preview = 1
|
|
let g:ale_sign_column_always = 1
|
|
let g:ale_history_log_output = 1
|
|
let g:ale_linters = {
|
|
\ 'javascript': ['eslint'],
|
|
\ 'go': ['gopls'],
|
|
\ 'rust': ['analyzer'],
|
|
\ 'css': ['stylelint'],
|
|
\ 'python': ['pyls'],
|
|
\ }
|
|
let g:ale_fixers = {
|
|
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
|
\ 'javascript': ['prettier'],
|
|
\ 'rust': [],
|
|
\ 'go': [],
|
|
\ 'css': ['stylelint'],
|
|
\ 'python': ['autopep8'],
|
|
\ }
|
|
|
|
" load ALE only after configured:
|
|
packadd! ale
|
|
|
|
runtime macros/matchit.vim
|